HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MSS_BrushBaseState.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: MSS_BrushBaseState.h
7  *
8  * COMMENTS:
9  * This is the state for interactively editing geometry
10  * and attributes, used with the Brush SOPs.
11  */
12 
13 #ifndef __MSS_BrushBaseState_H__
14 #define __MSS_BrushBaseState_H__
15 
16 #include "MSS_API.h"
17 #include <DM/DM_Detail.h>
18 #include <DM/DM_ModifierKeys.h>
19 #include <GA/GA_Types.h>
20 #include <GU/GU_Detail.h>
21 #include <GU/GU_RayIntersect.h>
22 #include <SOP/SOP_BrushBase.h>
23 #include <UT/UT_Vector2.h>
24 #include "MSS_SingleOpState.h"
25 
26 class UT_String;
27 class PRM_Template;
28 class DM_Workbench;
29 class JEDI_View;
30 
32 {
33 public:
34  // Class constructor and destructor.
35  MSS_BrushBaseState(JEDI_View &view, PI_StateTemplate &templ,
36  BM_SceneManager *scene,
37  const char *cursor = BM_DEFAULT_CURSOR);
38  virtual ~MSS_BrushBaseState();
39 
40  // This constructor and parameter template list go into the DM_StateTemplate
41  // for this state.
42  static BM_State *ourConstructor(BM_View &view, PI_StateTemplate &templ,
43  BM_SceneManager *scene);
45 
46  // The name and type of this class:
47  virtual const char *className() const;
48 
49  // Restart the selection...
50  virtual void restart();
51 
52  virtual void handleOpNodeChange(OP_Node &node);
53 
54  // Check if MMB can be used for indirect handle drags. Some states use
55  // the MMB themselves.
56  virtual bool getAllowIndirectHandleDrag() const { return false; }
57 
58 protected:
59  virtual int enter(BM_SimpleState::BM_EntryType how);
60  virtual void exit (void);
61  virtual void interrupt(BM_SimpleState * = 0);
62  virtual void resume (BM_SimpleState * = 0);
63 
64  // Set the state's node
65  virtual void setNode(OP_Node *node);
66 
67  // Generate the necessary nodes and connect them
68  virtual bool generateAllNodes();
69 
70  // We're done selecting and we've been successful. In this class we simply
71  // display the state prompt.
72  virtual void doneSelecting(void);
73 
74  // Respond to mouse or keyboard events.
75  virtual int handleMouseEvent(UI_Event *event);
76  virtual int handleMouseWheelEvent(UI_Event *event);
77  virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &);
78  virtual int handleParameterEvent(UI_Event *event);
79 
80  // Render the brush "cursor" geometry:
81  virtual void doRender(RE_Render *r, int x, int y, int ghost);
82 
83  // Convert an op menu entry to a brush operation:
84  virtual SOP_BrushOp menuToBrushOp(const UI_Value &menuvalue) const;
85  virtual int brushopToMenu(SOP_BrushOp op) const;
86 
87  // If this state is reselecting and it tries to reselect within the same
88  // node then that node's unique id is returned. Otherwise, 0 is returned.
89  virtual int nodeIdToReselectWithin() const;
90 
91  UI_Value &getPrimaryVal () { return myPrimaryButtonVal; }
92  UI_Value &getSecondaryVal() { return mySecondaryButtonVal; }
93 
96 
97  virtual void updatePrompt();
98 
99  virtual bool forceVisualization() const { return true; }
100 
101  virtual void enableVisualization();
102  virtual void disableVisualization();
103 
105  { return myModifierKeys; }
106 
108  SOP_BrushBase *brush_sop,
109  SOP_Node *intersect_sop,
110  fpreal t)
111  { return nullptr; }
112 
113 private:
114  void handleBrushShapeChange (UI_Event *event);
115  void handleBrushOrientChange(UI_Event *event);
116  void handleAccumStencilChange(UI_Event *event);
117  void handlePrimaryTieChange(UI_Event *event);
118  void handleSecondaryTieChange(UI_Event *event);
119 
120  // Set the appropriate operation whether we use the primary or secondary
121  // mouse button.
122  void usePrimaryButton (void);
123  void useSecondaryButton(void);
124 
125  int sendRay( const UT_Vector2& screen_coord, bool isuv,
126  fpreal t, UT_Vector3 &rayorig,
127  UT_Vector3 &hitpos,
128  UT_Vector3 &dir, GU_RayInfo &hinfo,
129  GA_Index &hitptind,
130  float &scalehistory,
131  int checkgeo);
132 
133  // This orients the cursor.
134  void orientCursor(fpreal t, const UT_Vector3 &hitpos,
135  const UT_Vector3 &nml,
136  float scalehistory,
137  bool isuv, GA_Index prim,
138  float u, float v, float w);
139 
140  // This rebuilds the cursor orientation from the last stashed
141  // value.
142  void reorientCursor();
143 
144 
145  DM_ModifierKeys myModifierKeys;
146  DM_ModifierKeys myFinishModifierKeys;
147  DM_ModifierKeys myWheelModifierKeys;
148  SOP_BrushBase *mySavedBrushNode;
149  GU_RayIntersect myRayIntersect;
150  DM_Detail myBrushHandle;
151  GU_Detail myBrushCursor;
152  UT_Matrix4 myBrushCursorXform;
153  bool myRenderBrushCursor;
154  bool myBrushCursorIsUV;
155  bool myOneHit;
156  bool myLocatedFlag;
157  UT_Vector2 myOldCoord;
158 
159  // These are used track the resizing of the cursor in the viewport
160  bool myResizingCursor;
161  int myLastCursorX, myLastCursorY;
162 
163  // This is used to stash the last valid cursor orientation.
164  // This allows us to rebuild the orientation to resize on
165  // the users request without reintersecting.
166  bool myOldOrientValid;
167  fpreal myOldOrientT;
168  UT_Vector3 myOldOrientHitPos;
169  UT_Vector3 myOldOrientHitNml;
170  float myOldOrientScaleHistory;
171  bool myOldOrientIsUV;
172  GA_Index myOldOrientHitPrim;
173  float myOldOrientHitU;
174  float myOldOrientHitV;
175  float myOldOrientHitW;
176 
177  UI_Value myPrimaryButtonVal;
178  UI_Value mySecondaryButtonVal;
179  UI_Value myBrushShapeVal;
180  UI_Value myBrushOrientVal;
181  UI_Value myAccumStencilVal;
182 };
183 
184 #endif
virtual int enter(BM_SimpleState::BM_EntryType how)
virtual void doneSelecting(void)
virtual int handleMouseWheelEvent(UI_Event *event)
SOP_BrushBase * getBrushSOP() const
const GLdouble * v
Definition: glcorearb.h:836
virtual bool getAllowIndirectHandleDrag() const
GLint y
Definition: glcorearb.h:102
3D Vector class.
#define MSS_API
Definition: MSS_API.h:10
virtual void doRender(RE_Render *r, int, int, int ghost)
virtual void interrupt(BM_SimpleState *state=0)
struct _cl_event * event
Definition: glcorearb.h:2960
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:35
virtual const char * className() const
virtual void handleOpNodeChange(OP_Node &)
static PRM_Template * ourTemplateList
OP_Node * getNode(void) const
virtual bool forceVisualization() const
virtual void exit()
virtual void setNode(OP_Node *node)
SOP_BrushOp
Definition: SOP_BrushBase.h:38
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &)
Respond to keyboard events.
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
virtual void resume(BM_SimpleState *state=0)
double fpreal
Definition: SYS_Types.h:263
Definition of a modifier key context.
UI_Value & getSecondaryVal()
static BM_State * ourConstructor(BM_View &view, PI_StateTemplate &templ, BM_SceneManager *scene)
const DM_ModifierKeys & getModifierKeys() const
GLint GLenum GLint x
Definition: glcorearb.h:408
virtual void restart(void)
virtual int nodeIdToReselectWithin() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
virtual SOP_Node * updateBrushIntersectSop(SOP_BrushBase *brush_sop, SOP_Node *intersect_sop, fpreal t)
virtual int handleParameterEvent(UI_Event *event)
virtual int handleMouseEvent(UI_Event *event)
UI_Value & getPrimaryVal()
virtual bool generateAllNodes()