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  // Used by scripted states to indicate if the state is able to handle
144  // changes to the selection. Most node states cannot, but the Edit state or
145  // Layout state, for example, can transform any selected primitive.
146  void setSupportsSelectionChange(bool supports_change)
147  { mySupportsSelectionChange = supports_change; }
149  { return mySupportsSelectionChange; }
150  // Used by scripted states to indicate that they are able to provide a
151  // "move" tool, which means they should be allowed to handle t/r/e keys.
152  void setSupportsMoveTool(bool supports_movetool)
153  { mySupportsMoveTool = supports_movetool; }
154  bool getSupportsMoveTool() const
155  { return mySupportsMoveTool; }
156 
157  void setHidden(bool hide)
158  { myHidden = hide; }
159  bool getHidden() const
160  { return myHidden; }
161 
162  // Used in BM_OpStateControl::enterState to maintain old behavior
163  virtual bool forceStateToEnter() const
164  { return myOpIndependentFlag > 0; }
165 
166 protected:
167  void setVolatileKeys(const UT_Array<int> &keys,
168  const UT_Array<int> &modifiers)
169  {
170  myVolatileKeys = keys;
171  myVolatileKeysModifiers = modifiers;
172  }
173 
174 private:
175  UT_String myIconName;
176  UT_String myHotkeyString;
177  PRM_Template *myTemplates;
178  OP_Operator *myOp;
179  PI_ViewerType myViewerType;
180  unsigned myNetworkTypes;
181  int myOpIndependentFlag;
182  UT_Array<int> myVolatileKeys;
183  UT_Array<int> myVolatileKeysModifiers;
184  bool mySupportsSelectionChange;
185  bool mySupportsMoveTool;
186  bool myHidden;
187 };
188 
189 //------------------------------------------------------------------------
190 
192 {
193 public:
194  PI_HandleTemplate(const char *name,
195  const char *english,
196  void *constructor,
197  PRM_Template *templates);
198  ~PI_HandleTemplate() override;
199 
200  virtual const PRM_Template *templates() const
201  {
202  return myTemplates;
203  }
205  {
206  return myTemplates;
207  }
208 
209 private:
210  PRM_Template *myTemplates;
211 };
212 
213 //------------------------------------------------------------------------
214 
216 
217 namespace PI_PythonHandle
218 {
219  class PITemplate;
220 };
221 
223 {
224 public:
225  PI_PITemplate(const char *name,
226  const char *english,
227  const char *types,
228  const char *icon_name,
229  const char *parms[],
230  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
231  unsigned viewmask = 0xFFFFFFFF,
232  bool display_always = false);
233  ~PI_PITemplate() override;
234 
236  { return myParmNameTable; }
238  { return myParmNameList; }
239  const char *iconName() const { return myIconName; }
240 
241  bool isDisplayAlways() const
242  { return myDisplayAlwaysFlag; }
243 
244  short isEthereal() const { return myEtherealFlag; }
245  bool supportsType(const char *type) const;
246  unsigned getViewerMask() const { return myViewerMask;}
247 
248  // Not const as we use a cache.
249  const char *getHelp();
250 
251 private:
252  friend class PI_PythonHandle::PITemplate;
253  void addParmName(char const* parm_name, int index);
254 
255  UT_String myTypes;
256  UT_String myIconName;
257  int myHelpCached;
258  UT_String myHelp;
259  PI_ParmNameIndexMap myParmNameTable;
260  UT_StringArray myParmNameList;
261  short myEtherealFlag;
262  unsigned myViewerMask;
263  bool myDisplayAlwaysFlag;
264 };
265 
266 //------------------------------------------------------------------------
267 
269 {
270 public:
271  PI_SelectorTemplate(const char *name,
272  const char *english,
273  const char *types,
274  bool ordered = false);
275  ~PI_SelectorTemplate() override;
276 
277  bool isGeneric() const { return (myData != 0); }
278  bool supportsType(const char *type) const;
279  void data(void *d) { myData = d; }
280  void *data() const { return myData; }
281  bool ordered() const { return myOrdered; }
282 
283 private:
284  UT_String myTypes;
285  void *myData;
286  bool myOrdered;
287 };
288 
289 #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
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
void setSupportsSelectionChange(bool supports_change)
const UT_Array< int > & volatileKeysModifiers()
const UT_StringArray & parmNameList() const
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
void setSupportsMoveTool(bool supports_movetool)
const unsigned PI_NETMASK_OBJ
const UT_Array< int > & volatileKeys()
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
bool getSupportsMoveTool() const
type
Definition: core.h:1059
virtual const PRM_Template * templates() const
void setHidden(bool hide)
const unsigned PI_NETMASK_LOP