00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: IMG_TileOptions.h ( IMG Library, C++) 00014 * 00015 * COMMENTS: 00016 */ 00017 00018 #ifndef __IMG_TileOptions__ 00019 #define __IMG_TileOptions__ 00020 00021 #include "IMG_API.h" 00022 #include "IMG_FileTypes.h" 00023 #include <UT/UT_Options.h> 00024 #include <UT/UT_PtrArray.h> 00025 00026 class UT_StringArray; 00027 class IMG_Format; 00028 00029 class IMG_API IMG_TileOptions { 00030 public: 00031 /// If the format is a null pointer, it will be inferred from the filename 00032 IMG_TileOptions(); 00033 virtual ~IMG_TileOptions(); 00034 00035 /// Create a new copy of myself 00036 virtual IMG_TileOptions *clone() const; 00037 00038 void setPlaneInfo(const char *filename, 00039 const char *channel, 00040 const char *format, 00041 IMG_DataType dtype = IMG_DT_ANY, 00042 IMG_ColorModel cmodel = IMG_CM_ANY); 00043 00044 // Change the filename extension to match the format 00045 bool changeFileExtension(); 00046 00047 /// There are sevaral ways to set format options: 00048 /// 1) A sting (which is parsed into token/value pairs) 00049 /// 2) A set of token/value pairs specified as a linear array 00050 void clearOptions(); 00051 void setFormatOptions(const char *string); 00052 void setFormatOptions(int argc, char *argv[]); 00053 void setFormatOptions(const UT_StringArray &options); 00054 void setFormatOption(const char *token, const char *value); 00055 void setFormatOptions(const UT_Options &options); 00056 00057 /// Get the IMG_Format associated with these options. This will possibly 00058 /// return a null ptr. 00059 virtual const IMG_Format *getFormat() const; 00060 00061 const char *getFilename() const; 00062 const char *getChannel() const; 00063 const char *getFormatName() const; 00064 IMG_DataType getDataType() const; 00065 IMG_ColorModel getColorModel() const; 00066 const UT_Options &getLocalOptions() const; 00067 00068 /// Getting the option will return true/false based on whether the option 00069 /// was defined. If the option was not defined, the value will not be 00070 /// touched (i.e. it will remain unchanged). 00071 virtual bool getOption(const char *token, UT_String &value) const; 00072 00073 /// Texture options are only output for specific file formats. These 00074 /// texture options are used to pass information from the calling 00075 /// application to the device (where required). 00076 /// The application can write directly to the UT_Options, which will 00077 /// then be output in the file. 00078 virtual void setTextureOptions(UT_Options &options); 00079 00080 /// Pack all options into a single string. Returns the number of options 00081 /// packed. 00082 virtual int packOptionsString(UT_String &result) const; 00083 protected: 00084 // Copy from the option source 00085 void copy(const IMG_TileOptions &src); 00086 00087 UT_String myFilename; 00088 UT_String myChannel; 00089 UT_String myFormatName; 00090 IMG_DataType myDataType; 00091 IMG_ColorModel myColorModel; 00092 UT_Options myOptions; 00093 }; 00094 00095 class IMG_API IMG_TileOptionList { 00096 public: 00097 IMG_TileOptionList(); 00098 ~IMG_TileOptionList(); 00099 00100 /// WARNING: Using this class will delete all the contents, so you must 00101 /// append clones if you're creating single lists from existing options. 00102 int entries() const { return myOptions.entries(); } 00103 void append(IMG_TileOptions *opt) { myOptions.append(opt); } 00104 IMG_TileOptions *operator()(int i) { return myOptions(i); } 00105 private: 00106 UT_PtrArray<IMG_TileOptions *> myOptions; 00107 }; 00108 00109 #endif
1.5.9