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 {
46 
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_CHOP= 1 << (unsigned)PI_NETWORK_CHOP;
56 const unsigned PI_NETMASK_LOP = 1 << (unsigned)PI_NETWORK_LOP;
57 const unsigned PI_NETMASK_TOP = 1 << (unsigned)PI_NETWORK_TOP;
58 
59 class OP_Operator;
60 class PI_StateTemplate;
61 class PI_PITemplate;
62 class PI_HandleTemplate;
64 
66 {
67 public:
68  PI_ResourceTemplate(const char *name, const char *english,
69  void *constructor);
70  virtual ~PI_ResourceTemplate();
71 
72  void initialize(const char *name, const char *english,
73  void *constructor);
74 
75  const UT_String &name() const { return myName; }
76  const UT_String &englishName() const { return myEnglishName; }
77  void *constructor() const { return myConstructor; }
78  void constructor(void *c){ myConstructor = c; }
79 
80 private:
81  UT_String myName;
82  UT_String myEnglishName;
83  void *myConstructor;
84 };
85 
86 //------------------------------------------------------------------------
87 
89 {
90 public:
91  PI_StateTemplate(const char *name,
92  const char *english,
93  const char *icon_name,
94  void *constructor,
95  PRM_Template *templates,
96  PI_ViewerType viewer_type,
97  unsigned network_types,
98  int op_independent = 1,
99  const char *volatile_hotkey = 0,
100  OP_Operator *op = 0);
101  ~PI_StateTemplate() override;
102 
103  void initialize(const char *name,
104  const char *english,
105  const char *icon_name,
106  void *constructor,
107  PRM_Template *templates,
108  PI_ViewerType viewer_type,
109  unsigned network_types,
110  int op_independent = 1,
111  const char *volatile_hotkey = 0,
112  bool hidden = false);
113 
114  // Since myVolatileKeys and myVolatileKeysModifiers are
115  // build during object initialization, they may no longer
116  // match with the hotkeys if the user decides to change the settings,
117  // so we need to rebuild. In some occasions (such as the use of the
118  // alt key for volatile view), we may want to enable ("inject")
119  // volatile that are determined at runtime out of outside of
120  // hotkey settings.
121  void rebuildVolatileKeys(
122  UT_Array<int>* injectionKeys = 0,
123  UT_Array<int>* injectionKeysModifiers = 0);
124 
125  virtual PRM_Template *templates() { return myTemplates; }
126  virtual const PRM_Template *templates() const
127  { return myTemplates; }
129  { return myViewerType; }
130  unsigned networkTypes() const
131  { return myNetworkTypes; }
132  const char *getIconName() const
133  { return myIconName; }
134  int opIndependent() const
135  { return myOpIndependentFlag; }
137  { return myVolatileKeys; }
139  {return myVolatileKeysModifiers;}
140  const char *getHotkeyString() const
141  { return myHotkeyString; }
143  { return myOp; }
144 
145  // Used by scripted states to indicate if the state is able to handle
146  // changes to the selection. Most node states cannot, but the Edit state or
147  // Layout state, for example, can transform any selected primitive.
148  void setSupportsSelectionChange(bool supports_change)
149  { mySupportsSelectionChange = supports_change; }
151  { return mySupportsSelectionChange; }
152  // Used by scripted states to indicate that they are able to provide a
153  // "move" tool, which means they should be allowed to handle t/r/e keys.
154  void setSupportsMoveTool(bool supports_movetool)
155  { mySupportsMoveTool = supports_movetool; }
156  bool getSupportsMoveTool() const
157  { return mySupportsMoveTool; }
158 
159  void setHidden(bool hide)
160  { myHidden = hide; }
161  bool getHidden() const
162  { return myHidden; }
163 
164  // Used in BM_OpStateControl::enterState to maintain old behavior
165  virtual bool forceStateToEnter() const
166  { return myOpIndependentFlag > 0; }
167 
168 protected:
169  void setVolatileKeys(const UT_Array<int> &keys,
170  const UT_Array<int> &modifiers)
171  {
172  myVolatileKeys = keys;
173  myVolatileKeysModifiers = modifiers;
174  }
175 
176 private:
177  UT_String myIconName;
178  UT_String myHotkeyString;
179  PRM_Template *myTemplates;
180  OP_Operator *myOp;
181  PI_ViewerType myViewerType;
182  unsigned myNetworkTypes;
183  int myOpIndependentFlag;
184  UT_Array<int> myVolatileKeys;
185  UT_Array<int> myVolatileKeysModifiers;
186  bool mySupportsSelectionChange;
187  bool mySupportsMoveTool;
188  bool myHidden;
189 };
190 
191 //------------------------------------------------------------------------
192 
194 {
195 public:
196  PI_HandleTemplate(const char *name,
197  const char *english,
198  void *constructor,
199  PRM_Template *templates);
200  ~PI_HandleTemplate() override;
201 
202  virtual const PRM_Template *templates() const
203  {
204  return myTemplates;
205  }
207  {
208  return myTemplates;
209  }
210 
211 private:
212  PRM_Template *myTemplates;
213 };
214 
215 //------------------------------------------------------------------------
216 
218 
219 namespace PI_PythonHandle
220 {
221  class PITemplate;
222 };
223 
225 {
226 public:
227  PI_PITemplate(const char *name,
228  const char *english,
229  const char *types,
230  const char *icon_name,
231  const char *parms[],
232  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
233  unsigned viewmask = 0xFFFFFFFF,
234  bool display_always = false);
235  ~PI_PITemplate() override;
236 
238  { return myParmNameTable; }
240  { return myParmNameList; }
241  const char *iconName() const { return myIconName; }
242 
243  bool isDisplayAlways() const
244  { return myDisplayAlwaysFlag; }
245 
246  short isEthereal() const { return myEtherealFlag; }
247  bool supportsType(const char *type) const;
248  unsigned getViewerMask() const { return myViewerMask;}
249 
250  // Not const as we use a cache.
251  const char *getHelp();
252 
253 private:
254  friend class PI_PythonHandle::PITemplate;
255  void addParmName(char const* parm_name, int index);
256 
257  UT_String myTypes;
258  UT_String myIconName;
259  int myHelpCached;
260  UT_String myHelp;
261  PI_ParmNameIndexMap myParmNameTable;
262  UT_StringArray myParmNameList;
263  short myEtherealFlag;
264  unsigned myViewerMask;
265  bool myDisplayAlwaysFlag;
266 };
267 
268 //------------------------------------------------------------------------
269 
271 {
272 public:
273  PI_SelectorTemplate(const char *name,
274  const char *english,
275  const char *types,
276  bool ordered = false);
277  ~PI_SelectorTemplate() override;
278 
279  bool isGeneric() const { return (myData != 0); }
280  bool supportsType(const char *type) const;
281  void data(void *d) { myData = d; }
282  void *data() const { return myData; }
283  bool ordered() const { return myOrdered; }
284 
285 private:
286  UT_String myTypes;
287  void *myData;
288  bool myOrdered;
289 };
290 
291 #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
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
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