HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Network.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: OP Library (C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __OP_Network_h__
13 #define __OP_Network_h__
14 
15 #include "OP_API.h"
16 #include "OP_DataTypes.h"
17 #include "OP_DotList.h"
18 #include "OP_GroupList.h"
19 #include "OP_NetworkBox.h"
20 #include "OP_NetworkBoxList.h"
21 #include "OP_Node.h"
22 #include "OP_PostIt.h"
23 #include "OP_PostItNoteList.h"
24 #include <UT/UT_Array.h>
25 #include <UT/UT_ValArray.h>
26 #include <UT/UT_Set.h>
27 #include <UT/UT_String.h>
28 #include <UT/UT_StringMMPattern.h>
29 #include <UT/UT_SymbolTable.h>
30 #include <SYS/SYS_Types.h>
31 #include <iosfwd>
32 #include <set>
33 
34 class UT_CPIO;
35 class UT_WorkBuffer;
36 class UT_StringArray;
37 class OP_Director;
38 class OP_Dot;
39 class OP_Group;
40 class OP_Operator;
41 class OP_OperatorTable;
42 class OP_ProxyRefNode;
44 class OP_UndoLoad;
45 class op_PathSet;
46 class MOT_Director;
47 
49 
51 
52 // The tile type is used to distinguish between the various types of
53 // nodes that the networks are starting to contain.
55 {
56  OP_TILE_ALL = 0xFF,
57  OP_TILE_NODE = 0x01, // The regular op nodes
58  OP_TILE_PARENT = 0x02, // The parent inputs for subnets
59  OP_TILE_GROUP = 0x04, // The op groups
60 
61  // These are for convenience
65 };
66 
67 // If you are looking for the OBJ_TABLE_NAME and SOP_SCRIPT_NAME style #defines
68 // that used to be here, they have been moved up to OP_Node.h.
69 
71 {
72  OP_RENAME_NO_PROPAGATE = 0x00, // does no propagation
73  OP_RENAME_NORMAL = 0x01, // does all propagation
74  OP_RENAME_NO_EVENTS = 0x02, // does not send op events AND
75  // does not re-export chops
76  OP_RENAME_NO_DEPENDENCIES = 0x04, // does not notify dependencies
77 
79 };
80 
82 {
84  {
85  replacePrefix = 0;
86  replaceSuffix = 0;
88  }
89 
97 
98 private:
99  // copy constructors are not implemented yet
100  OP_FixNameParms( const OP_FixNameParms &copy );
101  OP_FixNameParms &operator =( const OP_FixNameParms &copy );
102 };
103 
104 // This class is used to filter OP_Operators from being instantiated
105 // and shelf tools from appearing in the Tab menu.
107 {
108  public:
110  virtual ~OP_OperatorFilter() { }
111 
112  /// Returns true if an operator type can be created as a child, and
113  /// false otherwise.
114  virtual bool allowOperatorAsChild(OP_Operator *op) { return true; }
115 
116  /// Returns true if an operator type should be listed in the Tab menu,
117  /// and false otherwise.
119  { return allowOperatorAsChild(op); }
120 
121  /// Returns true if a shelf tool by the given name can appear
122  /// in the Tab menu for that (parent) network.
123  virtual bool allowTool(const char *tool_name) { return true; }
124 
125  /// Returns true if a shelf tool by the given name can appear
126  /// in the Tab menu for that (parent) network.
127  virtual bool allowToolSubmenus(const UT_StringHolder &tool_name,
128  const UT_StringArray &submenus) { return allowTool(tool_name); }
129 };
130 
131 typedef void *(OP_Network::*OP_FindItemFunc) (const char *);
132 
134 {
135 public:
137  ~OP_NetworkOperatorFilter() override;
138 
139  bool allowOperatorAsChild(OP_Operator *op) override;
140  bool allowOperatorInTabMenu(OP_Operator *op) override;
141 
142  bool allowToolSubmenus(const UT_StringHolder &tool_name,
143  const UT_StringArray &submenus) override;
144 
145  void setFilter(const UT_StringHolder &filter);
146 private:
147  UT_StringHolder myFilterString;
148  UT_StringMMPattern myPattern;
149  bool myHasSlash;
150 };
151 
152 class OP_API OP_Network : public OP_Node
153 {
154 public:
155  static const char *getScriptFromTable(const char *table);
156  static const char *getOpTypeFromTable(const char *table);
157 
158  // Primary node access methods. Only take OP_Node's into consideration
159  int getNchildren() const override;
160  OP_Node *getChild(const char *name=nullptr,
161  int *hint=nullptr) const override;
162  OP_Node *getChild(int index) const override;
163  virtual int getChildIndex(const OP_Node *) const;
164 
165  // isNetwork returns if the node can have children. This is true
166  // if the node has an operator table or has any children.
167  // This does NOT tell you if it is derived from OP_Network.
168  int isNetwork() const override;
169 
170  int getDandROpsEqual() override;
171  int updateDandROpsEqual(int check_inputs = 1) override;
172 
173  // This method a node within the network's UT_ValArray of children
174  // dstindex can be any number between 0 and childcount + 1.
175  // dstindex refers to the index of the child before which the
176  // src node should be moved.
177  virtual void moveChildIndex(int srcindex, int dstindex);
178 
179  // These work the same as getOpType* but return what sort of ops
180  // this network usually has as children. Of course, there's
181  // always the chance of heterogenous ops skulking around in there
182  // so treat it as a guideline rather than an assertion.
183  virtual const char *getChildType() const;
184  virtual OP_OpTypeId getChildTypeID() const = 0;
185 
186  int getTemplateOps(UT_ValArray<OP_Node *> &list);
187 
188  // obtains the children that match a given operator name.
189  // INPUTS:
190  // op_name - the name of a operator to look for (e.g., "object_merge")
191  // OUTPUTS:
192  // list - the list of children that are instances of an operator
193  // that is identified by op_name
194  // RETURNS:
195  // number of children in the output list
196  int getOpsByName(const char *op_name,
197  UT_Array<OP_Node *> &list) const;
198 
199  OP_Node *peekCurrentNodePtr();
200  void stashCurrentNodePtr(const OP_Node *child);
201  OP_Node * getStashedCurrentNodePtr() const;
202 
203  virtual OP_Node *getCurrentNodePtr();
204  virtual OP_Node *getDisplayNodePtr();
205  virtual OP_Node *getRenderNodePtr();
206  virtual OP_Node *getExportNodePtr();
207  virtual CHOP_Node *getAudioNodePtr();
208  virtual OP_Node *getCop3DNodePtr(); // Export if present, else display
209  virtual void toggleCop3DNodePtr(); // Stash/Unstash 3d node ptr
210  virtual OP_Node *getStashedCop3DNodePtr(); // The stashed if present
211  virtual void setStashedCop3DNodePtr(const OP_Node *node);
212  virtual const UT_ValArray<OP_Node *> &getOutputNodePtrs() const;
213 
214  virtual void childDeleted(OP_Node *);
215  virtual void childFlagChange(OP_Node *);
216 
217  fpreal getChildrenScale() const { return myChildScale; }
218  void setChildrenScale(fpreal scale);
219 
220  // Returns the OP_OperatorFilter object for this network. Used to
221  // filter out some OP_Operator types. See OP_OperatorFilter above.
222  virtual OP_OperatorFilter *getOperatorFilter();
223 
224  /// Obtains the namespace scope names for this network and for its parents,
225  /// all aranged in a stack array, with this network's name first in the
226  /// array, and the node hierarchy root (director) appearing last.
227  /// By convention, the scope name is the same as the network operator name
228  /// (with the table name).
229  void getNetworkScopeStack(UT_StringArray &scope_stack);
230 
231  /// Returns true if the given op can be created as a child of this network.
232  bool isOperatorAllowedAsChild(OP_Operator *op);
233 
234  /// Returns true if the given op can show up in the Tab menu.
235  virtual bool isOperatorAllowedInTabMenu(OP_Operator *op);
236 
237  /// Returns true if the given op can show up in the Tab menu.
238  bool isOperatorCreateAllowed(OP_Operator *op);
239 
240  /// Returns true if the given tool can appear in the Tab menu for this net.
241  bool isToolAllowed(const UT_StringHolder &tool_name,
242  const UT_StringArray &submenus);
243 
244  /// Adds a new OP_Node of the specified type as a child of this node.
245  /// If 'name' is not given, then it will use 'type' suffixed with a unique
246  /// numeric suffix. In either case, if the 'name' collides with a
247  /// pre-existing node, then the actual node will be created with a unique
248  /// name created by numeric suffixing.
249  /// @param exact_type If true, the operator name parameter 'type',
250  /// is used verbatim to lookup the operator. Otherwise,
251  /// a preferred operator name that matches 'type'
252  /// specification is found first and then is used to lookup
253  /// the operator. The preferred type may be different than
254  /// 'type' for version namespace (eg "hda"
255  /// may match the preferred "hda::2.0" operator), for
256  /// scope namespace (eg "hda" may match
257  /// "Object/outer::hda" inside "outer" subnet), or for
258  /// operator namespace (eg, "userX::hda" may be preferred
259  /// to "hda", if the namespace hierarchy is so configured
260  /// that "userX" namespace trumps the top level (global)
261  /// namespace).
262  OP_Node *createNode(
263  const char *type,
264  const char *name = nullptr,
265  int notify = 1,
266  int explicitly = 1,
267  int loadcontents = 1,
268  int *aliased_scripted_op = nullptr,
269  char *mat_icon_filename = nullptr,
270  bool exact_type = false);
271 
272  /// Convenience method for requesting en exact type
274  const char *name = nullptr)
275  {
276  return createNode(type, name, 1, 1, 1, nullptr,
277  nullptr, true);
278  }
279 
280  // Create dummy reference proxy nodes for dangling references
281  // This should only be called from OP_Node!
282  OP_Network *createProxyRefNode( const char *path ) override;
283 
284 
285  // Returns the list of nodes eligible to be considered for child
286  // errors.
288  OP_NodeList &nodes) const override;
289 
290  // Makes a copy of a single node inside this network. The source node does
291  // not need to be inside this network.
292  OP_Node *copyNode(const OP_Node *srcnode,
293  const char *toname = nullptr,
294  bool reference_parameters = false);
295 
296  // Makes a copy of any number of network items inside this network. The
297  // source items must all be contained in a single network, but it does
298  // not need to be this network.
299  bool copyItems(const OP_NetworkBoxItemList &srcitems,
300  OP_NetworkBoxItemList &destitems,
301  bool reference_parameters,
302  bool relative_references,
303  bool connect_outputs_to_multi_inputs);
304 
305  // Makes a copy of all picked network items into this network. The source
306  // network does not need to be this network.
307  void copyPickedItems(
308  const OP_Network *srcnet,
309  OP_ItemTypeMask item_type_mask,
310  OP_Group *newnodes = nullptr,
311  const OP_FixNameParms *fix_name_parms=nullptr);
312 
313  // Copy 'srcnetbox' and its contents to this network. 'toname' specifies
314  // the name you'd like the copy to have. If this name has already been
315  // taken in this network, we'll use a slightly altered unique version of
316  // it. 'nodes' may only be non-null when 'save_type' is
317  // OP_NETWORKBOX_SAVE_SPECIFIED_CONTENTS, in which case it must be a valid
318  // ptr array of nodes in 'netbox'.
319  OP_NetworkBox *copyNetworkBox(OP_NetworkBox *srcnetbox,
320  OP_NetworkBoxSaveType save_type,
321  OP_NodeList *nodes = nullptr,
322  const char *toname = nullptr,
323  bool reference_parameters = false);
324 
325  // Copy a single post-it note into this network. The source post-it does
326  // not need to be in this network.
327  OP_PostIt *copyPostItNote(OP_PostIt *src_note,
328  const char *toname = nullptr);
329 
330  // Makes a copy of all picked nodes into this network. The source network
331  // does not need to be this network.
332  void copyPickedNodes(const OP_Network *srcnet,
333  OP_Group *newnodes=nullptr,
334  const OP_FixNameParms *fix_name_parms=nullptr);
335 
336  // Moves the picked nodes from srcnet into this network.
337  // If src_nodes_ptr and dest_nodes_ptr are not null, they will be set
338  // to the original node pointers and the new node pointers. (The nodes
339  // in src_nodes_ptr will have been deleted.)
340  virtual bool movePickedNodes(OP_Network *src_net,
341  OP_NodeList *src_nodes_ptr=nullptr,
342  OP_NodeList *dest_nodes_ptr=nullptr);
343 
344  /// Returns true if it is safe at this time to destroy this node.
345  static bool canDestroyNode(OP_Node *node);
346 
347  int destroyNode(OP_Node *node);
348  int destroyNodes(const OP_NodeList &nodes);
349 
350  virtual int renameNode(OP_Node *node, const char *name,
352 
353  /// Obtains the CHOP network to store motion effects. If create is true,
354  /// then it will be created if it doesn't exist yet.
355  OP_Network *findOrCreateMotionEffectsNetwork(bool create=true);
356 
357  // Delete implicit ancestors. If included is true delete the initial given
358  // node as well. If a state name is passed in, check that the nodes were
359  // created by that state. The node is not deleted if any of its outputs do
360  // not match the given state. This function will have no effect on nodes
361  // not belonging to this network, or on subnetworks. The deletion will
362  // stop at the first invalid node (if keep_node points to anything, that
363  // node is invalid for deletion).
364  OP_Node *deleteImplicitAncestors(
365  OP_Node &node,
366  const char *state = nullptr,
367  OP_Node *keep_node = nullptr,
368  bool included = true);
369  // non-destructive version of deleteImplicitAncestors() that just returns
370  // the information.
371  OP_Node *getImplicitAncestors(
372  OP_NodeList &implicit_nodes,
373  OP_NodeList &border_nodes,
374  OP_Node &node,
375  const char *state = nullptr,
376  OP_Node *keep_node = nullptr,
377  bool included = true);
378 
379  // Fetch all channel collections from this node down.
380  int getAllCollections(UT_ValArray<CH_Collection *> &list,
381  int hide=0);
382 
383  /// Build a unique node name or a unique operator name from
384  /// the one given. We'll pretend we also have children with the names in
385  /// 'fakeChildren' when we do our name-collision checking if 'fakeChildren'
386  /// is non-NULL.
387  void uniqueNodeName(UT_String &name,
388  UT_StringSet *fake_children = nullptr);
389 
390  // This function is used to make some extra names invalid. Returns 0
391  // by default. Used by the VOPNET manager to prevent a new VOPNET
392  // with a name that matches an existing operator type.
393  virtual int isInvalidName(const char *name);
394 
395  static void fixName( const char *name,
396  const OP_FixNameParms &fix_name_parms,
397  UT_String &fixed_name );
398 
399  // I/O methods - there are also the save & load inherited from the
400  // OP_Node class.
401 
402  ///Save all picked items of the types specified by 'item_type'. Note that
403  ///saving any nodes or netboxes implicitly always saves indirect inputs if
404  ///they're picked (legacy behaviour). If 'item_type' includes netboxes, you
405  ///can specify the save policy for netboxes regarding how much of their
406  ///contents they should be saved along with themselves. This is the only way
407  ///for a node to remember which netbox it was in.
408  OP_ERROR savePickedItems(std::ostream &os,
409  const OP_SaveFlags &flags,
410  OP_ItemTypeMask item_type,
411  OP_NetworkBoxSaveType save_type =
413 
414  ///Save all items of the types specified by 'item_type'. Note that
415  ///saving any nodes or netboxes implicitly always saves indirect inputs if
416  ///they're picked or part of a picked netbox (legacy behaviour).
417  OP_ERROR saveAllItems(std::ostream &os,
418  const OP_SaveFlags &flags,
419  OP_ItemTypeMask item_type);
420 
421  // Saves a single node with the same save options on the child nodes
422  // as on the top level node, with the exception of network box membership
423  // for children (which should always be saved)
424  OP_ERROR saveSingle(std::ostream &os, OP_Node *op,
425  const OP_SaveFlags &flags,
426  const UT_String &name_override = UT_String());
427  // Saves a single node with different save options for the child nodes
428  // compared to the top level node.
429  OP_ERROR saveSingle(std::ostream &os, OP_Node *op,
430  const OP_SaveFlags &flags,
431  const OP_SaveFlags &childflags,
432  std::set<int>* renaming_exclude_ids = nullptr,
433  const UT_String &name_override = UT_String());
434 
435  ///Saves a single netbox. 'save_type' lets you specify the save policy
436  ///with regards to how much of its contents the network box saves with it.
437  ///'nodes' may only be non-null when 'save_type' is
438  ///OP_NETWORKBOX_SAVE_SPECIFIED_CONTENTS, in which case it must be a valid
439  ///ptr array of nodes in 'netbox'.
440  OP_ERROR saveSingleNetworkBox(std::ostream &os,
441  OP_NetworkBox &netbox,
442  const OP_SaveFlags &flags,
443  OP_NetworkBoxSaveType save_type,
444  OP_NodeList *nodes = nullptr);
445 
446  /// Save a single post it note.
447  OP_ERROR saveSinglePostIt(std::ostream &os, OP_PostIt &pnote,
448  const OP_SaveFlags &flags);
449 
450  /// Save a single dot.
451  OP_ERROR saveSingleDot(std::ostream &os, OP_Dot &dot,
452  const OP_SaveFlags &flags);
453 
454  ///In order to avoid duplicately saving nodes in 'op_list' that have already
455  ///been saved by their netboxes, make sure to mark those netboxes and then
456  ///pass in 'skip_nodes_in_marked_netboxes' as true.
457  OP_ERROR saveOpList(std::ostream &os,
458  const UT_Array<OP_Node *> &op_list,
459  const OP_SaveFlags &save_flags,
460  int *nsaved = nullptr);
461 
462  //Use when saving a mixture of different types of items into 1 file
463  OP_ERROR saveItemList(std::ostream &os,
464  const OP_NetworkBoxItemList &items,
465  const OP_SaveFlags &save_flags);
466 
467  const char *getClipboardFile(const char *file_prefix = nullptr);
468 
469  //Note that although we now have an OP_ItemTypeMask parameter available to
470  //us, we still need to keep the OP_TileType parameters to indicate saving
471  //of groups *boo*
472  int saveToClipboard(int all, OP_TileType type=OP_TILE_NODE,
473  int grouplist=0,
474  OP_ItemTypeMask item_type = OP_ITEMTYPE_NODE,
475  const char *file_prefix = nullptr);
476  int loadFromClipboard(fpreal x = 0, fpreal y = 0,
477  bool turn_off_display = false,
478  const char *file_prefix = nullptr);
479 
480  // loadNetwork will load nodes into the current net. For example,
481  // if there file is "foo.sops", you would call obj->loadNetwork().
482  // if the file were "foo.obj", you would call obj->getParent()->loadNetwork
483  bool loadNetwork(UT_IStream &is,
484  int merge = 0,
485  const char *pattern = nullptr,
486  int overwrite = 0,
487  const OP_FixNameParms *fix_name_parms = nullptr,
488  UT_StringArray *src_names = nullptr,
489  UT_StringArray *dest_names = nullptr);
490 
491  // Second signature for loadNetwork which takes an OP_OverwriteAction enum
492  // to control the overwrite behavior in a more granular way than the bool
493  // parameter offered in the method above.
494  bool loadIntoNetwork(UT_IStream &is,
496  bool merge = false,
497  const char *pattern = nullptr,
498  const OP_FixNameParms *fix_name_parms = nullptr,
499  UT_StringArray *src_names = nullptr,
500  UT_StringArray *dest_names = nullptr);
501 
502  bool pasteNetworkForMove(UT_IStream &is,
503  UT_StringArray &src_names,
504  UT_StringArray &dest_names);
505 
506  bool opShouldHandleChange(OP_EventType reason) override;
507 
508  static bool isOpWritten(UT_IStream &is);
509 
510  void clearUnreferencedInputs() override;
511 
512  /// Check a stream for collisions for loading... This will add the
513  /// problem nodes to 'node_list' and the problem network boxes to
514  /// 'netbox_list', and also return the total number of collisions found...
515  /// It rewinds the stream to the starting point, thus, it can't be used with
516  /// stdin! Remember that a node can collide with a network box, since they
517  /// share the same namespace!
518  int getLoadCollisions(UT_IStream &is, OP_NodeList &node_list,
519  UT_ValArray<OP_NetworkBox *> &netbox_list,
520  UT_ValArray<OP_PostIt *> &pnote_list,
521  const char *pattern = "*");
522 
523  /// Simulates adding items with the names in 'names' to this network, and
524  /// stores the resulting names after name-collisions have been addressed
525  /// back into 'names'. This works for anything sharing the node namespace,
526  /// which currently includes nodes and network boxes.
527  void simulateNameCollisions(UT_StringArray &names);
528 
529  // The getSortedList() returns an array of all the child nodes sorted
530  // alphabetically.
531  const UT_ValArray<OP_Node *> *getSortedList();
532 
533  // getAnyOutputOf will return the first OP found which is has the
534  // given OP as an input. Returns null if no such op exists.
535  OP_Node *getAnyOutputOf(OP_Node *op) const;
536 
537  // getAnyOP will return any OP in the collection.
538  // Null if there are none.
539  OP_Node *getAnyOP() const;
540 
541  // Group manipulation methods:
542  char *findUniqueGroupName(const char *basename=nullptr);
543  OP_Group * findGroup(const char *name) const;
544  OP_Group * createGroup(const char *name=nullptr);
545  int destroyGroup(const char *name);
546  int destroyGroup(OP_Group *group);
547 
548  int getNgroups() const;
549  OP_Group *getGroup(int index) const;
550  int getGroups(UT_ValArray<OP_Group *> &list, int internal=0);
551  int getMemberships(const OP_Node *node,
553  int internal=0);
554 
555  char *findUniqueNetworkBoxName(const char *base = nullptr);
556  char *findUniquePostItNoteName(const char *base = nullptr);
557  char *findUniqueDotName(const char *base = nullptr);
558 
559  /// Pass in NULL as the name if you'd like a default name. Passing in
560  /// 'items' will automatically create a network box containing those items
561  /// with the netbox positioned properly around them
562  OP_NetworkBox *createNetworkBox(const char *name,
563  OP_NetworkBoxItemList *items = nullptr);
564  int getNnetworkBoxes() const;
565  // Given a path, return the network box. The path may be relative.
566  OP_NetworkBox *findNetworkBox(const char *const_path) override;
567  // Unlike 'findNetworkBox()', these 2 methods only return netboxes
568  // contained directly in this network itself.
569  OP_NetworkBox *getNetworkBox(int index) const;
570  OP_NetworkBox *getNetworkBox(const char *name) const;
571 
572  /// Pass in NULL as the name if you'd like a default name.
573  OP_PostIt *createPostItNote(const char *name);
574  int getNpostItNotes() const;
575  // Given a path, return the post it note. The path may be relative.
576  OP_PostIt *findPostItNote(const char *const_path) override;
577  // Unlike 'findPostItNote()', these 2 methods only return postits
578  // contained directly in this network itself.
579  OP_PostIt *getPostItNote(int index) const;
580  OP_PostIt *getPostItNote(const char *name) const;
581 
582  // Dots are not meant to be referenced by name.
584  { return myDotList; }
585  int getNdots() const;
586  // Given a path, return the post it note. The path may be relative.
587  OP_Dot *findDot(const char *const_path) override;
588  OP_Dot *getDot(int index) const;
589  OP_Dot *getDot(const char *name) const;
590 
591  /// Return the number of items picked. 'item_type_mask' is a bit field used
592  /// to specify which item types you'd liked to include in the count. Use the
593  /// values in OP_ItemType to set the bits in 'item_type_mask'.
594  unsigned int nPicked(OP_ItemTypeMask item_type_mask,
595  bool include_hidden_nodes) const;
596 
597  /// Return all picked items of types specified by 'item_type_mask'.
598  /// Note that if only picked nodes are of interest, there is also
599  /// OP_Node::getPickedChildren().
600  void getPickedItems(OP_ItemTypeMask item_type_mask,
601  OP_NetworkBoxItemList &picked,
602  bool include_hidden = false,
603  bool recurse_picked_netboxes = false) const;
604 
605  /// Return all items that match the type mask.
606  void getAllItems(OP_ItemTypeMask item_type_mask,
607  OP_NetworkBoxItemList &items) const;
608 
609  /// Returns true if the item was successfully deleted
610  bool destroyItem(OP_NetworkBoxItem *item);
611  /// Returns the number of successfully deleted items
612  int destroyItems(const OP_NetworkBoxItemList &items);
613 
614  /// Same as findNode or findNetworkBox, but more generalized so you can
615  /// search through multiple items with just one method. 'item_type_mask' is
616  /// used to specify what type of items you want to consider in your search.
617  /// Does not support indirect parent input searches.
618  OP_NetworkBoxItem *findItem(const char *const_path,
619  OP_ItemTypeMask item_type = OP_ITEMTYPE_ALL
620  ) override;
621 
622  /// Look up a direct child item by name, with an option to screen based
623  /// on the item type. Like findItem above, but doesn't look into child
624  /// networks.
625  OP_NetworkBoxItem *getItem(const char *name,
626  OP_ItemTypeMask item_type = OP_ITEMTYPE_ALL);
627 
628  /// Returns true if the given node is a child descendant of the same
629  /// type with no intervening levels of different type.
630  bool isSubNode(const OP_Node *node) const;
631 
632  /// Try to avoid using this method, it only clears the selection for tiles,
633  /// not network boxes (network boxes are considered items but not tiles).
634  /// Can use setAllPickFlags() instead. In fact, since there are no group
635  /// tiles in the worksheet any more, this method has become somewhat useless
636  void clearSelection(OP_TileType t, int grouplist);
637 
638  ///Set the pick flags to 'value' for all items of types specified by
639  ///'item_type'
640  void setAllPickFlags(OP_ItemTypeMask item_type, int value);
641  void pickRequest(OP_NetworkBoxItem *item, int shift);
642  void pickRequest(int shift)
643  { OP_Node::pickRequest(shift); }
644 
645  void addPicked(const OP_Group *group); // Pick these nodes
646  void subPicked(const OP_Group *group); // Removed from picked
647 
648  // There are two versions of getOperatorTable. One that takes an
649  // operator type and returns the table for that type. The second
650  // returns the operator table associated with this network. This
651  // latter assumes that "setOperatorTable" has been called. All
652  // OP_Network sub-class constructors should do this:
653  //
654  // setOperatorTable(getOperatorTable(operatorType));
655  //
656  // If the script_path is NOT null, this method will create the
657  // operator table if it doesn't exist. Otherwise, it will return
658  // null for non-existant table names.
659  static OP_OperatorTable *getOperatorTable(
660  const UT_StringRef &op_type,
661  const char *script_path=nullptr);
663  { return myOperatorTable; }
664  virtual const char *getScriptDirectory();
665 
666  // this is overridden so that we can clear the group flags
667  void clearUndoFlags() override;
668 
669  // Sub-networks use parent inputs to connect open inputs in
670  // the net to inputs in the parent. A list of the parent connections
671  // is the bookeeping required to manage and resolve these connections.
672  bool wantsParentInputs() const;
673 
674  // Get all picked Parent Inputs
675  int getNparentInputs() const
676  { return myParentInputs.entries(); }
677  OP_SubnetIndirectInput *findParentInput(const char *const_path) override;
678  OP_SubnetIndirectInput *getParentInput(OP_InputIdx index) const;
679  OP_SubnetIndirectInput *getParentInput(const char *name) const;
680 
681  // getIndirectString returns a string that can be used to save
682  // parent inputs that refer to our parent input table.
683  // These are simply saved as a string index into our table.
684  // These can be resolved back using resolveIndirectString.
685  int getIndirectString(OP_IndirectInput *, UT_String &);
686  OP_IndirectInput *resolveIndirectString(const char *);
687 
688  void inputConnectChanged(OP_InputIdx which) override;
689 
690  void getAllConnectedChildren(
691  OP_InputIdx input_index, UT_Array<OP_Node*> &nodes,
692  bool expand_subnets = true) const;
693  void getAllConnectedChildrenNamed(
694  const OP_ConnectorId& input_name,
695  UT_Array<OP_Node*> &nodes,
696  bool expand_subnets = true) const;
697 
698  // The ViewSetting functions are used by ICE to store the name
699  // of the COP currently being viewed. Put here because COP2_SubNets
700  // and ICENET_Nodes both need to store this information.
701  virtual void setViewSetting(const char *) {};
702  virtual const char *getViewSetting() const { return ""; }
703 
704  void dumpDependencies(std::ostream &os) override;
705 
706  void changeParmTemplate(
707  PRM_Template *new_template) override;
708 
709  int getNumChildManagers(OP_OpTypeId type) const;
710  void addChildManager(OP_OpTypeId type);
711  void removeChildManager(OP_OpTypeId type);
712  bool getSaveWithVopnets() override;
713  void runDelScript() override;
714  void clearDelScripts(int picked_only);
715 
716  /// This method will unscope all the channels belonging to this op.
717  /// If the recurse flag is set it will recurse through the children
718  /// (at this level the recurse flag is ignored).
719  void unscopeChannels(bool recurse) override;
720 
721  /// This method will undisplay all the channels belonging to this op.
722  /// If the recurse flag is set it will recurse through the children
723  /// (at this level the recurse flag is ignored).
724  void undisplayChannels(bool recurse) override;
725 
726  /// This method will undisplay all the channels belonging to this op.
727  /// If the recurse flag is set it will recurse through the children
728  /// (at this level the recurse flag is ignored).
729  void unpinChannels(bool recurse) override;
730 
731  // Do global expansion on a pattern - get lists of network boxes
732  // If expand is given, concatenated with full list of names
733  // If list is given, appended with list of nodes.
734  void globNetworkBoxes(
735  const char *pat,
736  UT_String *expand,
737  UT_ValArray<OP_NetworkBox *> *list = nullptr,
738  OP_GlobContext *context = nullptr,
739  const char *prefix = " ") override;
740 
741  void globPostIts(
742  const char *pat, UT_String *expand,
743  UT_ValArray<OP_PostIt *> *list = nullptr,
744  OP_GlobContext *context = nullptr,
745  const char *prefix = " ") override;
746 
747  /// Returns the unique id of the representative operator that this network
748  /// may have. The changed_child parameter and the current_rep_id are used
749  /// in order to minimize the number of findSubNode() calls that are made.
750  int getRepresentativeNodeId(OP_Node *changed_child,
751  int current_rep_id);
752 
753  // Changes a child node's type from its current type to 'newtype'
754  // the keep... parameters will maintain the same name, pararmeter values
755  // and network contents if set to true.
756  bool changeChildNodeType(OP_Node *child,
757  const char *newtype,
758  bool keepname,
759  bool keepparms,
760  bool keepcontents,
761  bool quiet,
762  int *new_child_id = nullptr);
763 
764  // Returns true if the supplied node is specially marked as editable
765  // in this locked HDA node.
766  bool getIsSubNodeEditable(const OP_Node *subnode) const;
767  bool hasAnyEditableSubNodes() const;
769  { return myEditableSubNodes; }
770 
771  /// Builds the list of subnodes that are marked as message nodes.
772  /// Returns false if there are none (list.entries() == 0 then)
773  bool getMessageSubNodes(OP_NodeList &list) const;
774 
775  // Add any OTL-defined operators used by this network to the specified
776  // table.
778  UT_Set<OP_Operator *> &active_operators
779  ) const override;
780 
781  // Save a packet containing the fallback library paths for the specified
782  // operators.
783  static void saveOTLBackupInformation(std::ostream &os,
784  const OP_OperatorList &fallbackops,
785  const OP_OperatorList &dummyops);
786 
787  static void saveFallbacksPathsFor(
788  std::ostream &os,
789  const UT_Set<OP_Operator *> &otloptable);
790 
791  OP_SubnetIndirectInput *getNamedParentInput(
792  const OP_ConnectorId& name) const;
794  { return myIsClearingContentsOfEditableSubnodes; }
795 
796  int64 getMemoryUsage(bool inclusive) const override;
797 
798  static bool warnDeprecatedOpsOnLoad()
799  { return theWarnDeprecatedOpsOnLoad; }
800  static void setWarnDeprecatedOpsOnLoad(bool enable)
801  { theWarnDeprecatedOpsOnLoad = enable; }
802 
803  void setCachedMimeFile(const char *filename);
804  const char *getCachedMimeFile() const;
805  void clearCachedMimeFile();
806  bool hasCachedMimeFile() const;
807 
808  OP_ERROR getErrorSeverity() override;
809  void getRawErrors(UT_Array<UT_Error> &errors,
810  bool update) override;
811 
812 protected:
813  // Protected constructor since networks are only created by Operators.
814  OP_Network(OP_Network *parent, const char *name, OP_Operator *op);
815  ~OP_Network() override;
816 
817  void clearAndDestroy() override;
818  void clearAndDestroyNodes();
819 
821  OP_Node *by_whom,
822  OP_EventType reason,
823  int parm_index,
824  OP_PropagateData &prop_data) override;
825 
826  // new method for dependencies: use the PRM_TYPE_OP_REF_*
827  // in your parm template to add your dependency.
828  // override this to do special cases, make sure you call the base class
829  void buildOpDependencies() override;
831  const UT_String &full_from,
832  OP_NodeList &cook_nodes) override;
834  const UT_String &full_from,
835  OP_NodeList &cook_nodes) override;
836  void rebuildOpDependents( bool proxy_only ) override;
837 
838  // clone dependencies from the proxy. proxy is no longer valid
839  // after the clone!
840  void cloneFromProxyRefNode( OP_Network *proxy ) override;
841  // clone a new proxy node. this node is no longer valid after this!
842  OP_Network * cloneToProxyRefNode() override;
843  int hasProxyRefNodes() const override
844  { return myProxyRefNodes.entries() > 0; }
845  void removeProxyRefNode( OP_Network *proxy );
846  void moveProxyRefNodes( OP_Network *dest ) override;
847 
848  void moveDependencies( OP_Node *from_node ) override;
849 
850  // Override of OP_Node::load to handle some network-specific packets.
851  bool load(UT_IStream &is,
852  const char *ext = "",
853  const char *path = nullptr) override;
854 
855  /// Called upon entering and exiting loadNetwork() method
856  virtual void beginLoadingInNetwork();
857  virtual void endLoadingInNetwork();
858 
859  // Called at the end of loadChildOrder()
860  virtual void finishedLoadingChildOrder();
861 
862  // Called when loadNetwork finishes loading this whole network.
863  // Do not set `is_child_call`. That argument is set internally to
864  // true when finishedLoadingNetwork() is called on the node's children.
865  virtual void finishedLoadingNetwork(bool is_child_call=false);
866 
867 public:
868  /// Returns the current recursion depth of syncContents, note this is
869  /// NOT thread safe.
870  static int syncContentsLevel();
871 
872 protected:
873  // This overrides the OP_Node function.
874  // syncContents loads the given stream into this operator.
875  // The stream should be in .hip file format, with "this" pointing to
876  // the root node in the .hip file. It handles collisions gracefully
877  // by updating the existing operators instead of deleting and
878  // recreating them. It deletes any existing nodes not in the
879  // stream, and creates nodes if necessary.
880  bool syncContents(UT_IStream &is) override;
881 
882  // The following should only be called by the director, who doesn't have
883  // a real choice, does he?
884  virtual void addNode(OP_Node *node, int notify=1, int explicitly=1);
885 
886  OP_Node *findConnectedNode(OP_Node *op) const;
887 
888  // These functions ensure we have valid render and display nodes.
889  OP_Node *getPreferredDisplayNodePtr(OP_Node *skipthisnode)const;
890  void resetDisplayNodePtr(OP_Node *skipthisnode=nullptr);
891  OP_Node *getPreferredRenderNodePtr(OP_Node *skipthisnode) const;
892  void resetRenderNodePtr(OP_Node *skipthisnode=nullptr);
893  OP_Node *getPreferredAudioNodePtr(OP_Node *skipthisnode) const;
894  void resetAudioNodePtr(OP_Node *skipthisnode=nullptr);
895  virtual CHOP_Node **getAudioNodeRef();
896 
897  // This function calls all of the above, for when we are deleting nodes.
898  void validateStatusNodePtrs(const OP_NodeList &skipnodes);
899 
900  virtual void updateExtraFlagPtrs();
901 
902  void nodeUnlocked() override;
903 
904  bool canDestroyNode() override;
905  virtual void destroySingleNode(OP_Node *node);
906 
907  // This function goes recursively through every node below this one and
908  // renames it to some unique but meaningless value. This is used for
909  // compiling networks.
910  void modifyAllChildNodeNames(bool renamepickableobjects,
911  const char *prefix, int &id,
912  std::set<int>* renaming_exclude_ids = nullptr);
913 
914  /// This is a helper method to the setChannelScope method. It traverses
915  /// the node's parameters and sets the scope on them according to the
916  /// given pattern.
917  /// This method is also defined in OP_Parameters, it is overridden here
918  /// to provide parsing support for network paths.
919  void traverseScope(const char *pattern,
920  OP_ScopeOp scope_op,
921  const OP_ScopeOptions &scope_opts) override;
922 
923 
928  int myCop3DNodeStash = OP_INVALID_NODE_ID;
930 
931  // Implemented in VOPs. Only the new nodes are to be inserted into the out
932  // list, not any of the existing ones.
933  virtual void getAdditionalUndoNodes(const OP_NodeList& orig_list,
934  OP_NodeList& nodes_for_input_undo) { }
935 
936  /// Returns true if the child at node can should be saved, false otherwise.
937  virtual bool getAllowSavingChild(OP_Node *node,
938  const OP_SaveFlags &flags)
939  { return true; }
940 
941 private:
942  // Some helper functions for loading and saving.
943  OP_ERROR saveNetwork(std::ostream &os, const OP_SaveFlags &flags,
944  const OP_SaveFlags &childflags,
945  const char *path_prefix, bool vopnets);
946  OP_ERROR saveChildNodes(std::ostream &os, const OP_SaveFlags &flags,
947  const char *path_prefix, bool vopnets,
948  bool force_no_init = false);
949  OP_ERROR saveOp(std::ostream &os, OP_Node *node,
950  const OP_SaveFlags &flags,
951  const OP_SaveFlags &childflags, const char *path_prefix,
952  bool vopnets, bool force_no_init = false,
953  const UT_StringHolder &name_override = UT_StringHolder());
954  OP_ERROR savePostIt(std::ostream &os, OP_PostIt *pnote,
955  const OP_SaveFlags &flags,
956  const char *path_prefix);
957  bool loadNodeType(UT_IStream &is, OP_Network *net,
958  UT_String &node_type, int &matches);
959  bool loadOp(UT_IStream &is,
960  OP_OverwriteAction overwrite,
961  const char *path,
962  op_PathSet &noneditable_missing_table);
963 
964  ///Save out all the netboxes in this network to 'os' in separate packets
965  OP_ERROR saveNetworkBoxes(std::ostream &os, const OP_SaveFlags &flags,
966  const char *path_prefix);
967  OP_ERROR savePostIts(std::ostream &os, const OP_SaveFlags &flags,
968  const char *path_prefix);
969  OP_ERROR saveDots(std::ostream &os, const OP_SaveFlags &flags,
970  const char *path_prefix);
971 
972  /// Load a network box from 'is'. Can load from both .hip files and the
973  /// clipboard. 'path' is used as the new netbox's name. If 'overwrite' is
974  /// specified, the new netbox will overwrite any other netboxes in this
975  /// network with the same name, rather than modify its name to be unique.
976  /// 'created' is used to return a ptr to the new network box.
977  bool loadNetworkBox(UT_IStream &is, const char *path = "",
978  bool path_contains_network = true,
979  bool path_contains_packet_ext = true,
981  OP_NetworkBox **created = nullptr);
982 
983  /// Load a post-it note from 'is'. Can load from both .hip files and the
984  /// clipboard. 'path' is used as the new post-it's name. If 'overwrite' is
985  /// specified, the new post-it will overwrite any other post-its in this
986  /// network with the same name, rather than modify its name to be unique.
987  /// 'created' is used to return a ptr to the new post-it.
988  bool loadPostIt(UT_IStream &is, const char *path = "",
989  bool path_contains_network = true,
990  bool path_contains_packet_ext = true,
992  OP_PostIt **created = nullptr);
993 
994  /// Load a network dot from 'is'. Can load from both .hip files and the
995  /// clipboard. 'path' is used as the new dot's name. If 'overwrite' is
996  /// specified, the new dot will overwrite any other dots in this
997  /// network with the same name, rather than modify its name to be unique.
998  /// 'created' is used to return a ptr to the new post-it.
999  bool loadDot(UT_IStream &is, const char *path = "",
1000  bool path_contains_network = true,
1001  bool path_contains_packet_ext = true,
1002  OP_OverwriteAction overwrite = OP_NO_OVERWRITE,
1003  OP_Dot **created = nullptr);
1004 
1005  // Some special handling for items loaded into a network due to copy/paste
1006  // or undo/redo. We need to register these items with an OP_UndoLoad, and
1007  // we may want to pick them.
1008  void beginPickLoaded(bool pick_loaded);
1009  void beginLoadUndo(OP_Node *save_ops[4]);
1010  void itemLoaded(OP_NetworkBoxItem *item);
1011  void endLoadUndo(OP_Node *save_ops[4]);
1012  void endPickLoaded();
1013 
1014  // Some helper functions for syncContents.
1015  bool syncContentsInit(UT_IStream &is,
1016  OP_Network *net, OP_Node *node,
1017  UT_String &node_name, OP_Node *&newnode,
1018  bool &match_definition_failure,
1019  const char *packet_node_path);
1020  // Helper method to clear the netboxes/post-its from any subnodes of the
1021  // given network whose netboxes may be saved to *this network's contents
1022  // section without a preceding .init packet for that subnode.
1023  void syncContentsClearNetboxesFromNonInitSubNodes(OP_Network *net);
1024  // Helper method to clear the contents of any editable subnodes which will
1025  // be loaded from the hip file or a parent asset's contents.
1026  void clearContentsOfEditableSubNodes();
1027  // Helper method to determine if an ancestor is an instance of a particular
1028  // operator currently loading its contents section.
1029  bool isLoadingContentsSection(OP_Operator *op) const;
1030 
1031  void setDoMergeFlag( bool flag ) { myDoMerge = flag; }
1032 
1033  // These functions perform operations that are required after loading
1034  // a number of new operators. Used by loadNetwork and syncContents.
1035  void resolveNetworkBoxOwnership();
1036  void initSpecialNodes(OP_NodeList &loaded_ops);
1037  void initNodeConnectors(OP_NodeList &loaded_ops);
1038  void sendBulkNotifications(const OP_NodeList &loaded_ops,
1039  const OP_NodeList &op_roots,
1040  bool builddependencies,
1041  bool notify_name_dependents);
1042  void fixPendingOverride();
1043 
1044  int savePartialVerify(std::ostream &os);
1045  void createParentInputs();
1046 
1047  // Build a list of item roots from the stream. In English, this means that
1048  // 'item_roots' will be populated with the paths of all items at the top
1049  // level of this load. Initial stream position is unchanged.
1050  bool buildItemRoots(UT_IStream &is, const char *merge_pattern,
1051  UT_StringArray &item_roots);
1052 
1053  // Destroys all child nodes except those that appear in the supplied
1054  // list (and their parents). Traverses into writable child nodes too.
1055  // Returns the number of descendants found in nodes.
1056  void destroyAllNodesExcept(const UT_Set<OP_Node *> &nodes);
1057 
1058  // Then after the list is made, we go through and rename the original
1059  // items so there won't be any collisions on loading
1060  void prepareCollisionNames(const OP_NetworkBoxItemList &items,
1061  UT_WorkBuffer &prefix);
1062  // Then, after the load, we go through and rename the items to their
1063  // original status (renaming the collisions along the way)
1064  void fixLoadInputs(); // Resolves references of nodes
1065  void fixLoadNames(const OP_NetworkBoxItemList &items,
1066  UT_WorkBuffer &prefix,
1067  const OP_FixNameParms *fix_name_parms,
1068  UT_StringArray *dest_names);
1069 
1070  int groupCount() const; // Doesn't count internal groups.
1071  OP_ERROR saveGroupList(std::ostream &os, int binary = 0);
1072  bool loadGroupList(UT_IStream &is, const char *path="");
1073  OP_ERROR saveParentInputs(std::ostream &os, int picked= 0);
1074  bool loadParentInputs(UT_IStream &is, const char *path = "");
1075  OP_ERROR saveNetworkData(std::ostream &os, int binary = 0,
1076  int picked= 0);
1077  bool loadNetworkData(UT_IStream &is, const char *path = "");
1078  OP_ERROR saveChildOrder(std::ostream &os, const OP_SaveFlags &flags);
1079  bool loadChildOrder(UT_IStream &is);
1080  OP_ERROR saveCompiledSection(std::ostream &os, int binary = 0,
1081  int picked= 0);
1082  bool loadCompiledSection(UT_IStream &is, const char *path = "");
1083 
1084  // these should surround saving of ops within a network.
1085  void prepareOpSave(std::ostream &os, const OP_SaveFlags &flags,
1086  int &nsaved, int &write_trailer);
1087  void cleanupOpSave(std::ostream &os, const OP_SaveFlags &flags,
1088  int &nsaved, int &write_trailer);
1089 
1090  // A helper function for findUniqueGroupName and findUniqueNetworkBoxName
1091  // and findUniqueDotName which takes the "does this item exist" function as
1092  // a parameter
1093  char *findUniqueName(const char *base, OP_FindItemFunc find);
1094 
1095  void changeNodeIdFromLoad(OP_Node &node, int new_id);
1096  void invokeFinishLoadingNetwork(OP_NodeList& op_roots);
1097 
1098  bool verifyParents();
1099  static bool verifyAllParents();
1100 
1101  void setOperatorTable(OP_OperatorTable *table);
1102 
1103  UT_SymbolMap<OP_Node *> mySymbols;
1105  UT_ValArray<OP_Network *> myProxyRefNodes;
1106  UT_ValArray<OP_Node *> mySortedList;
1107  UT_ValArray<OP_SubnetIndirectInput*> myParentInputs;
1108  OP_GroupList myGroups;
1109  OP_NetworkBoxList myNetworkBoxes;
1110  OP_PostItNoteList myPostItNotes;
1111  OP_DotList myDotList;
1112  OP_OperatorTable *myOperatorTable;
1113  OP_Node *myLastLoadedOpPtr;
1114  OP_NetworkBox *myLastLoadedNetworkBox;
1115  OP_PostIt *myLastLoadedPostIt;
1116  OP_Dot *myLastLoadedDot;
1117  OP_Node *myCreatedNode;
1118  UT_SortedSet<int> myEditableSubNodes;
1119  OP_UndoLoad *myUndoLoad;
1120  bool myPickLoaded;
1121 
1122  fpreal myChildScale;
1123  int myDandRCounter;
1124  short myDandROpsEqual;
1125  char myNameSortDirty;
1126  char myOpLoadedFlag;
1127  bool myDoMerge;
1128  UT_StringHolder mySkipBadNodePath;
1129 
1130  OP_InputIdx myLastInputChanged;
1131  int myChildManagerCount[NUM_MANAGERS];
1132  int myStashedCurrentNodeId;
1133  bool myIsClearingContentsOfEditableSubnodes;
1134  UT_StringHolder myCachedMimeFile;
1135 
1136  OP_NetworkOperatorFilter myNetworkFilter;
1137 
1138  static bool theWarnDeprecatedOpsOnLoad;
1139 
1140  friend class OP_Director;
1141  friend class MOT_Director;
1142 };
1143 
1145 
1146 /// Safe reference to an OP node
1148 {
1149 public:
1151  OP_NetworkId(const OP_Network *node) { *this = node; }
1152  OP_NetworkId(const OP_NetworkId &id) { myId = id.myId; }
1153 
1154  bool isValid() const
1155  {
1156  const OP_Node *node = OP_Node::lookupNode(myId);
1157  return (node && node->isNetwork());
1158  }
1159 
1161  {
1162  OP_Node *node = OP_Node::lookupNode(myId);
1163  if(node && node->isNetwork())
1164  return static_cast<OP_Network *>(node);
1165  return nullptr;
1166  }
1167  const OP_Network *ptr() const
1168  {
1169  const OP_Node *node = OP_Node::lookupNode(myId);
1170  if(node && node->isNetwork())
1171  return static_cast<const OP_Network *>(node);
1172  return nullptr;
1173  }
1175  {
1176  OP_Node *node = OP_Node::lookupNode(myId);
1177  if(node && node->isNetwork())
1178  return static_cast<OP_Network *>(node);
1179  return nullptr;
1180  }
1181  void clear() { myId = OP_INVALID_NODE_ID; }
1182 
1183  void operator=(const OP_Network *net)
1184  {
1185  myId = net ? net->getUniqueId() : OP_INVALID_NODE_ID;
1186  }
1187  bool operator==(const OP_Network *net) const
1188  {
1189  const int id = net ? net->getUniqueId() : OP_INVALID_NODE_ID;
1190  return id == myId;
1191  }
1192  bool operator!=(const OP_Network *net) const
1193  {
1194  const int id = net ? net->getUniqueId() : OP_INVALID_NODE_ID;
1195  return id != myId;
1196  }
1197  bool operator==(const OP_Node *node) const
1198  {
1199  const int id = node ? node->getUniqueId() : OP_INVALID_NODE_ID;
1200  return id == myId;
1201  }
1202  bool operator!=(const OP_Node *node) const
1203  {
1204  const int id = node ? node->getUniqueId() : OP_INVALID_NODE_ID;
1205  return id != myId;
1206  }
1207  void setId(int id) { myId = id; }
1208 private:
1209  int myId;
1210 };
1211 
1212 #endif
1213 
UT_ValArray< OP_Node * > myOutputNodes
Definition: OP_Network.h:929
bool isValid() const
Definition: OP_Network.h:1154
int getUniqueId() const
Definition: OP_Node.h:777
virtual bool allowOperatorInTabMenu(OP_Operator *op)
Definition: OP_Network.h:118
OP_TileType
Definition: OP_Network.h:54
GLbitfield flags
Definition: glcorearb.h:1596
UT_String suffixReplaceStr
Definition: OP_Network.h:94
Definition: UT_Set.h:58
virtual void moveProxyRefNodes(OP_Network *)
Definition: OP_Node.h:3657
virtual void globNetworkBoxes(const char *pat, UT_String *expand, UT_ValArray< OP_NetworkBox * > *list=nullptr, OP_GlobContext *glob_context=nullptr, const char *prefix=" ")
GT_API const UT_StringHolder filename
myNodes
Definition: UT_RTreeImpl.h:708
virtual void traverseScope(const char *pattern, OP_ScopeOp scope_op, const OP_ScopeOptions &scope_options)
Safe reference to an OP node.
Definition: OP_Network.h:1147
void operator=(const OP_Network *net)
Definition: OP_Network.h:1183
int getNparentInputs() const
Definition: OP_Network.h:675
virtual void clearAndDestroy()
virtual void cloneFromProxyRefNode(OP_Network *proxy)
virtual OP_Node * getChild(const char *name, int *hint=nullptr) const
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual bool canDestroyNode()
Return true if it is safe at this time to destroy this node.
OP_OperatorTable * getOperatorTable() const
Definition: OP_Network.h:662
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
int OP_InputIdx
Definition: OP_DataTypes.h:184
OP_NetworkId(const OP_Network *node)
Definition: OP_Network.h:1151
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual const char * getViewSetting() const
Definition: OP_Network.h:702
virtual bool load(UT_IStream &is, const char *ext="", const char *path=nullptr)
void buildOpDependencies() override
GLint y
Definition: glcorearb.h:103
virtual OP_Network * cloneToProxyRefNode()
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2138
virtual void nodeUnlocked()
Definition: OP_Node.h:3793
bool operator!=(const OP_Node *node) const
Definition: OP_Network.h:1202
void setId(int id)
Definition: OP_Network.h:1207
#define OP_INVALID_NODE_ID
Definition: OP_ItemId.h:24
virtual void runDelScript()
bool operator!=(const OP_Network *net) const
Definition: OP_Network.h:1192
fpreal getChildrenScale() const
Definition: OP_Network.h:217
OP_NetworkBoxSaveType
Definition: OP_NetworkBox.h:40
int64 getMemoryUsage(bool inclusive) const override
virtual void inputConnectChanged(OP_InputIdx which)
bool operator==(const OP_Node *node) const
Definition: OP_Network.h:1197
OP_Node * myDisplayNodePtr
Definition: OP_Network.h:925
SIM_API const UT_StringHolder all
virtual bool getAllowSavingChild(OP_Node *node, const OP_SaveFlags &flags)
Returns true if the child at node can should be saved, false otherwise.
Definition: OP_Network.h:937
virtual int propagateModification(OP_Node *by_whom, OP_EventType reason, int parm_index, OP_PropagateData &prop_data)
void notifyRenameDependents(const UT_String &full_from)
virtual OP_PostIt * findPostItNote(const char *const_path)
Definition: OP_Node.h:932
virtual void globPostIts(const char *pat, UT_String *expand, UT_ValArray< OP_PostIt * > *list=nullptr, OP_GlobContext *glob_context=nullptr, const char *prefix=" ")
GA_API const UT_StringHolder scale
virtual ~OP_OperatorFilter()
Definition: OP_Network.h:110
virtual bool allowTool(const char *tool_name)
Definition: OP_Network.h:123
static bool warnDeprecatedOpsOnLoad()
Definition: OP_Network.h:798
virtual int isNetwork() const
int hasProxyRefNodes() const override
Definition: OP_Network.h:843
virtual int getNchildren() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
OP_NetworkId(const OP_NetworkId &id)
Definition: OP_Network.h:1152
virtual void unpinChannels(bool recurse)
UT_SymbolMap< OP_OperatorTable * > OP_OperatorTableMap
Definition: OP_Network.h:50
OP_DotList & getDotList()
Definition: OP_Network.h:583
UT_String prefixReplaceStr
Definition: OP_Network.h:91
virtual OP_Network * createProxyRefNode(const char *path)
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
Definition: CE_Vector.h:138
virtual OP_ERROR getErrorSeverity()
virtual void setViewSetting(const char *)
Definition: OP_Network.h:701
static void setWarnDeprecatedOpsOnLoad(bool enable)
Definition: OP_Network.h:800
void notifyRenameReferences(const UT_String &full_from)
OP_Node * createNodeOfExactType(const char *type, const char *name=nullptr)
Convenience method for requesting en exact type.
Definition: OP_Network.h:273
long long int64
Definition: SYS_Types.h:116
GLuint id
Definition: glcorearb.h:655
OP_OpTypeId
Definition: OP_OpTypeId.h:18
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: OP_Dot.h:24
virtual OP_NetworkBoxItem * findItem(const char *const_path, OP_ItemTypeMask item_type=OP_ITEMTYPE_ALL)
Definition: OP_Node.h:938
GLushort pattern
Definition: glad.h:2583
bool getIsClearingContentsOfEditableSubnodes()
Definition: OP_Network.h:793
virtual void undisplayChannels(bool recurse)
GLint GLenum GLint x
Definition: glcorearb.h:409
GLenum GLenum GLsizei void * table
Definition: glad.h:5129
bool operator==(const OP_Network *net) const
Definition: OP_Network.h:1187
OP_Node * myRenderNodePtr
Definition: OP_Network.h:924
void pickRequest(int shift)
GLdouble t
Definition: glad.h:2397
virtual bool allowOperatorAsChild(OP_Operator *op)
Definition: OP_Network.h:114
int removeTrailingDigits
Definition: OP_Network.h:96
friend class OP_Network
Definition: OP_Node.h:4280
const UT_SortedSet< int > & getEditableSubNodes() const
Definition: OP_Network.h:768
OP_OverwriteAction
Definition: OP_DataTypes.h:286
OP_Network * operator->() const
Definition: OP_Network.h:1174
void pickRequest(int shift)
Definition: OP_Network.h:642
void *(OP_Network::* OP_FindItemFunc)(const char *)
Definition: OP_Network.h:131
virtual void changeParmTemplate(PRM_Template *new_template)
unsigned int OP_ItemTypeMask
Definition: OP_ItemId.h:43
Create an evaluation context scope with a new node.
Definition: OP_Director.h:72
virtual void rebuildOpDependents(bool proxy_only)
virtual bool syncContents(UT_IStream &is)
virtual bool allowToolSubmenus(const UT_StringHolder &tool_name, const UT_StringArray &submenus)
Definition: OP_Network.h:127
virtual void unscopeChannels(bool recurse)
virtual void dumpDependencies(std::ostream &os)
fpreal64 fpreal
Definition: SYS_Types.h:283
#define OP_API
Definition: OP_API.h:10
GLuint index
Definition: glcorearb.h:786
virtual void getPotentialChildErrorNodes(OP_NodeList &nodes) const
virtual int getDandROpsEqual()
Definition: OP_Node.h:873
OP_EventType
Definition: OP_Value.h:22
virtual void getActiveOperatorsDefinedByOTL(UT_Set< OP_Operator * > &active_operators) const
static OP_Node * lookupNode(int unique_id, bool include_proxy=false)
Definition: OP_Node.h:761
virtual bool getSaveWithVopnets()
void clearUndoFlags() override
virtual int updateDandROpsEqual(int=1)
Definition: OP_Node.h:876
const OP_Network * ptr() const
Definition: OP_Network.h:1167
virtual bool opShouldHandleChange(OP_EventType reason)
OutGridT XformOp bool bool MergePolicy merge
virtual void getAdditionalUndoNodes(const OP_NodeList &orig_list, OP_NodeList &nodes_for_input_undo)
Definition: OP_Network.h:933
virtual void moveDependencies(OP_Node *from_node)
virtual void getRawErrors(UT_Array< UT_Error > &errors, bool update)
virtual OP_SubnetIndirectInput * findParentInput(const char *const_path)
Definition: OP_Node.h:936
OP_ScopeOp
Definition: OP_Parameters.h:58
virtual OP_NetworkBox * findNetworkBox(const char *name)
Definition: OP_Node.h:930
OP_Network * ptr()
Definition: OP_Network.h:1160
OP_RenameAction
Definition: OP_Network.h:70
UT_String suffixStr
Definition: OP_Network.h:95
state
Definition: core.h:2289
OP_API const OP_OperatorTableMap & OPgetGlobalOperatorTables()
void clear()
Definition: OP_Network.h:1181
bool myExportNodeDirty
Definition: OP_Network.h:926
virtual void clearUnreferencedInputs()
Definition: OP_PostIt.h:42
OP_Node * myExportNodePtr
Definition: OP_Network.h:927
virtual OP_Dot * findDot(const char *const_path)
Definition: OP_Node.h:934
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
UT_String prefixStr
Definition: OP_Network.h:92