1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: iparamb.h
|
---|
4 |
|
---|
5 | DESCRIPTION: Interface to Parameter blocks
|
---|
6 |
|
---|
7 | CREATED BY: Rolf Berteig
|
---|
8 |
|
---|
9 | HISTORY: created 1/25/95
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef __IPARAMB__
|
---|
15 | #define __IPARAMB__
|
---|
16 |
|
---|
17 | class UserType : public ReferenceTarget {
|
---|
18 | public:
|
---|
19 | virtual ~UserType() {};
|
---|
20 | virtual Control* CreateController()=0;
|
---|
21 | virtual BOOL operator==( const UserType &t )=0;
|
---|
22 | virtual UserType& operator=( const UserType &t )=0;
|
---|
23 | };
|
---|
24 |
|
---|
25 |
|
---|
26 | // Built in data types
|
---|
27 | enum ParamType {
|
---|
28 | TYPE_FLOAT,
|
---|
29 | TYPE_INT,
|
---|
30 | TYPE_RGBA,
|
---|
31 | TYPE_POINT3,
|
---|
32 | TYPE_BOOL,
|
---|
33 |
|
---|
34 | // We can add types up to 32 total.
|
---|
35 | TYPE_USER,
|
---|
36 | };
|
---|
37 |
|
---|
38 |
|
---|
39 | // Chunk IDs for loading/saving
|
---|
40 | #define PB_COUNT_CHUNK 0x0001
|
---|
41 | #define PB_PARAM_CHUNK 0x0002
|
---|
42 | #define PB_INDEX_CHUNK 0x0003
|
---|
43 | #define PB_ANIMATABLE_CHUNK 0x0004
|
---|
44 | #define PB_VERSION_CHUNK 0x0005
|
---|
45 | #define PB_FLOAT_CHUNK (TYPE_FLOAT + 0x100)
|
---|
46 | #define PB_INT_CHUNK (TYPE_INT + 0x100)
|
---|
47 | #define PB_RGBA_CHUNK (TYPE_RGBA + 0x100)
|
---|
48 | #define PB_POINT3_CHUNK (TYPE_POINT3 + 0x100)
|
---|
49 | #define PB_BOOL_CHUNK (TYPE_BOOL + 0x100)
|
---|
50 |
|
---|
51 | #define PB_TYPE_CHUNK 0x0200
|
---|
52 | #define PB_TYPE_FLOAT_CHUNK (PB_TYPE_CHUNK + TYPE_FLOAT)
|
---|
53 | #define PB_TYPE_INT_CHUNK (PB_TYPE_CHUNK + TYPE_INT)
|
---|
54 | #define PB_TYPE_RGBA_CHUNK (PB_TYPE_CHUNK + TYPE_RGBA)
|
---|
55 | #define PB_TYPE_POINT3_CHUNK (PB_TYPE_CHUNK + TYPE_POINT3)
|
---|
56 | #define PB_TYPE_BOOL_CHUNK (PB_TYPE_CHUNK + TYPE_BOOL)
|
---|
57 | #define PB_TYPE_USER_CHUNK (PB_TYPE_CHUNK + TYPE_USER)
|
---|
58 |
|
---|
59 |
|
---|
60 | // When a client of a param block receives the REFMSG_GET_PARAM_NAME
|
---|
61 | // message, the partID field is set to point at one of these structures.
|
---|
62 | // The client should fill in the parameter name.
|
---|
63 | class GetParamName {
|
---|
64 | public:
|
---|
65 | TSTR name;
|
---|
66 | int index;
|
---|
67 | GetParamName(TSTR n,int i) { name=n;index=i; }
|
---|
68 | };
|
---|
69 |
|
---|
70 | // When a client of a param block receives the REFMSG_GET_PARAM_DIM
|
---|
71 | // message, the partID field is set to point at one of these structs.
|
---|
72 | // The client should set dim to point at it's dim descriptor.
|
---|
73 | class GetParamDim {
|
---|
74 | public:
|
---|
75 | ParamDimension *dim;
|
---|
76 | int index;
|
---|
77 | GetParamDim(int i) {index=i;dim=NULL;}
|
---|
78 | };
|
---|
79 |
|
---|
80 |
|
---|
81 | // To create a parameter block, pass an array of these descriptors
|
---|
82 | // into the Create function.
|
---|
83 | // Items in the parameter block can be refered to by index. The
|
---|
84 | // index is derived from the order in which the descriptors appear
|
---|
85 | // in the array. If a parameter is a UserType, then a pointer to a
|
---|
86 | // new UserType must be passed in. The parameter block will be responsible
|
---|
87 | // for deleting it when it is done with it.
|
---|
88 |
|
---|
89 | class ParamBlockDesc {
|
---|
90 | public:
|
---|
91 | ParamType type;
|
---|
92 | UserType *user;
|
---|
93 | BOOL animatable;
|
---|
94 | };
|
---|
95 |
|
---|
96 | // This version of the descriptor has an ID for each parameter.
|
---|
97 | class ParamBlockDescID {
|
---|
98 | public:
|
---|
99 | ParamType type;
|
---|
100 | UserType *user;
|
---|
101 | BOOL animatable;
|
---|
102 | DWORD id;
|
---|
103 | };
|
---|
104 |
|
---|
105 | class IParamBlock;
|
---|
106 |
|
---|
107 | // This class represents a virtual array of parameters.
|
---|
108 | // Parameter blocks are one such implementation of this class, but
|
---|
109 | // it can also be useful to implement a class that abstracts non-
|
---|
110 | // parameter block variables.
|
---|
111 | //
|
---|
112 | // The ParamMap class (see IParamM.h) uses this base class so that
|
---|
113 | // a ParamMap can be used to control UI for not only parameter blocks
|
---|
114 | // but variables stored outside of parameter blocks.
|
---|
115 | class IParamArray {
|
---|
116 | public:
|
---|
117 | virtual BOOL SetValue( int i, TimeValue t, float v ) {return FALSE;}
|
---|
118 | virtual BOOL SetValue( int i, TimeValue t, int v ) {return FALSE;}
|
---|
119 | virtual BOOL SetValue( int i, TimeValue t, Point3& v ) {return FALSE;}
|
---|
120 |
|
---|
121 | virtual BOOL GetValue( int i, TimeValue t, float &v, Interval &ivalid ) {return FALSE;}
|
---|
122 | virtual BOOL GetValue( int i, TimeValue t, int &v, Interval &ivalid ) {return FALSE;}
|
---|
123 | virtual BOOL GetValue( int i, TimeValue t, Point3 &v, Interval &ivalid ) {return FALSE;}
|
---|
124 |
|
---|
125 | // If it is a param block, this will get a pointer to it, otherwise it will return NULL.
|
---|
126 | // Note that casting won't work because of multiple iheritance.
|
---|
127 | virtual IParamBlock *GetParamBlock() {return NULL;}
|
---|
128 | };
|
---|
129 |
|
---|
130 | class IParamBlock :
|
---|
131 | public ReferenceTarget,
|
---|
132 | public IParamArray {
|
---|
133 | public:
|
---|
134 | // Get's the super class of a parameters controller
|
---|
135 | virtual SClass_ID GetAnimParamControlType(int anim)=0;
|
---|
136 |
|
---|
137 | // one for each known type
|
---|
138 | virtual BOOL SetValue( int i, TimeValue t, float v )=0;
|
---|
139 | virtual BOOL SetValue( int i, TimeValue t, int v )=0;
|
---|
140 | virtual BOOL SetValue( int i, TimeValue t, Point3& v )=0;
|
---|
141 | virtual BOOL SetValue( int i, TimeValue t, Color& v )=0; // uses Point3 controller
|
---|
142 |
|
---|
143 | // one for each known type
|
---|
144 | virtual BOOL GetValue( int i, TimeValue t, float &v, Interval &ivalid )=0;
|
---|
145 | virtual BOOL GetValue( int i, TimeValue t, int &v, Interval &ivalid )=0;
|
---|
146 | virtual BOOL GetValue( int i, TimeValue t, Point3 &v, Interval &ivalid )=0;
|
---|
147 | virtual BOOL GetValue( int i, TimeValue t, Color &v, Interval &ivalid )=0; // uses Point3 Controller
|
---|
148 |
|
---|
149 | virtual Color GetColor(int i, TimeValue t=0)=0;
|
---|
150 | virtual Point3 GetPoint3(int i, TimeValue t=0)=0;
|
---|
151 | virtual int GetInt(int i, TimeValue t=0)=0;
|
---|
152 | virtual float GetFloat(int i, TimeValue t=0)=0;
|
---|
153 |
|
---|
154 | virtual DWORD GetVersion()=0;
|
---|
155 | virtual int NumParams()=0;
|
---|
156 |
|
---|
157 | virtual void RemoveController(int i)=0;
|
---|
158 | virtual Control* GetController(int i)=0;
|
---|
159 | virtual void SetController(int i, Control *c, BOOL preserveFrame0Value=TRUE)=0;
|
---|
160 | virtual void SwapControllers(int j, int k )=0;
|
---|
161 |
|
---|
162 | // Given the parameter index, what is the refNum?
|
---|
163 | virtual int GetRefNum(int paramNum)=0;
|
---|
164 |
|
---|
165 | // Given the parameter index what is the animNum?
|
---|
166 | virtual int GetAnimNum(int paramNum)=0;
|
---|
167 |
|
---|
168 | // Given the animNum what is the parameter index?
|
---|
169 | virtual int AnimNumToParamNum(int animNum)=0;
|
---|
170 |
|
---|
171 | // Inherited from IParamArray
|
---|
172 | IParamBlock *GetParamBlock() {return this;}
|
---|
173 |
|
---|
174 | };
|
---|
175 |
|
---|
176 | CoreExport IParamBlock *CreateParameterBlock(ParamBlockDesc *pdesc, int count);
|
---|
177 | CoreExport IParamBlock *CreateParameterBlock(ParamBlockDescID *pdesc, int count,DWORD version);
|
---|
178 |
|
---|
179 | // This creates a new parameter block, based on an existing parameter block of
|
---|
180 | // a later version. The new parameter block inherits any parameters from
|
---|
181 | // the old parameter block whose parameter IDs match.
|
---|
182 | CoreExport IParamBlock *UpdateParameterBlock(
|
---|
183 | ParamBlockDescID *pdescOld, int oldCount, IParamBlock *oldPB,
|
---|
184 | ParamBlockDescID *pdescNew, int newCount, DWORD newVersion);
|
---|
185 |
|
---|
186 |
|
---|
187 | // ----------------------------------------------------------
|
---|
188 | // A handy post load call back for fixing up parameter blocks.
|
---|
189 |
|
---|
190 | // This structure describes a version of the parameter block.
|
---|
191 | class ParamVersionDesc {
|
---|
192 | public:
|
---|
193 | ParamBlockDescID *desc;
|
---|
194 | int count;
|
---|
195 | DWORD version;
|
---|
196 | ParamVersionDesc(ParamBlockDescID *d,int c,int v) {desc=d;count=c;version=v;}
|
---|
197 | };
|
---|
198 |
|
---|
199 | // This will look up the version of the loaded callback and
|
---|
200 | // fix it up so it matches the current version.
|
---|
201 | // NOTE: this thing deletes itself when it's done.
|
---|
202 | class ParamBlockPLCB : public PostLoadCallback {
|
---|
203 | public:
|
---|
204 | ParamVersionDesc *versions;
|
---|
205 | int count;
|
---|
206 | ParamVersionDesc *cur;
|
---|
207 | ReferenceTarget *targ;
|
---|
208 | int pbRefNum;
|
---|
209 |
|
---|
210 | ParamBlockPLCB(
|
---|
211 | ParamVersionDesc *v,int cnt,ParamVersionDesc *c,
|
---|
212 | ReferenceTarget *t,int refNum)
|
---|
213 | {versions=v;count=cnt;cur=c;targ=t;pbRefNum=refNum;}
|
---|
214 | CoreExport void proc(ILoad *iload);
|
---|
215 | };
|
---|
216 |
|
---|
217 |
|
---|
218 | #endif
|
---|
219 |
|
---|
220 |
|
---|