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 SYS_VISIBILITY_EXPORT 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 fpreal64 now,
00083 const UT_Options *options);
00084 static bool isParmDefaultValue(OP_Node *node,
00085 const char *parmname,
00086 fpreal64 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, fpreal64 now,
00099 const UT_Options *options);
00100
00101
00102 virtual bool matchesShaderType(SHOP_TYPE shop_type);
00103
00104
00105
00106 virtual int collectShaders(UT_PtrArray<SHOP_Node *>&list,
00107 SHOP_TYPE shop_type, fpreal64 now,
00108 const UT_Options *options);
00109
00110 virtual int getInputTileLOD() const;
00111 virtual int getOutputTileLOD() const;
00112 virtual bool isInputVisible(int idx) const;
00113 virtual bool isOutputVisible(int idx) const;
00114
00115 virtual bool getBoundingBox(UT_BoundingBox &box, OP_Context &ctx)
00116 { return OP_Network::getBoundingBox(box, ctx); }
00117 virtual bool getBoundingBox(UT_BoundingBox &box, OP_Context &ctx,
00118 const char *rtype);
00119
00120 virtual SHOP_Node *getOutputNode() const;
00121 virtual void getInputName(UT_String &name, int idx) const;
00122 virtual SHOP_TYPE getInputType(int idx) const;
00123 virtual void getOutputName(UT_String &name, int idx) const;
00124 virtual SHOP_TYPE getOutputType(int idx) const;
00125
00126 virtual void saveDialogScriptExtraInfo(ostream &os);
00127 virtual void createGalleryEntry(OP_GalleryEntry &entry);
00128
00129
00130
00131 static UT_PtrArray<SHOP_Clerk *> &getClerkList(SHOP_TYPE type);
00132
00133
00134
00135
00136 virtual const char *getShaderName(bool forvex, SHOP_TYPE shop_type) const;
00137 virtual void getVariableString(int idx, UT_String &str, int thread);
00138
00139 virtual bool createSpareParametersFromChannels(
00140 UT_BitArray &selection,
00141 const CH_ChannelList &channels);
00142 virtual bool createSpareParametersForLoad(
00143 UT_StringArray &names,
00144 PRM_ParmNameMap &nmap,
00145 UT_String &errors);
00146
00147
00148
00149
00150 OP_Node *getCallingOBJ() { return myCallingOBJ; }
00151 void setCallingOBJ(OP_Node *o) { myCallingOBJ = o; }
00152 OP_Node *getCallingSOP() { return myCallingSOP; }
00153 void setCallingSOP(OP_Node *s) { myCallingSOP = s; }
00154
00155
00156
00157
00158
00159 SHOP_Clerk *getClerk(const char *rendertype,
00160 SHOP_TYPE interpret_type = SHOP_INVALID );
00161 SHOP_Clerk *getAnyClerk(bool only_string_generators);
00162
00163 virtual bool buildShaderString(UT_String &result, fpreal64 now,
00164 const UT_Options *options,
00165 OP_Node *obj=0, OP_Node *sop=0,
00166 SHOP_TYPE interpret_type = SHOP_INVALID);
00167 virtual bool buildShaderData(SHOP_ReData &data, fpreal64 now,
00168 const UT_Options *options,
00169 OP_Node *obj=0, OP_Node *sop=0,
00170 SHOP_TYPE interpret_type = SHOP_INVALID);
00171 virtual bool buildShaderBounds(UT_BoundingBox &box, fpreal64 now,
00172 const UT_Options *options,
00173 OP_Node *obj=0, OP_Node *sop=0,
00174 SHOP_TYPE interpret_type = SHOP_INVALID);
00175
00176
00177
00178 virtual bool buildVopShaderString(VOP_Node *vop,
00179 UT_String &result, fpreal64 now,
00180 const UT_Options *options,
00181 OP_Node *obj, OP_Node *sop,
00182 SHOP_TYPE interpret_type = SHOP_INVALID);
00183
00184
00185 bool getVopShaderName(OP_Node *node,
00186 UT_WorkBuffer &name,
00187 bool forvex, SHOP_TYPE shop_type) const;
00188
00189 void destroyCache();
00190 SHOP_ClerkCacheEntry *getClerkData(const SHOP_Clerk *clerk);
00191 void destroyClerkData(const SHOP_Clerk *clerk);
00192 void addClerkData(const SHOP_Clerk *clerk,
00193 SHOP_ClerkCacheEntry *entry);
00194
00195 virtual SHOP_TYPE getShaderType() const;
00196
00197
00198 virtual void getOutputShaderTypes(UT_RefArray<SHOP_TYPE> & types);
00199
00200 static bool addShaderClerk(SHOP_TYPE type, SHOP_Clerk *shop);
00201 static void buildShaderTable(OP_OperatorTable &table);
00202 static OP_Operator *getManagementOperator();
00203
00204
00205
00206
00207 bool findPropertiesParameter(const char *parm, fpreal64 now,
00208 int &opid, int &pidx);
00209
00210
00211 void addError(int code, const char *msg = 0)
00212 { UTaddError("SHOP", code, msg);}
00213 void addMessage(SHOP_ErrorCode code, const char *msg = 0)
00214 { UTaddMessage("SHOP", code, msg);}
00215 void addWarning(SHOP_ErrorCode code, const char *msg = 0)
00216 { UTaddWarning("SHOP", code, msg);}
00217 void addFatal(SHOP_ErrorCode code, const char *msg = 0)
00218 { UTaddFatal("SHOP", code, msg);}
00219 void addSystemError(const char *msg = 0)
00220 { UTaddSystemError(msg);}
00221 void addCommonError(UT_CommonErrorCode what, const char *msg = 0)
00222 { UTaddCommonError(what, msg);}
00223
00224 int getOGLTextureCount() const { return myOGLTextureCount; }
00225 void bumpOGLTextureCount(int dir) { myOGLTextureCount += dir; }
00226
00227 bool containsShopType(SHOP_TYPE type) const;
00228 void bumpContainedType(SHOP_TYPE type, int dir);
00229
00230 int getOGLScriptCacheState() const { return myOGLScriptCache; }
00231 void setOGLScriptCache(int val,
00232 const char *vtxsrc, const char *fragsrc)
00233 { myOGLScriptCache = val;
00234 myOGLVtxSource.harden(vtxsrc);
00235 myOGLFragSource.harden(fragsrc);
00236 }
00237 const char *getOGLVtxSource() const
00238 { return (const char *) myOGLVtxSource; }
00239 const char *getOGLFragSource() const
00240 { return (const char *) myOGLFragSource; }
00241
00242
00243
00244
00245
00246
00247
00248
00249 void evalStringParm(UT_String &result,
00250 const char *parm_name,
00251 int vector_index, fpreal64 now,
00252 const PRM_Template *tplate,
00253 bool "ed,
00254 const char *rtype, int fprecision);
00255
00256
00257 virtual const char *getChildType() const;
00258 virtual const char *getOpType() const;
00259
00260 virtual OP_OpTypeId getChildTypeID() const;
00261 virtual OP_OpTypeId getOpTypeID() const;
00262
00263
00264 virtual fpreal getW() const;
00265
00266 virtual fpreal getH() const;
00267
00268 static void initializeExpressions();
00269
00270
00271 bool evalShopParameter(const char *name, int vec_idx,
00272 fpreal64 now, int &value,
00273 const UT_Options *options,
00274 bool add_cook_dependency=false);
00275 bool evalShopParameter(const char *name, int vec_idx,
00276 fpreal64 now, fpreal &value,
00277 const UT_Options *options,
00278 bool add_cook_dependency=false);
00279 bool evalShopParameter(const char *name, int vec_idx,
00280 fpreal64 now, UT_String &value,
00281 const UT_Options *options,
00282 bool add_cook_dependency=false);
00283
00284
00285 virtual UT_String *getMaterialIconFilename()
00286 { return &myMaterialIconFilename; }
00287 virtual void setMaterialIconFilename(const char *icon_file)
00288 { myMaterialIconFilename.harden(icon_file); }
00289
00290 virtual IMG_Raster *getMaterialIconImage()
00291 { return &myMaterialIconImage; }
00292
00293 virtual bool getMaterialIconAllowRegenerateFlag()
00294 { return myAllowIconRegeneration; }
00295 virtual void setMaterialIconAllowRegenerateFlag(bool allow)
00296 { myAllowIconRegeneration = allow; }
00297
00298
00299
00300 virtual VOP_Node * getProcedural(VOP_Type type);
00301
00302
00303
00304 virtual void handleOTLIndexFileCleared()
00305 {}
00306
00307 protected:
00308 virtual void changeParmTemplate(PRM_Template *new_template);
00309
00310
00311 virtual int getDataClass() const;
00312 virtual OP_ERROR cookMe(OP_Context &);
00313 virtual OP_ERROR bypassMe(OP_Context &, int &);
00314 virtual const char *getFileExtension(int binary) const;
00315
00316 virtual OP_DATA_TYPE getCookedDataType() const;
00317 virtual void deleteCookedData();
00318 virtual int saveCookedData(const char *, OP_Context &);
00319 virtual int saveCookedData(ostream &, OP_Context &, int);
00320
00321 virtual bool cookedDataUsesAllParameters() const
00322 { return true; }
00323 virtual bool cookedDataNeedsErrors() const
00324 { return true; }
00325
00326
00327
00328 void resolveParmBundle(const char *parm_name,
00329 int vector_index,
00330 UT_String &pattern,
00331 OP_Network *creator,
00332 const char *filter,
00333 bool expand_fullpath = false);
00334
00335
00336
00337 SHOP_Node *getFullInput(int input_idx, int &output_idx) const;
00338
00339 void setShaderType(SHOP_TYPE t);
00340
00341
00342
00343
00344
00345 SHOP_Node * checkRenderMask( const UT_Options *options);
00346
00347 bool renderMatch(const char *rendertype) const;
00348 bool renderMatch(const SHOP_Clerk &clerk) const;
00349
00350 int myContainedShops[SHOP_MAX_TYPES];
00351 UT_String myRenderMask;
00352 UT_HashTable myClerkCache;
00353 OP_Node *myCallingOBJ, *myCallingSOP;
00354 int myOGLTextureCount;
00355 int myOGLScriptCache;
00356 UT_String myOGLVtxSource, myOGLFragSource;
00357
00358 UT_String myMaterialIconFilename;
00359 IMG_Raster myMaterialIconImage;
00360 bool myAllowIconRegeneration;
00361
00362 private:
00363 static void installClerks();
00364 static void installCommands();
00365
00366 SHOP_TYPE myShaderType;
00367 };
00368
00369
00370
00371 SHOP_API extern void
00372 SHOPgetVexReservedTemplateLists(UT_PtrArray<PRM_Template *> &tplatelists);
00373
00374 #endif