VTK
vtkOpenGLContextDevice2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLContextDevice2D.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
32 #ifndef vtkOpenGLContextDevice2D_h
33 #define vtkOpenGLContextDevice2D_h
34 
35 #include "vtkRenderingContextOpenGL2Module.h" // For export macro
36 #include "vtkContextDevice2D.h"
37 
38 #include <vector> // STL Header
39 #include <list> // for std::list
40 
41 class vtkMatrix4x4;
43 class vtkOpenGLHelper;
45 class vtkRenderer;
46 class vtkShaderProgram;
47 class vtkStringToImage;
48 class vtkTransform;
49 class vtkViewport;
50 class vtkWindow;
51 
52 class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice2D : public vtkContextDevice2D
53 {
54 public:
56  virtual void PrintSelf(ostream &os, vtkIndent indent);
57 
59  static vtkOpenGLContextDevice2D *New();
60 
62 
65  virtual void DrawPoly(float *f, int n, unsigned char *colors = 0,
66  int nc_comps = 0);
68 
70 
73  virtual void DrawLines(float *f, int n, unsigned char *colors = 0,
74  int nc_comps = 0);
76 
78 
81  virtual void DrawPoints(float *points, int n, unsigned char* colors = 0,
82  int nc_comps = 0);
84 
86 
91  virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
92  unsigned char* colors = 0, int nc_comps = 0);
94 
96 
102  virtual void DrawMarkers(int shape, bool highlight, float *points, int n,
103  unsigned char *colors = 0, int nc_comps = 0);
105 
107 
111  vtkSetMacro(MaximumMarkerCacheSize, int)
112  vtkGetMacro(MaximumMarkerCacheSize, int)
114 
116  virtual void DrawQuad(float *points, int n);
117 
119  virtual void DrawQuadStrip(float *points, int n);
120 
122  virtual void DrawPolygon(float *, int);
123 
125 
131  virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy,
132  float inRx, float inRy, float startAngle,
133  float stopAngle);
135 
137 
140  virtual void DrawEllipticArc(float x, float y, float rX, float rY,
141  float startAngle, float stopAngle);
143 
144 
146  virtual void DrawString(float *point, const vtkStdString &string);
147 
149 
156  virtual void ComputeStringBounds(const vtkStdString &string,
157  float bounds[4]);
159 
161  virtual void DrawString(float *point, const vtkUnicodeString &string);
162 
164 
171  virtual void ComputeStringBounds(const vtkUnicodeString &string,
172  float bounds[4]);
174 
178  virtual void DrawMathTextString(float point[2], const vtkStdString &string);
179 
182  virtual void DrawImage(float p[2], float scale, vtkImageData *image);
183 
187  void DrawImage(const vtkRectf& pos, vtkImageData *image);
188 
190  virtual void SetColor4(unsigned char color[4]);
191 
193  virtual void SetColor(unsigned char color[3]);
194 
196  virtual void SetTexture(vtkImageData* image, int properties = 0);
197 
199  virtual void SetPointSize(float size);
200 
202  virtual void SetLineWidth(float width);
203 
205  virtual void SetLineType(int type);
206 
208  virtual void MultiplyMatrix(vtkMatrix3x3 *m);
209 
211  virtual void SetMatrix(vtkMatrix3x3 *m);
212 
214  virtual void GetMatrix(vtkMatrix3x3 *m);
215 
217  virtual void PushMatrix();
218 
220  virtual void PopMatrix();
221 
224  virtual void SetClipping(int *x);
225 
227  virtual void EnableClipping(bool enable);
228 
230  virtual void Begin(vtkViewport* viewport);
231 
233  virtual void End();
234 
238  virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
239 
244  virtual void BufferIdModeEnd();
245 
249  bool SetStringRendererToFreeType();
250 
253  bool SetStringRendererToQt();
254 
256  bool HasGLSL();
257 
259 
263 
267  virtual void ReleaseGraphicsResources(vtkWindow *window);
268 
270 
271  vtkMatrix4x4 *GetProjectionMatrix();
272  vtkMatrix4x4 *GetModelMatrix();
274 
275 //BTX
276 protected:
278  virtual ~vtkOpenGLContextDevice2D();
279 
281 
285  int GetNumberOfArcIterations(float rX,
286  float rY,
287  float startAngle,
288  float stopAngle);
290 
292  int Geometry[2];
293 
295  vtkRenderer *Renderer;
296 
298  vtkStringToImage *TextRenderer;
299 
301  bool InRender;
302 
304 
305  class Private;
306  Private *Storage;
308 
310  vtkOpenGLRenderWindow* RenderWindow;
311 
312  vtkOpenGLHelper *VCBO; // vertex + color
313  void ReadyVCBOProgram();
314  vtkOpenGLHelper *VBO; // vertex
315  void ReadyVBOProgram();
316  vtkOpenGLHelper *VTBO; // vertex + tcoord
317  void ReadyVTBOProgram();
318  vtkOpenGLHelper *SCBO; // sprite + color
319  void ReadySCBOProgram();
320  vtkOpenGLHelper *SBO; // sprite
321  void ReadySBOProgram();
322 
323  void SetMatrices(vtkShaderProgram *prog);
324  void BuildVBO(vtkOpenGLHelper *cbo,
325  float *v, int nv,
326  unsigned char *coolors, int nc,
327  float *tcoords);
328  void CoreDrawTriangles(std::vector<float> &tverts);
329 
330 private:
331  vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
332  void operator=(const vtkOpenGLContextDevice2D &); // Not implemented.
333 
334  void AlignText(double orientation, float width, float height, float *p);
335 
341  vtkImageData *GetMarker(int shape, int size, bool highlight);
342 
343  class vtkMarkerCacheObject
344  {
345  public:
346  vtkTypeUInt64 Key;
347  vtkImageData *Value;
348  bool operator==(vtkTypeUInt64 key)
349  {
350  return this->Key == key;
351  }
352  };
353 
354  vtkTransform *ProjectionMatrix;
355  vtkTransform *ModelMatrix;
356 
357  std::list<vtkMarkerCacheObject> MarkerCache;
358  int MaximumMarkerCacheSize;
359 
363  vtkImageData * GenerateMarker(int shape, int size, bool highlight);
364 
365 //ETX
366 };
367 
368 #endif //vtkOpenGLContextDevice2D_h
OpenGL rendering window.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
abstract specification for Viewports
Definition: vtkViewport.h:46
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
Class for drawing 2D primitives using OpenGL 1.1+.
abstract specification for renderers
Definition: vtkRenderer.h:63
static vtkContextDevice2D * New()
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
virtual void DrawPoints(float *points, int n, unsigned char *colors=0, int nc_comps=0)=0
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
virtual void DrawMarkers(int shape, bool highlight, float *points, int n, unsigned char *colors=0, int nc_comps=0)
uses Qt to render the supplied text to an image.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
virtual void DrawPoly(float *points, int n, unsigned char *colors=0, int nc_comps=0)=0
a simple class to control print indentation
Definition: vtkIndent.h:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
Abstract class for drawing 2D primitives.
Interface class for querying and using OpenGL extensions.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
2D array of ids, used for picking.
virtual void PrintSelf(ostream &os, vtkIndent indent)
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:35
virtual void DrawLines(float *f, int n, unsigned char *colors=0, int nc_comps=0)=0
virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n, unsigned char *colors=0, int nc_comps=0)=0
String class that stores Unicode text.
The ShaderProgram uses one or more Shader objects.
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:79