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