HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BM_OpState.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: BM_State.h
7  *
8  * COMMENTS:
9  * This is an "automated" state that links handles with op
10  * parameters.
11  */
12 
13 #ifndef __BM_OpState_H__
14 #define __BM_OpState_H__
15 
16 #include "BM_API.h"
17 #include <UT/UT_SymbolTable.h>
18 #include <UI/UI_LookType.h>
19 #include <PRM/PRM_Template.h>
20 #include "BM_MoveTool.h"
21 #include "BM_State.h"
22 
23 class OP_Node;
24 class BM_OpView;
25 class BM_Handle;
26 class UI_Feel;
27 class SI_Folders;
28 class BM_SceneManager;
29 class OPUI_Dialog;
30 class PI_OpHandleLink;
31 
32 class opbm_DialogInfo; // private to implementation
33 class opbm_PIContext; // private to implementation
34 
35 // NOTE: If you change this default cursor, make sure you update
36 // RE/RE_Cursor to reflect it.
37 #define BM_DEFAULT_CURSOR "iris"
38 
39 class BM_API BM_OpState : public BM_State
40 {
41 public:
42  // Class constructor and destructor.
43  BM_OpState(BM_OpView &view, PI_StateTemplate &templ,
44  BM_SceneManager *sceneManager,
45  const char *cursor = BM_DEFAULT_CURSOR);
46  ~BM_OpState() override;
47 
48  // Mouse events are passed on to all visible PI's.
49  int handleMouseEvent (UI_Event *event) override;
50  int handleMouseWheelEvent (UI_Event *event) override;
51 
52  // The name and type of this class:
53  const char *className() const override;
54 
55  void prepareDialogForDisplay() const override;
56  int hasDialog() const override;
57  UI_Feel *dialogFeel() const override;
58 
59  int findPI(BM_OpHandleLink *pi) const override;
60 
61  // Called to give any PIs a chance to update (and optionally reveal) an
62  // invisible handle rather than have the viewer switch to a move tool
63  // state. This method returns true if a handle was updated (i.e. the
64  // viewer should not launch a move tool state).
65  virtual bool updateInvisiblePIHandleForMoveTool(
66  bool (*func)(BM_Handle *handle,
67  BM_MoveTool::Type tool,
68  unsigned vport_mask),
69  BM_MoveTool::Type tool,
70  unsigned vport_mask,
71  bool make_visible);
72 
73  // These set the flag as to whether or not we highlight ops
74  // as we drop them.
75  static int getAutoHighlightFlag() { return theAutoHighlightFlag;}
76  static void setAutoHighlightFlag(int o)
77  { theAutoHighlightFlag = o; }
78  /// Obtains the current global time.
79  fpreal getTime() const;
80 
81  bool getStateParmNames(
82  UT_StringArray &ret,
83  const char* prefix=nullptr ) override;
84  bool evalStateParm(
85  const char *name,
86  UT_StringHolder &ret) override;
87  bool setStateParm(
88  const char *name,
89  const UT_StringHolder &val) override;
90  bool pressStateButton(const char *name) override;
91 
92  BM_OpHandleLink* piByRootDescription(const char *description);
93  BM_OpHandleLink const* piByRootDescription(const char *description) const;
94 
95  // Return the the operator name linked to the state. Defaults to the
96  // state template name.
97  // NOTE: This method is required in several places in Houdini where
98  // a state is being asked for an operator name. This is likey to be
99  // overriden by python state derived classes as the state name
100  // (template name) is not necessarily the same as the state operator
101  // name.
102  virtual const char* getOperatorName() const;
103 
104 protected:
105  BM_OpView &baseViewer() { return myViewer; }
106  const BM_OpView &baseViewer() const { return myViewer; }
107 
108 
109  // Interrupt this state or resume its activity.
110  void interrupt(BM_SimpleState * = 0) override;
111  void resume (BM_SimpleState * = 0) override;
112 
113  void getKeyResolveInfo(UI_KeyResolveInfo &info) override;
114 
115  // deal with events coming from either the popup menus or the keyboard
116  int handleKeyTypeEvent(UI_Event *event,
117  BM_Viewport &viewport) override;
118  // Handle transitory key presses.
119  bool handleTransitoryKey(const UI_Event &event) override;
120 
121  // Create a PI and add it to the list of PI's. If add_button is set,
122  // a button is added to turn the PI on and off, and the makePIVisible
123  // method is called when the button is pressed. This button is added
124  // to the specified folder. On success, the index of the newly added
125  // PI is returned. -1 is returned on failure.
126  int createPI(const char *pi_name, int opnum = -1,
127  const char *description = 0);
128 
129  // allows base class to react when a new PI is created, appended or removed
130  virtual void onCreatePI(PI_OpHandleLink *pi);
131  virtual void onAppendPI(PI_OpHandleLink *pi);
132  virtual void onRemovePI(PI_OpHandleLink *pi);
133 
134  // Append an already existing PI and reflect it it our UI:
135  int appendPI(BM_OpHandleLink *pi, int opnum = -1);
136  virtual void removePI(int pi_idx);
137  void removeAllLinkedPIs();
138  BM_OpHandleLink *pi(int index);
139  const BM_OpHandleLink *pi(int index) const;
140  BM_OpHandleLink *pi(const char *name);
141  const BM_OpHandleLink *pi(const char *name) const;
142 
143  const char *piDescription(int index) const;
144  int piOpnum(int index) const;
145  int numPIs() const { return myPIs.entries(); }
146 
147  // This method is called whenever the button is pressed to turn a PI
148  // on or off. It does not need to redraw the workbench. It does nothing
149  // in this base class.
150  virtual void makePIVisible(int pi_idx, int onoff);
151 
152  // Methods to combine different dialogs into the dialog for this state.
153  int appendFolder(const char *folder_name);
154  void appendFeelToFolder(const char *folder_name,
155  UI_Feel *child_feel);
156  int appendDialogToFolder(const char *folder_name,
157  BM_ParmState &state_or_handle);
158  int appendDialogToFolder(const char *folder_name,
159  OP_Node &op_node,
160  PRM_Template::PRM_Export export_level);
161  int appendThisStateDialogToFolder(const char *folder_name);
162  int appendDividerToFolder(const char *folder_name);
163  int appendTextToFolder(
164  const char *folder_name, const char *text,
165  UI_LookType look_type = UI_LOOK_HEADING_TEXT);
166  int removeDialog(BM_ParmState &state);
167  int removeDialog(OP_Node &op_node,
168  PRM_Template::PRM_Export export_level);
169  int removeFolder(const char *name);
170 
171  // Switches the UI to look at the folder given by name (if it exists)
172  void switchToFolder(const char *name);
173 
174  // callback that is called when a dialog is deleted. It clears
175  // any pointers that may become stale.
176  virtual void handleDialogDeleted( OPUI_Dialog *deleted_dialog );
177 
178  // This will remove all the dialogs which this state has created.
179  // It is virtual as some derived states may have extra dialogs.
180  virtual void removeAllDialogs();
181  void handlePIVisibilityChange(UI_Event *event);
182 
183  // Make the new, not-yet-connected node an output of the inputnode.
184  // If not branching off, move inputnode's outputs to newnode's
185  // output list.
186  void connectNode(OP_Node &newnode, OP_Node &inputnode,
187  int input_idx = 0, int branch_off = 0);
188 
189  // Stamp the node with the name of this state:
190  void stampNode(OP_Node &newnode);
191 
192  // Return 1 if the node is generated by a state that matches our name,
193  // or if the node's name matches our name:
194  virtual int matchesNode(OP_Node &node) const = 0;
195 
196  BM_OpView &myViewer;
197 
201  SI_Folders *myFolders;
202 
203  static const char *STATE_DIALOG_FOLDER;
204  static const char *HANDLES_FOLDER;
205  static const char *OP_DIALOG_FOLDER;
207 
208 private:
209  // callback that is called when a dialog is deleted. It clears
210  // any pointers that may become stale.
211  void dialogDeletedCallback( UI_Event* event );
212 
213  void buildStateParmPrefix(UT_WorkBuffer &buf, BM_OpHandleLink *pii, BM_Handle *h);
214  BM_ParmState* findStateParm( UT_String &name );
215 
216 };
217 
218 #endif
GLuint const GLchar * name
Definition: glew.h:1814
SI_Folders * myFolders
Definition: BM_OpState.h:201
GLuint index
Definition: glew.h:1814
GLuint const GLfloat * val
Definition: glew.h:2794
UT_ValArray< opbm_PIContext * > myPIs
Definition: BM_OpState.h:199
virtual UI_Feel * dialogFeel() const
static const char * HANDLES_FOLDER
Definition: BM_OpState.h:204
UI_LookType
Definition: UI_Types.h:150
UT_ValArray< UI_Feel * > myMiscFeels
Definition: BM_OpState.h:200
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:37
BM_OpView & myViewer
Definition: BM_OpState.h:196
static int getAutoHighlightFlag()
Definition: BM_OpState.h:75
virtual int handleMouseWheelEvent(UI_Event *event)
virtual bool setStateParm(const char *name, const UT_StringHolder &val)
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &viewport)
void resume(BM_SimpleState *state=0) override
virtual bool getStateParmNames(UT_StringArray &ret, const char *prefix=nullptr)
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
static const char * OP_DIALOG_FOLDER
Definition: BM_OpState.h:205
virtual int findPI(BM_OpHandleLink *pi) const
#define BM_API
Definition: BM_API.h:10
virtual bool pressStateButton(const char *name)
UT_ValArray< opbm_DialogInfo * > myDialogs
Definition: BM_OpState.h:198
cl_event event
Definition: glew.h:3695
GLenum func
Definition: glcorearb.h:782
static void setAutoHighlightFlag(int o)
Definition: BM_OpState.h:76
static const char * STATE_DIALOG_FOLDER
Definition: BM_OpState.h:203
const BM_OpView & baseViewer() const
Definition: BM_OpState.h:106
virtual bool handleTransitoryKey(const UI_Event &)
Definition: BM_State.h:198
fpreal64 fpreal
Definition: SYS_Types.h:277
BM_OpView & baseViewer()
Definition: BM_OpState.h:105
void interrupt(BM_SimpleState *state=0) override
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:108
int handleMouseEvent(UI_Event *event) override
virtual bool evalStateParm(const char *name, UT_StringHolder &ret)
virtual int hasDialog() const
virtual void getKeyResolveInfo(UI_KeyResolveInfo &info)
virtual void prepareDialogForDisplay() const
static int theAutoHighlightFlag
Definition: BM_OpState.h:206
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580
int numPIs() const
Definition: BM_OpState.h:145
const char * className() const override