HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PRM_ScriptParm.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: DS_Parm.h ( PRM Library, C++)
7  *
8  * COMMENTS: Scripted version of a parameter. This class is typically
9  * created by reading a script. It contains all the relevant
10  * information to create a PRM_Template.
11  */
12 
13 #ifndef __PRM_ScriptParm__
14 #define __PRM_ScriptParm__
15 
16 #include "PRM_API.h"
17 #include "PRM_Template.h"
18 #include "PRM_Default.h"
19 #include "PRM_Conditional.h"
20 #include <UT/UT_Array.h>
21 #include <UT/UT_StringArray.h>
22 
23 class DS_Stream;
24 class PRM_SpareData;
25 class PRM_ScriptPage;
26 class PRM_ScriptParm;
27 class PRM_Default;
28 class PRM_Range;
29 class PRM_ChoiceList;
30 class PRM_ScriptImports;
31 
33 public:
35  bool asmultiparm = false);
36  virtual ~PRM_ScriptGroup();
37 
38  void addPage(PRM_ScriptPage *page)
39  { myPages.append(page); }
40 
41  int getPageCount() const
42  { return myPages.entries(); }
44  { return myPages(idx); }
45 
47  {
48  if (!mySizes) buildSizes();
49  return mySizes;
50  }
51 
52  bool isMultiParm() const
53  { return myMultiParmFlag; }
54 
56  { return myMultiType; }
57  void setMultiType(PRM_MultiType multitype)
58  { myMultiType = multitype; }
59 
60  int computeTemplateSize();
61 
62  void fillTemplate(PRM_Template *array, int &idx,
63  PRM_ScriptImports *&imports,
64  int nest_level);
65 
67  {
68  if (!myGroupConditional)
69  buildConditionals();
70  return myGroupConditional;
71  }
72 
73 protected:
74  // This will build the defaults by counting the number of parameters in
75  // each page and allocating a correct default.
76  void buildSizes();
77  void buildConditionals();
78 
85 };
86 
88 public:
90  virtual ~PRM_ScriptParm();
91 
92  enum {
93  PRM_SPARM_REQUIRED = 0x001,// Parm is required (not an option)
94  PRM_SPARM_DIRECTION = 0x002,// Represents a direction jack
95  PRM_SPARM_COLOR = 0x004,// Represents a color
96  PRM_SPARM_OBJECT = 0x008,// Object parameter (needs menu)
97  PRM_SPARM_RENDERER = 0x010,// Renderer parameter (needs menu)
98  PRM_SPARM_ANIMSTRING = 0x020,// Int/Flt parm has a string default
99  PRM_SPARM_OBJECTLIST = 0x040,// Object list
100  PRM_SPARM_EMBED = 0x080,// Embedded parmlist
101  PRM_SPARM_LOGARITHMIC = 0x100,// Logarithmic slider
102  PRM_SPARM_OBSOLETE = 0x200,// Obsolete parameter
103  PRM_SPARM_ALLFLAGS = 0x3FF // All flags
104  };
105 
106  int parse(DS_Stream &is, bool inside_group = false);
107  int parseGroup(DS_Stream &is,
108  PRM_ScriptPage *page,
109  const char *grouptype);
110  bool parseMultiParm(DS_Stream &is,
111  PRM_MultiType multitype,
112  PRM_ScriptPage *page);
113  int parseGroupAttribute(DS_Stream &is);
114  int parseRange(DS_Stream &is);
115 
116  void appendScriptParms(
118 
119  void setFlag(unsigned flag) { myFlag |= flag; }
120  void clearFlag(unsigned flag) { myFlag &= ~flag; }
121  unsigned getFlag(unsigned bit) const { return myFlag & bit;}
122 
123  PRM_ScriptGroup *getGroup() const { return myGroup; }
124  PRM_Name &getName() { return myName; }
125  const PRM_Name &getName() const { return myName; }
126  const PRM_Type &getType() const { return myType; }
127  PRM_TypeExtended getTypeExtended() const{ return myTypeExtended; }
128  PRM_MultiType getMultiType() const { return myMultiType; }
129  const PRM_Default *getDefaults() const
130  { return myDefaults.entries() ? &myDefaults(0)
131  : (const PRM_Default*)NULL; }
133  { return myDefaults.entries() ? &myDefaults(0)
134  : (PRM_Default*)NULL; }
135  PRM_Range *getRange() const { return myRange; }
136  int getSize() const { return myVectorSize; }
137  PRM_ChoiceList *getMenu() const { return myMenu; }
138  const UT_String &getOption() const { return myOption; }
139  const UT_String &getHelpText() const { return myHelpText; }
140  PRM_ConditionalGroup&getConditionalGroup() { return myConditionalGroup; }
141  PRM_Template *getMultiTemplate();
142  bool getBaseParm() const { return myBaseParm; }
143 
144  PRM_SpareData *getSpareData(bool create=false);
145 
146  bool hasObsoleteGroup() const { return myObsoleteGroup!=0; }
147  PRM_ScriptParm *createObsoleteGroupParm();
148 
149  /// Clear any type or extended type settings related to joining. Returns
150  /// true if any settings were changed.
151  bool clearJoinNext();
152 
153  /// Some parameter dialogs require options for every parameter.
154  void enforceOptions();
155 
156  /// Inserts double backslashes to protect verbatim strings in script files.
157  static const char *protectString(const char *s, int handlenull = 0);
158  static void protectStrcat(UT_WorkBuffer &dest, const char *s,
159  int handlenull = 0);
160 
161  int computeTemplateSize();
162  void fillTemplate(PRM_Template *array, int &idx,
163  PRM_ScriptImports *&imports,
164  int nest_level);
165 
166  static bool parseConditional(DS_Stream &is,
167  PRM_Conditional &cond);
168 protected:
169  virtual PRM_ScriptGroup *newGroup(bool asmultiparm = false);
170  virtual PRM_ScriptPage *newPage();
171 
172  virtual int handleUnknown(DS_Stream &is, UT_String &token);
173  virtual PRM_Callback getScriptParmCallback() const;
174  virtual bool wantsParametersAnimatable() const;
175  int buildMultiParmTemplate(
176  PRM_ScriptImports *&imports,
177  int nest_level);
178 
179  int parseMenu(DS_Stream &is);
180  int parseAttribute(DS_Stream &is);
181  int parseDefaults(DS_Stream &is, int isstring);
182  void clearMenu();
183  void clearDefaults();
184 
185  static bool parseConditionalInfo(DS_Stream &is,
186  PRM_Conditional &cond);
187 
204  unsigned myFlag;
208 
209  // This option string is used for command building (DS_Command).
211 
212  static const char *theTokens[];
213  static int theNumParms[];
214 };
215 
216 #endif
217 
PRM_Range * myRange
const UT_String & getOption() const
unsigned getFlag(unsigned bit) const
PRM_ScriptPage * getPage(int idx)
int getSize() const
void clearFlag(unsigned flag)
PRM_Name & getName()
bool hasObsoleteGroup() const
PRM_Default * getDefaults()
PRM_ChoiceList * myMenu
const PRM_Default * getDefaults() const
PRM_Template * myMultiTemplate
UT_String myHelpText
PRM_MultiType getMultiType() const
UT_Array< PRM_Default > myDefaults
const PRM_Type & getType() const
PRM_TypeExtended myTypeExtended
PRM_Range * getRange() const
PRM_MultiType myMultiType
void setMultiType(PRM_MultiType multitype)
void setFlag(unsigned flag)
PRM_ConditionalGroup & getConditionalGroup()
UT_ValArray< PRM_ScriptPage * > myPages
PRM_TypeExtended getTypeExtended() const
const UT_String & getHelpText() const
bool isMultiParm() const
PRM_ConditionalSwitcher * getGroupConditional()
PRM_MultiType getMultiType() const
PRM_MultiType myMultiType
PRM_Default * getDefaults()
PRM_ConditionalGroup myConditionalGroup
bool getBaseParm() const
PRM_Name * myMenuNames
PRM_ConditionalSwitcher * myGroupConditional
PRM_ScriptParm * myOwner
UT_String myOption
PRM_TypeExtended
Definition: PRM_Type.h:508
This class allow setting multiple conditionals for a PRM_Template.
PRM_ScriptGroup * myGroup
PRM_ChoiceList * getMenu() const
UT_StringArray myDefaultStrings
const PRM_Name & getName() const
PRM_ScriptGroup * myObsoleteGroup
void addPage(PRM_ScriptPage *page)
png_infop png_uint_32 flag
Definition: png.h:2242
#define PRM_API
Definition: PRM_API.h:10
int getPageCount() const
PRM_SpareData * mySpareData
PRM_Default * mySizes
PRM_MultiType
This type enum defines the different types of multi (dynamic) parameters.
Definition: PRM_Type.h:417
PRM_ScriptGroup * getGroup() const