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