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