HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TIL_Thumbnail.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_Thumbnail.h (IPR Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __TIL_Thumbnail__
12 #define __TIL_Thumbnail__
13 
14 #include "TIL_API.h"
15 #include <UT/UT_Vector3.h>
16 #include <UT/UT_Matrix4.h>
17 #include <UT/UT_StringHolder.h>
18 
19 class TIL_Raster;
20 class UT_Options;
21 class UT_JSONWriter;
22 
23 /// Rendering parms for thumbnail generation. Some options are currently
24 /// not supported.
26 {
27 public:
29  : myTransform(1)
30  , mySurface()
31  , mySurfaceSource()
32  , myDisplace()
33  , myDisplaceSource()
34  , myRes(64)
35  , myShapeFile("shadersphere.bgeo")
36  { }
38  { }
39 
40  virtual void setOptions(const UT_Options &options);
41 
42  int res() const
43  { return myRes; }
44  const UT_StringHolder &shapeFile() const
45  { return myShapeFile; }
46  const UT_Matrix4D transform() const
47  { return myTransform; }
48  const UT_StringHolder &surface() const
49  { return mySurface; }
51  { return mySurfaceArgs; }
53  { return mySurfaceSource; }
54  const UT_StringHolder &displace() const
55  { return myDisplace; }
57  { return myDisplaceArgs; }
59  { return myDisplaceSource; }
60 
61  void setRes(int res)
62  { myRes = res; }
64  { myShapeFile = s; }
65  void transform(const UT_Matrix4D &x)
66  { myTransform *= x; }
67  void setCamera(const UT_Vector3 &camera_origin)
68  { }
69  void setTransform(const UT_Matrix4D &x)
70  { myTransform = x; }
71  void setSurface(const UT_StringHolder &shader_name,
72  const UT_StringHolder &args)
73  {
74  mySurface = shader_name;
75  mySurfaceArgs = args;
76  }
78  { mySurfaceSource=s; }
79  void setDisplace(const UT_StringHolder &shader_name,
80  const UT_StringHolder &args)
81  {
82  myDisplace = shader_name;
83  myDisplaceArgs = args;
84  }
86  { myDisplaceSource=s; }
87 
88  /// @{
89  /// Dump parameters
90  void dump() const;
91  void dump(UT_JSONWriter &w) const;
92  /// @}
93 
94 private:
95  static UT_DMatrix4 shapeTransform(const char *values);
96 
97  UT_StringHolder myShapeFile;
98  UT_StringHolder mySurface;
99  UT_StringHolder mySurfaceArgs;
100  UT_StringHolder mySurfaceSource;
101  UT_StringHolder myDisplace;
102  UT_StringHolder myDisplaceArgs;
103  UT_StringHolder myDisplaceSource;
104  UT_Matrix4D myTransform;
105  int myRes;
106 };
107 
108 /// Base class to generate a thumbnail for a shader
109 ///
110 /// For each thumbnail required, create an TIL_Thumbnail object. This acts
111 /// as a handle to a render. By default, you'll get a sphere with the shader
112 /// specified in the parms applied to it.
114 {
115 public:
116  /// Reasons for update
118  {
119  TIL_THUMB_ERROR, // Error creating thumbnail
120  TIL_THUMB_UPDATE, // Image has new pixels
121  TIL_THUMB_DONE // Render completed
122  };
123 
124  TIL_Thumbnail();
125  virtual ~TIL_Thumbnail();
126 
127  /// If you want to get updates on the rendering progress, you can implement
128  /// this method.
129  ///
130  /// @warning This method will likely be called by a child thread.
131  virtual void update(UpdateReason reason);
132 
133  /// Return the percent complete (0-100).
134  virtual int percentComplete() const = 0;
135  /// Return any error message.
136  virtual UT_StringHolder errorMessage() const = 0;
137 
138  /// Tracks whether this thubnail is out of date.
139  bool needsRefresh() const;
140  void setNeedsRefresh();
141 
142  /// Start thumbnail generation.
143  virtual void start(const TIL_ThumbnailParms &parms) = 0;
144  /// Return the RGBA raster. It's possible the raster is incomplete, but
145  /// the raster will be updated as the render proceeds.
146  virtual const TIL_Raster *getImage() const = 0;
147 
148 private:
149  bool myNeedsRefresh;
150 };
151 
152 #endif
const UT_StringHolder & surfaceSource() const
Definition: TIL_Thumbnail.h:52
const UT_Matrix4D transform() const
Definition: TIL_Thumbnail.h:46
GLuint start
Definition: glcorearb.h:474
const UT_StringHolder & shapeFile() const
Definition: TIL_Thumbnail.h:44
UpdateReason
Reasons for update.
virtual ~TIL_ThumbnailParms()
Definition: TIL_Thumbnail.h:37
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
void setRes(int res)
Definition: TIL_Thumbnail.h:61
const UT_StringHolder & displaceArgs() const
Definition: TIL_Thumbnail.h:56
const UT_StringHolder & displaceSource() const
Definition: TIL_Thumbnail.h:58
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
int res() const
Definition: TIL_Thumbnail.h:42
void setSurfaceSource(const UT_StringHolder &s)
Definition: TIL_Thumbnail.h:77
const UT_StringHolder & displace() const
Definition: TIL_Thumbnail.h:54
void setTransform(const UT_Matrix4D &x)
Definition: TIL_Thumbnail.h:69
void setShapeFile(const UT_StringHolder &s)
Definition: TIL_Thumbnail.h:63
A map of string to various well defined value types.
Definition: UT_Options.h:42
void transform(const UT_Matrix4D &x)
Definition: TIL_Thumbnail.h:65
void setCamera(const UT_Vector3 &camera_origin)
Definition: TIL_Thumbnail.h:67
const UT_StringHolder & surface() const
Definition: TIL_Thumbnail.h:48
GLint GLenum GLint x
Definition: glcorearb.h:408
void setDisplaceSource(const UT_StringHolder &s)
Definition: TIL_Thumbnail.h:85
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
void setSurface(const UT_StringHolder &shader_name, const UT_StringHolder &args)
Definition: TIL_Thumbnail.h:71
#define TIL_API
Definition: TIL_API.h:10
const UT_StringHolder & surfaceArgs() const
Definition: TIL_Thumbnail.h:50
void setDisplace(const UT_StringHolder &shader_name, const UT_StringHolder &args)
Definition: TIL_Thumbnail.h:79