00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __SHOP_Node__
00021 #define __SHOP_Node__
00022
00023 #include "SHOP_API.h"
00024 #include <UT/UT_HashTable.h>
00025 #include <IMG/IMG_Raster.h>
00026 #include <OP/OP_Network.h>
00027 #include "SHOP_Error.h"
00028
00029 class UT_Options;
00030 class OP_OperatorTable;
00031 class OP_TemplatePair;
00032 class OP_OperatorTable;
00033 class SHOP_Data;
00034 class SHOP_ReData;
00035 class SHOP_Node;
00036 class SHOP_Clerk;
00037 class SHOP_ClerkCacheEntry;
00038 class SHOP_BundleRef;
00039
00040 extern "C" {
00041 DLLEXPORT extern void newShopClerk();
00042 }
00043
00044
00045 enum {
00046 SHOP_VAR_OBJ = 0,
00047 SHOP_VAR_SOP,
00048 SHOP_VAR_MAX_BASE
00049 };
00050
00051 #include "SHOP_NodeTypes.h"
00052
00053 #define SHOP_RENDERTYPE_OPTION "rendertype"
00054 #define SHOP_FPRECISION_OPTION "soho_precision"
00055
00056 class SHOP_API SHOP_Node : public OP_Network {
00057 public:
00058 SHOP_Node(OP_Network *dad, const char *name,
00059 OP_Operator *entry, SHOP_TYPE shader_type=SHOP_SURFACE);
00060 virtual ~SHOP_Node();
00061
00062 static OP_VariablePair myVariablePair;
00063 static CH_LocalVariable myVariableList[];
00064
00065 static PRM_Template *getObsolete(SHOP_TYPE type);
00066 static const char *getShaderType(SHOP_TYPE type);
00067 static const char *getShaderLabel(SHOP_TYPE type);
00068 static const char *getIconName(SHOP_TYPE type);
00069 static const char *getBundleFilter(SHOP_TYPE type);
00070 static const char *getShaderParmPath(SHOP_TYPE type);
00071 static const char *getShaderSpaceParm(SHOP_TYPE type);
00072 static SHOP_TYPE getShaderType(const char *name);
00073 static SHOP_TYPE getTypeFromParm(const char *parmname);
00074 static SHOP_TYPE getTypeFromSpaceParm(const char *parmname);
00075
00076
00077 static bool convertStringToOptions(UT_Options &options,
00078 const char *str);
00079
00080 static bool isParmDefaultValue(OP_Node *node,
00081 PRM_Parm *parm,
00082 fpreal now,
00083 const UT_Options *options);
00084 static bool isParmDefaultValue(OP_Node *node,
00085 const char *parmname,
00086 fpreal now,
00087 const UT_Options *options);
00088
00089 const UT_String &getRenderMask() const { return myRenderMask; }
00090
00091 virtual int getFirstParameter();
00092 virtual int getLastParameter();
00093
00094 virtual bool runCreateScript();
00095
00096
00097
00098 virtual SHOP_Node *findShader(SHOP_TYPE shop_type, fpreal now,
00099 const UT_Options *options);
00100
00101
00102
00103 virtual int collectShaders(UT_PtrArray<SHOP_Node *>&list,
00104 SHOP_TYPE shop_type, fpreal now,
00105 const UT_Options *options);
00106
00107 virtual int getInputTileLOD() const;
00108 virtual int getOutputTileLOD() const;
00109 virtual bool isInputVisible(int idx) const;
00110 virtual bool isOutputVisible(int idx) const;
00111
00112 virtual bool getBoundingBox(UT_BoundingBox &box, OP_Context &ctx,
00113 const char *rtype);
00114
00115 virtual SHOP_Node *getOutputNode() const;
00116 virtual void getInputName(UT_String &name, int idx) const;
00117 virtual SHOP_TYPE getInputType(int idx) const;
00118 virtual void getOutputName(UT_String &name, int idx) const;
00119 virtual SHOP_TYPE getOutputType(int idx) const;
00120
00121 virtual void saveDialogScriptExtraInfo(ostream &os);
00122 virtual void createGalleryEntry(OP_GalleryEntry &entry);
00123
00124
00125
00126 static UT_PtrArray<SHOP_Clerk *> &getClerkList(SHOP_TYPE type);
00127
00128
00129
00130
00131 virtual const char *getShaderName(bool forvex) const;
00132 virtual void getVariableString(int idx, UT_String &str, int thread);
00133
00134 virtual bool createSpareParametersFromChannels(
00135 UT_BitArray &selection,
00136 const CH_ChannelList &channels);
00137 virtual bool createSpareParametersForLoad(
00138 UT_StringArray &names,
00139 PRM_ParmNameMap &nmap,
00140 UT_String &errors);
00141
00142
00143
00144
00145 OP_Node *getCallingOBJ() { return myCallingOBJ; }
00146 void setCallingOBJ(OP_Node *o) { myCallingOBJ = o; }
00147 OP_Node *getCallingSOP() { return myCallingSOP; }
00148 void setCallingSOP(OP_Node *s) { myCallingSOP = s; }
00149
00150 SHOP_Clerk *getClerk(const char *rendertype);
00151 SHOP_Clerk *getAnyClerk(bool only_string_generators);
00152
00153 virtual bool buildShaderString(UT_String &result, fpreal now,
00154 const UT_Options *options,
00155 OP_Node *obj=0, OP_Node *sop=0);
00156 virtual bool buildShaderData(SHOP_ReData &data, fpreal now,
00157 const UT_Options *options,
00158 OP_Node *obj=0, OP_Node *sop=0);
00159 virtual bool buildShaderBounds(UT_BoundingBox &box, fpreal now,
00160 const UT_Options *options,
00161 OP_Node *obj=0, OP_Node *sop=0);
00162
00163 void destroyCache();
00164 SHOP_ClerkCacheEntry *getClerkData(const SHOP_Clerk *clerk);
00165 void destroyClerkData(const SHOP_Clerk *clerk);
00166 void addClerkData(const SHOP_Clerk *clerk,
00167 SHOP_ClerkCacheEntry *entry);
00168
00169 virtual SHOP_TYPE getShaderType() const;
00170
00171 static bool addShaderClerk(SHOP_TYPE type, SHOP_Clerk *shop);
00172 static void buildShaderTable(OP_OperatorTable &table);
00173 static OP_Operator *getManagementOperator();
00174
00175
00176
00177
00178 bool findPropertiesParameter(const char *parm, fpreal now,
00179 int &opid, int &pidx);
00180
00181
00182 void addError(UT_Error *error)
00183 { UTaddError(error);}
00184 void addError(int code, const char *msg = 0)
00185 { UTaddError("SHOP", code, msg);}
00186 void addMessage(SHOP_ErrorCode code, const char *msg = 0)
00187 { UTaddMessage("SHOP", code, msg);}
00188 void addWarning(SHOP_ErrorCode code, const char *msg = 0)
00189 { UTaddWarning("SHOP", code, msg);}
00190 void addFatal(SHOP_ErrorCode code, const char *msg = 0)
00191 { UTaddFatal("SHOP", code, msg);}
00192 void addSystemError(const char *msg = 0)
00193 { UTaddSystemError(msg);}
00194 void addCommonError(UT_CommonErrorCode what, const char *msg = 0)
00195 { UTaddCommonError(what, msg);}
00196
00197 int getOGLTextureCount() const { return myOGLTextureCount; }
00198 void bumpOGLTextureCount(int dir) { myOGLTextureCount += dir; }
00199
00200 bool containsShopType(SHOP_TYPE type) const;
00201 void bumpContainedType(SHOP_TYPE type, int dir);
00202
00203 int getOGLScriptCacheState() const { return myOGLScriptCache; }
00204 void setOGLScriptCache(int val,
00205 const char *vtxsrc, const char *fragsrc)
00206 { myOGLScriptCache = val;
00207 myOGLVtxSource.harden(vtxsrc);
00208 myOGLFragSource.harden(fragsrc);
00209 }
00210 const char *getOGLVtxSource() const
00211 { return (const char *) myOGLVtxSource; }
00212 const char *getOGLFragSource() const
00213 { return (const char *) myOGLFragSource; }
00214
00215
00216
00217
00218
00219
00220
00221
00222 void evalStringParm(UT_String &result,
00223 const char *parm_name,
00224 int vector_index, float now,
00225 PRM_Template *tplate, bool "ed,
00226 const char *rtype, int fprecision);
00227
00228
00229 virtual const char *getChildType() const;
00230 virtual const char *getOpType() const;
00231
00232 virtual OP_OpTypeId getChildTypeID() const;
00233 virtual OP_OpTypeId getOpTypeID() const;
00234
00235
00236 virtual fpreal getW() const;
00237
00238 virtual fpreal getH() const;
00239
00240 static void initializeExpressions();
00241
00242
00243 bool evalShopParameter(const char *name, int vec_idx,
00244 fpreal now, int &value,
00245 const UT_Options *options,
00246 bool add_cook_dependency=false);
00247 bool evalShopParameter(const char *name, int vec_idx,
00248 fpreal now, fpreal &value,
00249 const UT_Options *options,
00250 bool add_cook_dependency=false);
00251 bool evalShopParameter(const char *name, int vec_idx,
00252 fpreal now, UT_String &value,
00253 const UT_Options *options,
00254 bool add_cook_dependency=false);
00255
00256
00257 virtual UT_String *getMaterialIconFilename()
00258 { return &myMaterialIconFilename; }
00259 virtual void setMaterialIconFilename(char *matIconFilename)
00260 { myMaterialIconFilename.harden(matIconFilename); }
00261
00262 virtual IMG_Raster *getMaterialIconImage()
00263 { return &myMaterialIconImage; }
00264
00265 virtual bool getMaterialIconAllowRegenerateFlag()
00266 { return myAllowIconRegeneration; }
00267 virtual void setMaterialIconAllowRegenerateFlag(bool allow)
00268 { myAllowIconRegeneration = allow; }
00269
00270 protected:
00271 virtual void changeParmTemplate(PRM_Template *new_template);
00272
00273
00274 virtual int getDataClass() const;
00275 virtual OP_ERROR cookMe(OP_Context &);
00276 virtual OP_ERROR bypassMe(OP_Context &, int &);
00277 virtual const char *getFileExtension(int binary) const;
00278
00279 virtual OP_DATA_TYPE getCookedDataType() const;
00280 virtual void deleteCookedData();
00281 virtual int saveCookedData(const char *, OP_Context &);
00282 virtual int saveCookedData(ostream &, OP_Context &, int);
00283
00284 virtual bool cookedDataUsesAllParameters() const
00285 { return true; }
00286 virtual bool cookedDataNeedsErrors() const
00287 { return true; }
00288
00289
00290
00291 void resolveParmBundle(const char *parm_name,
00292 int vector_index,
00293 UT_String &pattern,
00294 OP_Network *creator,
00295 const char *filter,
00296 bool expand_fullpath = false);
00297
00298
00299
00300 SHOP_Node *getFullInput(int input_idx, int &output_idx) const;
00301
00302 void setShaderType(SHOP_TYPE t);
00303
00304 bool renderMatch(const char *rendertype) const;
00305 bool renderMatch(const SHOP_Clerk &clerk) const;
00306
00307 int myContainedShops[SHOP_MAX_TYPES];
00308 UT_String myRenderMask;
00309 UT_HashTable myClerkCache;
00310 OP_Node *myCallingOBJ, *myCallingSOP;
00311 int myOGLTextureCount;
00312 int myOGLScriptCache;
00313 UT_String myOGLVtxSource, myOGLFragSource;
00314
00315 UT_String myMaterialIconFilename;
00316 IMG_Raster myMaterialIconImage;
00317 bool myAllowIconRegeneration;
00318
00319 private:
00320 static void installClerks();
00321 static void installCommands();
00322
00323 SHOP_TYPE myShaderType;
00324 };
00325
00326
00327
00328 SHOP_API extern void
00329 SHOPgetVexReservedTemplateLists(UT_PtrArray<PRM_Template *> &tplatelists);
00330
00331 #endif