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  ~BM_SingleOpState() override;
41 
42  // Enter or exit this state.
43  int enter(BM_SimpleState::BM_EntryType how) override;
44  void exit() override;
45  void restart() override;
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.
50  const GenerateParms &parms) override;
51 
52 
53  // Stop the generation process.
54  void stopGenerating() override;
55 
56  // See how you can handle a node being deleted. If it's an implicit
57  // node we might be OK. Return 0 if we can handle it, -1 if we must
58  // be exited or restarted from scratch.
59  int handleNodeDeleted(OP_Node &node) override;
60 
61  int hasOpNode(const OP_Node &node) const override;
62 
63  void handleOpNetClear() override;
64 
65  // The name and type of this class:
66  const char *className() const override;
67 
68  // Allow the state to access the node so that it can process information.
69  OP_Node *getNode() const;
70 
71  int getToolboxCount() const override;
72  UI_Feel *getToolbox(int index) const override;
73 
74 protected:
75  // Provide the Op to work with. The criteria for which OP to use will
76  // be specific to each network type. This method does NOT overwrite
77  // the myOpNode pointer.
78  virtual OP_Node *getChosenOp() const = 0;
79 
80  // This method is called whenever the button is pressed to turn a PI
81  // on or off. It does not need to redraw the workbench.
82  void makePIVisible(int pi_idx, int onoff) override;
83 
84  // Begin generating (and maybe finish too if you can od it quickly).
85  // This method is called from generate() and is currently empty. You may
86  // not need to redefine it at all.
87  virtual void doGenerate();
88 
89  // Build an OP that matches our name or the name passed into the function
90  // if not nil. This does not set myOpNode.
91  OP_Node *createNode(const char *optype = 0,
92  const char *nettype = 0,
93  OP_Network *parent = 0,
94  int explicitly = 1);
95 
96  // return the node name required for createNode
97  virtual const char* getCreateNodeName() const
98  {
99  return getName();
100  }
101 
102  // Set the work node. This will detach and clean up after the previous
103  // node should there be one.
104  // setNode is virtual because the state may want to do different
105  // things when the node is set, like saving the look of PIs.
106  virtual void setNode(OP_Node *node);
107  void setNodeId(int id);
108 
109  // Make this node current. Derived classes may choose to do other things.
110  virtual void setNodeFlags(OP_Node &node);
111 
112  // Disable the footprint flag of the current node if it has outputs
113  virtual void clearChosenNodeFlags();
114 
115  // The user can dynamically change the bindings from the textport
116  // We need to refresh the current handle in the viewports
117  // cause they could be affected.
118  void refreshBindings(int id, const char *op_type) override;
119  void refreshSettings(int id, const char *op_type) override;
120 
121  // Access to the saved node, ie the node that we may have stashed away
122  // on a restart():
123  OP_Node *savedNode() const { return mySavedOpNode; }
125  {
126  clearRestartInfo();
127  mySavedOpNode = n;
128  }
129 
130  // Generate the parts of the dialog needed before the PI's are created.
131  virtual void initializeDialogs();
132  // Generate the parts of the dialog that can only be created after all the
133  // PI's are created.
134  virtual void completeDialogs();
135 
136  // Return 1 if the node is generated by a state that matches our name,
137  // or if the node's name matches our name:
138  int matchesNode(OP_Node &node) const override;
139 
140  // Removes all the dialogs including our locally defined toolbox.
141  void removeAllDialogs() override;
142 
143  // callback that is called when a dialog is deleted. It clears
144  // any pointers that may become stale.
145  void handleDialogDeleted( OPUI_Dialog *dialog ) override;
146 
147  // The method gets called when reselecting and should be overridden to
148  // add any undos needed to undo reselection.
149  virtual void addAnyReselectionUndos();
150 
151  // Return false from this function to prevent our node from having its
152  // inputs disconnected when we restart this state. Used by DOP data
153  // states, which want to leave inputs connected. The default
154  // implementation returns true.
155  virtual bool disconnectInputsOnRestart() const;
156 
157  void clearOpHandleLinks();
158 
159  // Override this to return false if undesired
160  virtual bool allowOpMaxExportToDialog() const { return true; }
161 
162 private:
163  // Create, link, attach, position, push, and activate the PI's.
164  void createOpHandleLinks();
165 
166  // Link the parms of the op to all the parms of the PI's.
167  // This method is called from createOpHandleLinks.
168  void linkAllParms();
169 
170  // Link a given (non-input) op parm to a PI, and create the PI if it
171  // doesn't already exist. This method is called from linkNonInputParms.
172  int linkSingleParm(const PI_BindingHandleInfo &bhi,
173  const PI_BindingParmInfo &bpi,
174  OP_Operator &op_type);
175 
176  BM_OpHandleLink * createSingleOpHandleLink(
177  const PI_BindingHandleInfo &bhi);
178 
179  void clearRestartInfo();
180  void saveRestartInfo(const OP_Node &node,
181  const OP_NodeList &implicits);
182  bool restoreRestartInfo(OP_Node &node);
183 
184 protected:
185  // Delete all the PI's. This method ensures that all interests in the
186  // PI's are removed and they are all deactivated.
187  void deleteOpHandleLinks();
188 
189  // data
192  OPUI_Dialog *myOpToolbox;
194 
195  // As long as this state is alive, remember what PIs are visible
197 
202 };
203 
204 #endif
virtual void stopGenerating()
Definition: BM_State.h:216
virtual int matchesNode(OP_Node &node) const =0
const char * className() const override
UT_IntArray myRestartOpInputs
OPUI_Dialog * myOpToolbox
void exit() override
UT_String myRestartInfoFile
int getToolboxCount() const override
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)
const UT_String & getName() const
Return the name passed in the constructor.
Definition: AP_Interface.h:58
UT_SymbolMap< int > myHandleTable
OP_Node * savedNode() const
#define BM_API
Definition: BM_API.h:10
int enter(BM_SimpleState::BM_EntryType how) override
GLdouble n
Definition: glcorearb.h:2007
void savedNode(OP_Node *n)
virtual void handleDialogDeleted(OPUI_Dialog *deleted_dialog)
UT_StringArray myRestartOpIndirectInputs
virtual void restart()
GLuint index
Definition: glcorearb.h:785
virtual void handleOpNetClear()
virtual int handleNodeDeleted(OP_Node &)
virtual const char * getCreateNodeName() const
virtual int generate(BM_SimpleState::BM_EntryType how, const GenerateParms &parms)
UI_Feel * getToolbox(int index) const override