HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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, int multiparm_depth);
107  int parseGroup(DS_Stream &is,
108  PRM_ScriptPage *page,
109  const char *grouptype,
110  int multiparm_depth);
111  bool parseMultiParm(DS_Stream &is,
112  PRM_MultiType multitype,
113  PRM_ScriptPage *page,
114  int multiparm_depth);
115  int parseGroupAttribute(DS_Stream &is);
116  int parseRange(DS_Stream &is);
117 
118  void appendScriptParms(
120 
121  void setFlag(unsigned flag) { myFlag |= flag; }
122  void clearFlag(unsigned flag) { myFlag &= ~flag; }
123  unsigned getFlag(unsigned bit) const { return myFlag & bit;}
124 
125  PRM_ScriptGroup *getGroup() const { return myGroup; }
126  PRM_Name &getName() { return myName; }
127  const PRM_Name &getName() const { return myName; }
128  const PRM_Type &getType() const { return myType; }
129  PRM_TypeExtended getTypeExtended() const{ return myTypeExtended; }
130  PRM_MultiType getMultiType() const { return myMultiType; }
131  const PRM_Default *getDefaults() const
132  { return myDefaults.entries() ? &myDefaults(0)
133  : (const PRM_Default*)NULL; }
135  { return myDefaults.entries() ? &myDefaults(0)
136  : (PRM_Default*)NULL; }
137  PRM_Range *getRange() const { return myRange; }
138  int getSize() const { return myVectorSize; }
139  PRM_ChoiceList *getMenu() const { return myMenu; }
140  const UT_String &getOption() const { return myOption; }
141  const UT_String &getHelpText() const { return myHelpText; }
142  PRM_ConditionalGroup&getConditionalGroup() { return myConditionalGroup; }
143  PRM_Template *getMultiTemplate();
144  bool getBaseParm() const { return myBaseParm; }
145 
146  PRM_SpareData *getSpareData(bool create=false);
147 
148  bool hasObsoleteGroup() const { return myObsoleteGroup!=0; }
149  PRM_ScriptParm *createObsoleteGroupParm();
150 
151  /// Clear any type or extended type settings related to joining. Returns
152  /// true if any settings were changed.
153  bool clearJoinNext();
154 
155  /// Some parameter dialogs require options for every parameter.
156  void enforceOptions();
157 
158  /// Inserts double backslashes to protect verbatim strings in script files.
159  static const char *protectString(const char *s, int handlenull = 0);
160  static void protectStrcat(UT_WorkBuffer &dest, const char *s,
161  int handlenull = 0);
162 
163  int computeTemplateSize();
164  void fillTemplate(PRM_Template *array, int &idx,
165  PRM_ScriptImports *&imports,
166  int nest_level);
167 
168  static bool parseConditional(DS_Stream &is,
169  PRM_Conditional &cond);
170 protected:
171  virtual PRM_ScriptGroup *newGroup(bool asmultiparm = false);
172  virtual PRM_ScriptPage *newPage();
173 
174  virtual int handleUnknown(DS_Stream &is, UT_String &token);
175  virtual PRM_Callback getScriptParmCallback() const;
176  virtual bool wantsParametersAnimatable() const;
177  int buildMultiParmTemplate(
178  PRM_ScriptImports *&imports,
179  int nest_level);
180 
181  int parseMenu(DS_Stream &is);
182  int parseAttribute(DS_Stream &is);
183  int parseDefaults(DS_Stream &is, int isstring);
184  void clearMenu();
185  void clearDefaults();
186 
187  static bool parseConditionalInfo(DS_Stream &is,
188  PRM_Conditional &cond);
189 
206  unsigned myFlag;
210 
211  // This option string is used for command building (DS_Command).
213 
214  static const char *theTokens[];
215  static int theNumParms[];
216 };
217 
218 #endif
219 
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:506
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