Free Electron
HoudiniSOP.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 //* derived from Houndini sample: SOP_Surface
8 
9 #ifndef __houdini_HoudiniSOP_h__
10 #define __houdini_HoudiniSOP_h__
11 
12 namespace fe
13 {
14 namespace ext
15 {
16 
17 /**************************************************************************//**
18  @brief Houdini SOP node
19 
20  @ingroup houdini
21 *//***************************************************************************/
22 class HoudiniSOP:
23  public SOP_Node,
24  public MetaPlugin
25 {
26  public:
27 
28  class OpOperator:
29  public OP_Operator
30  {
31  public:
32  OpOperator(const char *name,
33  const char *english,
34  OP_Constructor construct,
35  PRM_Template *templates,
36  unsigned min_sources,
37  unsigned max_sources,
38  CH_LocalVariable *variables,
39  unsigned flags,
40  const char **inputlabels,
41  sp<Catalog> a_spCatalog);
42 
43  //* as OP_Operator
44  virtual bool getOpHelpURL(UT_String& a_rUtString) override;
45 
46 #if FE_HOUDINI_13_PLUS
47  virtual bool wantsInputEditor(void) const override
48  { return false; }
49 #endif
50 
51  private:
52  String m_helpUrl;
53  };
54 
55  class UndoCallback:
56  public UT_Undo
57  {
58  public:
59  UndoCallback(HoudiniSOP* a_pHoudiniSOP,
60  String a_change,
61  sp<Catalog> a_spNewCatalog,
62  sp<Counted> a_spOldCounted,
63  sp<Counted> a_spNewCounted);
64 
65  virtual bool isValid(void) override;
66  virtual void undo(void) override { undoOrRedo(FALSE); }
67  virtual void redo(void) override { undoOrRedo(TRUE); }
68 
69  private:
70 
71  virtual void undoOrRedo(BWORD a_redo);
72 
73  HoudiniSOP* m_pHoudiniSOP;
74  String m_change;
75  sp<Catalog> m_spNewCatalog;
76  sp<Counted> m_spOldCounted;
77  sp<Counted> m_spNewCounted;
78  };
79 
80  HoudiniSOP(OP_Network *pNetwork,
81  const char *name,OP_Operator *pOp);
82 virtual ~HoudiniSOP(void);
83 
84  //* as OperatorPlugin
85 virtual void dirty(BWORD a_aggressive) override;
86 virtual void select(void) override;
87 
88  //* as MetaPlugin
89 virtual BWORD chronicle(String a_change,
90  sp<Counted> a_spOldCounted,
91  sp<Counted> a_spNewCounted) override;
92 virtual BWORD interrupted(void) override;
93 
94  //* NOTE called by CacheOp
95  BWORD cookInputs(void);
96 
97 static int discoverOperators(OP_OperatorTable *pTable);
98 
99  /// @internal
100 static OP_Node* create(OP_Network *pNetwork,const char *name,
101  OP_Operator *pOp);
102 
103  /// @internal
104 static int reloadCallback(void *pData,int index,float time,
105  const PRM_Template* pTemplate);
106 
107  /// @internal
108  void brush(GU_Detail* pGdp,WindowEvent& a_rEvent,
109  SpatialVector& a_rRayOrigin,
110  SpatialVector& a_rRayDirection);
111 
112  void clearErrors(void);
113  void relayErrors(void);
114 const String prompt(void);
115 const String idleEvents(void);
116 const String brushVisible(void);
117 const String brushCook(void);
118 
119 static String classOfImplementation(String a_implementation);
120 
121  protected:
122  //* as OP_Node
123 virtual void getDescriptiveName(
124  UT_String& a_rString) const override;
125 virtual OP_ERROR bypassMe(OP_Context &context,
126  int &copied_input) override;
127 virtual void opChanged(OP_EventType reason,
128  void *data) override;
129 virtual bool load(UT_IStream& a_rStreamIn,
130  const char* a_extension,
131  const char* a_path) override;
132 virtual OP_ERROR save(std::ostream& a_rStreamOut,
133  const OP_SaveFlags& a_rFlags,
134  const char* a_pathPrefix,
135  const UT_String& a_name_override)
136  override;
137 
138  //* as SOP_Node
139 virtual OP_ERROR cookMySop(OP_Context& a_rContext) override;
140 virtual OP_ERROR cookMyGuide1(OP_Context& a_rContext) override;
141 
142  //* as OP_Parameters
143 virtual unsigned int disableParms(void) override;
144 
145  protected:
146 virtual bool evalParamBoolean(String a_key,Real a_time);
147 virtual I32 evalParamInteger(String a_key,Real a_time);
148 virtual String evalParamString(String a_key,Real a_time);
149 
150  private:
151  void createOperator(String a_operatorName,
152  Real a_time);
153  void updateCatalog(Real time,BWORD a_doInput,
154  BWORD a_force=FALSE);
155  void resignalBrush(void);
156 
157 static int buttonCallback(void* a_pNode,int a_index,
158  fpreal32 a_time,
159  const PRM_Template* a_pPrmTemplate);
160 
161  HoudiniContext m_houdiniContext;
162  String m_brushName;
163  String m_loadedState;
164  double m_frame;
165  BWORD m_cooking;
166  BWORD m_inputsLocked;
167  BWORD m_guideEmpty;
168  BWORD m_temporaryTemplate;
169 
170  OP_Operator* m_pOpOperator;
171  OP_Context* m_pOpContext;
172  UT_AutoInterrupt* m_pInterrupt;
173 };
174 
175 } /* namespace ext */
176 } /* namespace fe */
177 
178 #endif /* __houdini_HoudiniSOP_h__ */
shared FE context for Houdini plugins
Definition: HoudiniContext.h:20
static OP_Node * create(OP_Network *pNetwork, const char *name, OP_Operator *pOp)
Definition: HoudiniSOP.cc:958
kernel
Definition: namespace.dox:3
static int reloadCallback(void *pData, int index, float time, const PRM_Template *pTemplate)
Definition: HoudiniSOP.cc:121
Generalized windowing event.
Definition: WindowEvent.h:43
Automatically reference-counted string container.
Definition: String.h:128
void brush(GU_Detail *pGdp, WindowEvent &a_rEvent, SpatialVector &a_rRayOrigin, SpatialVector &a_rRayDirection)
Definition: HoudiniSOP.cc:2492
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Common functionality of meta plugins for Houdini, Maya, etc.
Definition: MetaPlugin.h:20
Houdini SOP node.
Definition: HoudiniSOP.h:22