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  PRM_Template *templates() { return myTemplates; }
124  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 protected:
149  void setVolatileKeys(const UT_Array<int> &keys,
150  const UT_Array<int> &modifiers)
151  {
152  myVolatileKeys = keys;
153  myVolatileKeysModifiers = modifiers;
154  }
155 
156 private:
157  UT_String myIconName;
158  UT_String myHotkeyString;
159  PRM_Template *myTemplates;
160  OP_Operator *myOp;
161  PI_ViewerType myViewerType;
162  unsigned myNetworkTypes;
163  int myOpIndependentFlag;
164  UT_Array<int> myVolatileKeys;
165  UT_Array<int> myVolatileKeysModifiers;
166  bool myHidden;
167 };
168 
169 //------------------------------------------------------------------------
170 
172 {
173 public:
174  PI_HandleTemplate(const char *name,
175  const char *english,
176  void *constructor,
177  PRM_Template *templates);
178  virtual ~PI_HandleTemplate();
179 
180  const PRM_Template *templates() const { return myTemplates; }
181  PRM_Template *templates() { return myTemplates; }
182 
183 private:
184  PRM_Template *myTemplates;
185 };
186 
187 //------------------------------------------------------------------------
188 
190 
192 {
193 public:
194  PI_PITemplate(const char *name,
195  const char *english,
196  const char *types,
197  const char *icon_name,
198  const char *parms[],
199  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
200  unsigned viewmask = 0xFFFFFFFF,
201  bool display_always = false);
202  virtual ~PI_PITemplate();
203 
205  { return myParmNameTable; }
207  { return myParmNameList; }
208  const char *iconName() const { return myIconName; }
209 
210  bool isDisplayAlways() const
211  { return myDisplayAlwaysFlag; }
212 
213  short isEthereal() const { return myEtherealFlag; }
214  bool supportsType(const char *type) const;
215  unsigned getViewerMask() const { return myViewerMask;}
216 
217  // Not const as we use a cache.
218  const char *getHelp();
219 
220 private:
221  UT_String myTypes;
222  UT_String myIconName;
223  int myHelpCached;
224  UT_String myHelp;
225  PI_ParmNameIndexMap myParmNameTable;
226  UT_StringArray myParmNameList;
227  short myEtherealFlag;
228  unsigned myViewerMask;
229  bool myDisplayAlwaysFlag;
230 };
231 
232 //------------------------------------------------------------------------
233 
235 {
236 public:
237  PI_SelectorTemplate(const char *name,
238  const char *english,
239  const char *types,
240  bool ordered = false);
241  virtual ~PI_SelectorTemplate();
242 
243  bool isGeneric() const { return (myData != 0); }
244  bool supportsType(const char *type) const;
245  void data(void *d) { myData = d; }
246  void *data() const { return myData; }
247  bool ordered() const { return myOrdered; }
248 
249 private:
250  UT_String myTypes;
251  void *myData;
252  bool myOrdered;
253 };
254 
255 #endif
const unsigned PI_NETMASK_DOP
const UT_String & name() const
const PRM_Template * templates() 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()
const UT_StringArray & parmNameList() const
bool getHidden() const
const unsigned PI_NETMASK_COP2
const unsigned PI_NETMASK_CHOP
const char * iconName() const
const PRM_Template * templates() const
short isEthereal() const
const char * getHotkeyString() const
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:318
GLuint const GLchar * name
Definition: glcorearb.h:785
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()
PRM_Template * templates()
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
unsigned getViewerMask() const
void setVolatileKeys(const UT_Array< int > &keys, const UT_Array< int > &modifiers)
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
void setHidden(bool hide)
const unsigned PI_NETMASK_LOP