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