HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PI_EditScriptedOp.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: PI_EditScriptedOp.h ( OP Library, C++)
7  *
8  * COMMENTS: Provides a data structure for holding all the information
9  * required to edit the various facets of a PI_ScriptOperator.
10  * Also contains code to write a .ds file given just a pointer
11  * to a OP_ScriptOperator.
12  */
13 
14 #ifndef __PI_EditScriptedOp__
15 #define __PI_EditScriptedOp__
16 
17 #include "PI_API.h"
18 #include <UT/UT_String.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_SymbolTable.h>
22 #include <iosfwd>
23 #include "PI_EditScriptedParms.h"
24 
25 class OP_ScriptOperator;
26 class OP_SpecificData;
27 
29 {
30 public:
31  PI_EditScriptedOpHandle(const char *type);
34 
35  int save(std::ostream &os);
36  void addPIName(const char *name);
37  int bindChannel(const char *piname, const char *chname);
38  bool hasBinding() const;
39 
42 
43  // Only used by type handles...
45 
46  // Only used by persistant handles...
48 
49  // Our binding array...
52 
53  static UT_StringArray getValidTypes();
54 };
55 
57 {
58 public:
61  virtual ~PI_EditScriptedOp();
62 
63  // Save the entire operator definition to it's current OTL.
64  int save(OP_SpecificData *opspecific = 0);
65  // Save the dialog script to a stream.
66  int save(std::ostream &os,
67  OP_SpecificData *opspecific = 0);
68 
69  // Access our parm information.
70  PI_EditScriptedParms &getParms();
71  const PI_EditScriptedParms &getParms() const;
72 
73  // Get handle binding information.
74  int getNHandles() const;
75  PI_EditScriptedOpHandle *getHandle(int i);
76 
77  // Add, remove, and reorder handles.
78  void addHandle(PI_EditScriptedOpHandle *handle);
79  bool moveHandles(int first, int last, int offset);
80  bool removeHandles(int first, int last);
81 
82  // Set the basic information about the operator type.
83  void setLabel(const char *newlabel)
84  { myLabel.harden(newlabel); }
85  void setName(const char *newname)
86  { myName.harden(newname); }
87  void setScript(const char *newscript)
88  { myScript.harden(newscript); }
89  void setInputName(int idx, const char *name);
90  void setInputLabel(int idx, const char *label);
91  void setInputIsReference(int idx, bool isref);
92  void setOutputLabel(int idx, const char *label);
93  void setUnitLength(fpreal l) { myUnitLength = l; }
94  void setUnitMass(fpreal l) { myUnitMass = l; }
95 
96  // Get some basic information about the operator type.
97  int getShopFlag() const { return myShopFlag; }
98  int getVopFlag() const { return myVopFlag; }
99  int getObjFlag() const { return myObjFlag; }
100  const char *getInputName(int idx) const;
101  const char *getInputLabel(int idx) const;
102  bool getInputIsReference(int idx) const;
104  { return myAllowsInputNameEditing; }
105  const char *getOutputLabel(int idx) const;
106  fpreal getUnitLength() const { return myUnitLength; }
107  fpreal getUnitMass() const { return myUnitMass; }
108 
109  const OP_ScriptOperator *getOp() const { return myOp; }
110 
111  // Handle our warning string.
112  void clearWarning() { myWarning = ""; }
113  const UT_String &getWarning() const { return myWarning; }
114 
115  // Save a block of data into the stream in a format suitable for a
116  // dialog script file. This means that the string is written as a
117  // series of quoted strings which when concatenated together recreate
118  // the original string.
119  static void saveBlock(std::ostream &os, const char *block,
120  const char *indent = "\t");
121 
122 private:
123  int saveUnboundSelectors(std::ostream &os);
124  int saveReservedSelectors(std::ostream &os);
125  void saveHelp(std::ostream &os);
126 
127  OP_ScriptOperator *myOp;
128  PI_EditScriptedParms myParms;
130 
131  // These guys are copies of the Op's value. Note this is what
132  // is used for saving, NOT the op's value, so adjust them
133  // to save properly. (You may want to change the Op value too
134  // so everyone is synched nicely.)
135  UT_String myName;
136  UT_String myScript;
137  UT_String myLabel;
138  UT_String myHelp;
139  int myShopFlag;
140  int myVopFlag;
141  int myObjFlag;
142  UT_String myWarning;
143  UT_StringArray myInputNames;
144  UT_StringArray myInputLabels;
145  UT_Array<bool> myInputReferences;
146  UT_StringArray myOutputLabels;
147  bool myAllowsInputNameEditing;
148  fpreal myUnitLength;
149  fpreal myUnitMass;
150 };
151 
152 #endif
153 
GLint first
Definition: glcorearb.h:405
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
const OP_ScriptOperator * getOp() const
void setUnitLength(fpreal l)
#define PI_API
Definition: PI_API.h:10
int getObjFlag() const
UT_StringArray myChannelNames
void setScript(const char *newscript)
GLintptr offset
Definition: glcorearb.h:665
const UT_String & getWarning() const
int getShopFlag() const
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
GLuint const GLchar * name
Definition: glcorearb.h:786
fpreal getUnitLength() const
fpreal64 fpreal
Definition: SYS_Types.h:277
bool allowsInputNameEditing() const
fpreal getUnitMass() const
void setLabel(const char *newlabel)
void setName(const char *newname)
type
Definition: core.h:1059
void setUnitMass(fpreal l)
GLenum src
Definition: glcorearb.h:1793
int getVopFlag() const