HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_Shared.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: OBJ_Shared.h ( Object Library, C++)
7  *
8  * COMMENTS:
9  * These are structures that are needed by the rest of the
10  * object library.
11  */
12 
13 #ifndef __OBJ_Shared__
14 #define __OBJ_Shared__
15 
16 #include "OBJ_API.h"
17 #include <UT/UT_Assert.h>
18 #include <PRM/PRM_Default.h>
19 
20 // These macros are used by all objects as a simple way of copying a
21 // PRM_Template from one of the arrays below into their own PRM_Template
22 // array. The second form exports the parm to the toolbox.
24 public:
25  obj_SwitcherBuilder(PRM_Default *switcher, int maxsize)
26  {
27  myPrev = 0;
28  mySwitcher = switcher;
29  myFolder = -1;
30  myMaxSize = maxsize;
31  myCount = 0;
32  }
34  {
35  UT_ASSERT(!myPrev && theCurrentSwitcher != this);
36  if (theCurrentSwitcher == this)
37  pop();
38  if (myFolder >= 0 && myFolder != myMaxSize)
39  {
40  UT_ASSERT(0 && "Forgot to call finish() didn't you?");
41  endFolder();
42  }
43  }
44  void push()
45  {
46  UT_ASSERT(myPrev == 0);
47  myPrev = theCurrentSwitcher;
48  theCurrentSwitcher = this;
49  }
50  static void pop()
51  {
52  UT_ASSERT(theCurrentSwitcher);
53  obj_SwitcherBuilder *prev;
54  prev = theCurrentSwitcher->myPrev;
55  theCurrentSwitcher->myPrev = 0;
56  theCurrentSwitcher = prev;
57  }
58  static void folder(const char *label)
59  {
60  UT_ASSERT(theCurrentSwitcher);
61  theCurrentSwitcher->startFolder(label);
62  }
63  static void finish()
64  {
65  UT_ASSERT(theCurrentSwitcher);
66  theCurrentSwitcher->endFolder();
67  pop();
68  }
69  static void add()
70  {
71  if (theCurrentSwitcher)
72  {
73  UT_ASSERT(theCurrentSwitcher->isValid());
74  theCurrentSwitcher->myCount++;
75  }
76  }
77 private:
78  bool isValid() const
79  {
80  return myFolder >= 0 && myFolder < myMaxSize;
81  }
82  void startFolder(const char *label)
83  {
84  if (myCount || myFolder >= 0)
85  {
86  UT_ASSERT(myCount && myFolder >= 0);
87  mySwitcher[myFolder].setOrdinal(myCount);
88  }
89  myFolder++;
90  UT_ASSERT(myFolder < myMaxSize);
91  mySwitcher[myFolder].setString(label);
92  myCount = 0;
93  }
94  void endFolder()
95  {
96  // This is only called on the last folder
97  UT_ASSERT(myCount > 0);
98  UT_ASSERT(myFolder == myMaxSize-1);
99  mySwitcher[myFolder].setOrdinal(myCount);
100  myFolder = myMaxSize;
101  }
102  static obj_SwitcherBuilder *theCurrentSwitcher;
103  obj_SwitcherBuilder *myPrev;
104  PRM_Default *mySwitcher;
105  int myFolder;
106  int myCount;
107  int myMaxSize;
108 };
109 
110 
111 #define SET_DECL_SWITCHER(builder, switcher) \
112  obj_SwitcherBuilder builder(switcher, sizeof(switcher)/sizeof(PRM_Default));
113 #define SET_PUSH_SWITCHER(builder) builder.push();
114 #define SET_FOLDER(label) obj_SwitcherBuilder::folder(label);
115 #define SET_POP_SWITCHER() obj_SwitcherBuilder::finish();
116 #define SET_TPLATE(src, idx) \
117  theTemplate[i] = src[idx]; i++; obj_SwitcherBuilder::add();
118 #define SET_TPLATE_NOINC(src, idx) \
119  theTemplate[i] = src[idx]; i++;
120 #define SET_ADDED_TPLATE() obj_SwitcherBuilder::add();
121 #define SET_TPLATE_EX(src, idx) \
122  theTemplate[i] = src[idx]; \
123  obj_SwitcherBuilder::add(); \
124  theTemplate[i].setExportLevel(PRM_Template::PRM_EXPORT_TBX); i++;
125 
126 // Hide the Lookat and Path related params by default
127 #define SET_TPLATE_LEGACY_LOOKAT_PATH() \
128  SET_TPLATE(OBJbaseTemplate, I_CONSTRAINTS_ON) \
129  SET_TPLATE(OBJbaseTemplate, I_CONSTRAINTS) \
130  SET_TPLATE(OBJbaseITemplate, I_LOOKAT) \
131  SET_TPLATE(OBJbaseITemplate, I_LOOKUPOBJ) \
132  SET_TPLATE(OBJbaseITemplate, I_LOOKUP) \
133  SET_TPLATE(OBJbaseITemplate, I_PATHOBJ) \
134  SET_TPLATE(OBJbaseITemplate, I_PATHROLL) \
135  SET_TPLATE(OBJbaseITemplate, I_PATHPOS) \
136  SET_TPLATE(OBJbaseITemplate, I_PATHUPARMTYPE) \
137  SET_TPLATE(OBJbaseITemplate, I_PATHORIENT) \
138  SET_TPLATE(OBJbaseITemplate, I_PATHUP) \
139  SET_TPLATE(OBJbaseITemplate, I_PATHBANK)
140 
141 // the 'I' version is called when old parms were already invisible
142 #define SET_TPLATEI_LEGACY_LOOKAT_PATH() \
143  SET_TPLATE(OBJbaseTemplate, I_CONSTRAINTS_ON) \
144  SET_TPLATE(OBJbaseTemplate, I_CONSTRAINTS) \
145  SET_TPLATE(OBJbaseITemplate, I_LOOKAT) \
146  SET_TPLATE(OBJbaseITemplate, I_LOOKUPOBJ) \
147  SET_TPLATE(OBJbaseITemplate, I_LOOKUP) \
148  SET_TPLATE(OBJbaseITemplate, I_PATHOBJ) \
149  SET_TPLATE(OBJbaseITemplate, I_PATHROLL) \
150  SET_TPLATE(OBJbaseITemplate, I_PATHPOS) \
151  SET_TPLATE(OBJbaseITemplate, I_PATHUPARMTYPE) \
152  SET_TPLATE(OBJbaseITemplate, I_PATHORIENT) \
153  SET_TPLATE(OBJbaseITemplate, I_PATHUP) \
154  SET_TPLATE(OBJbaseITemplate, I_PATHBANK)
155 
156 
157 class PRM_Template;
158 
172 
194 
215 
216 OBJ_API extern const char *displaySopToken;
217 OBJ_API extern const char *renderSopToken;
218 OBJ_API extern const char *boundingBoxToken;
219 OBJ_API extern const char *boundingSphereToken;
220 OBJ_API extern const char *input1ObjectToken;
221 OBJ_API extern const char *input2ObjectToken;
222 OBJ_API extern const char *input3ObjectToken;
223 OBJ_API extern const char *input4ObjectToken;
224 
225 #endif
OBJ_API PRM_Template OBJambientObsolete[]
OBJ_API PRM_Template OBJstickyITemplate[]
OBJ_API PRM_Template OBJstickySharedTemplate[]
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
OBJ_API PRM_Template OBJstickyTemplate[]
OBJ_API PRM_Template OBJgeoITemplate[]
OBJ_API PRM_Template OBJcamSwitchTemplate[]
OBJ_API const char * input1ObjectToken
OBJ_API PRM_Template OBJgeoObsolete[]
OBJ_API const char * renderSopToken
OBJ_API PRM_Template OBJcamObsolete[]
OBJ_API PRM_Template OBJhandleTemplate[]
OBJ_API PRM_Template OBJambientITemplate[]
OBJ_API PRM_Template OBJsubnetITemplate[]
OBJ_API PRM_Template OBJsubnetTemplate[]
OBJ_API PRM_Template OBJdopnetITemplate[]
OBJ_API PRM_Template OBJstickyBlendITemplate[]
OBJ_API PRM_Template OBJmicrophoneITemplate[]
OBJ_API const char * displaySopToken
OBJ_API PRM_Template OBJfogObsolete[]
OBJ_API PRM_Template OBJblendTemplate[]
OBJ_API PRM_Template OBJfetchObsolete[]
OBJ_API PRM_Template OBJhandleITemplate[]
OBJ_API PRM_Template OBJstickySharedITemplate[]
OBJ_API PRM_Template OBJmuscleITemplate[]
OBJ_API PRM_Template OBJboneTemplate[]
OBJ_API PRM_Template OBJfetchITemplate[]
OBJ_API PRM_Template OBJhandleObsolete[]
OBJ_API PRM_Template OBJfogITemplate[]
OBJ_API PRM_Template OBJfetchTemplate[]
OBJ_API const char * input3ObjectToken
OBJ_API PRM_Template OBJlightObsolete[]
OBJ_API PRM_Template OBJsoundTemplate[]
OBJ_API const char * boundingSphereToken
OBJ_API const char * boundingBoxToken
OBJ_API const char * input4ObjectToken
OBJ_API PRM_Template OBJbaseObsolete[]
OBJ_API PRM_Template OBJmuscleTemplate[]
OBJ_API PRM_Template OBJboneITemplate[]
OBJ_API PRM_Template OBJsoundObsolete[]
OBJ_API PRM_Template OBJrivetTemplate[]
OBJ_API PRM_Template OBJboneObsolete[]
OBJ_API PRM_Template OBJcamSwitchITemplate[]
static void pop()
Definition: OBJ_Shared.h:50
static void finish()
Definition: OBJ_Shared.h:63
OBJ_API PRM_Template OBJdopnetObsolete[]
OBJ_API PRM_Template OBJsoundITemplate[]
OBJ_API PRM_Template OBJbaseITemplate[]
OBJ_API PRM_Template OBJdopnetTemplate[]
static void folder(const char *label)
Definition: OBJ_Shared.h:58
OBJ_API PRM_Template OBJblendObsolete[]
OBJ_API PRM_Template OBJnullTemplate[]
OBJ_API PRM_Template OBJgeoTemplate[]
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
OBJ_API PRM_Template OBJrivetITemplate[]
OBJ_API const char * input2ObjectToken
OBJ_API PRM_Template OBJbaseTemplate[]
obj_SwitcherBuilder(PRM_Default *switcher, int maxsize)
Definition: OBJ_Shared.h:25
#define OBJ_API
Definition: OBJ_API.h:10
OBJ_API PRM_Template OBJnullITemplate[]
OBJ_API PRM_Template OBJextractgeoTemplate[]
static void add()
Definition: OBJ_Shared.h:69
OBJ_API PRM_Template OBJfogTemplate[]
OBJ_API PRM_Template OBJstereoCameraITemplate[]
OBJ_API PRM_Template OBJmicrophoneObsolete[]
OBJ_API PRM_Template OBJambientTemplate[]
OBJ_API PRM_Template OBJstereoCameraTemplate[]
OBJ_API PRM_Template OBJmicrophoneTemplate[]
OBJ_API PRM_Template OBJblendITemplate[]
OBJ_API PRM_Template OBJstickyBlendTemplate[]