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  virtual ~BM_OpState(void);
47 
48  // Mouse events are passed on to all visible PI's.
49  virtual int handleMouseEvent (UI_Event *event);
50  virtual int handleMouseWheelEvent (UI_Event *event);
51 
52  // The name and type of this class:
53  virtual const char *className() const;
54 
55  virtual void prepareDialogForDisplay() const;
56  virtual int hasDialog() const;
57  virtual UI_Feel *dialogFeel() const;
58 
59  virtual int findPI(BM_OpHandleLink *pi) const;
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  virtual bool getStateParmNames(UT_StringArray &ret, const char* prefix=nullptr );
82  virtual bool evalStateParm(const char *name, UT_StringHolder &ret);
83  virtual bool setStateParm(const char *name, const UT_StringHolder &val);
84  virtual bool pressStateButton(const char *name);
85 
86  BM_OpHandleLink* piByRootDescription(const char *description);
87  BM_OpHandleLink const* piByRootDescription(const char *description) const;
88 
89 protected:
90  BM_OpView &baseViewer() { return myViewer; }
91  const BM_OpView &baseViewer() const { return myViewer; }
92 
93 
94  // Interrupt this state or resume its activity.
95  virtual void interrupt(BM_SimpleState * = 0);
96  virtual void resume (BM_SimpleState * = 0);
97 
98  // deal with events coming from either the popup menus or the keyboard
99  virtual int handleKeyTypeEvent(UI_Event *event,
100  BM_Viewport &viewport);
101  // Handle transitory key presses.
102  virtual bool handleTransitoryKey(const UI_Event &event);
103 
104  // Create a PI and add it to the list of PI's. If add_button is set,
105  // a button is added to turn the PI on and off, and the makePIVisible
106  // method is called when the button is pressed. This button is added
107  // to the specified folder. On success, the index of the newly added
108  // PI is returned. -1 is returned on failure.
109  int createPI(const char *pi_name, int opnum = -1,
110  const char *description = 0);
111 
112  // allows base class to react when a new PI is created or removed
113  virtual void onCreatePI(PI_OpHandleLink *pi);
114  virtual void onRemovePI(PI_OpHandleLink *pi);
115 
116  // Append an already existing PI and reflect it it our UI:
117  int appendPI(BM_OpHandleLink *pi, int opnum = -1);
118  virtual void removePI(int pi_idx);
119  void removeAllLinkedPIs();
120  BM_OpHandleLink *pi(int index);
121  const BM_OpHandleLink *pi(int index) const;
122  BM_OpHandleLink *pi(const char *name);
123  const BM_OpHandleLink *pi(const char *name) const;
124 
125  const char *piDescription(int index) const;
126  int piOpnum(int index) const;
127  int numPIs() const { return myPIs.entries(); }
128 
129  // This method is called whenever the button is pressed to turn a PI
130  // on or off. It does not need to redraw the workbench. It does nothing
131  // in this base class.
132  virtual void makePIVisible(int pi_idx, int onoff);
133 
134  // Methods to combine different dialogs into the dialog for this state.
135  int appendFolder(const char *folder_name);
136  void appendFeelToFolder(const char *folder_name,
137  UI_Feel *child_feel);
138  int appendDialogToFolder(const char *folder_name,
139  BM_ParmState &state_or_handle);
140  int appendDialogToFolder(const char *folder_name,
141  OP_Node &op_node,
142  PRM_Template::PRM_Export export_level);
143  int appendThisStateDialogToFolder(const char *folder_name);
144  int appendDividerToFolder(const char *folder_name);
145  int appendTextToFolder(
146  const char *folder_name, const char *text,
147  UI_LookType look_type = UI_LOOK_HEADING_TEXT);
148  int removeDialog(BM_ParmState &state);
149  int removeDialog(OP_Node &op_node,
150  PRM_Template::PRM_Export export_level);
151  int removeFolder(const char *name);
152 
153  // Switches the UI to look at the folder given by name (if it exists)
154  void switchToFolder(const char *name);
155 
156  // callback that is called when a dialog is deleted. It clears
157  // any pointers that may become stale.
158  virtual void handleDialogDeleted( OPUI_Dialog *deleted_dialog );
159 
160  // This will remove all the dialogs which this state has created.
161  // It is virtual as some derived states may have extra dialogs.
162  virtual void removeAllDialogs();
163  void handlePIVisibilityChange(UI_Event *event);
164 
165  // Make the new, not-yet-connected node an output of the inputnode.
166  // If not branching off, move inputnode's outputs to newnode's
167  // output list.
168  void connectNode(OP_Node &newnode, OP_Node &inputnode,
169  int input_idx = 0, int branch_off = 0);
170 
171  // Stamp the node with the name of this state:
172  void stampNode(OP_Node &newnode);
173 
174  // Return 1 if the node is generated by a state that matches our name,
175  // or if the node's name matches our name:
176  virtual int matchesNode(OP_Node &node) const = 0;
177 
178  BM_OpView &myViewer;
179 
183  SI_Folders *myFolders;
184 
185  static const char *STATE_DIALOG_FOLDER;
186  static const char *HANDLES_FOLDER;
187  static const char *OP_DIALOG_FOLDER;
189 
190 private:
191  // callback that is called when a dialog is deleted. It clears
192  // any pointers that may become stale.
193  void dialogDeletedCallback( UI_Event* event );
194 
195  void buildStateParmPrefix(UT_WorkBuffer &buf, BM_OpHandleLink *pii, BM_Handle *h);
196  BM_ParmState* findStateParm( UT_String &name );
197 
198 };
199 
200 #endif
virtual void resume(BM_SimpleState *state=0)
virtual void interrupt(BM_SimpleState *state=0)
SI_Folders * myFolders
Definition: BM_OpState.h:183
UT_ValArray< opbm_PIContext * > myPIs
Definition: BM_OpState.h:181
static const char * HANDLES_FOLDER
Definition: BM_OpState.h:186
UI_LookType
Definition: UI_Types.h:150
virtual int hasDialog(void) const
UT_ValArray< UI_Feel * > myMiscFeels
Definition: BM_OpState.h:182
struct _cl_event * event
Definition: glcorearb.h:2960
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:37
BM_OpView & myViewer
Definition: BM_OpState.h:178
static int getAutoHighlightFlag()
Definition: BM_OpState.h:75
virtual int handleMouseWheelEvent(UI_Event *event)
virtual UI_Feel * dialogFeel(void) const
virtual const char * className(void) const
virtual bool setStateParm(const char *name, const UT_StringHolder &val)
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &viewport)
virtual bool getStateParmNames(UT_StringArray &ret, const char *prefix=nullptr)
GLuint const GLchar * name
Definition: glcorearb.h:785
static const char * OP_DIALOG_FOLDER
Definition: BM_OpState.h:187
virtual int findPI(BM_OpHandleLink *pi) const
#define BM_API
Definition: BM_API.h:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
virtual bool pressStateButton(const char *name)
double fpreal
Definition: SYS_Types.h:270
UT_ValArray< opbm_DialogInfo * > myDialogs
Definition: BM_OpState.h:180
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:185
const BM_OpView & baseViewer() const
Definition: BM_OpState.h:91
virtual bool handleTransitoryKey(const UI_Event &)
Definition: BM_State.h:194
GLuint index
Definition: glcorearb.h:785
GLuint GLfloat * val
Definition: glcorearb.h:1607
BM_OpView & baseViewer()
Definition: BM_OpState.h:90
virtual int handleMouseEvent(UI_Event *event)
virtual bool evalStateParm(const char *name, UT_StringHolder &ret)
virtual void prepareDialogForDisplay() const
static int theAutoHighlightFlag
Definition: BM_OpState.h:188
int numPIs() const
Definition: BM_OpState.h:127