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 {
45 
47 };
48 
49 const unsigned PI_NETMASK_OBJ = 1 << (unsigned)PI_NETWORK_OBJ;
50 const unsigned PI_NETMASK_SOP = 1 << (unsigned)PI_NETWORK_SOP;
51 const unsigned PI_NETMASK_DOP = 1 << (unsigned)PI_NETWORK_DOP;
52 const unsigned PI_NETMASK_COP2= 1 << (unsigned)PI_NETWORK_COP2;
53 const unsigned PI_NETMASK_CHOP= 1 << (unsigned)PI_NETWORK_CHOP;
54 const unsigned PI_NETMASK_LOP = 1 << (unsigned)PI_NETWORK_LOP;
55 const unsigned PI_NETMASK_TOP = 1 << (unsigned)PI_NETWORK_TOP;
56 
57 class OP_Operator;
58 class PI_StateTemplate;
59 class PI_PITemplate;
60 class PI_HandleTemplate;
62 
64 {
65 public:
66  PI_ResourceTemplate(const char *name, const char *english,
67  void *constructor);
68  virtual ~PI_ResourceTemplate();
69 
70  void initialize(const char *name, const char *english,
71  void *constructor);
72 
73  const UT_String &name() const { return myName; }
74  const UT_String &englishName() const { return myEnglishName; }
75  void *constructor() const { return myConstructor; }
76  void constructor(void *c){ myConstructor = c; }
77 
78 private:
79  UT_String myName;
80  UT_String myEnglishName;
81  void *myConstructor;
82 };
83 
84 //------------------------------------------------------------------------
85 
87 {
88 public:
89  PI_StateTemplate(const char *name,
90  const char *english,
91  const char *icon_name,
92  void *constructor,
93  PRM_Template *templates,
94  PI_ViewerType viewer_type,
95  unsigned network_types,
96  int op_independent = 1,
97  const char *volatile_hotkey = 0,
98  OP_Operator *op = 0);
99  ~PI_StateTemplate() override;
100 
101  void initialize(const char *name,
102  const char *english,
103  const char *icon_name,
104  void *constructor,
105  PRM_Template *templates,
106  PI_ViewerType viewer_type,
107  unsigned network_types,
108  int op_independent = 1,
109  const char *volatile_hotkey = 0,
110  bool hidden = false);
111 
112  // Since myVolatileKeys and myVolatileKeysModifiers are
113  // build during object initialization, they may no longer
114  // match with the hotkeys if the user decides to change the settings,
115  // so we need to rebuild. In some occasions (such as the use of the
116  // alt key for volatile view), we may want to enable ("inject")
117  // volatile that are determined at runtime out of outside of
118  // hotkey settings.
119  void rebuildVolatileKeys(
120  UT_Array<int>* injectionKeys = 0,
121  UT_Array<int>* injectionKeysModifiers = 0);
122 
123  virtual PRM_Template *templates() { return myTemplates; }
124  virtual const PRM_Template *templates() const
125  { return myTemplates; }
127  { return myViewerType; }
128  unsigned networkTypes() const
129  { return myNetworkTypes; }
130  const char *getIconName() const
131  { return myIconName; }
132  int opIndependent() const
133  { return myOpIndependentFlag; }
135  { return myVolatileKeys; }
137  {return myVolatileKeysModifiers;}
138  const char *getHotkeyString() const
139  { return myHotkeyString; }
141  { return myOp; }
142 
143  void setHidden(bool hide)
144  { myHidden = hide; }
145  bool getHidden() const
146  { return myHidden; }
147 
148  // Used in BM_OpStateControl::enterState to maintain old behavior
149  virtual bool forceStateToEnter() const
150  {
151  return myOpIndependentFlag > 0;
152  }
153 
154 protected:
155  void setVolatileKeys(const UT_Array<int> &keys,
156  const UT_Array<int> &modifiers)
157  {
158  myVolatileKeys = keys;
159  myVolatileKeysModifiers = modifiers;
160  }
161 
162 private:
163  UT_String myIconName;
164  UT_String myHotkeyString;
165  PRM_Template *myTemplates;
166  OP_Operator *myOp;
167  PI_ViewerType myViewerType;
168  unsigned myNetworkTypes;
169  int myOpIndependentFlag;
170  UT_Array<int> myVolatileKeys;
171  UT_Array<int> myVolatileKeysModifiers;
172  bool myHidden;
173 };
174 
175 //------------------------------------------------------------------------
176 
178 {
179 public:
180  PI_HandleTemplate(const char *name,
181  const char *english,
182  void *constructor,
183  PRM_Template *templates);
184  ~PI_HandleTemplate() override;
185 
186  virtual const PRM_Template *templates() const
187  {
188  return myTemplates;
189  }
191  {
192  return myTemplates;
193  }
194 
195 private:
196  PRM_Template *myTemplates;
197 };
198 
199 //------------------------------------------------------------------------
200 
202 
203 namespace PI_PythonHandle
204 {
205  class PITemplate;
206 };
207 
209 {
210 public:
211  PI_PITemplate(const char *name,
212  const char *english,
213  const char *types,
214  const char *icon_name,
215  const char *parms[],
216  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
217  unsigned viewmask = 0xFFFFFFFF,
218  bool display_always = false);
219  ~PI_PITemplate() override;
220 
222  { return myParmNameTable; }
224  { return myParmNameList; }
225  const char *iconName() const { return myIconName; }
226 
227  bool isDisplayAlways() const
228  { return myDisplayAlwaysFlag; }
229 
230  short isEthereal() const { return myEtherealFlag; }
231  bool supportsType(const char *type) const;
232  unsigned getViewerMask() const { return myViewerMask;}
233 
234  // Not const as we use a cache.
235  const char *getHelp();
236 
237 private:
238  friend class PI_PythonHandle::PITemplate;
239  void addParmName(char const* parm_name, int index);
240 
241  UT_String myTypes;
242  UT_String myIconName;
243  int myHelpCached;
244  UT_String myHelp;
245  PI_ParmNameIndexMap myParmNameTable;
246  UT_StringArray myParmNameList;
247  short myEtherealFlag;
248  unsigned myViewerMask;
249  bool myDisplayAlwaysFlag;
250 };
251 
252 //------------------------------------------------------------------------
253 
255 {
256 public:
257  PI_SelectorTemplate(const char *name,
258  const char *english,
259  const char *types,
260  bool ordered = false);
261  ~PI_SelectorTemplate() override;
262 
263  bool isGeneric() const { return (myData != 0); }
264  bool supportsType(const char *type) const;
265  void data(void *d) { myData = d; }
266  void *data() const { return myData; }
267  bool ordered() const { return myOrdered; }
268 
269 private:
270  UT_String myTypes;
271  void *myData;
272  bool myOrdered;
273 };
274 
275 #endif
const unsigned PI_NETMASK_DOP
const UT_String & name() const
GLuint const GLchar * name
Definition: glew.h:1814
virtual PRM_Template * templates()
GLuint index
Definition: glew.h:1814
virtual bool forceStateToEnter() const
PI_NetworkType
OP_Operator * getOperator() const
const unsigned PI_NETMASK_SOP
PI_ViewerType
int opIndependent() const
#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
const UT_Array< int > & volatileKeysModifiers()
GLsizei GLenum GLenum * types
Definition: glew.h:3954
const UT_StringArray & parmNameList() const
bool getHidden() const
const unsigned PI_NETMASK_COP2
const unsigned PI_NETMASK_CHOP
const char * iconName() const
const GLfloat * c
Definition: glew.h:16296
short isEthereal() const
const char * getHotkeyString() const
virtual PRM_Template * templates()
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:291
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
void * constructor() const
virtual const PRM_Template * templates() const
const unsigned PI_NETMASK_OBJ
const UT_Array< int > & volatileKeys()
void initialize(const char *name, const char *english, void *constructor)
bool isDisplayAlways() const
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)
virtual const PRM_Template * templates() const
void setHidden(bool hide)
const unsigned PI_NETMASK_LOP