HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IMG_TileOptions.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: IMG_TileOptions.h ( IMG Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __IMG_TileOptions__
12 #define __IMG_TileOptions__
13 
14 #include "IMG_API.h"
15 #include "IMG_FileTypes.h"
16 #include "IMG_Format.h"
17 #include <UT/UT_Options.h>
18 #include <UT/UT_ValArray.h>
19 
20 class UT_StringArray;
21 class UT_JSONWriter;
22 
24 {
25 public:
26  /// If the format is a null pointer, it will be inferred from the filename
27  IMG_TileOptions() = default;
28  virtual ~IMG_TileOptions() = default;
29 
30  /// Create a new copy of myself
31  virtual IMG_TileOptions *clone() const;
32 
33  void setPlaneInfo(const UT_StringHolder &filename,
34  const UT_StringHolder &channel,
35  const UT_StringHolder &format,
36  IMG_DataType dtype = IMG_DT_ANY,
37  IMG_ColorModel cmodel = IMG_CM_ANY,
38  IMG_TypeInfo tinfo = IMG_TI_COLOR);
39  void setPlaneInfo(const char *filename,
40  const char *channel,
41  const char *format,
42  IMG_DataType dtype = IMG_DT_ANY,
43  IMG_ColorModel cmodel = IMG_CM_ANY,
44  IMG_TypeInfo tinfo = IMG_TI_COLOR)
45  {
46  setPlaneInfo(UT_StringHolder(filename),
47  UT_StringHolder(channel),
48  UT_StringHolder(format),
49  dtype, cmodel, tinfo);
50  }
51 
52  fpreal gamma() const { return myGamma; }
53  void setGamma(fpreal gamma) { myGamma = gamma; }
54  PXL_ColorSpace colorSpace() const;
55 
56  // Change the filename extension to match the format
57  bool changeFileExtension();
58 
59  /// There are sevaral ways to set format options:
60  /// 1) A sting (which is parsed into token/value pairs)
61  /// 2) A set of token/value pairs specified as a linear array
62  void clearOptions();
63  void setFormatOptions(const char *string);
64  void setFormatOptions(int argc, const char *const argv[]);
65  void setFormatOptions(const UT_StringArray &options);
66  void setFormatOption(const char *token, const char *value);
67  void setFormatOptions(const UT_Options &options);
68 
69  /// Get the IMG_Format associated with these options. This will possibly
70  /// return a null ptr.
71  virtual const IMG_Format *getFormat(IMG_Format::AccessType
73 
74  const char *getFilename() const;
75  const char *getChannel() const;
76  const char *getFormatName() const;
77  IMG_DataType getDataType() const;
78  IMG_ColorModel getColorModel() const;
79  IMG_TypeInfo getTypeInfo() const;
80  const UT_Options &getLocalOptions() const;
81 
82  /// Getting the option will return true/false based on whether the option
83  /// was defined. If the option was not defined, the value will not be
84  /// touched (i.e. it will remain unchanged).
85  virtual bool getOption(const char *token, UT_String &value) const;
86 
87  /// Texture options are only output for specific file formats. These
88  /// texture options are used to pass information from the calling
89  /// application to the device (where required).
90  /// The application can write directly to the UT_Options, which will
91  /// then be output in the file.
92  virtual void setTextureOptions(UT_Options &options);
93 
94  /// Pack all options into a single string. Returns the number of options
95  /// packed.
96  virtual int packOptionsString(UT_String &result) const;
97 
98  /// @{
99  /// Dump options
100  void dump(UT_JSONWriter &w) const;
101  void dump() const;
102  /// @}
103 
104 protected:
105  // Copy from the option source
106  void copy(const IMG_TileOptions &src);
107 
112  IMG_DataType myDataType = IMG_DT_ANY;
113  IMG_ColorModel myColorModel = IMG_CM_ANY;
115  fpreal myGamma = 1;
116 };
117 
119 {
120 public:
123 
124  /// WARNING: Using this class will delete all the contents, so you must
125  /// append clones if you're creating single lists from existing options.
126  int entries() const { return myOptions.entries(); }
127  void append(IMG_TileOptions *opt) { myOptions.append(opt); }
128  IMG_TileOptions *operator()(int i) { return myOptions(i); }
129 
130  /// @{
131  /// Dump option list
132  void dump(UT_JSONWriter &w) const;
133  void dump() const;
134  /// @}
135 private:
136  UT_Array<IMG_TileOptions *> myOptions;
137 };
138 
139 #endif
void append(IMG_TileOptions *opt)
void setPlaneInfo(const char *filename, const char *channel, const char *format, IMG_DataType dtype=IMG_DT_ANY, IMG_ColorModel cmodel=IMG_CM_ANY, IMG_TypeInfo tinfo=IMG_TI_COLOR)
IMG_TypeInfo
How the channel data should be interpreted.
Definition: IMG_FileTypes.h:39
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
void setGamma(fpreal gamma)
png_uint_32 i
Definition: png.h:2877
#define IMG_API
Definition: IMG_API.h:10
UT_StringHolder myFilename
GLuint GLint GLboolean GLint GLenum access
Definition: glcorearb.h:2221
IMG_TileOptions * operator()(int i)
int entries() const
IMG_DataType
Definition: IMG_FileTypes.h:17
fpreal gamma() const
UT_StringHolder myFormatName
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:263
A map of string to various well defined value types.
Definition: UT_Options.h:42
PXL_ColorSpace
Definition: PXL_Common.h:42
IMG_ColorModel
Definition: IMG_FileTypes.h:53
UT_Options myOptions
UT_StringHolder myChannel
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLenum src
Definition: glcorearb.h:1792