00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __OP_ScriptOperator__
00020 #define __OP_ScriptOperator__
00021
00022 #include "OP_API.h"
00023 #include <sys/types.h>
00024 #include <UT/UT_SymbolTable.h>
00025 #include "OP_Operator.h"
00026
00027 class UT_InfoTree;
00028 class PRM_ScriptParm;
00029 class PRM_ScriptPage;
00030 class PRM_ScriptImports;
00031 class PRM_Name;
00032 class DS_Stream;
00033 class OP_Node;
00034
00035
00036 typedef int (*OP_ScriptParmFunc)(OP_Node *node, PRM_Template *temp,
00037 int idx, float t, void *data);
00038
00039 class OP_API OP_ScriptOperator : public OP_Operator
00040 {
00041 public:
00042 virtual ~OP_ScriptOperator();
00043
00044 static OP_ScriptOperator *createMantraScriptOp(const char *name,
00045 const char *english);
00046
00047 virtual bool hasLoadedParmTemplates() const;
00048 virtual int updateParmTemplates();
00049 virtual PRM_Template *getParmTemplates();
00050 virtual PRM_ScriptImports *getParmTemplateImports();
00051
00052 void getScriptName(UT_String &name,
00053 bool forvex, bool for_python=false) const;
00054
00055 void resetTemplate(OP_TemplatePair *pair);
00056 void resetVariables(OP_VariablePair *vars);
00057
00058
00059
00060
00061
00062
00063 int buildVexCommand(UT_String &result, OP_Node *node, float now);
00064
00065
00066 void buildIndexEntry(UT_String &result, const UT_String &dsloc);
00067
00068
00069
00070
00071
00072 static int findScriptOperators(const char *path,
00073 const char *filename,
00074 OP_OTLDefinitionArray &defs);
00075
00076 static UT_SymbolTable &getAllIndexFiles();
00077
00078
00079
00080 int traverseCommand(OP_Node *node,
00081 OP_ScriptParmFunc traverseFunc, void *data,
00082 float now);
00083
00084
00085 enum {
00086 OP_SYNTAX_VEX,
00087 OP_SYNTAX_SHELL,
00088 OP_SYNTAX_RMAN
00089 };
00090
00091
00092
00093
00094 virtual int handleUnknownToken(DS_Stream &is, UT_String &token);
00095
00096 UT_String &getScriptHelp() { return myHelp; }
00097 virtual const char *getOperatorShortHelpString();
00098 virtual void getOperatorSpecificInfoText(int verbose,
00099 UT_WorkBuffer &text);
00100
00101
00102
00103 virtual void fillInfoTreeOperatorSpecific(UT_InfoTree &tree);
00104
00105
00106
00107
00108
00109
00110 void editScriptFile(const char *pathprefix,
00111 const char *context = "surface",
00112 const char *extension = ".vfl",
00113 const char *title = "VEX Function",
00114 const char **obj_extensions = 0,
00115 int localdir = 1);
00116
00117
00118
00119
00120
00121
00122 PY_CompiledCode *getCachedCompiledPythonCookCode();
00123
00124
00125
00126 virtual void forceUpdateParmTemplates();
00127
00128 virtual PRM_Template *getLayoutParmTemplates();
00129 virtual PRM_ScriptImports *getLayoutParmTemplateImports();
00130 virtual const PRM_Template *getBaseParmTemplates();
00131
00132 protected:
00133 OP_ScriptOperator( const char *name,
00134 const char *english,
00135 OP_Constructor construct,
00136 PRM_Template *templates,
00137 unsigned min_sources,
00138 unsigned max_sources = 9999,
00139 CH_LocalVariable *variables = 0,
00140 unsigned flags = 0);
00141
00142
00143 virtual void removeAllBindings()
00144 { }
00145 virtual void refreshAllBindings()
00146 { }
00147 virtual PRM_Template *loadParmTemplates(UT_IStream & ,
00148 const char * ,
00149 UT_String & ,
00150 PRM_ScriptImports *& )
00151 { return 0; }
00152
00153
00154 static void freeParmTemplates(PRM_Template *templates);
00155
00156
00157 static void freeSwitcherDefaults(PRM_Default *defs);
00158
00159 UT_String myScriptName;
00160 UT_String myHelp;
00161 PRM_Template *myBase;
00162 PRM_ScriptPage *myPage;
00163 PRM_ScriptImports *myImports;
00164 time_t myDialogTimeStamp;
00165 int myStartParm, myEndParm;
00166
00167 PRM_Template *myLayoutParmTemplates;
00168 PRM_ScriptImports *myLayoutParmImports;
00169
00170
00171
00172
00173 int myBaseControlsSwitcherIndex;
00174 int myBaseControlsSwitcherPageNum;
00175 int myBaseControlsInsertIndex;
00176 PRM_Default *myBaseSwitcherDefaults;
00177
00178
00179 unsigned mySyntax;
00180
00181
00182 UT_String myInfoText;
00183
00184
00185 static UT_SymbolTable theAllIndexFiles;
00186 };
00187
00188
00189
00190
00191 class OP_API OP_ScriptOpExtraInfo
00192 {
00193 public:
00194 OP_ScriptOpExtraInfo();
00195 OP_ScriptOpExtraInfo(const UT_String &extra_info);
00196 ~OP_ScriptOpExtraInfo();
00197
00198
00199
00200
00201 void parseExtraInfo(const UT_String &extra_info);
00202
00203
00204
00205 void getExtraInfoString(UT_String &extra_info);
00206
00207 bool getHideDefaultParms() const
00208 { return myHideDefaultParms; }
00209 void setHideDefaultParms(bool hide)
00210 { myHideDefaultParms = hide; }
00211
00212 const char *getRepresentativeNodePath() const
00213 { return (const char *)myRepresentativeNodePath; }
00214 void setRepresentativeNodePath(const char *path)
00215 { myRepresentativeNodePath.harden(path); }
00216
00217 const char *getGuideNodePath() const
00218 { return (const char *)myGuideNodePath; }
00219 void setGuideNodePath(const char *path)
00220 { myGuideNodePath.harden(path); }
00221
00222 const char *getOpSubType() const
00223 { return (const char *)myOpSubType; }
00224 void setOpSubType(const char *type)
00225 { myOpSubType.harden(type); }
00226
00227 static void createSubTypeString(UT_String &result, const char *subtype);
00228
00229 protected:
00230
00231 void resetSettings();
00232
00233 private:
00234 bool myHideDefaultParms;
00235 UT_String myRepresentativeNodePath;
00236 UT_String myGuideNodePath;
00237 UT_String myOpSubType;
00238 };
00239
00240 #endif