HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HOM_Module.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  * COMMENTS:
7  * This class is not directly wrapped by swig. However, when creating
8  * the swig wrapper modules we wrap each of the methods of this class
9  * in functions. This way, the methods of this class appear as the
10  * top-level parts of the hou module.
11  */
12 
13 #ifndef __HOM_Module_h__
14 #define __HOM_Module_h__
15 
16 #include "HOM_API.h"
17 #include "HOM_BinaryString.h"
18 #include "HOM_Defines.h"
19 #include "HOM_Errors.h"
20 #include "HOM_ElemPtr.h"
21 #include "HOM_EnumModules.h"
23 #include <UT/UT_Lock.h>
24 #include <UT/UT_NonCopyable.h>
25 #include <UT/UT_Notifier.h>
26 #include <UT/UT_TaskLock.h>
27 #include <UT/UT_Thread.h>
28 #include <SYS/SYS_Types.h>
29 #include <typeinfo>
30 #include <string>
31 #include <vector>
32 #include <map>
33 #include <hboost/shared_ptr.hpp>
34 #include <hboost/any.hpp>
35 
36 class OP_Node;
37 class STORUI_OrboltURLHandler;
38 class HOM_AgentClip;
40 class HOM_AgentLayer;
41 class HOM_AgentRig;
42 class HOM_AgentShape;
46 class HOM_anonstats;
47 class HOM_audio;
49 class HOM_ChopNode;
50 class HOM_Color;
51 class HOM_crowds;
53 class HOM_dop;
54 class HOM_Edge;
55 class HOM_EnumValue;
56 class HOM_EvaluationCache;
60 class HOM_galleries;
61 class HOM_Geometry;
62 class HOM_hda;
63 class HOM_HDADefinition;
64 class HOM_HDAModule;
65 class HOM_HDAOptions;
66 class HOM_hipFile;
67 class HOM_hmath;
70 class HOM_Keyframe;
73 class HOM_NetworkBox;
74 class HOM_NetworkDot;
76 class HOM_Node;
77 class HOM_NodeBundle;
78 class HOM_NodeConnection;
79 class HOM_NodeType;
82 class HOM_Parm;
83 class HOM_ParmTemplate;
85 class HOM_ParmTuple;
86 class HOM_perfMon;
88 class HOM_pypanel;
89 class HOM_playbar;
90 class HOM_Point;
91 class HOM_Prim;
92 class HOM_properties;
93 class HOM_qt;
95 class HOM_RedrawBlock;
96 #ifndef SWIG
98 #endif
99 class HOM_Selection;
101 class HOM_shelves;
102 class HOM_StickyNote;
103 class HOM_StringKeyframe;
106 class HOM_styles;
107 class HOM_StyleSheet;
108 class HOM_takes;
110 class HOM_ui;
111 class HOM_hotkeys;
112 class HOM_undos;
113 class HOM_Vertex;
114 class HOM_VexContext;
116 
117 #define HOM_SESSION_MODULE_NAME "hou.session"
118 #define HOM_SESSION_MODULE_CPIO_NAME "." HOM_SESSION_MODULE_NAME
119 
120 // Use this function to access the HOM module from C++ in Houdini. This
121 // is equivalent to writing "hou" in python. It will only throw an exception
122 // if the python module could not be imported, which should not happen.
123 class HOM_Module;
125 
127 {
128 public:
129  static void setHOMCreator(void (*homCreator)());
130 
131  virtual ~HOM_Module() {}
132 
133  virtual std::vector<std::string> _getArgumentAutoComplete(
134  const char *method_name, const char *arguments,
135  bool meta_info_only = false) = 0;
136 
137  // This method is called by the expression editor to force autocompletion
138  // to be relative to the node containing the expression. It is not
139  // wrapped by swig.
140  virtual void setRelativeNodeForAutoComplete(OP_Node *node) = 0;
141 
142  virtual HOM_ui& ui() = 0;
143  virtual HOM_qt& qt() = 0;
144  virtual HOM_hotkeys& hotkeys() = 0;
145  virtual HOM_audio& audio() = 0;
146  virtual bool isUIAvailable() = 0;
147 
148  virtual HOM_galleries& galleries() = 0;
149  virtual HOM_hda& hda() = 0;
150  virtual HOM_hipFile& hipFile() = 0;
151  virtual HOM_perfMon& perfMon() = 0;
152  virtual HOM_playbar& playbar() = 0;
153  virtual HOM_pypanel& pypanel() = 0;
154  virtual HOM_hmath& hmath() = 0;
155  virtual HOM_dop& dop() = 0;
156  virtual HOM_properties& properties() = 0;
157  virtual HOM_shelves& shelves() = 0;
158  virtual HOM_styles& styles() = 0;
159  virtual HOM_takes& takes() = 0;
160  virtual HOM_undos& undos() = 0;
161  virtual HOM_viewportVisualizers& viewportVisualizers() = 0;
162  virtual HOM_anonstats& anonstats() = 0;
163  virtual HOM_crowds& crowds() = 0;
164 
165  virtual void exit(int exit_code=0, bool suppress_save_prompt=false) = 0;
166 
167  // isExiting() will return true if the program is actually Houdini (not
168  // mplay) and the UI queue is closed. This method is wrapped by swig, but
169  // only so houdiniInterpreter can call it.
170  virtual bool isExiting() = 0;
171 
172  virtual void addPreloadIcon(const char *name, int w, int h) = 0;
173  virtual void rasterizePreloadIcons() = 0;
174 
175  virtual std::string applicationName() = 0;
176  virtual std::vector<int> applicationVersion(bool include_patch=false) = 0;
177  virtual std::string applicationVersionString() = 0;
178  virtual std::string applicationCompilationDate() = 0;
179  virtual std::string applicationPlatformInfo() = 0;
180  virtual HOM_EnumValue &licenseCategory() = 0;
181  virtual bool isApprentice() = 0;
182  virtual void releaseLicense() = 0;
183 
184  // Threading controls
185  virtual int maxThreads() = 0;
186  virtual void setMaxThreads(int max_threads) = 0;
187 
188  // These methods return a new HOM_Node object.
189  virtual HOM_Node* root() = 0;
190  virtual HOM_Node* pwd() = 0;
191  virtual HOM_Node* parent() = 0;
192 
193  virtual void setPwd(HOM_Node &newpwd) = 0;
194  virtual void cd(const char *path) = 0;
195 
196  // Calling phm() is a shortcut for calling pwd().hdaModule().
197  virtual HOM_HDAModule* phm() = 0;
198 
199  // This method returns a new HOM_DopNetNode object or None.
200  virtual HOM_Node* currentDopNet() = 0;
201  virtual void setCurrentDopNet(HOM_Node &dopnet) = 0;
202 
203  // Gets or sets the simulation enabled state.
204  virtual bool simulationEnabled() = 0;
205  virtual void setSimulationEnabled(bool enabled) = 0;
206 
207  // These methods return a new HOM_Node object or null if the node couldn't
208  // be found.
209  virtual HOM_Node *node(const char *path) = 0;
210  virtual HOM_NetworkMovableItem* item(const char *path) = 0;
211 
212  virtual std::vector<HOM_ElemPtr<HOM_Node> > nodes(const std::vector<std::string> &paths) = 0;
213  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > items(const std::vector<std::string> &paths) = 0;
214 
215  virtual HOM_Node *nodeBySessionId(int session_id) = 0;
216  virtual HOM_NetworkBox *networkBoxBySessionId(int session_id) = 0;
217  virtual HOM_StickyNote *stickyNoteBySessionId(int session_id) = 0;
218  virtual HOM_SubnetIndirectInput *subnetIndirectInputBySessionId(
219  int64 session_id) = 0;
220  virtual HOM_NetworkDot *networkDotBySessionId(int session_id) = 0;
221  virtual HOM_NetworkMovableItem *itemBySessionId(
222  HOM_EnumValue &item_type, int64 session_id) = 0;
223  virtual HOM_NodeConnection *nodeConnectionBySessionId(
224  int node_session_id, int input_index) = 0;
225 
226  // Functions for configuring default colors on network elements.
227  virtual HOM_Color defaultColor(HOM_EnumValue &color_item) = 0;
228  virtual void setDefaultColor(HOM_EnumValue &color_item, HOM_Color *color) = 0;
229 
230  // Return HOM_Nodes for all selected nodes in the session.
231  virtual std::vector<HOM_ElemPtr<HOM_Node> > selectedNodes(
232  bool include_hidden = false) = 0;
233  virtual std::vector<HOM_ElemPtr<HOM_NetworkMovableItem> > selectedItems(
234  bool include_hidden = false) = 0;
235  virtual std::vector<HOM_ElemPtr<HOM_NodeConnection> > selectedConnections() = 0;
236  virtual void clearAllSelected() = 0;
237 
238  // Copy nodes to and paste from clipboard.
239  virtual void copyNodesToClipboard(const std::vector<HOM_Node *> &nodes) = 0;
240  virtual void pasteNodesFromClipboard(HOM_Node &destination_node) = 0;
241 
242  // These methods return new HOM_Parm/HOM_ParmTuple objects or null if the
243  // parm couldn't be found.
244  virtual HOM_Parm* parm(const char *path) = 0;
245  virtual HOM_ParmTuple* parmTuple(const char *path) = 0;
246  virtual HOM_Parm *evaluatingParm() = 0;
247 
248  // Access to the contents of the parm clipboard
249  virtual std::vector< std::map<std::string, std::string> >
250  parmClipboardContents() = 0;
251 
252  // These methods return a new HOM_NodeType object or null if it couldn't
253  // be found.
254  virtual HOM_NodeType *nodeType(
255  HOM_NodeTypeCategory &category, const char *name) = 0;
256  virtual HOM_NodeType *nodeType(const char *name) = 0;
257 
258  virtual HOM_NodeType *preferredNodeType(
259  const char *name, HOM_Node *parentNode = NULL) = 0;
260 
261  virtual HOM_NodeTypeCategory &objNodeTypeCategory() = 0;
262  virtual HOM_NodeTypeCategory &sopNodeTypeCategory() = 0;
263  virtual HOM_NodeTypeCategory &popNodeTypeCategory() = 0;
264  virtual HOM_NodeTypeCategory &dopNodeTypeCategory() = 0;
265  virtual HOM_NodeTypeCategory &cop2NodeTypeCategory() = 0;
266  virtual HOM_NodeTypeCategory &shopNodeTypeCategory() = 0;
267  virtual HOM_NodeTypeCategory &vopNodeTypeCategory() = 0;
268  virtual HOM_NodeTypeCategory &ropNodeTypeCategory() = 0;
269  virtual HOM_NodeTypeCategory &chopNodeTypeCategory() = 0;
270  virtual HOM_NodeTypeCategory &popNetNodeTypeCategory() = 0;
271  virtual HOM_NodeTypeCategory &cop2NetNodeTypeCategory() = 0;
272  virtual HOM_NodeTypeCategory &vopNetNodeTypeCategory() = 0;
273  virtual HOM_NodeTypeCategory &chopNetNodeTypeCategory() = 0;
274  virtual HOM_NodeTypeCategory &managerNodeTypeCategory() = 0;
275  virtual HOM_NodeTypeCategory &rootNodeTypeCategory() = 0;
276  virtual std::map<std::string, HOM_NodeTypeCategory *>
277  nodeTypeCategories() = 0;
278 
279  virtual std::vector<HOM_ElemPtr<HOM_Node> > copyNodesTo(
280  const std::vector<HOM_Node *> &nodes,
281  HOM_Node &destination_node) = 0;
282  virtual std::vector<HOM_ElemPtr<HOM_Node> > moveNodesTo(
283  const std::vector<HOM_Node *> &nodes,
284  HOM_Node &destination_node) = 0;
285 
286  virtual HOM_NodeBundle *addNodeBundle(const char *name = NULL) = 0;
287  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > nodeBundles() = 0;
288  virtual std::vector<HOM_ElemPtr<HOM_NodeBundle> > selectedNodeBundles() = 0;
289  virtual HOM_NodeBundle *nodeBundle(const char *name) = 0;
290 
291  virtual HOM_HDADefinition *hdaDefinition(
292  HOM_NodeTypeCategory &category, const char *name,
293  const char *file_path) = 0;
294 
295  // Note that getTimeWithoutAddingDependency is not wrapped by swig.
296  virtual fpreal getTimeWithoutAddingDependency() = 0;
297  virtual double time() = 0;
298  virtual void setTime(double time) = 0;
299  virtual double frame() = 0;
300  virtual int intFrame() = 0;
301  virtual void setFrame(double frame) = 0;
302  virtual double fps() = 0;
303  virtual void setFps(double fps) = 0;
304  virtual double timeToFrame(double time) = 0;
305  virtual double frameToTime(double frame) = 0;
306 
307  // Computes a scale factor given units
308  virtual fpreal scaleFromMKS(const char *units) = 0;
309  virtual fpreal scaleToMKS(const char *units) = 0;
310 
311  virtual double bezier() = 0;
312  virtual double constant() = 0;
313  virtual double cubic() = 0;
314  virtual double cycle(double start_frame, double end_frame) = 0;
315  virtual double cyclet(double start_time, double end_time) = 0;
316  virtual double cycleoffset(double start_frame, double end_frame) = 0;
317  virtual double cycleoffsett(double start_time, double end_time) = 0;
318  virtual double ease() = 0;
319  virtual double easein() = 0;
320  virtual double easeinp(double ease_speed) = 0;
321  virtual double easeout() = 0;
322  virtual double easeoutp(double ease_speed) = 0;
323  virtual double easep(double ease_bias) = 0;
324  virtual double linear() = 0;
325  virtual double match() = 0;
326  virtual double matchin() = 0;
327  virtual double matchout() = 0;
328  virtual double qlinear() = 0;
329  virtual double quintic() = 0;
330  virtual double repeat(double start_frame, double end_frame) = 0;
331  virtual double repeatt(double start_time, double end_time) = 0;
332  virtual double spline() = 0;
333  virtual double vmatch() = 0;
334  virtual double vmatchin() = 0;
335  virtual double vmatchout() = 0;
336 
337  virtual std::string chopExportConflictResolutionPattern() = 0;
338  virtual void setChopExportConflictResolutionPattern( const char *pattern) = 0;
339 
340  virtual std::vector<HOM_ElemPtr<HOM_VexContext> >
341  vexContexts() = 0;
342 
343  virtual HOM_VexContext* vexContextForShaderType(HOM_EnumValue &shader_type) = 0;
344 
345  virtual HOM_VexContext* vexContextForNodeTypeCategory(
346  HOM_NodeTypeCategory &node_type_category) = 0;
347 
348  virtual std::string helpServerUrl() = 0;
349 
350  virtual std::string hscriptCommandHelp(const char *command_name) = 0;
351 
352  // This method returns a pair of strings: one for stdout and one for
353  // stderr.
354  virtual std::vector<std::string> hscript(const char *command) = 0;
355 
356  // Compare if two numbers are almost equal.
357  virtual bool almostEqual(double x, double y) = 0;
358 
359  virtual std::vector<std::pair<HOM_ElemPtr<HOM_Parm>, std::string> >
360  fileReferences(
361  const char *project_dir_variable="HIP", bool include_all_refs=true) = 0;
362 
363  // Find files in $HOUDINI_PATH.
364  virtual std::string findFile(const char *file_name) = 0;
365  virtual std::vector<std::string> findFiles(
366  const char *file_name) = 0;
367  virtual std::vector<std::string> findFilesWithExtension(
368  const char *file_extension, const char *subdirectory = NULL) = 0;
369 
370  // Find directories in $HOUDINI_PATH.
371  virtual std::string findDirectory(const char *directory_name) = 0;
372  virtual std::vector<std::string> findDirectories(
373  const char *directory_name) = 0;
374 
375  virtual std::vector<std::string> houdiniPath(const char *pathvar = nullptr) = 0;
376 
377  virtual std::string homeHoudiniDirectory() = 0;
378 
379  virtual HOM_BinaryString readFile(const char *file_path) = 0;
380 
381  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromString(
382  const char *data, int length) = 0;
383 
384  virtual std::map<std::string, HOM_BinaryString> loadIndexDataFromFile(
385  const char *file_path) = 0;
386 
387  virtual HOM_BinaryString saveIndexDataToString(
388  const std::map<std::string, std::string> &index_data) = 0;
389 
390  virtual void saveIndexDataToFile(
391  const char *file_path,
392  const std::map<std::string, std::string> &index_data) = 0;
393 
394  // Note that, when wrapped by swig, this function takes a single string
395  // parameter.
396  virtual std::vector<std::pair<std::string, HOM_BinaryString> >
397  loadCPIODataFromString(const char *data, int length) = 0;
398 
399  virtual HOM_BinaryString saveCPIODataToString(
400  const std::vector<std::pair<std::string, std::string> > &data) = 0;
401 
402  // These 3 methods are not wrapped by swig. They are used to notify
403  // interested parties that a change to the module source code was made and
404  // that they should forcefully update to match the change. The third
405  // is used to load the session module source from a hip file, even though
406  // that source might generate an exception.
407  virtual UT_NotifierImpl<int> &getSessionModuleSourceForceUpdateNotifier()=0;
408  virtual void forceUpdateFromSessionModuleSource() = 0;
409  virtual void forceSetSessionModuleSource(const char *source) = 0;
410 
411  virtual void setSessionModuleSource(const char *source) = 0;
412  virtual void appendSessionModuleSource(const char *source) = 0;
413  virtual std::string sessionModuleSource() = 0;
414  // This method is not wrapped by swig:
415  virtual int sessionModuleSourceChangeCount() = 0;
416 
417  // This static method lets you know if the HOM implementation is set,
418  // so you can check if it's safe to call the HOM() function. This method
419  // should only be called in rare cases.
420  static bool isImplementationSet()
421  { return theImplementation != NULL; }
422 
423  // Evaluates a parameter as if it was an OPpath parameter
424  virtual std::string chsop(const char *path) = 0;
425 
426  // Evaluates a parameter as if it was an OPlist parameter
427  virtual std::string chsoplist(const char *path) = 0;
428 
429  // Sorts a list of node paths using topological order from the graph.
430  virtual std::vector<std::string> sortedNodePaths(const std::vector<std::string> &paths) = 0;
431 
432  // Sorts a list of HOM_Node using topological order from the graph.
433  virtual std::vector<HOM_ElemPtr<HOM_Node> > sortedNodes(const std::vector<HOM_Node*> &nodes) = 0;
434 
435  virtual int patternMatch(
436  const char *pattern, const char *str, bool ignore_case=false) = 0;
437 
438  // hscriptExpression() will return different types, according to
439  // the return value of the expression.
440  virtual hboost::any hscriptExpression(const char *expression) = 0;
441  virtual double hscriptFloatExpression(const char *expression) = 0;
442  virtual std::string hscriptStringExpression(const char *expression) = 0;
443  virtual std::vector<double> hscriptVectorExpression(const char *expression) = 0;
444  virtual std::vector<std::vector<double> > hscriptMatrixExpression(
445  const char *expression) = 0;
446 
447  virtual std::string expandString(const char *str) = 0;
448  virtual std::string expandStringAtFrame(const char *str, double frame) = 0;
449 
450  virtual double lvar(const char *name) = 0;
451 
452  virtual char *getenv(const char *name, const char *default_value=NULL) = 0;
453 
454  virtual void putenv(const char *name, const char *value) = 0;
455 
456  virtual void unsetenv(const char *name) = 0;
457 
458  virtual void allowEnvironmentToOverwriteVariable(
459  const char *name, bool onoff) = 0;
460 
461  virtual void *expressionGlobals() = 0;
462 
463  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
464 
465  // This method is used to interact with the global interrupt object.
466  virtual bool updateProgressAndCheckForInterrupt(int percentage=-1) = 0;
467 
468  virtual std::map<std::string, hboost::any> runVex(
469  const char *vex_file,
470  const std::map<std::string, hboost::any> &inputs) = 0;
471 
472  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
473 
474  virtual void saveImageDataToFile(
475  const std::vector<float> &color_and_alpha_data,
476  int width, int height,
477  const char *file_name) = 0;
478 
479  virtual void saveImageDataToFile(
480  const std::string &color_and_alpha_data,
481  int width, int height,
482  const char *file_name) = 0;
483 
484  virtual HOM_BinaryString loadImageDataFromFile(
485  const char *image_file_name,
486  HOM_EnumValue &image_depth = HOM_imageDepth::Int8) = 0;
487 
488  virtual std::vector<int> imageResolution(const char *image_file_name) = 0;
489 
490  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
491 
492  virtual HOM_EnumValue &updateModeSetting() = 0;
493  virtual void setUpdateMode(HOM_EnumValue &mode) = 0;
494 
495  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
496 
497  virtual HOM_OrboltURLHandler *orboltURLHandler() = 0;
498 
499  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
500 
501  virtual void *opaqueRunCallbackAndCatchCrashes(void *opaque_callback) = 0;
502 
503  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
504 
505  // These methods are used to grant functions defined in an asset's
506  // PythonModule enhanced privileges. They are not wrapped by swig.
507  virtual void pushAccessPrivilege(const char *key) = 0;
508  virtual void popAccessPrivilege(const char *key) = 0;
509 
510  virtual std::string currentPythonModuleKey() = 0;
511 
512  virtual void registerAccessPrivilegePyClient(void *opaque_python_object) = 0;
513 
514  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
515 
516  // These methods are used to instantiate HOMF objects from the HOM
517  // library level. They are not wrapped by swig.
518  virtual HOM_FloatParmTemplate *newFloatParmTemplate(
519  const char *name,
520  const char *label,
521  int num_components,
522  const std::vector<double> &default_value,
523  double min, double max,
524  bool min_is_strict, bool max_is_strict,
525  HOM_EnumValue &look,
526  HOM_EnumValue &naming_scheme,
527  const char *disable_when,
528  bool is_hidden,
529  bool is_label_hidden,
530  bool join_with_next,
531  const char *help,
532  const char *script_callback,
533  HOM_EnumValue &script_callback_language,
534  const std::map<std::string, std::string> &tags,
535  const std::map<HOM_EnumValue, std::string> &conditionals,
536  const std::vector<std::string> &default_expression,
537  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
538 
539  virtual HOM_IntParmTemplate *newIntParmTemplate(
540  const char *name,
541  const char *label,
542  int num_components,
543  const std::vector<int> &default_value,
544  int min, int max,
545  bool min_is_strict, bool max_is_strict,
546  HOM_EnumValue &naming_scheme,
547  const std::vector<std::string> &menu_items,
548  const std::vector<std::string> &menu_labels,
549  const std::vector<std::string> &icon_names,
550  const std::string &item_generator_script,
551  HOM_EnumValue *item_generator_script_language,
552  HOM_EnumValue &menu_type,
553  const char *disable_when,
554  bool is_hidden,
555  bool is_label_hidden,
556  bool join_with_next,
557  const char *help,
558  const char *script_callback,
559  HOM_EnumValue &script_callback_language,
560  const std::map<std::string, std::string> &tags,
561  const std::map<HOM_EnumValue, std::string> &conditionals,
562  const std::vector<std::string> &default_expression,
563  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
564 
565  virtual HOM_StringParmTemplate *newStringParmTemplate(
566  const char *name,
567  const char *label,
568  int num_components,
569  const std::vector<std::string> &default_value,
570  HOM_EnumValue &naming_scheme,
571  HOM_EnumValue &string_type,
572  HOM_EnumValue &file_type,
573  const std::vector<std::string> &menu_items,
574  const std::vector<std::string> &menu_labels,
575  const std::vector<std::string> &icon_names,
576  const std::string &item_generator_script,
577  HOM_EnumValue *item_generator_script_language,
578  HOM_EnumValue &menu_type,
579  const char *disable_when,
580  bool is_hidden,
581  bool is_label_hidden,
582  bool join_with_next,
583  const char *help,
584  const char *script_callback,
585  HOM_EnumValue &script_callback_language,
586  const std::map<std::string, std::string> &tags,
587  const std::map<HOM_EnumValue, std::string> &conditionals,
588  const std::vector<std::string> &default_expression,
589  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
590 
591  virtual HOM_DataParmTemplate *newDataParmTemplate(
592  const char *name,
593  const char *label,
594  int num_components,
595  HOM_EnumValue &look,
596  HOM_EnumValue &naming_scheme,
597  HOM_EnumValue &data_parm_type,
598  const char *disable_when,
599  bool is_hidden,
600  bool is_label_hidden,
601  bool join_with_next,
602  const char *help,
603  const char *script_callback,
604  HOM_EnumValue &script_callback_language,
605  const std::map<std::string, std::string> &tags,
606  const std::map<HOM_EnumValue, std::string> &conditionals,
607  const std::vector<std::string> &default_expression,
608  const std::vector<HOM_EnumValue *> &default_expression_language) = 0;
609 
610  virtual HOM_ToggleParmTemplate *newToggleParmTemplate(
611  const char *name,
612  const char *label,
613  bool default_value,
614  const char *disable_when,
615  bool is_hidden,
616  bool is_label_hidden,
617  bool join_with_next,
618  const char *help,
619  const char *script_callback,
620  HOM_EnumValue &script_callback_language,
621  const std::map<std::string, std::string> &tags,
622  const std::map<HOM_EnumValue, std::string> &conditionals,
623  const std::string &default_expression,
624  const HOM_EnumValue &default_expression_language) = 0;
625 
626  virtual HOM_MenuParmTemplate *newMenuParmTemplate(
627  const char *name,
628  const char *label,
629  const std::vector<std::string> &menu_items,
630  const std::vector<std::string> &menu_labels,
631  int default_value,
632  const std::vector<std::string> &icon_names,
633  const std::string &item_generator_script,
634  HOM_EnumValue *item_generator_script_language,
635  HOM_EnumValue &menu_type,
636  const char *disable_when,
637  bool is_hidden,
638  bool is_label_hidden,
639  bool join_with_next,
640  const char *help,
641  const char *script_callback,
642  HOM_EnumValue &script_callback_language,
643  const std::map<std::string, std::string> &tags,
644  const std::map<HOM_EnumValue, std::string> &conditionals,
645  const std::string &default_expression,
646  const HOM_EnumValue &default_expression_language,
647  bool store_default_value_as_string) = 0;
648 
649  virtual HOM_ButtonParmTemplate *newButtonParmTemplate(
650  const char *name,
651  const char *label,
652  const char *disable_when,
653  bool is_hidden,
654  bool is_label_hidden,
655  bool join_with_next,
656  const char *help,
657  const char *script_callback,
658  HOM_EnumValue &script_callback_language,
659  const std::map<std::string, std::string> &tags,
660  const std::map<HOM_EnumValue, std::string> &conditionals ) = 0;
661 
662  virtual HOM_LabelParmTemplate *newLabelParmTemplate(
663  const char *name,
664  const char *label,
665  const std::vector<std::string> &column_labels,
666  bool is_hidden,
667  bool is_label_hidden,
668  bool join_with_next,
669  const char *help,
670  const std::map<std::string, std::string> &tags,
671  const std::map<HOM_EnumValue, std::string> &conditionals) = 0;
672 
673  virtual HOM_SeparatorParmTemplate *newSeparatorParmTemplate(
674  const char *name,
675  bool is_hidden,
676  const std::map<std::string, std::string> &tags,
677  const std::map<HOM_EnumValue, std::string> &conditionals) = 0;
678 
679  virtual HOM_FolderSetParmTemplate *newFolderSetParmTemplate(
680  const char *name,
681  const std::vector<std::string> &folder_names,
682  HOM_EnumValue &folder_type,
683  const std::map<std::string, std::string> &tags) = 0;
684 
685  virtual HOM_FolderParmTemplate *newFolderParmTemplate(
686  const char *name,
687  const char *label,
688  const std::vector<HOM_ParmTemplate *> &parm_templates,
689  HOM_EnumValue &folder_type,
690  int default_value,
691  bool is_hidden,
692  bool ends_tab_group,
693  const char *script_callback,
694  HOM_EnumValue &script_callback_language,
695  const std::map<std::string, std::string> &tags,
696  const std::map<HOM_EnumValue, std::string> &conditionals) = 0;
697 
698  virtual HOM_RampParmTemplate *newRampParmTemplate(
699  const char *name,
700  const char *label,
701  HOM_EnumValue &ramp_parm_type,
702  int default_value,
703  HOM_EnumValue *default_basis,
704  bool show_controls,
706  const char *disable_when,
707  bool is_hidden,
708  const char *help,
709  const char *script_callback,
710  HOM_EnumValue &script_callback_language,
711  const std::map<std::string, std::string> &tags,
712  const std::map<HOM_EnumValue, std::string> &conditionals,
713  const std::string &default_expression,
714  const HOM_EnumValue &default_expression_language) = 0;
715 
716  virtual HOM_ParmTemplateGroup *newParmTemplateGroup(
717  const std::vector<HOM_ParmTemplate *> &parm_templates) = 0;
718 
719  virtual HOM_PerfMonRecordOptions *newPerfMonRecordOptions(
720  bool cook_stats, bool solve_stats, bool draw_stats,
721  bool gpu_draw_stats, bool viewport_stats, bool script_stats,
722  bool render_stats, bool thread_stats, bool frame_stats,
723  bool memory_stats, bool errors) = 0;
724 
725 
726  virtual HOM_Keyframe *newKeyframe() = 0;
727  virtual HOM_Keyframe *newKeyframe(double value) = 0;
728  virtual HOM_Keyframe *newKeyframe(double value, double time) = 0;
729  virtual HOM_Keyframe *newKeyframe(const HOM_Keyframe &keyframe) = 0;
730 
731  virtual HOM_StringKeyframe *newStringKeyframe() = 0;
732  virtual HOM_StringKeyframe *newStringKeyframe(
733  const std::string &value, HOM_EnumValue &language) = 0;
734  virtual HOM_StringKeyframe *newStringKeyframe(
735  const std::string &value, double time, HOM_EnumValue &language) = 0;
736  virtual HOM_StringKeyframe *newStringKeyframe(
737  const HOM_StringKeyframe &string_keyframe) = 0;
738 
739  virtual HOM_HDAOptions *newHDAOptions() = 0;
740 
741  virtual HOM_InterruptableOperation *newInterruptableOperation(
742  const char *operation_name, const char *long_operation_name,
743  bool open_interrupt_dialog) = 0;
744 
745  virtual HOM_RedrawBlock *newRedrawBlock() = 0;
746 #ifndef SWIG
747  virtual HOM_RedrawResumeBlock *newRedrawResumeBlock() = 0;
748 #endif
749 
750  virtual HOM_StyleSheet *newStyleSheet() = 0;
751  virtual HOM_StyleSheet *newStyleSheet(const char *json_text) = 0;
752 
753  virtual HOM_Selection *newSelection(HOM_EnumValue &selection_type,
754  HOM_Geometry *geo, const char *selection_string) = 0;
755  virtual HOM_Selection *newSelection(
756  const std::vector<HOM_EnumValue *> &selection_types,
757  HOM_Geometry *geo, const char *selection_string) = 0;
758  virtual HOM_Selection *newSelection(
759  const std::vector<HOM_Prim *> &prims) = 0;
760  virtual HOM_Selection *newSelection(
761  const std::vector<HOM_Point *> &points) = 0;
762  virtual HOM_Selection *newSelection(
763  const std::vector<HOM_Vertex *> &vertices) = 0;
764  virtual HOM_Selection *newSelection(
765  const std::vector<HOM_Edge *> &edges) = 0;
766 
767  // This method returns a new HOM_Geometry object.
768  virtual HOM_Geometry *newGeometry() = 0;
769  virtual HOM_Geometry *newGeometry(HOM_Geometry &) = 0;
770 
771  virtual HOM_AgentDefinition *newAgentDefinition(
772  const HOM_AgentRig &rig, const HOM_AgentShapeLibrary &shapelib) = 0;
773 
774  virtual HOM_AgentClip *newAgentClip(
775  const char *name, const char *path, const HOM_AgentRig &rig,
776  bool keep_external_ref) = 0;
777 
778  virtual HOM_AgentClip *newAgentClip(
779  const char *name, HOM_ChopNode &chop, const HOM_AgentRig &rig,
780  double frame) = 0;
781 
782  virtual HOM_AgentClip *newAgentClip(
783  const HOM_AgentClip &clip, const HOM_AgentRig &rig,
784  const char *name) = 0;
785 
786  virtual HOM_AgentRig *newAgentRig(const char *path, bool keep_external_ref) = 0;
787 
788  virtual HOM_AgentRig *newAgentRig(
789  const char *name, const std::vector<std::string> &transform_names,
790  const std::vector<std::vector<int>> &hierarchy) = 0;
791 
792  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
793  const char *path, const HOM_AgentRig &rig,
794  bool keep_external_ref = true) = 0;
795 
796  virtual HOM_AgentTransformGroup *newAgentTransformGroup(
797  const char *name, const std::vector<int> &transforms,
798  const HOM_AgentRig &rig, const std::vector<double> &weights) = 0;
799 
800  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary() = 0;
801  virtual HOM_AgentShapeLibrary *newAgentShapeLibrary(
802  const char *path, bool keep_external_ref) = 0;
803 
804  virtual HOM_AgentShapeBinding *
805  newAgentShapeBinding(int transform, const HOM_AgentShape &shape,
806  bool deforming, double bounds_scale) = 0;
807 
808  virtual HOM_AgentLayer *newAgentLayer(
809  const char *name, const HOM_AgentRig &rig,
810  const HOM_AgentShapeLibrary &shapelib,
811  const std::vector<HOM_AgentShapeBinding *> &shape_bindings,
812  const HOM_AgentLayer *source_layer = 0) = 0;
813 
814  virtual HOM_AgentLayer *
815  newAgentLayer(const char *path, const HOM_AgentRig &rig,
816  const HOM_AgentShapeLibrary &shapelib,
817  bool keep_external_ref = true) = 0;
818 
819  virtual bool compareNode(const char *path, const char *dest = NULL) = 0;
820  virtual bool compareNodeBackup(const char *path, int index, const char *dest = NULL) = 0;
821  virtual bool compareHDA(const char *path_left, const char *path_right, const char *dest = NULL) = 0;
822  virtual bool compareHDABackup(const char *path, int index, const char *dest = NULL) = 0;
823  virtual bool compareHip(const char *dest = NULL) = 0;
824  virtual bool compareHipBackup(int index, const char *dest = NULL) = 0;
825 
826  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
827 
828  // This method is called when orbolt_url runs. It is not wrapped by swig.
829  virtual void setOrboltURLHandler(
830  STORUI_OrboltURLHandler &orbolt_url_handler) = 0;
831 
832  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
833 
834  // These methods are used to help debug HOM to make sure no objects
835  // get allocated that don't get deallocated.
836  virtual void constructObject(void *pointer, const std::type_info &type) = 0;
837  virtual void destructObject(void *pointer, const std::type_info &type) = 0;
838  virtual std::map<std::string, int> objectCounts() = 0;
839 
840 private:
841  // HOMF_Module::ensureHoudiniInternalsExist() uses this to create the HOM_Module.
842  static void (*theHOMCreator)();
843 
844  // A subclass of HOM_Module in the HOMF library will define the
845  // implementation of HOM. Importing the python module will set the
846  // implementation, so this function should only be called by HOMF_Module::
847  // ensureHoudiniInternalsExist().
848  friend class HOMF_Module;
849  static void setImplementation(HOM_Module* implementation);
850 
851  // We could add a static method to access the implementation, but we
852  // want to make it easy to access the HOM module from C++. So, the
853  // global function HOM() needs access to the implementation.
854  friend HOM_API HOM_Module& HOM();
855  static HOM_Module *theImplementation;
856 };
857 
858 
859 // Use this function to automatically delete objects for functions that
860 // return new objects. This lets you, for example, write code like
861 // HOMdel(HOM().findNode("/obj/geo1"))->setName("geo2")
862 template <typename T>
863 hboost::shared_ptr<T> HOMdel(T *hom_object)
864 { return hboost::shared_ptr<T>(hom_object); }
865 
866 
867 // This lock is used to synchronize HOM scripts running in a separate
868 // thread and Houdini. Houdini's UI queue will give up the lock when it's
869 // waiting for events and reacquire it when it handles an event.
870 //
871 // Note that this lock allows multiple threads in the same thread group to hold
872 // it at the same time. By default, a thread started from Houdini is added to
873 // the group containing the main thread. This way, since Houdini started the
874 // thread, we can be confident that it will use other locks to synchronize
875 // access to Houdini. This approach allows, for example, a volume SOP to
876 // cook using multiple threads, evaluating Python in each thread while the
877 // main thread holds the HOM lock, without deadlocking and without allowing
878 // non-Houdini threads to acquire the HOM lock. (Note that the GIL will
879 // synchronize access to Python's internals.)
882 {
883  // This is not thread-safe but should be ok because HOMgetLock() is called
884  // pretty early on during startup when there is only one thread executing.
885  if (!HOM_theHOMLock)
887 
889  return *HOM_theHOMLock;
890 }
891 
892 // The HOM implementation uses the HOM_AutoLock to make sure Houdini isn't busy
893 // when they make calls into the Houdini libraries. Note that constructing
894 // a HOM_AutoLock will release the python global interpreter lock (GIL) if
895 // it was held before acquiring the HOM lock. This way, other python threads
896 // can run if it needs to block waiting for the HOM lock.
898 {
899 public:
901  {
902  if (!HOMgetLock().hasLock())
903  {
904  HOMgetLock().lock();
905  myLocked = true;
906  }
907  else
908  myLocked = false;
909  }
910 
912  {
913  if (myLocked)
914  HOMgetLock().unlock();
915  }
916 
917 private:
918 
919  // It is important that we release the python global interpreter lock
920  // (GIL) for the duration of waiting for, acquiring and holding onto
921  // the HOM lock. This gives other threads that are either blocked
922  // on the GIL or that will try to acquire the GIL a chance to continue
923  // execution.
924  //
925  // If the current thread needs to access the Python API,
926  // then it should explicitly acquire the GIL by creating a
927  // PY_InterpreterAutoLock object. The PY_InterpreterAutoLock must be
928  // constructed *after* the HOM_AutoLock or it will have no effect.
929  //
930  // This prevents deadlocks that occur when the current thread
931  // spawns other threads which access the Python API and try to
932  // acquire the GIL.
933  //
934  // Note that we will reacquire the GIL when the HOM auto lock is destructed.
935  PY_InterpreterAutoUnlock myPyInterpAutoUnlock;
936 
937  // Boolean to determine if the auto lock actually locked the HOM lock.
938  bool myLocked;
939 };
940 
941 // The HOM implementation uses HOM_AutoUnlock to allow the main thread to
942 // run while waiting for something to happen. Constructing a HOM_AutoUnlock
943 // instance will release the HOM lock but not the Python GIL. When it's
944 // destructed it will reacquire the HOM lock. Since it releases the HOM lock,
945 // it's important that a HOM_AutoLock was already created in a containing
946 // scope.
947 //
948 // Use HOM_AutoUnlock in conjunction with PY_InterpreterAutoUnlock to
949 // also release the Python GIL. Be sure to create the HOM_AutoUnlock *after*
950 // the PY_InterpreterAutoUnlock, so that when the auto locks are destructed
951 // the HOM lock is reacquired before the Python GIL. Otherwise, it will grab
952 // the GIL and then try to grab the HOM lock, and if another thread with the
953 // HOM lock tries to run Python we'll end up with deadlock.
955 {
956 public:
958  { HOMgetLock().unlock(); }
959 
961  { HOMgetLock().lock(); }
962 };
963 
964 
965 // These macros are used to help detect memory leaks when debugging is enabled.
966 #ifdef HOM_DEBUG
967 #define HOM_CONSTRUCT_OBJECT(pointer) \
968  HOM().constructObject(pointer, typeid(*pointer));
969 #define HOM_DESTRUCT_OBJECT(pointer) \
970  HOM().destructObject(pointer, typeid(*pointer));
971 #else
972 #define HOM_CONSTRUCT_OBJECT(pointer)
973 #define HOM_DESTRUCT_OBJECT(pointer)
974 #endif
975 
976 // gcc gets a parse error if we try to give a default map value in the
977 // signature, and the typedef avoids the error.
978 typedef std::map<std::string, std::string> HOM_StdMapStringString;
979 typedef std::map<HOM_EnumValue, std::string> HOM_StdMapEnumString;
980 
981 
982 // Houdini will call HOMextendLibrary() in HDK dso's so the user can install
983 // C++ HOM extensions.
984 extern "C" {
986 }
987 
988 #endif
hboost::shared_ptr< T > HOMdel(T *hom_object)
Definition: HOM_Module.h:863
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
png_infop int transforms
Definition: png.h:2591
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
#define SYS_VISIBILITY_EXPORT
UT_TaskRootLock & HOMgetLock()
Definition: HOM_Module.h:881
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
GLuint color
Definition: glcorearb.h:1260
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
GLint y
Definition: glcorearb.h:102
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2538
GLint GLsizei width
Definition: glcorearb.h:102
Definition: HOM_qt.h:19
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
long long int64
Definition: SYS_Types.h:100
UT_TaskLockT< false > UT_TaskRootLock
Definition: UT_TaskLock.h:281
HOM_API UT_TaskRootLock * HOM_theHOMLock
#define HOM_API
Definition: HOM_API.h:13
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
virtual ~HOM_Module()
Definition: HOM_Module.h:131
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
Definition: HOM_ui.h:35
GLfloat units
Definition: glcorearb.h:407
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
GA_API const UT_StringHolder transform
std::map< HOM_EnumValue, std::string > HOM_StdMapEnumString
Definition: HOM_Module.h:979
GLenum mode
Definition: glcorearb.h:98
GLint GLsizei GLsizei height
Definition: glcorearb.h:102
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:263
SYS_VISIBILITY_EXPORT void HOMextendLibrary()
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
GLenum void ** pointer
Definition: glcorearb.h:809
png_infop png_uint_32 png_uint_32 int int * color_type
Definition: png.h:2394
GLuint index
Definition: glcorearb.h:785
GLint GLenum GLint x
Definition: glcorearb.h:408
virtual bool readFile(GA_Detail &g, const char *filename, const GA_LoadOptions *opts, UT_StringArray *errors) const
Class which defines an I/O interface to save/load geometry.
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
void unlock()
Definition: UT_TaskLock.h:253
Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t)
Definition: ImathQuat.h:545
HOM_API HOM_Module & HOM()
static bool isImplementationSet()
Definition: HOM_Module.h:420
std::map< std::string, std::string > HOM_StdMapStringString
Definition: HOM_Module.h:978
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794