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  int getCopFlag() const { return myCopFlag; }
101  const char *getInputName(int idx) const;
102  const char *getInputLabel(int idx) const;
103  bool getInputIsReference(int idx) const;
105  { return myAllowsInputNameEditing; }
106  const char *getOutputLabel(int idx) const;
107  fpreal getUnitLength() const { return myUnitLength; }
108  fpreal getUnitMass() const { return myUnitMass; }
109 
110  const OP_ScriptOperator *getOp() const { return myOp; }
111 
112  // Handle our warning string.
113  void clearWarning() { myWarning = ""; }
114  const UT_String &getWarning() const { return myWarning; }
115 
116  // Save a block of data into the stream in a format suitable for a
117  // dialog script file. This means that the string is written as a
118  // series of quoted strings which when concatenated together recreate
119  // the original string.
120  static void saveBlock(std::ostream &os, const char *block,
121  const char *indent = "\t");
122 
123 private:
124  int saveUnboundSelectors(std::ostream &os);
125  int saveReservedSelectors(std::ostream &os);
126  void saveHelp(std::ostream &os);
127 
128  OP_ScriptOperator *myOp;
129  PI_EditScriptedParms myParms;
131 
132  // These guys are copies of the Op's value. Note this is what
133  // is used for saving, NOT the op's value, so adjust them
134  // to save properly. (You may want to change the Op value too
135  // so everyone is synched nicely.)
136  UT_String myName;
137  UT_String myScript;
138  UT_String myLabel;
139  UT_String myHelp;
140  int myShopFlag;
141  int myVopFlag;
142  int myCopFlag;
143  int myObjFlag;
144  UT_String myWarning;
145  UT_StringArray myInputNames;
146  UT_StringArray myInputLabels;
147  UT_Array<bool> myInputReferences;
148  UT_StringArray myOutputLabels;
149  bool myAllowsInputNameEditing;
150  fpreal myUnitLength;
151  fpreal myUnitMass;
152 };
153 
154 #endif
155 
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
int getCopFlag() const
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
GLuint const GLchar * name
Definition: glcorearb.h:786
fpreal getUnitLength() const
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
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