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; }
315  { return myEngineSessionSyncActive; }
317  { myEngineSessionSyncActive = active; }
318  bool getIsClearing() const
319  { return myIsClearing; }
320 
321  void destroyFileResolver();
322 
323  void beginTakeSwitch();
324  void endTakeSwitch();
325  bool isSwitchingTake() const
326  { return mySwitchingTake; }
327 
328  int renameNode(OP_Node *, const char *,
329  OP_RenameAction) override;
330 
331  // These methods are only called by the network load/save
332  void saveChannelGroups(std::ostream &os, int binary);
333  bool loadChannelGroups(UT_IStream &is, const char *path);
334  void saveTimeGroups(std::ostream &os, int binary);
335  bool loadTimeGroups(UT_IStream &is, const char *path);
336  void saveBookmarks(std::ostream &os, int binary);
337  bool loadBookmarks(UT_IStream &is);
338  void saveScriptedOpLibrary(std::ostream &os);
339  bool loadScriptedOpLibrary(UT_IStream &is, time_t modtime);
340  bool loadScriptedOpDefs(UT_IStream &is);
341  void saveInternalOpLibraries(std::ostream &os);
342  bool loadInternalOpLibraries(UT_IStream &is);
343  void saveLibraryPreferences(std::ostream &os);
344  bool loadLibraryPreferences(UT_IStream &is);
345  void saveUnselectedFilePatterns(std::ostream &os);
346  bool loadUnselectedFilePatterns(UT_IStream &is);
347 
348  virtual void clearHOMSessionModuleSource() { }
349  virtual void saveHOMSessionModuleSource(std::ostream &os) { }
350  virtual bool loadHOMSessionModuleSource(UT_IStream &is) { return true; }
351 
352  void saveOTLBackupInformation(std::ostream &os);
353 
354  OP_ExprFunc *getExprFunctions();
355  void saveExprFunctions(std::ostream &os);
356  bool loadExprFunctions(UT_IStream &is, const char *path);
357 
358  OP_BundleList *getBundles() { return myBundles; }
359 
360  // These track the current update mode: Should an OP recook?
361  int cookEnabled() const
362  { return myCookEnabled; }
364  { myCookEnabled = state; }
365 
366  // These track the simulation update mode: Should simulations cook?
367  int simulationEnabled() const
368  { return mySimulationEnabled; }
370  { mySimulationEnabled = state; }
371 
372  // These control whether those simulations reset by output drivers should
373  // reset based on the global or playback playbar range.
375  { return mySkipPlaybarBasedSimulationReset > 0; }
377  { mySkipPlaybarBasedSimulationReset += inc; }
378 
379  // These methods are used by SHOPs to keep track of visible clerks.
380  bool addShopClerk(const char *type);
381  int getNShopClerks() const
382  { return myShopInfo.entries(); }
383  const char *getShopClerkName(int clerk) const;
384  int getShopClerkVisibility(int clerk) const;
385  void setShopClerkVisibility(int clerk, int onoff);
386  bool isCompiledLibrary (OP_OTLLibrary *lib);
387 
388  // This function does nothing at this level, but it is meant to be
389  // overridden to create new OP_OperatorInfos for the given table based
390  // on the existance of VOP networks.
392  const char * /* indexPath */,
393  OP_OTLDefinitionArray & /* defs */)
394  { }
396  const char * /* definitionOp */,
397  OP_Operator * /* op */)
398  { return nullptr; }
400  OP_Node * /* definitionOp */,
401  UT_String & /* definition */)
402  { }
403  virtual void updateExportedParms(
404  OP_Node * /* definitionOp */)
405  { }
406  // Save the spare parameters section for the specified node. We have
407  // to do this through a virtual function that is actually implemented
408  // in the MOT library because it requires the PI_EditScriptedParms
409  // class.
411  bool,
412  std::ostream &) const
413  { return UT_ERROR_NONE; }
414  // Load the spare parms section for a node. Although it doesn't require
415  // the PI library, this function is also implemented in the MOT library
416  // just to keep the save and load code paths in a similar location.
418  UT_IStream &,
419  UT_String &) const
420  { return true; }
421  // Adds a single spare parm to the specified node. This function exists
422  // for backward compatibility with spare parms from H8. This function is
423  // implemented in the MOT library where we have access to the PI classes
424  // for editing parms (PI_EditScriptedParms).
425  virtual bool addNodeSpareParm(OP_Parameters * /*node*/,
426  PRM_Template * /*parmtemplate*/) const
427  { return false; }
428  // Removes a single spare parm to the specified node. This function exists
429  // for backward compatibility with spare parms from H8. This function is
430  // implemented in the MOT library where we have access to the PI classes
431  // for editing parms (PI_EditScriptedParms).
432  virtual bool removeNodeSpareParm(OP_Parameters *node,
433  const char *parmname,
434  UT_StringArray *errs = nullptr,
435  UT_StringArray *warn = nullptr
436  ) const
437  { return false; }
438  // Updates the spare parms of a node to match the supplied
439  // PI_EditScriptedParms. This class isn't defined until the PI
440  // library, so this function is actually implemented in MOT_Director.
443  UT_String &) const
444  { }
445  // Save a series of hscript commands to a stream to replicate the
446  // spare parameters of the specified node.
448  std::ostream &,
449  const char *,
450  bool) const
451  { }
452  // Delete spare parameter/base parameter mixing layout. This puts the
453  // spare parameters on their own page.
455  { }
456  // Delete all spare parameters on a node.
458  { }
459 
461  { return nullptr; }
462 
463  // Functions for saving and loading compiled VEX and RSL code for nodes
464  // with VOP_CodeGenerators in a compiled hip file.
465  virtual void saveNodeCompiledCode(OP_Node *, std::ostream &,
466  bool is_source_code = false)
467  { }
469  bool is_source_code = false)
470  { return true; }
471  virtual void saveNodeCompiledDs(OP_Node *, std::ostream &)
472  { }
474  { return true; }
475 
476  OP_Take *getTakeManager() { return myTakeManager; }
477  OP_StyleManager *getStyleManager() { return myStyleManager; }
478  UT_ColorTable &getGroupColorTable() { return myGroupColorTable; }
479 
480  // deprecated method: interest gets cleared out before every cook
481  void addExtraInput(OP_Node *op,
482  OP_InterestType type) override;
483 
484  // A utility function to glob (pattern expand) all arguments on a command
485  // line.
486  static int globAllArguments(OP_Node *node, UT_Args &args,
487  UT_WorkBuffer &workbuf,
488  UT_WorkArgs &argv,
489  OP_ItemTypeMask item_type,
490  OP_GlobContext *context,
491  int startitem = 1);
492 
493  // This function is similar to the one above, except it takes a string
494  // pattern (which may contain spaces) and returns an array of matching
495  // nodes and/or netboxes.
496  static void globAllArgumentsAsArray(OP_Node &relative_to_node,
497  const char *pattern,
498  OP_ItemTypeMask item_type,
499  OP_GlobContext &glob_context,
501 
502  // These functions are the instantiations of the virtual functions
503  // from our OP_OTLManagerSink base class.
504  void definitionsAdded(int libindex,
505  UT_IntArray &defindex) override;
506  void definitionsRemoved(int libindex,
507  UT_IntArray &defindex,
508  OP_OTLLibrary *&preserve) override;
509 
510  // Reloads the operator tables that were changed by an OTL library being
511  // added or removed. The OTL manager calls this once it has finished
512  // changing its library list.
513  void reloadPendingTables();
514 
515  // Given a path of the form "tablename/opname", return the table and
516  // operator indicated by the path. The relativetonode parm is used when
517  // the path is actualy a node path, and we want the table and operator
518  // of the node specified by the path. If it is a relative path, the
519  // relativetonode is the starting point. If it is null, the current
520  // working node is used, or the director.
521  void getTableAndOperator(
522  const char *path,
524  OP_Operator *&op,
525  const OP_Node *relativetonode = nullptr);
527  { return myOTLManager; }
529  { return myOTLManager; }
530 
531  // This function should be called right before exiting. It will go
532  // through all OP_Operators with active nodes and run the POSTLASTDELETE
533  // event script (though it doesn't actually delete the nodes).
534  void runDeleteScriptsOnQuit();
535 
536  // Add or remove callback functions that get executed whenever we call
537  // OP_Node::opChanged.
538  void addGlobalOpChangedCallback(
539  OP_GlobalOpChangedCallback cb, void *cbdata);
540  void removeGlobalOpChangedCallback(
541  OP_GlobalOpChangedCallback cb, void *cbdata);
542  // This function is called any time OP_Node::opChanged is called. It sends
543  // the change information along to any global op change callback functions
544  // that have been registered by addGlobalOpChangeCallback.
545  void globalOpChanged(OP_Node *node,
546  OP_EventType reason,
547  void *data);
548 
549  // This function creates a backup of the specified file, if the option
550  // to save backup files is turned on. The actual file name and file type
551  // are irrelevent. It returns true if the backup was successful (or was
552  // not required).
553  static bool createBackupFile(const char *filename,
554  bool domove= false);
555  // This function will rename the current file "filename" to the next
556  // filename in the sequence to free up "filename" so that it can be
557  // saved over. If successful, it will store the new filename in
558  // "newfilename". Otherwise, "newfilename" will be an empty string.
559  static void autoIncrementRename(const char *filename,
560  UT_String &newfilename,
561  UT_String &errorstring,
562  bool movefile,
563  bool autosave);
564 
565  void runScript(CMD_Manager *cman, const char *filename);
566  UT_Tuple<bool, int> runPython(CMD_Manager *cman, const char *filename);
567  UT_Tuple<bool, int> runPython(CMD_Manager *cman, int argc,
568  char *argv[]);
569  UT_Tuple<bool, int> runDefaultStartupScripts(CMD_Manager *cman,
570  const char *startup_script,
571  const char *postload_script);
572 
573  // Get the global (i.e. non-operator specific) script path cache.
574  OP_EventScriptPathCache *getGlobalEventScriptPathCache()
575  { return myGlobalEventScriptPathCache; }
576 
577  // Clear all cached paths to global event scripts.
578  void clearGlobalEventScriptPathCache();
579 
580  // Query all cached global event script paths.
581  void getCachedGlobalEventScriptPaths(
582  UT_StringArray &events,
583  UT_StringArray &paths,
584  bool only_nonempty) const;
585 
586  // Because of code complexity issues, this method must be used to destruct
587  // an OP_Director.
588  static void destroyDirector(OP_Director *opdir);
589 
590  bool getSaveSceneAsText() const;
591  void setSaveSceneAsText(bool on_off);
592  bool getNewFileSaveSceneAsText() const;
593  void setNewFileSaveSceneAsText(bool on_off);
594 
595  /// Run callbacks for before saving a scene,
596  /// 'autosave' indicates if the save was triggered by the autosave timer.
597  void notifyBeforeSceneSave(
598  const UT_StringHolder &filename,
599  bool autosave);
600  /// Run callbacks for before saving a scene,
601  /// 'autosave' indicates if the save was triggered by the autosave timer.
602  /// 'did_succeed' indicates if the save was successful.
603  void notifyAfterSceneSave(
604  const UT_StringHolder &filename,
605  bool autosave,
606  bool did_succeed);
607 
608  /// Run callbacks for before the application quits.
609  void notifyBeforeQuit();
610 
612 
614  { return myOrientationMode; }
616  { myOrientationMode = axis; }
617 
618  static UT_Obfuscator *getObfuscator();
619 
620 protected:
622  { return UT_ERROR_NONE; }
623  OP_ERROR bypassMe(OP_Context &, int &) override
624  { return UT_ERROR_NONE; }
625  const char *getFileExtension(int binary) const override
626  { return binary ? ".bhip" : ".hip"; }
627  void clearUnsupportedCommands() const;
628 
629  // This function is called when we update our OTL for an operator. It
630  // does nothing at this level, but in MOT it will clear out the PI
631  // settings that have been saved for the specified operator type.
632  virtual void clearHandleSettings(OP_Operator *) { }
633 
634  // We don't allow spare parms on the director, so just ignore this call.
636  UT_String &errors) override
637  {
638  errors += "Spare parameters are not alowed on ";
639  errors += "the root node.";
640  return false;
641  }
642 
643  /// Runs the user-defined post load script when loading
644  /// a new network into Houdini.
645  void runPostLoadScript();
646 
647  // Hooks for MOT_Director to set filenames at the appropriate times so that
648  // scene events get the correct values in their callbacks.
649  // NB: These are intended to be volatile in nature. Callers should reset
650  // these for each use.
653 
654 private:
655  // Disallow copying of OP_Director, these methods are not implemented
656  // on purpose
657  OP_Director(const OP_Director &copy);
658  OP_Director &operator =(const OP_Director &copy);
659 
660  void installCommands();
661  void installMoreCommands();
662  void installCHCommands();
663  void installOTLCommands();
664  void installOpRampResolver();
665 
666  void savePreCommands(std::ostream &os,
667  const OP_SaveFlags &flags);
668  void savePostCommands(std::ostream &os,
669  const OP_SaveFlags &flags);
670 
671  void notifyEventCallbacks(EventType type);
672 
673  /// Helper function to update to a new operator definition. May delete
674  /// the old operator and return a different one.
675  void updateNewDefinition(
676  OP_Operator *&op,
677  OP_OTLLibrary *newlib,
678  int newdefindex);
679 
680  void varChanged(const UT_String &varname);
681  void varsChanged(const UT_StringArray &varnames);
682 
683  /// Helper function for runDefaultStartupScripts().
684  /// Pass back the full path of the first startup script file
685  /// found in the Houdini path.
686  static void getFirstFoundStartupScriptFile(
687  UT_StringHolder &script_path,
688  const char *script_file_name);
689 
690  /// Helper function for runDefaultStartupScripts().
691  /// Passes back the full path of the first finding of inputpath
692  /// in the script search directories. The file name of outputpath
693  /// may end in any of the acceptable script file extensions
694  /// (i.e. .py or .cmd).
695  static void getFirstFoundScriptFile(
696  UT_StringHolder &outputpath,
697  const char *inputpath);
698 
699  static void sceneSaveEvent(EventType event, UT_Args &args);
700 
701 private:
702  char *myBadLoadData;
703  int myBadLoadDataLen;
704  OP_CommandManager myCommandManager;
705  fpreal32 myVersion;
706  int myInLoadCount;
707 
708  struct CwdContext
709  {
710  CwdContext() : myCwdId(-1)
711  {
712  }
713  int myCwdId;
714  UT_IntArray myCwdStack;
715  UT_IntArray myEvalCollectionStack;
716  };
718 
719  OP_ItemIdList myPickedItems;
721 
722  OP_SaveCallback *myCallbacks;
723  OP_SaveCallback *myUserDisplayOptionCallback;
724  OP_SaveCallback *mySceneFileVisualizersCallback;
725  OP_BundleList *myBundles;
726  OP_Take *myTakeManager;
727  OP_StyleManager *myStyleManager;
728  OP_FileResolver *myFileResolver;
729  UT_ColorTable myGroupColorTable;
730 
731  int myCookEnabled;
732  int mySimulationEnabled;
733  int mySkipPlaybarBasedSimulationReset;
735 
736  OP_OTLManager myOTLManager;
737  OP_OperatorTableList myTablesToReload;
738  UT_StringSet *myDummyDefinitionActivations;
739 
740  OP_GlobalOpChangedCallbacks myGlobalOpChangedCallbacks;
741  UT_ValArray<void *> myGlobalOpChangedCallbackData;
742 
743  struct EventCallbackInfo
744  {
745  EventCallback cb;
746  void *data;
747  friend bool operator==(const EventCallbackInfo &lhs, const EventCallbackInfo &rhs)
748  {
749  return (lhs.cb == rhs.cb) && (lhs.data == rhs.data);
750  }
751  };
752 
753  // EventCallbackInfoList will emulate an ordered set
754  //
755  // This is important since we want to ensure that:
756  // 1 - callbacks are executed in the order that they're registered
757  // 2 - only a single unique callback+data pair can be registered
758  //
759  // These are "enforced" in 1-notifyEventCallbacks and 2-addEventCallback
760  //
761  typedef UT_Array<EventCallbackInfo> EventCallbackInfoList;
762  EventCallbackInfoList myEventCallbacks[NUM_NETWORK_EVENT_TYPES];
763 
764  // Cache of global (i.e. non-operator specific) event script paths.
765  OP_EventScriptPathCache *myGlobalEventScriptPathCache;
766 
767  OrientationMode myOrientationMode;
768 
769  // This flag tracks whether any OPs that got loaded had the old
770  // style override flag. If so, we know we will have to do a complete
771  // update.
772  bool myOldCHOPOverrideFlag;
773  // This flag tracs whether or not we are inside a call to loadNetwork.
774  // This is different from the isLoading flag, which gets set during any
775  // network load.
776  bool myIsLoadingHip;
777  bool mySwitchingTake;
778  // This value is temporarily set to true when the user explicitly asks
779  // for a hip file save either by executing an mwrite, or choosing Save
780  // or Save As from the File menu.
781  bool myIsDoingExplicitSave;
782  // This flag is set to true while Houdini is exiting.
783  bool myIsQuitting;
784 
785  // This flag is set when the OP director is created for mantra. There are
786  // some OP features which are expensive (i.e. importing the hou python
787  // module). This option disables those features.
788  bool myIsMantra;
789 
790  // Set by OPUI while its Session Sync server is running.
791  bool myEngineSessionSyncActive;
792 
793  // Set to true while Houdini is clearing the scene.
794  bool myIsClearing;
795  bool mySaveSceneAsText;
796  bool myNewFileSaveSceneAsText;
797 
798  // Flag to track if we are running 456.cmd, in case the user wants to
799  // merge in another hip file in this script. We don't want to end up
800  // calling 456.cmd recursively.
801  bool myRunningPostLoadScript = false;
802 
803  // Callback ID for marking hip file dirty when context options change.
804  int myContextOptionCallbackId = -1;
805 
806  static UT_Obfuscator *theObfuscator;
807 };
808 
811 
812 /// Create an evaluation context scope with a new node
813 class OP_API OP_Director::CwdScope : UT_NonCopyable
814 {
815 public:
816  CwdScope(int thread, const OP_Node &new_cwd);
817  ~CwdScope();
818 private:
819  int myThread;
820  CH_EvalContext::Scope myEvalScope;
821  int myOldCwdId;
822 };
823 
824 #endif
virtual bool addNodeSpareParm(OP_Parameters *, PRM_Template *) const
Definition: OP_Director.h:425
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
GLbitfield flags
Definition: glcorearb.h:1596
GT_API const UT_StringHolder filename
virtual void clearHOMSessionModuleSource()
Definition: OP_Director.h:348
OP_StyleManager * getStyleManager()
Definition: OP_Director.h:477
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
const GLdouble * v
Definition: glcorearb.h:837
UT_ColorTable & getGroupColorTable()
Definition: OP_Director.h:478
bool isSwitchingTake() const
Definition: OP_Director.h:325
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:391
virtual bool loadNodeSpareParms(OP_Parameters *, UT_IStream &, UT_String &) const
Definition: OP_Director.h:417
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:574
OP_BundleList * getBundles()
Definition: OP_Director.h:358
**But if you need a result
Definition: thread.h:622
bool changeSpareParms(UT_IStream &, UT_String &errors) override
Definition: OP_Director.h:635
UT_Function< void()> myResetFileNameCallback
Definition: OP_Director.h:652
virtual int renameNode(OP_Node *node, const char *name, OP_RenameAction action=OP_RENAME_NORMAL)
virtual void clearHandleSettings(OP_Operator *)
Definition: OP_Director.h:632
virtual void deleteAllNodeSpareParms(OP_Parameters *) const
Definition: OP_Director.h:457
OrientationMode getOrientationMode() const
Definition: OP_Director.h:613
void setOrientationMode(OrientationMode axis)
Definition: OP_Director.h:615
float fpreal32
Definition: SYS_Types.h:200
int saveCookedData(std::ostream &, OP_Context &, int=0) override
Definition: OP_Director.h:104
void setEngineSessionSyncActive(bool active)
Definition: OP_Director.h:316
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:526
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:403
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
UT_Function< void()> mySetFileNameCallback
Definition: OP_Director.h:651
friend class OP_Director
Definition: OP_Network.h:1140
virtual bool loadNodeCompiledDs(OP_Node *, UT_IStream &)
Definition: OP_Director.h:473
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:468
int getCwdStackSize(int thread) const
Definition: OP_Director.h:178
OP_ERROR cookMe(OP_Context &) override
Definition: OP_Director.h:621
int cookEnabled() const
Definition: OP_Director.h:361
bool getIsDoingExplicitSave() const
Definition: OP_Director.h:306
void bumpSkipPlaybarBasedSimulationReset(int inc)
Definition: OP_Director.h:376
OP_InterestType
Definition: OP_DataTypes.h:206
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:381
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:334
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:410
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:432
GLenum GLenum GLsizei void * table
Definition: glad.h:5129
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
virtual OP_Node * linkInternalScriptOperator(const char *, OP_Operator *)
Definition: OP_Director.h:395
bool isEngineSessionSyncActive() const
Definition: OP_Director.h:314
GT_API const UT_StringHolder version
const OP_OTLManager & getOTLManager() const
Definition: OP_Director.h:528
virtual void getInternalScriptDefinition(OP_Node *, UT_String &)
Definition: OP_Director.h:399
virtual void deleteNodeSpareParmLayout(OP_Parameters *) const
Definition: OP_Director.h:454
virtual bool loadHOMSessionModuleSource(UT_IStream &is)
Definition: OP_Director.h:350
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:476
const char * getFileExtension(int binary) const override
Definition: OP_Director.h:625
fpreal64 fpreal
Definition: SYS_Types.h:283
virtual void saveNodeSpareParmCommands(OP_Parameters *, std::ostream &, const char *, bool) const
Definition: OP_Director.h:447
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:471
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:460
OP_OrientationMode
Definition: OP_Director.h:66
void setCookEnabled(int state)
Definition: OP_Director.h:363
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:465
virtual void changeNodeSpareParms(OP_Parameters *, PI_EditScriptedParms &, UT_String &) const
Definition: OP_Director.h:441
int simulationEnabled() const
Definition: OP_Director.h:367
OP_ERROR bypassMe(OP_Context &, int &) override
Definition: OP_Director.h:623
virtual void saveHOMSessionModuleSource(std::ostream &os)
Definition: OP_Director.h:349
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:369
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:335
UT_NonCopyable & operator=(const UT_NonCopyable &)=delete
bool getIsClearing() const
Definition: OP_Director.h:318
bool skipPlaybarBasedSimulationReset() const
Definition: OP_Director.h:374