HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_Director.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  * The OP_Director class is a collection (network) of managers.
10  * The Managers register themselves with an active OP_Director
11  * when they are created. The active OP_Director is obtained
12  * via the global function (yuch) OPgetDirector().
13  *
14  */
15 
16 #ifndef __OP_Director_h__
17 #define __OP_Director_h__
18 
19 #include "OP_API.h"
20 #include "OP_CommandManager.h"
21 #include "OP_Network.h"
22 #include "OP_Node.h"
23 #include "OP_OTLManager.h"
24 #include "OP_OperatorTable.h"
25 #include "OP_ConnectorId.h"
26 #include <CH/CH_Manager.h>
27 #include <UT/UT_ColorTable.h>
28 #include <UT/UT_IntArray.h>
29 #include <UT/UT_NonCopyable.h>
30 #include <UT/UT_Thread.h>
32 #include <UT/UT_Tuple.h>
33 #include <UT/UT_ValArray.h>
34 #include <SYS/SYS_Types.h>
35 #include <iosfwd>
36 #include <time.h>
37 
38 #define OP_POSTLOAD_SCRIPT "456.cmd"
39 
40 class UT_WorkArgs;
41 class UT_WorkBuffer;
42 class UT_Args;
43 class OP_SaveCallback;
44 class OP_Input;
45 class OP_ExprFunc;
46 class op_ShopClerkInfo;
47 class OP_BundleList;
48 class OP_StyleManager;
49 class OP_Take;
50 class OP_FileResolver;
51 class OP_GlobContext;
53 class PRM_ScriptPage;
54 class UT_Obfuscator;
55 class OP_EventScriptPathCache;
56 
58  void *data, void *cbdata);
60 
62 {
63  Y_UP,
64  Z_UP
65 };
66 
68 {
69 public:
70  enum EventType
71  {
81  };
82  typedef void (*EventCallback)(EventType type, void *);
83  typedef OP_ERROR (*SaveCallback)(std::ostream &, void *);
84 
85 public:
87  ~OP_Director() override;
88 
89  OP_OpTypeId getOpTypeID() const override
90  { return DIR_OPTYPE_ID; }
91  const char *getOpType() const override
92  { return DIR_OPTYPE_NAME; }
93  OP_DataType getCookedDataType() const override
94  { return OP_NO_DATA; }
95  void *getCookedData(const OP_Context &) override
96  { return nullptr; }
97  void deleteCookedData() override
98  { }
100  std::ostream &, OP_Context &, int = 0) override
101  { return 1; }
103  const char * = nullptr) override
104  { return true; }
105  int saveCookedData(const char *, OP_Context &) override
106  { return 1; }
107  OP_OpTypeId getChildTypeID() const override
108  { return MGR_OPTYPE_ID; }
109  const char *getChildType() const override
110  { return MGR_OPTYPE_NAME; }
111 
112  OP_Network *getManager(const char *name) const;
113  CH_Manager *getChannelManager() { return &myCommandManager; }
114  OP_CommandManager *getCommandManager() { return &myCommandManager; }
115  fpreal32 getVersion() const { return myVersion; }
116 
117  // NB: clearNetwork() will always reload the channel manager options!
118  // However, the user is responsible as to when we save them
119  bool loadChannelManagerOptions();
120  bool saveChannelManagerOptions();
121 
122  /// Export the active bookmarks to a file
123  bool saveBookmarks(const UT_StringHolder &filename,
124  bool include_temporary=false);
125  /// Export only the given bookmarks to a file
126  bool saveBookmarks(const UT_StringHolder &filename,
127  const UT_Array<CH_Bookmark *> &bookmarks);
128  /// Load the saved bookmarks, setting them as active
129  bool loadBookmarks(const UT_StringHolder &filename,
130  bool remove_existing = true);
131 
132  virtual void enable(int state);
133 
134  OP_ERROR saveNetwork(std::ostream &os,
135  const OP_SaveFlags &options);
136  bool loadNetwork(UT_IStream &is, int merge=0,
137  const char *merge_pattern=nullptr,
138  int overwrite=0);
139  void initializeManagerWireStyles();
140  virtual void clearNetwork( int clear_aliases );
141 
142  // This will go through the entire hip file and cook all the CHOPs
143  // that have their export flags set and cook them with CookOverride
144  // turned on.
145  virtual void opUpdateAllExports();
146 
148  { myOldCHOPOverrideFlag = true; }
150  { return myOldCHOPOverrideFlag; }
152  { myOldCHOPOverrideFlag = false; }
153 
154  /// Create an evaluation context scope with a new node
155  class CwdScope;
156 
158  { return getCwd(SYSgetSTID()); }
159  void getCwd(UT_String &str)
160  { getCwd(SYSgetSTID(), str); }
161 
162  OP_Node *getCwd(int thread);
163  void getCwd(int thread, UT_String &str);
164  void setCwd(int thread, const OP_Node *node,
165  int eval_collection=-1);
166 
167  // pushCwd() pushes the current cwd onto a stack that can later be restored
168  // using popCwd(). The optional new_cwd parameter sets the cwd to it at
169  // the same time.
170  void pushCwd(int thread, const OP_Node *new_cwd = nullptr);
171  void popCwd(int thread);
172 
173  int getCwdStackSize(int thread) const
174  {
175  return myCwdContext.getValueForThread(thread)
176  .myCwdStack.size();
177  }
178 
179  void setEditNetworkUI(OP_Network *net);
180 
181  bool getPickedNodes(OP_NodeList &picked_nodes,
182  bool include_hidden=false,
183  bool append_to_list=false) const;
184  bool getPickedItems(OP_NetworkBoxItemList &picked_items,
185  bool include_hidden=false) const;
186  bool getPickedInputs(
187  UT_Array<OP_Input *> &picked_inputs) const;
188  OP_Node *getLastPickedNode(OP_Node *parent = nullptr) const;
189  const OP_ItemIdList &getPickedItemIds() const;
190 
191  void clearPickedItems();
192 
193  // Pick the given item, clearing all other picked items first. This is here
194  // so that we can prevent an extra undo if the current state already
195  // matches what we want.
196  void makeOnlyPickedCurrent(OP_NetworkBoxItem &item);
197 
198  // These next 3 methods should only be called from OP_Node::setPicked()
199  // The myPickedItems array can't contain duplicates and maintains the
200  // invariant that:
201  // - node.getPicked() is TRUE iff it is in the list.
202  // - node.getPicked() is FALSE implies that it is NOT in the list.
203  void addPickedNode(const OP_Node &node, bool edit);
204  void removePickedNode(const OP_Node &node, bool edit);
205  void makePickedNodeLast(const OP_Node &node, bool edit);
206 
207  // These methods should only be called from the various
208  // setPicked() functions in OP_NetworkBoxItem subclasses. The
209  // myPickedXXXIds arrays can't contain duplicates and maintain the
210  // invariant that:
211  // - item.getPicked() is TRUE iff it is in the list.
212  // - item.getPicked() is FALSE implies that it is NOT in the list.
213  void addPickedItem(const OP_NetworkBoxItem &item);
214  void removePickedItem(const OP_NetworkBoxItem &item);
215  void itemBeingDeleted(const OP_NetworkBoxItem &item);
216 
217  // These methods should only be called from OP_Input::setPicked(). The
218  // myPickedXXXIds arrays can't contain duplicates and maintain the
219  // invariant that:
220  // - input.getPicked() is TRUE iff it is in the list.
221  // - input.getPicked() is FALSE implies that it is NOT in the list.
222  void addPickedInput(const OP_Input &input);
223  void removePickedInput(const OP_Input &input);
224 
225  // Control time.
226  void setTime(fpreal time);
227  fpreal getTime() const;
228 
229  /// Set the number of frames, adjusting the ending frame appropriately.
230  void setNFrames(fpreal nframes, bool notify = true);
231 
232  void setChopMotionSamples(int n, bool notify = true);
233 
234  /// Set the frame rate
235  /// @param fps The new samples per second
236  /// @param modify_frame_count Whether or not to scale the frame count to
237  /// preserve animation time duration (default = true)
238  /// @param preserve_keyframes If true, keeps keys on their existing
239  /// frames, changing the speed of the animation.
240  /// @param preserve_frame_start If true, will adjust the time of the start
241  /// time to ensure the corresponding frame is preserved
242  /// If modify_frame_count is false, the end frame will also be preserved.
243  /// @param notify Whether or not to trigger OP Node and varchange events
244  /// (default = true)
245  void setSamplesPerSec(
246  fpreal fps,
247  bool modify_frame_count = true,
248  bool preserve_keyframes = false,
249  bool preserve_frame_start = false,
250  bool notify = true);
251 
252  /// Set global start and end times
253  /// @note t_end refers to the STARTING time of the final frame
254  /// To set the END of the final frame, use setTimeRange instead
255  void setGlobalTime(fpreal t_start, fpreal t_end, bool notify = true);
256 
257  /// Set global start and end times
258  /// @note t_end refers to the ENDING time of the final frame
259  /// To set the START of the final frame, use setGlobalTime instead
260  void setTimeRange(fpreal t_start, fpreal t_end, bool notify = true);
261 
262  /// Set the frames shown in the playbar.
263  /// @note these frames are a subset of the global frame range, which is
264  /// controlled by setTimeRange/setGlobalTime
265  void setSampleRange(fpreal frame_start, fpreal fend, bool notify = true);
266 
267  /// The save callback is called when saving .hip files. It is called with
268  /// a stream reference to the .hip file so that the callback can insert
269  /// hscript commands into the .hip file's .application section. When a
270  /// .hip file is loaded, all the commands in the .application section are
271  /// executed.
272  // @{
273  void setSaveCallback(SaveCallback cb, void *cb_data);
274  void removeSaveCallback(SaveCallback cb, void *cb_data);
275 
276  /// Callbacks for certain global OP_Director events, such as new scene
277  /// and load scene.
278  void addEventCallback(EventType type, EventCallback cb,
279  void *data);
280  void removeEventCallback(EventType type, EventCallback cb,
281  void *data);
282  // @}
283 
284  void setUserDisplayOptionSaveCallback(
285  OP_ERROR (*cb)(std::ostream &, void *),
286  void *callback_data);
287  void setSceneFileVisualizersSaveCallback(
288  OP_ERROR (*cb)(std::ostream &, void *),
289  void *callback_data);
290  void addBadLoadData(char *str, int len);
291 
292  int isLoading() const { return (myInLoadCount > 0); }
293  virtual void beginLoading();
294  virtual void endLoading();
295  bool getIsLoadingHip() const
296  { return myIsLoadingHip; }
297  bool getIsQuitting() const
298  { return myIsQuitting; }
300  { myIsDoingExplicitSave = value; }
302  { return myIsDoingExplicitSave; }
303  const OP_Node *getAnyCookingNode() const;
304 
305  bool getIsMantra() const
306  { return myIsMantra; }
307  void setIsMantra(bool v)
308  { myIsMantra = v; }
309  bool getIsClearing() const
310  { return myIsClearing; }
311 
312  void destroyFileResolver();
313 
314  void beginTakeSwitch();
315  void endTakeSwitch();
316  bool isSwitchingTake() const
317  { return mySwitchingTake; }
318 
319  int renameNode(OP_Node *, const char *,
320  OP_RenameAction) override;
321 
322  // These methods are only called by the network load/save
323  void saveChannelGroups(std::ostream &os, int binary);
324  bool loadChannelGroups(UT_IStream &is, const char *path);
325  void saveTimeGroups(std::ostream &os, int binary);
326  bool loadTimeGroups(UT_IStream &is, const char *path);
327  void saveBookmarks(std::ostream &os, int binary);
328  bool loadBookmarks(UT_IStream &is);
329  void saveScriptedOpLibrary(std::ostream &os);
330  bool loadScriptedOpLibrary(UT_IStream &is, time_t modtime);
331  bool loadScriptedOpDefs(UT_IStream &is);
332  void saveInternalOpLibraries(std::ostream &os);
333  bool loadInternalOpLibraries(UT_IStream &is);
334  void saveLibraryPreferences(std::ostream &os);
335  bool loadLibraryPreferences(UT_IStream &is);
336  bool loadHOMSessionModuleSource(UT_IStream &is);
337  void saveUnselectedFilePatterns(std::ostream &os);
338  bool loadUnselectedFilePatterns(UT_IStream &is);
339 
340  void saveOTLBackupInformation(std::ostream &os);
341 
342  OP_ExprFunc *getExprFunctions();
343  void saveExprFunctions(std::ostream &os);
344  bool loadExprFunctions(UT_IStream &is, const char *path);
345 
346  OP_BundleList *getBundles() { return myBundles; }
347 
348  // These track the current update mode: Should an OP recook?
349  int cookEnabled() const
350  { return myCookEnabled; }
351  void setCookEnabled(int state)
352  { myCookEnabled = state; }
353 
354  // These track the simulation update mode: Should simulations cook?
355  int simulationEnabled() const
356  { return mySimulationEnabled; }
357  void setSimulationEnabled(int state)
358  { mySimulationEnabled = state; }
359 
360  // These control whether those simulations reset by output drivers should
361  // reset based on the global or playback playbar range.
363  { return mySkipPlaybarBasedSimulationReset > 0; }
365  { mySkipPlaybarBasedSimulationReset += inc; }
366 
367  // These methods are used by SHOPs to keep track of visible clerks.
368  bool addShopClerk(const char *type);
369  int getNShopClerks() const
370  { return myShopInfo.entries(); }
371  const char *getShopClerkName(int clerk) const;
372  int getShopClerkVisibility(int clerk) const;
373  void setShopClerkVisibility(int clerk, int onoff);
374  bool isCompiledLibrary (OP_OTLLibrary *lib);
375 
376  // This function does nothing at this level, but it is meant to be
377  // overridden to create new OP_OperatorInfos for the given table based
378  // on the existance of VOP networks.
380  const char * /* indexPath */,
381  OP_OTLDefinitionArray & /* defs */)
382  { }
384  const char * /* definitionOp */,
385  OP_Operator * /* op */)
386  { return nullptr; }
388  OP_Node * /* definitionOp */,
389  UT_String & /* definition */)
390  { }
391  virtual void updateExportedParms(
392  OP_Node * /* definitionOp */)
393  { }
394  // Save the spare parameters section for the specified node. We have
395  // to do this through a virtual function that is actually implemented
396  // in the MOT library because it requires the PI_EditScriptedParms
397  // class.
399  bool,
400  std::ostream &) const
401  { return UT_ERROR_NONE; }
402  // Load the spare parms section for a node. Although it doesn't require
403  // the PI library, this function is also implemented in the MOT library
404  // just to keep the save and load code paths in a similar location.
406  UT_IStream &,
407  UT_String &) const
408  { return true; }
409  // Adds a single spare parm to the specified node. This function exists
410  // for backward compatibility with spare parms from H8. This function is
411  // implemented in the MOT library where we have access to the PI classes
412  // for editing parms (PI_EditScriptedParms).
413  virtual bool addNodeSpareParm(OP_Parameters * /*node*/,
414  PRM_Template * /*parmtemplate*/) const
415  { return false; }
416  // Removes a single spare parm to the specified node. This function exists
417  // for backward compatibility with spare parms from H8. This function is
418  // implemented in the MOT library where we have access to the PI classes
419  // for editing parms (PI_EditScriptedParms).
420  virtual bool removeNodeSpareParm(OP_Parameters *node,
421  const char *parmname,
422  UT_StringArray *errs = nullptr,
423  UT_StringArray *warn = nullptr
424  ) const
425  { return false; }
426  // Updates the spare parms of a node to match the supplied
427  // PI_EditScriptedParms. This class isn't defined until the PI
428  // library, so this function is actually implemented in MOT_Director.
431  UT_String &) const
432  { }
433  // Save a series of hscript commands to a stream to replicate the
434  // spare parameters of the specified node.
436  std::ostream &,
437  const char *,
438  bool) const
439  { }
440  // Delete spare parameter/base parameter mixing layout. This puts the
441  // spare parameters on their own page.
443  { }
444  // Delete all spare parameters on a node.
446  { }
447 
449  { return nullptr; }
450 
451  // Functions for saving and loading compiled VEX and RSL code for nodes
452  // with VOP_CodeGenerators in a compiled hip file.
453  virtual void saveNodeCompiledCode(OP_Node *, std::ostream &,
454  bool is_source_code = false)
455  { }
457  bool is_source_code = false)
458  { return true; }
459  virtual void saveNodeCompiledDs(OP_Node *, std::ostream &)
460  { }
462  { return true; }
463 
464  OP_Take *getTakeManager() { return myTakeManager; }
465  OP_StyleManager *getStyleManager() { return myStyleManager; }
466  UT_ColorTable &getGroupColorTable() { return myGroupColorTable; }
467 
468  // deprecated method: interest gets cleared out before every cook
469  void addExtraInput(OP_Node *op,
470  OP_InterestType type) override;
471 
472  // A utility function to glob (pattern expand) all arguments on a command
473  // line.
474  static int globAllArguments(OP_Node *node, UT_Args &args,
475  UT_WorkBuffer &workbuf,
476  UT_WorkArgs &argv,
477  OP_ItemTypeMask item_type,
478  OP_GlobContext *context,
479  int startitem = 1);
480 
481  // This function is similar to the one above, except it takes a string
482  // pattern (which may contain spaces) and returns an array of matching
483  // nodes and/or netboxes.
484  static void globAllArgumentsAsArray(OP_Node &relative_to_node,
485  const char *pattern,
486  OP_ItemTypeMask item_type,
487  OP_GlobContext &glob_context,
489 
490  // These functions are the instantiations of the virtual functions
491  // from our OP_OTLManagerSink base class.
492  void definitionsAdded(int libindex,
493  UT_IntArray &defindex) override;
494  void definitionsRemoved(int libindex,
495  UT_IntArray &defindex,
496  OP_OTLLibrary *&preserve) override;
497 
498  // Given a path of the form "tablename/opname", return the table and
499  // operator indicated by the path. The relativetonode parm is used when
500  // the path is actualy a node path, and we want the table and operator
501  // of the node specified by the path. If it is a relative path, the
502  // relativetonode is the starting point. If it is null, the current
503  // working node is used, or the director.
504  void getTableAndOperator(
505  const char *path,
507  OP_Operator *&op,
508  const OP_Node *relativetonode = nullptr);
510  { return myOTLManager; }
512  { return myOTLManager; }
513 
514  // This function should be called right before exiting. It will go
515  // through all OP_Operators with active nodes and run the POSTLASTDELETE
516  // event script (though it doesn't actually delete the nodes).
517  void runDeleteScriptsOnQuit();
518 
519  // Add or remove callback functions that get executed whenever we call
520  // OP_Node::opChanged.
521  void addGlobalOpChangedCallback(
522  OP_GlobalOpChangedCallback cb, void *cbdata);
523  void removeGlobalOpChangedCallback(
524  OP_GlobalOpChangedCallback cb, void *cbdata);
525  // This function is called any time OP_Node::opChanged is called. It sends
526  // the change information along to any global op change callback functions
527  // that have been registered by addGlobalOpChangeCallback.
528  void globalOpChanged(OP_Node *node,
529  OP_EventType reason,
530  void *data);
531 
532  // This function creates a backup of the specified file, if the option
533  // to save backup files is turned on. The actual file name and file type
534  // are irrelevent. It returns true if the backup was successful (or was
535  // not required).
536  static bool createBackupFile(const char *filename,
537  bool domove= false);
538  // This function will rename the current file "filename" to the next
539  // filename in the sequence to free up "filename" so that it can be
540  // saved over. If successful, it will store the new filename in
541  // "newfilename". Otherwise, "newfilename" will be an empty string.
542  static void autoIncrementRename(const char *filename,
543  UT_String &newfilename,
544  UT_String &errorstring,
545  bool movefile,
546  bool autosave);
547 
548  void runScript(CMD_Manager *cman, const char *filename);
549  UT_Tuple<bool, int> runPython(CMD_Manager *cman, const char *filename);
550  UT_Tuple<bool, int> runPython(CMD_Manager *cman, int argc,
551  char *argv[]);
552  UT_Tuple<bool, int> runDefaultStartupScripts(CMD_Manager *cman,
553  const char *startup_script,
554  const char *postload_script);
555 
556  // Get the global (i.e. non-operator specific) script path cache.
557  OP_EventScriptPathCache *getGlobalEventScriptPathCache()
558  { return myGlobalEventScriptPathCache; }
559 
560  // Clear all cached paths to global event scripts.
561  void clearGlobalEventScriptPathCache();
562 
563  // Query all cached global event script paths.
564  void getCachedGlobalEventScriptPaths(
565  UT_StringArray &events,
566  UT_StringArray &paths,
567  bool only_nonempty) const;
568 
569  // Because of code complexity issues, this method must be used to destruct
570  // an OP_Director.
571  static void destroyDirector(OP_Director *opdir);
572 
573  bool getSaveSceneAsText() const;
574  void setSaveSceneAsText(bool on_off);
575  bool getNewFileSaveSceneAsText() const;
576  void setNewFileSaveSceneAsText(bool on_off);
577 
578  /// Run callbacks for before saving a scene,
579  /// 'autosave' indicates if the save was triggered by the autosave timer.
580  void notifyBeforeSceneSave(
581  const UT_StringHolder &filename,
582  bool autosave);
583  /// Run callbacks for before saving a scene,
584  /// 'autosave' indicates if the save was triggered by the autosave timer.
585  /// 'did_succeed' indicates if the save was successful.
586  void notifyAfterSceneSave(
587  const UT_StringHolder &filename,
588  bool autosave,
589  bool did_succeed);
590 
592 
594  { return myOrientationMode; }
596  { myOrientationMode = axis; }
597 
598  static UT_Obfuscator *getObfuscator();
599 
600 protected:
602  { return UT_ERROR_NONE; }
603  OP_ERROR bypassMe(OP_Context &, int &) override
604  { return UT_ERROR_NONE; }
605  const char *getFileExtension(int binary) const override
606  { return binary ? ".bhip" : ".hip"; }
607  void clearUnsupportedCommands() const;
608 
609  // This function is called when we update our OTL for an operator. It
610  // does nothing at this level, but in MOT it will clear out the PI
611  // settings that have been saved for the specified operator type.
612  virtual void clearHandleSettings(OP_Operator *) { }
613 
614  // We don't allow spare parms on the director, so just ignore this call.
616  UT_String &errors) override
617  {
618  errors += "Spare parameters are not alowed on ";
619  errors += "the root node.";
620  return false;
621  }
622 
623  /// Runs the user-defined post load script when loading
624  /// a new network into Houdini.
625  void runPostLoadScript();
626 
627 private:
628  // Disallow copying of OP_Director, these methods are not implemented
629  // on purpose
630  OP_Director(const OP_Director &copy);
632 
633  void installCommands();
634  void installMoreCommands();
635  void installCHCommands();
636  void installOTLCommands();
637  void installOpRampResolver();
638 
639  void savePreCommands(std::ostream &os);
640  void savePostCommands(std::ostream &os);
641 
642  void notifyEventCallbacks(EventType type);
643 
644  /// Helper function to update to a new operator definition. May delete
645  /// the old operator and return a different one.
646  void updateNewDefinition(
647  OP_Operator *&op,
648  OP_OTLLibrary *newlib,
649  int newdefindex);
650 
651  void varChanged(const UT_String &varname);
652  void varsChanged(const UT_StringArray &varnames);
653 
654  /// Helper function for runDefaultStartupScripts().
655  /// Pass back the full path of the first startup script file
656  /// found in the Houdini path.
657  static void getFirstFoundStartupScriptFile(
658  UT_StringHolder &script_path,
659  const char *script_file_name);
660 
661  /// Helper function for runDefaultStartupScripts().
662  /// Passes back the full path of the first finding of inputpath
663  /// in the script search directories. The file name of outputpath
664  /// may end in any of the acceptable script file extensions
665  /// (i.e. .py or .cmd).
666  static void getFirstFoundScriptFile(
667  UT_StringHolder &outputpath,
668  const char *inputpath);
669 
670  static void sceneSaveEvent(EventType event, UT_Args &args);
671 
672 private:
673  char *myBadLoadData;
674  int myBadLoadDataLen;
675  OP_CommandManager myCommandManager;
676  fpreal32 myVersion;
677  int myInLoadCount;
678 
679  struct CwdContext
680  {
681  CwdContext() : myCwdId(-1)
682  {
683  }
684  int myCwdId;
685  UT_IntArray myCwdStack;
686  UT_IntArray myEvalCollectionStack;
687  };
689 
690  OP_ItemIdList myPickedItems;
692 
693  OP_SaveCallback *myCallbacks;
694  OP_SaveCallback *myUserDisplayOptionCallback;
695  OP_SaveCallback *mySceneFileVisualizersCallback;
696  OP_BundleList *myBundles;
697  OP_Take *myTakeManager;
698  OP_StyleManager *myStyleManager;
699  OP_FileResolver *myFileResolver;
700  UT_ColorTable myGroupColorTable;
701 
702  int myCookEnabled;
703  int mySimulationEnabled;
704  int mySkipPlaybarBasedSimulationReset;
706 
707  OP_OTLManager myOTLManager;
708  OP_OperatorTableList myTablesToReload;
709  UT_StringSet *myDummyDefinitionActivations;
710 
711  OP_GlobalOpChangedCallbacks myGlobalOpChangedCallbacks;
712  UT_ValArray<void *> myGlobalOpChangedCallbackData;
713 
714  struct EventCallbackInfo
715  {
716  EventCallback cb;
717  void *data;
718  friend bool operator==(const EventCallbackInfo &lhs, const EventCallbackInfo &rhs)
719  {
720  return (lhs.cb == rhs.cb) && (lhs.data == rhs.data);
721  }
722  };
723 
724  // EventCallbackInfoList will emulate an ordered set
725  //
726  // This is important since we want to ensure that:
727  // 1 - callbacks are executed in the order that they're registered
728  // 2 - only a single unique callback+data pair can be registered
729  //
730  // These are "enforced" in 1-notifyEventCallbacks and 2-addEventCallback
731  //
732  typedef UT_Array<EventCallbackInfo> EventCallbackInfoList;
733  EventCallbackInfoList myEventCallbacks[NUM_NETWORK_EVENT_TYPES];
734 
735  // Cache of global (i.e. non-operator specific) event script paths.
736  OP_EventScriptPathCache *myGlobalEventScriptPathCache;
737 
738  OrientationMode myOrientationMode;
739 
740  // This flag tracks whether any OPs that got loaded had the old
741  // style override flag. If so, we know we will have to do a complete
742  // update.
743  bool myOldCHOPOverrideFlag;
744  // This flag tracs whether or not we are inside a call to loadNetwork.
745  // This is different from the isLoading flag, which gets set during any
746  // network load.
747  bool myIsLoadingHip;
748  bool mySwitchingTake;
749  // This value is temporarily set to true when the user explicitly asks
750  // for a hip file save either by executing an mwrite, or choosing Save
751  // or Save As from the File menu.
752  bool myIsDoingExplicitSave;
753  // This flag is set to true while Houdini is exiting.
754  bool myIsQuitting;
755 
756  // This flag is set when the OP director is created for mantra. There are
757  // some OP features which are expensive (i.e. importing the hou python
758  // module). This option disables those features.
759  bool myIsMantra;
760 
761  // Set to true while Houdini is clearing the scene.
762  bool myIsClearing;
763  bool mySaveSceneAsText;
764  bool myNewFileSaveSceneAsText;
765 
766  // Flag to track if we are running 456.cmd, in case the user wants to
767  // merge in another hip file in this script. We don't want to end up
768  // calling 456.cmd recursively.
769  bool myRunningPostLoadScript = false;
770 
771  static UT_Obfuscator *theObfuscator;
772 };
773 
776 
777 /// Create an evaluation context scope with a new node
778 class OP_API OP_Director::CwdScope : UT_NonCopyable
779 {
780 public:
781  CwdScope(int thread, const OP_Node &new_cwd);
782  ~CwdScope();
783 private:
784  int myThread;
785  CH_EvalContext::Scope myEvalScope;
786  int myOldCwdId;
787 };
788 
789 #endif
virtual bool addNodeSpareParm(OP_Parameters *, PRM_Template *) const
Definition: OP_Director.h:413
bool loadNetwork(UT_IStream &is, int merge=0, const char *pattern=NULL, int overwrite=0, const OP_FixNameParms *fix_name_parms=NULL, UT_StringArray *src_names=NULL, UT_StringArray *dest_names=NULL)
UT_ErrorSeverity OP_ERROR
Definition: OP_Error.h:6
UT_ValArray< OP_GlobalOpChangedCallback > OP_GlobalOpChangedCallbacks
Definition: OP_Director.h:59
GT_API const UT_StringHolder filename
OP_StyleManager * getStyleManager()
Definition: OP_Director.h:465
void setIsDoingExplicitSave(bool value)
Definition: OP_Director.h:299
OP_API OP_Director * OPsetDirector(OP_Director *boss)
void
Definition: png.h:1083
GLboolean * data
Definition: glcorearb.h:131
GT_API const UT_StringHolder time
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
const GLdouble * v
Definition: glcorearb.h:837
UT_ColorTable & getGroupColorTable()
Definition: OP_Director.h:466
bool isSwitchingTake() const
Definition: OP_Director.h:316
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool getIsMantra() const
Definition: OP_Director.h:305
void setOldCHOPOverrideFlag()
Definition: OP_Director.h:147
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
bool getOldCHOPOverrideFlag()
Definition: OP_Director.h:149
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual void findInternalScriptOperators(const char *, OP_OTLDefinitionArray &)
Definition: OP_Director.h:379
virtual bool loadNodeSpareParms(OP_Parameters *, UT_IStream &, UT_String &) const
Definition: OP_Director.h:405
int saveCookedData(const char *, OP_Context &) override
Definition: OP_Director.h:105
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual void definitionsRemoved(int, UT_IntArray &, OP_OTLLibrary *&)
std::tuple< Types...> UT_Tuple
Definition: UT_Tuple.h:53
OP_EventScriptPathCache * getGlobalEventScriptPathCache()
Definition: OP_Director.h:557
OP_BundleList * getBundles()
Definition: OP_Director.h:346
**But if you need a result
Definition: thread.h:613
bool changeSpareParms(UT_IStream &, UT_String &errors) override
Definition: OP_Director.h:615
virtual int renameNode(OP_Node *node, const char *name, OP_RenameAction action=OP_RENAME_NORMAL)
virtual void clearHandleSettings(OP_Operator *)
Definition: OP_Director.h:612
virtual void deleteAllNodeSpareParms(OP_Parameters *) const
Definition: OP_Director.h:445
OrientationMode getOrientationMode() const
Definition: OP_Director.h:593
void setOrientationMode(OrientationMode axis)
Definition: OP_Director.h:595
float fpreal32
Definition: SYS_Types.h:200
int saveCookedData(std::ostream &, OP_Context &, int=0) override
Definition: OP_Director.h:99
static void saveOTLBackupInformation(std::ostream &os, const OP_OperatorList &fallbackops, const OP_OperatorList &dummyops)
CH_Manager * getChannelManager()
Definition: OP_Director.h:113
struct _cl_event * event
Definition: glcorearb.h:2961
OP_OTLManager & getOTLManager()
Definition: OP_Director.h:509
const char * getOpType() const override
Definition: OP_Director.h:91
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
virtual void updateExportedParms(OP_Node *)
Definition: OP_Director.h:391
OP_OpTypeId getOpTypeID() const override
Definition: OP_Director.h:89
GLdouble n
Definition: glcorearb.h:2008
friend class OP_Director
Definition: OP_Network.h:1120
virtual bool loadNodeCompiledDs(OP_Node *, UT_IStream &)
Definition: OP_Director.h:461
OP_DataType getCookedDataType() const override
Definition: OP_Director.h:93
virtual bool loadNodeCompiledCode(OP_Node *, UT_IStream &, bool is_source_code=false)
Definition: OP_Director.h:456
OP_InterestType
Definition: OP_DataTypes.h:45
int getCwdStackSize(int thread) const
Definition: OP_Director.h:173
OP_ERROR cookMe(OP_Context &) override
Definition: OP_Director.h:601
int cookEnabled() const
Definition: OP_Director.h:349
bool getIsDoingExplicitSave() const
Definition: OP_Director.h:301
void bumpSkipPlaybarBasedSimulationReset(int inc)
Definition: OP_Director.h:364
void clearOldCHOPOverrideFlag()
Definition: OP_Director.h:151
bool getIsQuitting() const
Definition: OP_Director.h:297
int getNShopClerks() const
Definition: OP_Director.h:369
int isLoading() const
Definition: OP_Director.h:292
bool getIsLoadingHip() const
Definition: OP_Director.h:295
void getPickedItems(OP_ItemTypeMask item_type_mask, OP_NetworkBoxItemList &picked, bool include_hidden=false, bool recurse_picked_netboxes=false) const
#define MGR_OPTYPE_NAME
Definition: OP_Node.h:310
void deleteCookedData() override
Definition: OP_Director.h:97
const char * getChildType() const override
Definition: OP_Director.h:109
OP_Node * getCwd()
Definition: OP_Director.h:157
OP_OpTypeId
Definition: OP_OpTypeId.h:18
virtual OP_ERROR saveNodeSpareParms(OP_Parameters *, bool, std::ostream &) const
Definition: OP_Director.h:398
GLuint const GLchar * name
Definition: glcorearb.h:786
GLushort pattern
Definition: glad.h:2583
virtual bool removeNodeSpareParm(OP_Parameters *node, const char *parmname, UT_StringArray *errs=nullptr, UT_StringArray *warn=nullptr) const
Definition: OP_Director.h:420
GLenum GLenum GLsizei void * table
Definition: glad.h:5129
virtual OP_Node * linkInternalScriptOperator(const char *, OP_Operator *)
Definition: OP_Director.h:383
GT_API const UT_StringHolder version
const OP_OTLManager & getOTLManager() const
Definition: OP_Director.h:511
virtual void getInternalScriptDefinition(OP_Node *, UT_String &)
Definition: OP_Director.h:387
virtual void deleteNodeSpareParmLayout(OP_Parameters *) const
Definition: OP_Director.h:442
void setIsMantra(bool v)
Definition: OP_Director.h:307
unsigned int OP_ItemTypeMask
Definition: OP_ItemId.h:43
fpreal32 getVersion() const
Definition: OP_Director.h:115
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
Create an evaluation context scope with a new node.
Definition: OP_Director.h:67
SYS_API int SYSgetSTID()
virtual void addExtraInput(OP_Node *op, OP_InterestType type)
OP_Take * getTakeManager()
Definition: OP_Director.h:464
const char * getFileExtension(int binary) const override
Definition: OP_Director.h:605
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual void saveNodeSpareParmCommands(OP_Parameters *, std::ostream &, const char *, bool) const
Definition: OP_Director.h:435
OP_API OP_Director * OPgetDirector()
#define OP_API
Definition: OP_API.h:10
bool loadCookedData(UT_IStream &, const char *=nullptr) override
Definition: OP_Director.h:102
virtual void saveNodeCompiledDs(OP_Node *, std::ostream &)
Definition: OP_Director.h:459
OP_EventType
Definition: OP_Value.h:22
Scope(int thread)
OP_DataType
Definition: OP_DataTypes.h:28
OP_CommandManager * getCommandManager()
Definition: OP_Director.h:114
**If you just want to fire and args
Definition: thread.h:609
void getCwd(UT_String &str)
Definition: OP_Director.h:159
virtual PRM_ScriptPage * allocateSpareScriptPage(OP_Operator *)
Definition: OP_Director.h:448
Definition: core.h:1131
OP_OrientationMode
Definition: OP_Director.h:61
void setCookEnabled(int state)
Definition: OP_Director.h:351
virtual void definitionsAdded(int, UT_IntArray &)
virtual void saveNodeCompiledCode(OP_Node *, std::ostream &, bool is_source_code=false)
Definition: OP_Director.h:453
virtual void changeNodeSpareParms(OP_Parameters *, PI_EditScriptedParms &, UT_String &) const
Definition: OP_Director.h:429
int simulationEnabled() const
Definition: OP_Director.h:355
OP_ERROR bypassMe(OP_Context &, int &) override
Definition: OP_Director.h:603
type
Definition: core.h:1059
void * getCookedData(const OP_Context &) override
Definition: OP_Director.h:95
Cooks node data and makes it available through the reader.
OP_OpTypeId getChildTypeID() const override
Definition: OP_Director.h:107
OP_RenameAction
Definition: OP_Network.h:70
void setSimulationEnabled(int state)
Definition: OP_Director.h:357
void(* OP_GlobalOpChangedCallback)(OP_Node *node, OP_EventType reason, void *data, void *cbdata)
Definition: OP_Director.h:57
Definition: format.h:895
#define DIR_OPTYPE_NAME
Definition: OP_Node.h:311
UT_NonCopyable & operator=(const UT_NonCopyable &)=delete
bool getIsClearing() const
Definition: OP_Director.h:309
bool skipPlaybarBasedSimulationReset() const
Definition: OP_Director.h:362