HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MSS_BrushHairLen.C
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
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 {
125  int key = (int)*event->value;
126 
128  {
130  getPrimaryVal().changed(0); // we want it too to set the state PRM
131  return 1;
132  }
134  {
136  getSecondaryVal().changed(0); // we want it too to set the state PRM
137  return 1;
138  }
139 
141  {
143  getPrimaryVal().changed(0); // we want it too to set the state PRM
144  return 1;
145  }
147  {
149  getSecondaryVal().changed(0); // we want it too to set the state PRM
150  return 1;
151  }
152 
154  {
156  getPrimaryVal().changed(0); // we want it too to set the state PRM
157  return 1;
158  }
160  {
162  getSecondaryVal().changed(0); // we want it too to set the state PRM
163  return 1;
164  }
165 
166  if (!KEYCMP("h.pane.gview.state.sop.brush.p_callback"))
167  {
169  getPrimaryVal().changed(0); // we want it too to set the state PRM
170  return 1;
171  }
172  if (!KEYCMP("h.pane.gview.state.sop.brush.s_callback"))
173  {
175  getSecondaryVal().changed(0); // we want it too to set the state PRM
176  return 1;
177  }
178 
180  {
182  getPrimaryVal().changed(0); // we want it too to set the state PRM
183  return 1;
184  }
186  {
188  getSecondaryVal().changed(0); // we want it too to set the state PRM
189  return 1;
190  }
191 
192  return MSS_BrushBaseState::handleKeyTypeEvent(event, viewport);
193 }
194 
197 {
198  switch ((MSS_PaintOp)(int)v)
199  {
200  case MSS_PAINT: return SOP_BRUSHOP_PAINT;
201  case MSS_EYEDROP: return SOP_BRUSHOP_EYEDROP;
203  case MSS_CALLBACK: return SOP_BRUSHOP_CALLBACK;
204  case MSS_ERASE:
205  default: return SOP_BRUSHOP_ERASE;
206  }
207 }
208 
209 
212 {
213  return new PI_StateTemplate("proto_brushhairlen", // State Name.
214  "Brush Hair Len", // English name
215  "SOP_proto_brushhairlen", // Icon name
218  PI_NETMASK_SOP, // Marks this as a SOP state.
219  0);
220 }
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &)
Respond to keyboard events.
#define MSS_KEY_PAINT_P_EYEDROP
PI_StateTemplate * sopBrushHairLenState()
#define MSS_KEY_PAINT_S_EYEDROP
#define MSS_KEY_BRUSH_P_SMOOTH
const GLdouble * v
Definition: glcorearb.h:836
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
virtual void changed(UI_Object *by, UI_Reason reason=UI_VALUE_CHANGED, UI_DeviceEvent *state=0)
virtual int registerState(PI_StateTemplate *type)
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &)
Respond to keyboard events.
virtual SOP_BrushOp menuToBrushOp(const UI_Value &menuvalue) const
Convert an op menu entry to a brush operation:
struct _cl_event * event
Definition: glcorearb.h:2960
virtual void getUIFileName(UT_String &uifilename) const
MSS_BrushHairLen(JEDI_View &view, PI_StateTemplate &templ, BM_SceneManager *scene, const char *cursor=BM_DEFAULT_CURSOR)
#define MSS_KEY_BRUSH_S_MAIN
static PRM_ChoiceList theLMBMenu
SOP_BrushOp
Definition: SOP_BrushBase.h:38
UI_Value * value
Definition: UI_Event.h:55
static PRM_Template ourTemplateList[]
#define PRM_MENU_CHOICES
UI_Value & getSecondaryVal()
#define KEYCMP(symbol)
typedef int
Definition: png.h:1175
#define MSS_KEY_BRUSH_S_SMOOTH
#define MSS_KEY_BRUSH_P_ERASE
PRM_API PRM_Name PRMlmbName
PRM_API PRM_Name PRMmmbName
#define MSS_KEY_BRUSH_S_ERASE
PRM_API PRM_Default PRMzeroDefaults[]
static PRM_ChoiceList theMMBMenu
virtual const char * className() const
The name and type of this class:
UI_Value & getPrimaryVal()
static BM_State * ourConstructor(BM_View &view, PI_StateTemplate &templ, BM_SceneManager *scene)