HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BM_SingleOpState.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_SingleOpState.h
7  *
8  * COMMENTS:
9  * This is an "automated" state that links handles with op
10  * parameters.
11  */
12 
13 #ifndef __BM_SingleOpState_H__
14 #define __BM_SingleOpState_H__
15 
16 #include "BM_API.h"
17 #include <UT/UT_IntArray.h>
18 #include <UT/UT_String.h>
19 #include <UT/UT_SymbolTable.h>
20 #include <PRM/PRM_Value.h>
21 #include <PI/PI_ResourceManager.h>
22 #include "BM_OpState.h"
23 
24 class OP_Operator;
25 class OP_Node;
26 class BM_OpHandleLink;
27 class OPUI_Dialog;
28 
29 class BM_UndoSetNode;
30 
32 {
33  friend class BM_UndoSetNode;
34 
35 public:
36  // Class constructor and destructor.
37  BM_SingleOpState(BM_OpView &view, PI_StateTemplate &templ,
38  BM_SceneManager *scene,
39  const char *cursor = BM_DEFAULT_CURSOR);
40  virtual ~BM_SingleOpState(void);
41 
42  // Enter or exit this state.
43  virtual int enter(BM_SimpleState::BM_EntryType how);
44  virtual void exit (void);
45  virtual void restart(void);
46 
47  // Similar to enter, but totally from scratch. At this level, it's the
48  // same as doing an enter. It cannot be entered in volatile mode.
49  // We can start generating either in inline (insert) mode
50  // or in branching-off mode. The generation mode is relevant only when
51  // generating ops in a network. Some states reuse existing ops when
52  // possible instead of generating new ones. A request can be made for
53  // new ops here, but it is up to the individual state to interpret it.
54  virtual int generate(BM_SimpleState::BM_EntryType how,
55  bool insertmode = true,
56  bool requestnew = false);
57 
58 
59  // Stop the generation process.
60  virtual void stopGenerating (void);
61 
62  // See how you can handle a node being deleted. If it's an implicit
63  // node we might be OK. Return 0 if we can handle it, -1 if we must
64  // be exited or restarted from scratch.
65  virtual int handleNodeDeleted(OP_Node &node);
66 
67  virtual int hasOpNode(const OP_Node &node) const;
68 
69  // The name and type of this class:
70  virtual const char *className() const;
71 
72  // Allow the state to access the node so that it can process information.
73  OP_Node *getNode(void) const;
74 
75  virtual int getToolboxCount() const;
76  virtual UI_Feel *getToolbox(int index) const;
77 
78 protected:
79  // Provide the Op to work with. The criteria for which OP to use will
80  // be specific to each network type. This method does NOT overwrite
81  // the myOpNode pointer.
82  virtual OP_Node *getChosenOp(void) const = 0;
83 
84  // This method is called whenever the button is pressed to turn a PI
85  // on or off. It does not need to redraw the workbench.
86  virtual void makePIVisible(int pi_idx, int onoff);
87 
88  // Begin generating (and maybe finish too if you can od it quickly).
89  // This method is called from generate() and is currently empty. You may
90  // not need to redefine it at all.
91  virtual void doGenerate(void);
92 
93  // Build an OP that matches our name or the name passed into the function
94  // if not nil. This does not set myOpNode.
95  OP_Node *createNode(const char *optype = 0,
96  const char *nettype = 0,
97  OP_Network *parent = 0,
98  int explicitly = 1);
99 
100  // return the node name required for createNode
101  virtual const char* getCreateNodeName() const
102  {
103  return getName();
104  }
105 
106  // Set the work node. This will detach and clean up after the previous
107  // node should there be one.
108  // setNode is virtual because the state may want to do different
109  // things when the node is set, like saving the look of PIs.
110  virtual void setNode(OP_Node *node);
111  void setNodeId(int id);
112 
113  // Make this node current. Derived classes may choose to do other things.
114  virtual void setNodeFlags(OP_Node &node);
115 
116  // Disable the footprint flag of the current node if it has outputs
117  virtual void clearChosenNodeFlags();
118 
119  // The user can dynamically change the bindings from the textport
120  // We need to refresh the current handle in the viewports
121  // cause they could be affected.
122  virtual void refreshBindings(int id, const char *op_type);
123  virtual void refreshSettings(int id, const char *op_type);
124 
125  // Access to the saved node, ie the node that we may have stashed away
126  // on a restart():
127  OP_Node *savedNode(void) const { return mySavedOpNode; }
129  {
130  clearRestartInfo();
131  mySavedOpNode = n;
132  }
133 
134  // Generate the parts of the dialog needed before the PI's are created.
135  virtual void initializeDialogs();
136  // Generate the parts of the dialog that can only be created after all the
137  // PI's are created.
138  virtual void completeDialogs();
139 
140  // Return 1 if the node is generated by a state that matches our name,
141  // or if the node's name matches our name:
142  virtual int matchesNode(OP_Node &node) const;
143 
144  // Removes all the dialogs including our locally defined toolbox.
145  virtual void removeAllDialogs();
146 
147  // callback that is called when a dialog is deleted. It clears
148  // any pointers that may become stale.
149  virtual void handleDialogDeleted( OPUI_Dialog *dialog );
150 
151  // The method gets called when reselecting and should be overridden to
152  // add any undos needed to undo reselection.
153  virtual void addAnyReselectionUndos();
154 
155  // Return false from this function to prevent our node from having its
156  // inputs disconnected when we restart this state. Used by DOP data
157  // states, which want to leave inputs connected. The default
158  // implementation returns true.
159  virtual bool disconnectInputsOnRestart() const;
160 
161  void clearOpHandleLinks();
162 
163  // Override this to return false if undesired
164  virtual bool allowOpMaxExportToDialog() const { return true; }
165 
166 private:
167  // Create, link, attach, position, push, and activate the PI's.
168  void createOpHandleLinks();
169 
170  // Link the parms of the op to all the parms of the PI's.
171  // This method is called from createOpHandleLinks.
172  void linkAllParms();
173 
174  // Link a given (non-input) op parm to a PI, and create the PI if it
175  // doesn't already exist. This method is called from linkNonInputParms.
176  int linkSingleParm(const PI_BindingHandleInfo &bhi,
177  const PI_BindingParmInfo &bpi,
178  OP_Operator &op_type);
179 
180  BM_OpHandleLink * createSingleOpHandleLink(
181  const PI_BindingHandleInfo &bhi);
182 
183  void clearRestartInfo();
184  void saveRestartInfo(const OP_Node &node,
185  const OP_NodeList &implicits);
186  bool restoreRestartInfo(OP_Node &node);
187 
188 protected:
189  // Delete all the PI's. This method ensures that all interests in the
190  // PI's are removed and they are all deactivated.
191  void deleteOpHandleLinks();
192 
193  // data
196  OPUI_Dialog *myOpToolbox;
198 
199  // As long as this state is alive, remember what PIs are visible
201 
206 };
207 
208 #endif
virtual int matchesNode(OP_Node &node) const =0
virtual void exit(void)
UT_IntArray myRestartOpInputs
virtual UI_Feel * getToolbox(int index) const
OPUI_Dialog * myOpToolbox
UT_String myRestartInfoFile
virtual int generate(BM_SimpleState::BM_EntryType how, bool insertmode=true, bool requestnew=false)
virtual bool allowOpMaxExportToDialog() const
virtual void makePIVisible(int pi_idx, int onoff)
UT_BitArray myHandleVisibility
virtual int hasOpNode(const OP_Node &) const
virtual void removeAllDialogs()
virtual void refreshSettings(int id, const char *op_type)
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:37
virtual void refreshBindings(int id, const char *op_type)
GLdouble n
Definition: glcorearb.h:2007
const UT_String & getName() const
Return the name passed in the constructor.
Definition: AP_Interface.h:51
virtual void restart(void)
UT_SymbolMap< int > myHandleTable
virtual void stopGenerating(void)
Definition: BM_State.h:172
#define BM_API
Definition: BM_API.h:10
virtual const char * className() const
void savedNode(OP_Node *n)
virtual void handleDialogDeleted(OPUI_Dialog *deleted_dialog)
UT_StringArray myRestartOpIndirectInputs
OP_Node * savedNode(void) const
GLuint index
Definition: glcorearb.h:785
virtual int handleNodeDeleted(OP_Node &)
virtual const char * getCreateNodeName() const
virtual int enter(BM_SimpleState::BM_EntryType how)
virtual int getToolboxCount() const