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