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