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