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