HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PI_ResourceTemplate.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: PI_ResourceTemplate.h
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __PI_ResourceTemplate_H__
13 #define __PI_ResourceTemplate_H__
14 
15 #include "PI_API.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_String.h>
18 #include <UT/UT_SymbolTable.h>
19 #include <UT/UT_StringArray.h>
20 
21 class PRM_Template;
22 
23 // Viewer types that can have associated state templates.
24 // NB: The order here must correspond to theViewerTypeTokens in
25 // PI_ResourceManager.C
27 {
31 
32  PI_NUM_VIEWER_TYPES // sentinal value (not a valid value)
33 };
34 
35 // Network types to further differentiate the states for a given viewer type.
37 {
48 };
49 
50 const unsigned PI_NETMASK_OBJ = 1 << (unsigned)PI_NETWORK_OBJ;
51 const unsigned PI_NETMASK_SOP = 1 << (unsigned)PI_NETWORK_SOP;
52 const unsigned PI_NETMASK_DOP = 1 << (unsigned)PI_NETWORK_DOP;
53 const unsigned PI_NETMASK_COP2= 1 << (unsigned)PI_NETWORK_COP2;
54 const unsigned PI_NETMASK_COP = 1 << (unsigned)PI_NETWORK_COP;
55 const unsigned PI_NETMASK_COP_3D = 1 << (unsigned)PI_NETWORK_COP_3D;
56 const unsigned PI_NETMASK_CHOP= 1 << (unsigned)PI_NETWORK_CHOP;
57 const unsigned PI_NETMASK_LOP = 1 << (unsigned)PI_NETWORK_LOP;
58 const unsigned PI_NETMASK_TOP = 1 << (unsigned)PI_NETWORK_TOP;
59 
60 class OP_Operator;
61 class PI_StateTemplate;
62 class PI_PITemplate;
63 class PI_HandleTemplate;
65 
67 {
68 public:
69  PI_ResourceTemplate(const char *name, const char *english,
70  void *constructor);
71  virtual ~PI_ResourceTemplate();
72 
73  void initialize(const char *name, const char *english,
74  void *constructor);
75 
76  const UT_String &name() const { return myName; }
77  const UT_String &englishName() const { return myEnglishName; }
78  void *constructor() const { return myConstructor; }
79  void constructor(void *c){ myConstructor = c; }
80 
81 private:
82  UT_String myName;
83  UT_String myEnglishName;
84  void *myConstructor;
85 };
86 
87 //------------------------------------------------------------------------
88 
90 {
91 public:
92  PI_StateTemplate(const char *name,
93  const char *english,
94  const char *icon_name,
95  void *constructor,
96  PRM_Template *templates,
97  PI_ViewerType viewer_type,
98  unsigned network_types,
99  bool op_independent = true,
100  const char *volatile_hotkey = 0,
101  OP_Operator *op = 0);
102  ~PI_StateTemplate() override;
103 
104  void initialize(const char *name,
105  const char *english,
106  const char *icon_name,
107  void *constructor,
108  PRM_Template *templates,
109  PI_ViewerType viewer_type,
110  unsigned network_types,
111  int op_independent = 1,
112  const char *volatile_hotkey = 0,
113  bool hidden = false);
114 
115  // Since myVolatileKeys and myVolatileKeysModifiers are
116  // build during object initialization, they may no longer
117  // match with the hotkeys if the user decides to change the settings,
118  // so we need to rebuild. In some occasions (such as the use of the
119  // alt key for volatile view), we may want to enable ("inject")
120  // volatile that are determined at runtime out of outside of
121  // hotkey settings.
122  void rebuildVolatileKeys(
123  UT_Array<int>* injectionKeys = 0,
124  UT_Array<int>* injectionKeysModifiers = 0);
125 
126  virtual PRM_Template *templates() { return myTemplates; }
127  virtual const PRM_Template *templates() const
128  { return myTemplates; }
130  { return myViewerType; }
131  unsigned networkTypes() const
132  { return myNetworkTypes; }
133  const char *getIconName() const
134  { return myIconName; }
135  bool opIndependent() const
136  { return myOpIndependentFlag; }
138  { return myVolatileKeys; }
140  {return myVolatileKeysModifiers;}
141  const char *getHotkeyString() const
142  { return myHotkeyString; }
144  { return myOp; }
145 
146  // Used by scripted states to indicate if the state is able to handle
147  // changes to the selection. Most node states cannot, but the Edit state or
148  // Layout state, for example, can transform any selected primitive.
149  void setSupportsSelectionChange(bool supports_change)
150  { mySupportsSelectionChange = supports_change; }
152  { return mySupportsSelectionChange; }
153 
154  void setHidden(bool hide)
155  { myHidden = hide; }
156  bool getHidden() const
157  { return myHidden; }
158 
159  // Used in BM_OpStateControl::enterState to maintain old behavior
160  virtual bool forceStateToEnter() const
161  { return myOpIndependentFlag; }
162 
163 protected:
164  void setVolatileKeys(const UT_Array<int> &keys,
165  const UT_Array<int> &modifiers)
166  {
167  myVolatileKeys = keys;
168  myVolatileKeysModifiers = modifiers;
169  }
170 
171 private:
172  UT_String myIconName;
173  UT_String myHotkeyString;
174  PRM_Template *myTemplates;
175  OP_Operator *myOp;
176  PI_ViewerType myViewerType;
177  unsigned myNetworkTypes;
178  UT_Array<int> myVolatileKeys;
179  UT_Array<int> myVolatileKeysModifiers;
180  bool myOpIndependentFlag;
181  bool mySupportsSelectionChange;
182  bool myHidden;
183 };
184 
185 //------------------------------------------------------------------------
186 
188 {
189 public:
190  PI_HandleTemplate(const char *name,
191  const char *english,
192  void *constructor,
193  PRM_Template *templates);
194  ~PI_HandleTemplate() override;
195 
196  virtual const PRM_Template *templates() const
197  {
198  return myTemplates;
199  }
201  {
202  return myTemplates;
203  }
204 
205 private:
206  PRM_Template *myTemplates;
207 };
208 
209 //------------------------------------------------------------------------
210 
212 
213 namespace PI_PythonHandle
214 {
215  class PITemplate;
216 };
217 
219 {
220 public:
221  PI_PITemplate(const char *name,
222  const char *english,
223  const char *types,
224  const char *icon_name,
225  const char *parms[],
226  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
227  unsigned viewmask = 0xFFFFFFFF,
228  bool display_always = false);
229  ~PI_PITemplate() override;
230 
232  { return myParmNameTable; }
234  { return myParmNameList; }
235  const char *iconName() const { return myIconName; }
236 
237  bool isDisplayAlways() const
238  { return myDisplayAlwaysFlag; }
239 
240  short isEthereal() const { return myEtherealFlag; }
241  bool supportsType(const char *type) const;
242  unsigned getViewerMask() const { return myViewerMask;}
243 
244  // Not const as we use a cache.
245  const char *getHelp();
246 
247 private:
248  friend class PI_PythonHandle::PITemplate;
249  void addParmName(char const* parm_name, int index);
250 
251  UT_String myTypes;
252  UT_String myIconName;
253  int myHelpCached;
254  UT_String myHelp;
255  PI_ParmNameIndexMap myParmNameTable;
256  UT_StringArray myParmNameList;
257  short myEtherealFlag;
258  unsigned myViewerMask;
259  bool myDisplayAlwaysFlag;
260 };
261 
262 //------------------------------------------------------------------------
263 
265 {
266 public:
267  PI_SelectorTemplate(const char *name,
268  const char *english,
269  const char *types,
270  bool ordered = false);
271  ~PI_SelectorTemplate() override;
272 
273  bool isGeneric() const { return (myData != 0); }
274  bool supportsType(const char *type) const;
275  void data(void *d) { myData = d; }
276  void *data() const { return myData; }
277  bool ordered() const { return myOrdered; }
278 
279 private:
280  UT_String myTypes;
281  void *myData;
282  bool myOrdered;
283 };
284 
285 #endif
const unsigned PI_NETMASK_DOP
const UT_String & name() const
virtual PRM_Template * templates()
virtual bool forceStateToEnter() const
PI_NetworkType
OP_Operator * getOperator() const
const unsigned PI_NETMASK_SOP
PI_ViewerType
#define PI_API
Definition: PI_API.h:10
const UT_String & englishName() const
const unsigned PI_NETMASK_TOP
unsigned networkTypes() const
const char * getIconName() const
void setSupportsSelectionChange(bool supports_change)
const UT_Array< int > & volatileKeysModifiers()
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
const UT_StringArray & parmNameList() const
const unsigned PI_NETMASK_COP
bool getHidden() const
const unsigned PI_NETMASK_COP2
const unsigned PI_NETMASK_CHOP
const char * iconName() const
short isEthereal() const
const char * getHotkeyString() const
virtual PRM_Template * templates()
GLuint const GLchar * name
Definition: glcorearb.h:786
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
bool getSupportsSelectionChange() const
void * constructor() const
virtual const PRM_Template * templates() const
GA_API const UT_StringHolder parms
const unsigned PI_NETMASK_COP_3D
const unsigned PI_NETMASK_OBJ
const UT_Array< int > & volatileKeys()
bool opIndependent() const
void initialize(const char *name, const char *english, void *constructor)
bool isDisplayAlways() const
GLuint index
Definition: glcorearb.h:786
const PI_ParmNameIndexMap & parmNameTable() const
UT_SymbolMap< int > PI_ParmNameIndexMap
PI_ViewerType viewerType() const
unsigned getViewerMask() const
void setVolatileKeys(const UT_Array< int > &keys, const UT_Array< int > &modifiers)
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2542
virtual const PRM_Template * templates() const
void setHidden(bool hide)
const unsigned PI_NETMASK_LOP