HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TIL_CopResolver.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: TIL_CopResolver.h ( TIL Library, C++)
7  *
8  * COMMENTS:
9  * Class to get a pointer to a COPs raster. This class is used by the
10  * texture mapping code to resolve names of the form:
11  *
12  * op:/comp/copnet/cop{C,A}[frame]
13  * file:filename{xres,yres}
14  *
15  * The frame is optional. Sub-classes don't need to worry about parsing
16  * out the [frame], this is all handled by the static methods.
17  */
18 
19 #ifndef __TIL_CopResolver__
20 #define __TIL_CopResolver__
21 
22 #include "TIL_API.h"
23 #include "TIL_Defines.h"
24 #include <IMG/IMG_FileTypes.h>
25 #include <UT/UT_ValArray.h>
26 #include <UT/UT_WorkBuffer.h>
27 #include <stddef.h>
28 
29 
30 #define TIL_DEFAULT_COLOR_PLANE "(Default Color)"
31 #define TIL_DEFAULT_ALPHA_PLANE "(Default Alpha)"
32 #define TIL_NO_PLANE "(None)"
33 
34 class TIL_Raster;
35 class TIL_Sequence;
36 class TIL_ImageSource;
37 class UT_String;
38 
40 {
41 public:
43  virtual ~TIL_CopResolver();
44 
45  static void setResolver(TIL_CopResolver *resolver);
46  static TIL_CopResolver *getResolver();
47 
48  // Get an TIL_Raster associated with the COP in the path specified
49  static TIL_Raster *getRaster(const char *fullpath,
50  int &opid,
51  bool *specific_frame = nullptr);
52  static fpreal getRasterTime(int opid);
53  static size_t getRasterVersion(int opid);
54 
55  /// Tell the resolver we're done with the raster.
56  /// Some resolvers will delete rasters, others will hold onto them. If the
57  /// raster actually dirties/deletes the raster, @c doneWithRaster() will
58  /// return true.
59  static bool doneWithRaster(const TIL_Raster *r);
60 
61  // Returns 1 if the frame is specified in the filename. The id will be -1
62  // if there is no such path.
63  static int getIdFrame(const char *fullpath, int &id,
64  fpreal &frame);
65  static void splitFile(const char *fullpath,
66  UT_String &name,
67  int &xres,int &yres,
68  float &quality);
69 
70  // These split net/node methods are now out of style with networks
71  // within networks. Now you should specify full, absolute, paths.
72  static int getNodeId(const char *net, const char *node);
73  static void getNodeRes(const char *net, const char *node,
74  int &xres, int &yres);
75 
76  static int getNodeId(const char *fullpath);
77  static void getNodeRes(const char *fullpath,
78  int &xres, int &yres);
79 
80  static void getFileRes(const char *file,
81  int &xres, int &yres);
82 
83  static int splitPath(const char *cpath, int &id,
84  fpreal &frame,
85  UT_WorkBuffer &color, int &cindex,
86  UT_WorkBuffer &alpha, int &aindex,
87  int &xres, int &yres);
88 
89  // builds menus for plane selection (COPs2 only).
90  static void buildColorMenu(const char *net,
91  const char *node,
92  UT_ValArray<char *> &items);
93 
94  static void buildAlphaMenu(const char *net,
95  const char *node,
96  UT_ValArray<char *> &items);
97 
98  static bool canResolve(const char *fullpath);
99 
100  // These methods should really only be used inside the TIL_CopResolver
101  // class. They shouldn't be called directly.
102  virtual int resolveId(const char *fullpath) = 0;
103 
104  virtual TIL_Raster *resolveRaster(int id) = 0;
105  virtual TIL_Raster *resolveRasterFrame(int id, fpreal frame,
106  int xres=0, int yres=0) = 0;
107  virtual TIL_Raster *resolveRasterPlane(int id, fpreal frame,
108  const char *color, int cindex,
109  const char *alpha, int aindex,
110  int xres=0, int yres = 0,
111  TIL_DataFormat f =
113 
114  // Returns whether or not the resolver knows how to handle this path.
115  virtual bool resolveIsPossible(const char *fullpath) = 0;
116 
117  virtual TIL_Raster *getFileRaster(const char *file,
119  int xres = 0, int yres = 0);
120  virtual TIL_Raster *getNodeRaster(const char *fullpath,
121  const char *cmenu, const char *amenu,
122  bool override_frame = false,
123  fpreal frame = 1.0,
124  TIL_DataFormat f =
126 
127  virtual void getRes(int id, int &xres, int &yres);
128 
129  virtual TIL_Sequence *getSequence(int id);
130 
131  /// This cooks a bunch of planes simulataneously, and adds the created
132  /// rasters to 'new_rasters'. You are responsible for deleting them.
133  virtual bool resolveRasters(int id,
134  const UT_StringArray &plane_names,
135  fpreal t,
136  UT_ValArray<TIL_Raster *> &new_rasters,
138 
139 
140  virtual void buildPlaneMenu(const char *net, const char *node,
141  UT_ValArray<char *> &items);
142 
143  virtual TIL_ImageSource *resolveImageSource(int id);
144 
145  /// Caller is finished with the raster for now, so delete memory if
146  /// possible. Returns true if the raster is no longer valid, but false if
147  /// the raster hasn't been touched (and is still valid). This is
148  /// implementation dependent.
149  virtual bool returnRaster(const TIL_Raster *raster);
150 
151  // If the id returned is really an OP_Node, then this will return 1.
152  virtual int isOpBased();
153 
154  virtual fpreal getTimeForRaster(int id);
155  virtual size_t getVersionForRaster(int id);
156 
157 protected:
158  // Returns 1 if the frame is defined, 0 otherwise. It's possible that
159  // the name returned may be a reference to the path. Please harden if
160  // you need to keep it around.
161  int splitPath(const char *fullpath,
162  UT_String &name, fpreal &frame);
163 };
164 
165 #endif
GLuint color
Definition: glcorearb.h:1260
GLfloat f
Definition: glcorearb.h:1925
#define TIL_DataFormat
Definition: TIL_Defines.h:64
#define TILE_MAX_DATA_FORMAT
Definition: TIL_Defines.h:70
IMG_DataType
Definition: IMG_FileTypes.h:17
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:111
GLuint const GLchar * name
Definition: glcorearb.h:785
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
double fpreal
Definition: SYS_Types.h:263
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLboolean r
Definition: glcorearb.h:1221
#define TIL_API
Definition: TIL_API.h:10