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  virtual ~PI_StateTemplate();
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  virtual ~PI_HandleTemplate();
185 
186  const PRM_Template *templates() const { return myTemplates; }
187  PRM_Template *templates() { return myTemplates; }
188 
189 private:
190  PRM_Template *myTemplates;
191 };
192 
193 //------------------------------------------------------------------------
194 
196 
198 {
199 public:
200  PI_PITemplate(const char *name,
201  const char *english,
202  const char *types,
203  const char *icon_name,
204  const char *parms[],
205  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
206  unsigned viewmask = 0xFFFFFFFF,
207  bool display_always = false);
208  virtual ~PI_PITemplate();
209 
211  { return myParmNameTable; }
213  { return myParmNameList; }
214  const char *iconName() const { return myIconName; }
215 
216  bool isDisplayAlways() const
217  { return myDisplayAlwaysFlag; }
218 
219  short isEthereal() const { return myEtherealFlag; }
220  bool supportsType(const char *type) const;
221  unsigned getViewerMask() const { return myViewerMask;}
222 
223  // Not const as we use a cache.
224  const char *getHelp();
225 
226 private:
227  UT_String myTypes;
228  UT_String myIconName;
229  int myHelpCached;
230  UT_String myHelp;
231  PI_ParmNameIndexMap myParmNameTable;
232  UT_StringArray myParmNameList;
233  short myEtherealFlag;
234  unsigned myViewerMask;
235  bool myDisplayAlwaysFlag;
236 };
237 
238 //------------------------------------------------------------------------
239 
241 {
242 public:
243  PI_SelectorTemplate(const char *name,
244  const char *english,
245  const char *types,
246  bool ordered = false);
247  virtual ~PI_SelectorTemplate();
248 
249  bool isGeneric() const { return (myData != 0); }
250  bool supportsType(const char *type) const;
251  void data(void *d) { myData = d; }
252  void *data() const { return myData; }
253  bool ordered() const { return myOrdered; }
254 
255 private:
256  UT_String myTypes;
257  void *myData;
258  bool myOrdered;
259 };
260 
261 #endif
const unsigned PI_NETMASK_DOP
const UT_String & name() const
const PRM_Template * templates() const
GLuint const GLchar * name
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:318
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
void * constructor() 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
PRM_Template * templates()
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