00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __PRM_Template__
00026 #define __PRM_Template__
00027
00028 #include "PRM_API.h"
00029 #include <UT/UT_IntArray.h>
00030 #include <UT/UT_PtrArray.h>
00031 #include <UT/UT_String.h>
00032 #include "PRM_DisableList.h"
00033 #include "PRM_Name.h"
00034 #include "PRM_Type.h"
00035
00036 #define PRM_TYPE_IS_SWITCHER(type) (type.isSwitcher())
00037
00038 #define PRM_IS_JOIN(parm) (parm.getTypeExtended() == PRM_TYPE_TOGGLE_JOIN || \
00039 parm.getTypeExtended() == PRM_TYPE_JOIN_PAIR)
00040
00041 class PRM_ChoiceList;
00042 class PRM_Range;
00043 class PRM_Default;
00044 class PRM_Template;
00045 class PRM_SpareData;
00046
00047 PRM_API extern PRM_ChoiceList PRMtoggleMenu;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 typedef int (*PRM_Callback)(void *data, int index, float time,
00060 const PRM_Template *tplate);
00061
00062 class PRM_API PRM_Template
00063 {
00064 public:
00065
00066
00067
00068
00069
00070 enum PRM_Export
00071 {
00072 PRM_EXPORT_MIN,
00073 PRM_EXPORT_MED,
00074 PRM_EXPORT_MAX,
00075 PRM_EXPORT_TBX
00076 };
00077
00078 enum
00079 {
00080
00081
00082
00083
00084 MAX_VECTOR_SIZE = 31
00085 };
00086
00087
00088 PRM_Template(PRM_Type thetype = PRM_LIST_TERMINATOR,
00089 int thevectorsize = 1,
00090 PRM_Name *thenameptr = 0,
00091 PRM_Default *thedefaults = 0,
00092 PRM_ChoiceList *thechoicelistptr = 0,
00093 PRM_Range *therangeptr = 0,
00094 PRM_Callback thecallbackfunc = 0,
00095 PRM_SpareData *thespareptr = 0,
00096 int theparmgroup = 1,
00097 const char *thehelptext = 0,
00098 PRM_DisableList *thedisableptr = 0);
00099
00100
00101 PRM_Template(PRM_Type thetype,
00102 PRM_Export theexportlevel,
00103 int thevectorsize = 1,
00104 PRM_Name *thenameptr = 0,
00105 PRM_Default *thedefaults = 0,
00106 PRM_ChoiceList *thechoicelistptr = 0,
00107 PRM_Range *therangeptr = 0,
00108 PRM_Callback thecallbackfunc = 0,
00109 PRM_SpareData *thespareptr = 0,
00110 int theparmgroup = 1,
00111 const char *thehelptext = 0,
00112 PRM_DisableList *thedisableptr = 0);
00113
00114
00115 PRM_Template(PRM_Type thetype,
00116 PRM_TypeExtended thetype_ext,
00117 int thevectorsize = 1,
00118 PRM_Name *thenameptr = 0,
00119 PRM_Default *thedefaults = 0,
00120 PRM_ChoiceList *thechoicelistptr = 0,
00121 PRM_Range *therangeptr = 0,
00122 PRM_Callback thecallbackfunc = 0,
00123 PRM_SpareData *thespareptr = 0,
00124 int theparmgroup = 1,
00125 const char *thehelptext = 0,
00126 PRM_DisableList *thedisableptr = 0);
00127
00128
00129 PRM_Template(PRM_Type thetype,
00130 PRM_TypeExtended thetype_ext,
00131 PRM_Export theexportlevel,
00132 int thevectorsize = 1,
00133 PRM_Name *thenameptr = 0,
00134 PRM_Default *thedefaults = 0,
00135 PRM_ChoiceList *thechoicelistptr = 0,
00136 PRM_Range *therangeptr = 0,
00137 PRM_Callback thecallbackfunc = 0,
00138 PRM_SpareData *thespareptr = 0,
00139 int theparmgroup = 1,
00140 const char *thehelptext = 0,
00141 PRM_DisableList *thedisableptr = 0);
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 PRM_Template(PRM_MultiType thetype,
00162 PRM_Template *thetemplates,
00163 PRM_Export theexportlevel,
00164 float multisize,
00165 PRM_Name *thenameptr,
00166 PRM_Default *thedefaultsize = 0,
00167 PRM_Range *thedefaultrange = 0,
00168 PRM_SpareData *thespareptr = 0,
00169 const char *thehelptext = 0,
00170 PRM_DisableList *thedisableptr = 0
00171 );
00172
00173 PRM_Template(PRM_MultiType thetype,
00174 PRM_Template *thetemplates,
00175 float multisize,
00176 PRM_Name *thenameptr,
00177 PRM_Default *thedefaultsize = 0,
00178 PRM_Range *thedefaultrange = 0,
00179 PRM_SpareData *thespareptr = 0,
00180 const char *thehelptext = 0,
00181 PRM_DisableList *thedisableptr = 0
00182 );
00183 PRM_Template(const PRM_Template &src);
00184 ~PRM_Template();
00185
00186 const PRM_Template &operator=(const PRM_Template &src);
00187
00188 void initialize(PRM_Type thetype,
00189 PRM_TypeExtended thetype_ext,
00190 PRM_Export theexportlevel,
00191 int thevectorsize,
00192 PRM_Name *thenameptr,
00193 PRM_Default *thedefaults,
00194 PRM_ChoiceList *thechoicelistptr,
00195 PRM_Range *therangeptr,
00196 PRM_Callback thecallbackfunc,
00197 PRM_SpareData *thespareptr,
00198 int theparmgroup,
00199 const char *thehelptext,
00200 PRM_DisableList *thedisableptr);
00201
00202 void initMulti(PRM_MultiType thetype,
00203 PRM_Template *thetemplates,
00204 PRM_Export theexportlevel,
00205 float multisize,
00206 PRM_Name *thenameptr,
00207 PRM_Default *thedefaultsize,
00208 PRM_Range *thedefaultrange,
00209 PRM_SpareData *thespareptr,
00210 const char *thehelptext,
00211 PRM_DisableList *thedisableptr
00212 );
00213
00214
00215
00216 void assign(const PRM_Template &src, int thevectorsize,
00217 PRM_Default *thedefaults);
00218
00219 const PRM_Type &getType() const { return myType; }
00220 PRM_MultiType getMultiType() const { return myMultiType; }
00221 bool isMultiType() const;
00222 bool isRampType() const;
00223 bool isRampTypeColor() const;
00224 PRM_TypeExtended getTypeExtended() const { return myTypeExtended; }
00225 int getVectorSize() const { return myVectorSize; }
00226 float getMultiSize() const { return myMultiSize; }
00227 void setNamePtr(PRM_Name *name) { myNamePtr = name; }
00228 PRM_Name *getNamePtr() { return myNamePtr; }
00229 const PRM_Name *getNamePtr() const { return myNamePtr; }
00230 PRM_SpareData *getSparePtr() { return mySparePtr; }
00231 const PRM_SpareData *getSparePtr() const { return mySparePtr; }
00232 PRM_SpareData *getOrCreateSparePtr();
00233 PRM_DisableList *getDisablePtr() { return myDisablePtr; }
00234 const PRM_DisableList*getDisablePtr() const { return myDisablePtr; }
00235 const PRM_ChoiceList *getChoiceListPtr() const
00236 {
00237 const PRM_ChoiceList *list;
00238 if (!myChoiceListPtr &&
00239 (myType & PRM_TYPE_ORDINAL) &&
00240 (myType & PRM_TYPE_TOGGLE))
00241 list = &PRMtoggleMenu;
00242 else
00243 list = myChoiceListPtr;
00244 return list;
00245 }
00246 PRM_ChoiceList *getChoiceListPtr()
00247 {
00248 PRM_ChoiceList *list;
00249 if (!myChoiceListPtr &&
00250 (myType & PRM_TYPE_ORDINAL) &&
00251 (myType & PRM_TYPE_TOGGLE))
00252 list = &PRMtoggleMenu;
00253 else
00254 list = myChoiceListPtr;
00255 return list;
00256 }
00257 void setChoiceListPtr(PRM_ChoiceList *list)
00258 {
00259 myChoiceListPtr = list;
00260 }
00261 const PRM_Range *getRangePtr() const { return myRangePtr; }
00262 PRM_Range *getRangePtr() { return myRangePtr; }
00263 PRM_Callback getCallback() { return myCallbackFunc; }
00264 const UT_String &getHelpText() const { return myHelpText; }
00265 unsigned int getAutoScopeField();
00266
00267 const PRM_Template *getMultiParmTemplate() const
00268 { return myMultiParmTemplate; }
00269 PRM_Template *getMultiParmTemplate()
00270 { return myMultiParmTemplate; }
00271 void setMultiParmTemplate(PRM_Template *tplate)
00272 { myMultiParmTemplate = tplate; }
00273 int getMultiStartOffset() const;
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 static bool matchMultiInstance(const char *name,
00285 const char *multi_name,
00286 int start_offset,
00287 int &index,
00288 const UT_IntArray *instance_index);
00289
00290 PRM_Default *getDefault(int index)
00291 {
00292 return (index >= 0 && index < myVectorSize)
00293 ? myDefaults(index) : 0;
00294 }
00295 const PRM_Default *getDefault(int index) const
00296 {
00297 return (index >= 0 && index < myVectorSize)
00298 ? myDefaults(index) : 0;
00299 }
00300 PRM_Default *getFactoryDefaults() const
00301 {
00302 return myFactoryDefaults;
00303 }
00304 void setFactoryDefaults(PRM_Default *defaults)
00305 {
00306 myFactoryDefaults = defaults;
00307 }
00308 void restoreFactoryDefaults();
00309 void setFloatDefault(int index, float v);
00310 void setOrdinalDefault(int index, int v);
00311 void setStringDefault(int index, const char *v);
00312 void setDefault(int index, const PRM_Default &d);
00313
00314
00315
00316
00317
00318
00319
00320 void setNoResim(bool noresim);
00321 void setNoCook(bool nocook);
00322 void setBaseParm(bool baseparm);
00323 void setInvisible(bool invisible);
00324 void setJoinNext(bool joinnext);
00325
00326 PRM_Export exportLevel() const
00327 { return (PRM_Export)myExportLevel; }
00328 void setExportLevel(PRM_Export level)
00329 { myExportLevel = (unsigned char)level; }
00330 int getParmGroup() const { return (int)myParmGroup; }
00331
00332
00333 int findParmIndex(const char *thechannelname);
00334
00335 void getChannelToken(UT_String &thestrref,
00336 int theindex) const;
00337 void getChannelLabel(UT_String &thestrref,
00338 int theindex) const;
00339 void getToken(UT_String &thestrref) const
00340 {
00341 thestrref = myNamePtr->getToken();
00342 }
00343 void getLabel(UT_String &thestrref) const
00344 {
00345 thestrref = myNamePtr->getLabel();
00346 }
00347
00348 int getExpressionFlag() const
00349 {
00350 return myNamePtr->getExpressionFlag();
00351 }
00352
00353
00354
00355 const char *getToken() const
00356 {
00357 return myNamePtr->getToken();
00358 }
00359 const char *getLabel() const
00360 {
00361 return myNamePtr->getLabel();
00362 }
00363 unsigned getTokenHash() const
00364 {
00365 return myNamePtr->getHash();
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375 static int countTemplates(
00376 const PRM_Template *templates,
00377 bool for_switcher = false,
00378 bool for_joins = false,
00379 bool for_rows = false);
00380
00381
00382 static int getTemplateIndexByToken(
00383 const PRM_Template *templates,
00384 const char * token);
00385
00386
00387
00388 static const PRM_Template *getEndOfSwitcher(
00389 const PRM_Template *templates);
00390
00391
00392 static void getSwitcherStats(
00393 const PRM_Template *templates,
00394 UT_IntArray &numswitchersonpages,
00395 UT_IntArray &numnonswitchersonpages);
00396
00397 static bool getEnclosingSwitcherFolder(
00398 const PRM_Template *tplates,
00399 const int index,
00400 int &switcher, int &folder);
00401
00402
00403
00404 bool isAutomaticallyGeneratedChoiceList() const;
00405
00406
00407
00408 int findSwitcherFolderWithLabel(
00409 const char *label) const;
00410
00411 private:
00412 void clearOurData();
00413 void buildChannelNames() const;
00414 void buildChannelName(UT_String &str, int index) const;
00415 void setAutoScopeField();
00416
00417 PRM_Type myType;
00418 PRM_MultiType myMultiType;
00419 PRM_TypeExtended myTypeExtended;
00420 int myVectorSize;
00421 PRM_Name *myNamePtr;
00422 UT_PtrArray<PRM_Default *> myDefaults;
00423 PRM_Default *myFactoryDefaults;
00424 PRM_ChoiceList *myChoiceListPtr;
00425 PRM_Range *myRangePtr;
00426 PRM_Callback myCallbackFunc;
00427 PRM_SpareData *mySparePtr;
00428 PRM_DisableList *myDisablePtr;
00429 unsigned char myExportLevel;
00430 unsigned char myParmGroup;
00431 unsigned int myAutoScopeField;
00432 PRM_Template *myMultiParmTemplate;
00433 float myMultiSize;
00434 UT_String myHelpText;
00435 mutable char **myChannelNames;
00436 };
00437
00438 #endif