HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_State.h"
21 
22 class OP_Node;
23 class BM_OpView;
24 class BM_Handle;
25 class UI_Feel;
26 class SI_Folders;
27 class BM_SceneManager;
28 class OPUI_Dialog;
29 
30 class opbm_DialogInfo; // private to implementation
31 class opbm_PIContext; // private to implementation
32 
33 // NOTE: If you change this default cursor, make sure you update
34 // RE/RE_Cursor to reflect it.
35 #define BM_DEFAULT_CURSOR "iris"
36 
37 class BM_API BM_OpState : public BM_State
38 {
39 public:
40  // Class constructor and destructor.
41  BM_OpState(BM_OpView &view, PI_StateTemplate &templ,
42  BM_SceneManager *sceneManager,
43  const char *cursor = BM_DEFAULT_CURSOR);
44  virtual ~BM_OpState(void);
45 
46  // Mouse events are passed on to all visible PI's.
47  virtual int handleMouseEvent (UI_Event *event);
48  virtual int handleMouseWheelEvent (UI_Event *event);
49 
50  // The name and type of this class:
51  virtual const char *className() const;
52 
53  virtual void prepareDialogForDisplay() const;
54  virtual int hasDialog() const;
55  virtual UI_Feel *dialogFeel() const;
56 
57  virtual int findPI(BM_OpHandleLink *pi) const;
58 
59  // Called to give any PIs a chance to update (and optionally reveal) an
60  // invisible handle rather than have the viewer switch to a move tool
61  // state. This method returns true if a handle was updated (i.e. the
62  // viewer should not launch a move tool state).
63  virtual bool updateInvisiblePIHandleForMoveTool(
64  bool (*func)(BM_Handle *handle, int tool,
65  unsigned vport_mask),
66  int tool, unsigned vport_mask, bool make_visible);
67 
68  // These set the flag as to whether or not we highlight ops
69  // as we drop them.
70  static int getAutoHighlightFlag() { return theAutoHighlightFlag;}
71  static void setAutoHighlightFlag(int o)
72  { theAutoHighlightFlag = o; }
73  /// Obtains the current global time.
74  fpreal getTime() const;
75 
76 protected:
77  BM_OpView &baseViewer() { return myViewer; }
78  const BM_OpView &baseViewer() const { return myViewer; }
79 
80 
81  // Interrupt this state or resume its activity.
82  virtual void interrupt(BM_SimpleState * = 0);
83  virtual void resume (BM_SimpleState * = 0);
84 
85  // deal with events coming from either the popup menus or the keyboard
86  virtual int handleKeyTypeEvent(UI_Event *event,
87  BM_Viewport &viewport);
88  // Handle transitory key presses.
89  virtual bool handleTransitoryKey(const UI_Event &event);
90 
91  // Create a PI and add it to the list of PI's. If add_button is set,
92  // a button is added to turn the PI on and off, and the makePIVisible
93  // method is called when the button is pressed. This button is added
94  // to the specified folder. On success, the index of the newly added
95  // PI is returned. -1 is returned on failure.
96  int createPI(const char *pi_name, int opnum = -1,
97  const char *description = 0);
98  // Append an already existing PI and reflect it it our UI:
99  int appendPI(BM_OpHandleLink *pi, int opnum = -1);
100  virtual void removePI(int pi_idx);
101  void removeAllLinkedPIs();
102  BM_OpHandleLink *pi(int index);
103  const BM_OpHandleLink *pi(int index) const;
104  BM_OpHandleLink *pi(const char *name);
105  const BM_OpHandleLink *pi(const char *name) const;
106 
107  const char *piDescription(int index) const;
108  int piOpnum(int index) const;
109  int numPIs() const { return myPIs.entries(); }
110 
111  // This method is called whenever the button is pressed to turn a PI
112  // on or off. It does not need to redraw the workbench. It does nothing
113  // in this base class.
114  virtual void makePIVisible(int pi_idx, int onoff);
115 
116  // Methods to combine different dialogs into the dialog for this state.
117  int appendFolder(const char *folder_name);
118  void appendFeelToFolder(const char *folder_name,
119  UI_Feel *child_feel);
120  int appendDialogToFolder(const char *folder_name,
121  BM_ParmState &state_or_handle);
122  int appendDialogToFolder(const char *folder_name,
123  OP_Node &op_node,
124  PRM_Template::PRM_Export export_level);
125  int appendThisStateDialogToFolder(const char *folder_name);
126  int appendDividerToFolder(const char *folder_name);
127  int appendTextToFolder(
128  const char *folder_name, const char *text,
129  UI_LookType look_type = UI_LOOK_HEADING_TEXT);
130  int removeDialog(BM_ParmState &state);
131  int removeDialog(OP_Node &op_node,
132  PRM_Template::PRM_Export export_level);
133  int removeFolder(const char *name);
134 
135  // Switches the UI to look at the folder given by name (if it exists)
136  void switchToFolder(const char *name);
137 
138  // callback that is called when a dialog is deleted. It clears
139  // any pointers that may become stale.
140  virtual void handleDialogDeleted( OPUI_Dialog *deleted_dialog );
141 
142  // This will remove all the dialogs which this state has created.
143  // It is virtual as some derived states may have extra dialogs.
144  virtual void removeAllDialogs();
145  void handlePIVisibilityChange(UI_Event *event);
146 
147  // Make the new, not-yet-connected node an output of the inputnode.
148  // If not branching off, move inputnode's outputs to newnode's
149  // output list.
150  void connectNode(OP_Node &newnode, OP_Node &inputnode,
151  int input_idx = 0, int branch_off = 0);
152 
153  // Stamp the node with the name of this state:
154  void stampNode(OP_Node &newnode);
155 
156  // Return 1 if the node is generated by a state that matches our name,
157  // or if the node's name matches our name:
158  virtual int matchesNode(OP_Node &node) const = 0;
159 
160  BM_OpView &myViewer;
161 
165  SI_Folders *myFolders;
166 
167  static const char *STATE_DIALOG_FOLDER;
168  static const char *HANDLES_FOLDER;
169  static const char *OP_DIALOG_FOLDER;
171 
172 private:
173  // callback that is called when a dialog is deleted. It clears
174  // any pointers that may become stale.
175  void dialogDeletedCallback( UI_Event* event );
176 
177 };
178 
179 #endif
virtual void resume(BM_SimpleState *state=0)
virtual void interrupt(BM_SimpleState *state=0)
SI_Folders * myFolders
Definition: BM_OpState.h:165
UT_ValArray< opbm_PIContext * > myPIs
Definition: BM_OpState.h:163
static const char * HANDLES_FOLDER
Definition: BM_OpState.h:168
UI_LookType
Definition: UI_Types.h:147
virtual int hasDialog(void) const
UT_ValArray< UI_Feel * > myMiscFeels
Definition: BM_OpState.h:164
struct _cl_event * event
Definition: glcorearb.h:2960
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:35
BM_OpView & myViewer
Definition: BM_OpState.h:160
static int getAutoHighlightFlag()
Definition: BM_OpState.h:70
virtual int handleMouseWheelEvent(UI_Event *event)
virtual UI_Feel * dialogFeel(void) const
virtual const char * className(void) const
virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &viewport)
GLuint const GLchar * name
Definition: glcorearb.h:785
static const char * OP_DIALOG_FOLDER
Definition: BM_OpState.h:169
virtual int findPI(BM_OpHandleLink *pi) const
#define BM_API
Definition: BM_API.h:10
double fpreal
Definition: SYS_Types.h:263
UT_ValArray< opbm_DialogInfo * > myDialogs
Definition: BM_OpState.h:162
GLenum func
Definition: glcorearb.h:782
static void setAutoHighlightFlag(int o)
Definition: BM_OpState.h:71
static const char * STATE_DIALOG_FOLDER
Definition: BM_OpState.h:167
const BM_OpView & baseViewer() const
Definition: BM_OpState.h:78
virtual bool handleTransitoryKey(const UI_Event &)
Definition: BM_State.h:186
GLuint index
Definition: glcorearb.h:785
BM_OpView & baseViewer()
Definition: BM_OpState.h:77
virtual int handleMouseEvent(UI_Event *event)
virtual void prepareDialogForDisplay() const
static int theAutoHighlightFlag
Definition: BM_OpState.h:170
int numPIs() const
Definition: BM_OpState.h:109