HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_String.h>
17 #include <UT/UT_SymbolTable.h>
18 #include <UT/UT_StringArray.h>
19 
20 class PRM_Template;
21 
22 // Viewer types that can have associated state templates.
23 // NB: The order here must correspond to theViewerTypeTokens in
24 // PI_ResourceManager.C
26 {
29 
30  PI_NUM_VIEWER_TYPES // sentinal value (not a valid value)
31 };
32 
33 // Network types to further differentiate the states for a given viewer type.
35 {
41 
43 };
44 
45 const unsigned PI_NETMASK_OBJ = 1 << (unsigned)PI_NETWORK_OBJ;
46 const unsigned PI_NETMASK_SOP = 1 << (unsigned)PI_NETWORK_SOP;
47 const unsigned PI_NETMASK_DOP = 1 << (unsigned)PI_NETWORK_DOP;
48 const unsigned PI_NETMASK_COP2= 1 << (unsigned)PI_NETWORK_COP2;
49 const unsigned PI_NETMASK_CHOP= 1 << (unsigned)PI_NETWORK_CHOP;
50 
51 class OP_Operator;
52 class PI_StateTemplate;
53 class PI_PITemplate;
54 class PI_HandleTemplate;
56 
58 {
59 public:
60  PI_ResourceTemplate(const char *name, const char *english,
61  void *constructor);
62  virtual ~PI_ResourceTemplate();
63 
64  void initialize(const char *name, const char *english,
65  void *constructor);
66 
67  const UT_String &name() const { return myName; }
68  const UT_String &englishName() const { return myEnglishName; }
69  void *constructor() const { return myConstructor; }
70  void constructor(void *c){ myConstructor = c; }
71 
72 private:
73  UT_String myName;
74  UT_String myEnglishName;
75  void *myConstructor;
76 };
77 
78 //------------------------------------------------------------------------
79 
81 {
82 public:
83  PI_StateTemplate(const char *name,
84  const char *english,
85  const char *icon_name,
86  void *constructor,
87  PRM_Template *templates,
88  PI_ViewerType viewer_type,
89  unsigned network_types,
90  int op_independent = 1,
91  const char *volatile_hotkey = 0,
92  OP_Operator *op = 0);
93  virtual ~PI_StateTemplate();
94 
95  void initialize(const char *name,
96  const char *english,
97  const char *icon_name,
98  void *constructor,
99  PRM_Template *templates,
100  PI_ViewerType viewer_type,
101  unsigned network_types,
102  int op_independent = 1,
103  const char *volatile_hotkey = 0,
104  bool hidden = false);
105 
106  // Since myVolatileKeys and myVolatileKeysModifiers are
107  // build during object initialization, they may no longer
108  // match with the hotkeys if the user decides to change the settings,
109  // so we need to rebuild. In some occasions (such as the use of the
110  // alt key for volatile view), we may want to enable ("inject")
111  // volatile that are determined at runtime out of outside of
112  // hotkey settings.
113  void rebuildVolatileKeys(
114  std::vector<int>* injectionKeys = 0,
115  std::vector<int>* injectionKeysModifiers = 0);
116 
117  PRM_Template *templates() { return myTemplates; }
118  const PRM_Template *templates() const
119  { return myTemplates; }
121  { return myViewerType; }
122  unsigned networkTypes() const
123  { return myNetworkTypes; }
124  const char *getIconName() const
125  { return myIconName; }
126  int opIndependent() const
127  { return myOpIndependentFlag; }
128  const std::vector<int> &volatileKeys()
129  { return myVolatileKeys; }
130  const std::vector<int> &volatileKeysModifiers()
131  {return myVolatileKeysModifiers;}
132  const char *getHotkeyString() const
133  { return myHotkeyString; }
135  { return myOp; }
136 
137  void setHidden(bool hide)
138  { myHidden = hide; }
139  bool getHidden() const
140  { return myHidden; }
141 
142 protected:
143  void setVolatileKeys(std::vector<int> keys,
144  std::vector<int> modifiers)
145  {
146  myVolatileKeys = keys;
147  myVolatileKeysModifiers = modifiers;
148  }
149 
150 private:
151  UT_String myIconName;
152  UT_String myHotkeyString;
153  PRM_Template *myTemplates;
154  OP_Operator *myOp;
155  PI_ViewerType myViewerType;
156  unsigned myNetworkTypes;
157  int myOpIndependentFlag;
158  std::vector<int> myVolatileKeys;
159  std::vector<int> myVolatileKeysModifiers;
160  bool myHidden;
161 };
162 
163 //------------------------------------------------------------------------
164 
166 {
167 public:
168  PI_HandleTemplate(const char *name,
169  const char *english,
170  void *constructor,
171  PRM_Template *templates);
172  virtual ~PI_HandleTemplate();
173 
174  const PRM_Template *templates() const { return myTemplates; }
175  PRM_Template *templates() { return myTemplates; }
176 
177 private:
178  PRM_Template *myTemplates;
179 };
180 
181 //------------------------------------------------------------------------
182 
184 
186 {
187 public:
188  PI_PITemplate(const char *name,
189  const char *english,
190  const char *types,
191  const char *icon_name,
192  const char *parms[],
193  short ethereal = 0, // 0 = vis; 1 = int; 2 = float);
194  unsigned viewmask = 0xFFFFFFFF,
195  bool display_always = false);
196  virtual ~PI_PITemplate();
197 
199  { return myParmNameTable; }
201  { return myParmNameList; }
202  const char *iconName() const { return myIconName; }
203 
204  bool isDisplayAlways() const
205  { return myDisplayAlwaysFlag; }
206 
207  short isEthereal() const { return myEtherealFlag; }
208  bool supportsType(const char *type) const;
209  unsigned getViewerMask() const { return myViewerMask;}
210 
211  // Not const as we use a cache.
212  const char *getHelp();
213 
214 private:
215  UT_String myTypes;
216  UT_String myIconName;
217  int myHelpCached;
218  UT_String myHelp;
219  PI_ParmNameIndexMap myParmNameTable;
220  UT_StringArray myParmNameList;
221  short myEtherealFlag;
222  unsigned myViewerMask;
223  bool myDisplayAlwaysFlag;
224 };
225 
226 //------------------------------------------------------------------------
227 
229 {
230 public:
231  PI_SelectorTemplate(const char *name,
232  const char *english,
233  const char *types,
234  bool ordered = false);
235  virtual ~PI_SelectorTemplate();
236 
237  bool isGeneric() const { return (myData != 0); }
238  bool supportsType(const char *type) const;
239  void data(void *d) { myData = d; }
240  void *data() const { return myData; }
241  bool ordered() const { return myOrdered; }
242 
243 private:
244  UT_String myTypes;
245  void *myData;
246  bool myOrdered;
247 };
248 
249 #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
unsigned networkTypes() const
const char * getIconName() const
const std::vector< int > & volatileKeysModifiers()
void setVolatileKeys(std::vector< int > keys, std::vector< int > modifiers)
const std::vector< int > & volatileKeys()
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:316
GLuint const GLchar * name
Definition: glcorearb.h:785
void * constructor() const
const unsigned PI_NETMASK_OBJ
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
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
void setHidden(bool hide)