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