HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSS_BrushHairLen.C
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * This code is for creating the state to go with this op.
27 */
28 
29 #include <UT/UT_DSOVersion.h>
30 #include <GU/GU_Detail.h>
31 #include <GU/GU_PrimPoly.h>
32 #include <PRM/PRM_Include.h>
33 #include <PRM/PRM_ChoiceList.h>
34 #include <OP/OP_Operator.h>
35 #include <OP/OP_OperatorTable.h>
36 
37 #include <SOP/SOP_Guide.h>
38 #include <BM/BM_ResourceManager.h>
39 #include <SOP/SOP_Node.h>
40 #include <SOP/SOP_BrushBase.h>
41 #include <MSS/MSS_BrushBaseState.h>
42 #include <MSS/MSS_KeyBindings.h>
43 #include "MSS_BrushHairLen.h"
44 
45 #define PRM_MENU_CHOICES (PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE |\
46  PRM_CHOICELIST_REPLACE)
47 
48 // Prototype for function to create our state.
50 
51 using namespace HDK_Sample;
52 
53 // Define the new state...
54 void
56 {
58 }
59 
66 };
67 
68 static PRM_Name mssOpMenuNames[] = {
69  PRM_Name("paint", "Paint"),
70  PRM_Name("eyedrop", "Eye Dropper"),
71  PRM_Name("smooth", "Smooth"),
72  PRM_Name("callback", "Callback"),
73  PRM_Name("erase", "Erase Changes"),
74  PRM_Name(0)
75 };
76 
77 #define PRM_MENU_CHOICES (PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE |\
78  PRM_CHOICELIST_REPLACE)
79 
82 
85 {
86  PRM_Template(PRM_ORD, 1, &PRMlmbName, PRMzeroDefaults, &theLMBMenu),
87  PRM_Template(PRM_ORD, 1, &PRMmmbName, PRMzeroDefaults, &theMMBMenu),
88  PRM_Template(),
89 };
90 
91 BM_State *
93  BM_SceneManager *scene)
94 {
95  return new MSS_BrushHairLen((JEDI_View &)view, templ, scene);
96 }
97 
99  BM_SceneManager *scene, const char *cursor)
100  : MSS_BrushBaseState(view, templ, scene, cursor)
101 {
102  // Nothing needed.
103 }
104 
106 {
107  // Nothing needed.
108 }
109 
110 const char *
112 {
113  return "MSS_BrushHairLen";
114 }
115 
116 void
118 {
119  uifilename = "MSS_BrushHairLen.ui";
120 }
121 
122 int
124  BM_Viewport &viewport)
125 {
127  {
129  getPrimaryVal().changed(0); // we want it too to set the state PRM
130  return 1;
131  }
133  {
135  getSecondaryVal().changed(0); // we want it too to set the state PRM
136  return 1;
137  }
138 
140  {
142  getPrimaryVal().changed(0); // we want it too to set the state PRM
143  return 1;
144  }
146  {
148  getSecondaryVal().changed(0); // we want it too to set the state PRM
149  return 1;
150  }
151 
153  {
155  getPrimaryVal().changed(0); // we want it too to set the state PRM
156  return 1;
157  }
159  {
161  getSecondaryVal().changed(0); // we want it too to set the state PRM
162  return 1;
163  }
164 
165  if (!KEYCMP("h.pane.gview.state.sop.brush.p_callback"))
166  {
168  getPrimaryVal().changed(0); // we want it too to set the state PRM
169  return 1;
170  }
171  if (!KEYCMP("h.pane.gview.state.sop.brush.s_callback"))
172  {
174  getSecondaryVal().changed(0); // we want it too to set the state PRM
175  return 1;
176  }
177 
179  {
181  getPrimaryVal().changed(0); // we want it too to set the state PRM
182  return 1;
183  }
185  {
187  getSecondaryVal().changed(0); // we want it too to set the state PRM
188  return 1;
189  }
190 
191  return MSS_BrushBaseState::handleKeyTypeEvent(key, event, viewport);
192 }
193 
196 {
197  switch ((MSS_PaintOp)(int)v)
198  {
199  case MSS_PAINT: return SOP_BRUSHOP_PAINT;
200  case MSS_EYEDROP: return SOP_BRUSHOP_EYEDROP;
202  case MSS_CALLBACK: return SOP_BRUSHOP_CALLBACK;
203  case MSS_ERASE:
204  default: return SOP_BRUSHOP_ERASE;
205  }
206 }
207 
208 
211 {
212  return new PI_StateTemplate("proto_brushhairlen", // State Name.
213  "Brush Hair Len", // English name
214  "SOP_proto_brushhairlen", // Icon name
217  PI_NETMASK_SOP, // Marks this as a SOP state.
218  0);
219 }
void getUIFileName(UT_String &uifilename) const override
PRM_API PRM_Default PRMzeroDefaults[]
#define MSS_KEY_PAINT_P_EYEDROP
PI_StateTemplate * sopBrushHairLenState()
#define MSS_KEY_PAINT_S_EYEDROP
int handleKeyTypeEvent(int key, UI_Event *event, BM_Viewport &) override
#define MSS_KEY_BRUSH_P_SMOOTH
MSS_PaintOp
const unsigned PI_NETMASK_SOP
PRM_API const PRM_Type PRM_ORD
void newModelState(BM_ResourceManager *m)
#define MSS_KEY_BRUSH_P_MAIN
PRM_API PRM_Name PRMmmbName
virtual void changed(UI_Object *by, UI_Reason reason=UI_VALUE_CHANGED, UI_DeviceEvent *state=0)
virtual int registerState(PI_StateTemplate *type)
struct _cl_event * event
Definition: glcorearb.h:2960
const char * className() const override
The name and type of this class:
MSS_BrushHairLen(JEDI_View &view, PI_StateTemplate &templ, BM_SceneManager *scene, const char *cursor=BM_DEFAULT_CURSOR)
const GLdouble * v
Definition: glcorearb.h:836
#define MSS_KEY_BRUSH_S_MAIN
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static PRM_ChoiceList theLMBMenu
SOP_BrushOp
Definition: SOP_BrushBase.h:39
static PRM_Template ourTemplateList[]
#define PRM_MENU_CHOICES
SOP_BrushOp menuToBrushOp(const UI_Value &menuvalue) const override
Convert an op menu entry to a brush operation:
UI_Value & getSecondaryVal()
#define KEYCMP(symbol)
#define MSS_KEY_BRUSH_S_SMOOTH
#define MSS_KEY_BRUSH_P_ERASE
const GLdouble * m
Definition: glew.h:9166
#define MSS_KEY_BRUSH_S_ERASE
static PRM_ChoiceList theMMBMenu
UI_Value & getPrimaryVal()
static BM_State * ourConstructor(BM_View &view, PI_StateTemplate &templ, BM_SceneManager *scene)
PRM_API PRM_Name PRMlmbName
int handleKeyTypeEvent(int key, UI_Event *event, BM_Viewport &) override
Respond to keyboard events.