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 "vtkRenderingContextOpenGLModule.h" // For export macro
36 #include "vtkContextDevice2D.h"
37 
38 #include <list> // for std::list
39 
40 class vtkWindow;
41 class vtkViewport;
42 class vtkRenderer;
43 class vtkStringToImage;
46 
48 {
49 public:
51  virtual void PrintSelf(ostream &os, vtkIndent indent);
52 
55 
57 
60  virtual void DrawPoly(float *f, int n, unsigned char *colors = 0,
61  int nc_comps = 0);
63 
65 
68  virtual void DrawLines(float *f, int n, unsigned char *colors = 0,
69  int nc_comps = 0);
71 
73 
76  virtual void DrawPoints(float *points, int n, unsigned char* colors = 0,
77  int nc_comps = 0);
79 
81 
86  virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
87  unsigned char* colors = 0, int nc_comps = 0);
89 
91 
97  virtual void DrawMarkers(int shape, bool highlight, float *points, int n,
98  unsigned char *colors = 0, int nc_comps = 0);
100 
102 
106  vtkSetMacro(MaximumMarkerCacheSize, int)
107  vtkGetMacro(MaximumMarkerCacheSize, int)
109 
111  virtual void DrawQuad(float *points, int n);
112 
114  virtual void DrawQuadStrip(float *points, int n);
115 
117  virtual void DrawPolygon(float *, int);
118 
120 
126  virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy,
127  float inRx, float inRy, float startAngle,
128  float stopAngle);
130 
132 
135  virtual void DrawEllipticArc(float x, float y, float rX, float rY,
136  float startAngle, float stopAngle);
138 
139 
141  virtual void DrawString(float *point, const vtkStdString &string);
142 
144 
151  virtual void ComputeStringBounds(const vtkStdString &string,
152  float bounds[4]);
154 
156  virtual void DrawString(float *point, const vtkUnicodeString &string);
157 
159 
166  virtual void ComputeStringBounds(const vtkUnicodeString &string,
167  float bounds[4]);
169 
173  virtual void DrawMathTextString(float point[2], const vtkStdString &string);
174 
177  virtual void DrawImage(float p[2], float scale, vtkImageData *image);
178 
182  void DrawImage(const vtkRectf& pos, vtkImageData *image);
183 
185  virtual void SetColor4(unsigned char color[4]);
186 
188  virtual void SetColor(unsigned char color[3]);
189 
191  virtual void SetTexture(vtkImageData* image, int properties = 0);
192 
194  virtual void SetPointSize(float size);
195 
197  virtual void SetLineWidth(float width);
198 
200  virtual void SetLineType(int type);
201 
203  virtual void MultiplyMatrix(vtkMatrix3x3 *m);
204 
206  virtual void SetMatrix(vtkMatrix3x3 *m);
207 
209  virtual void GetMatrix(vtkMatrix3x3 *m);
210 
212  virtual void PushMatrix();
213 
215  virtual void PopMatrix();
216 
219  virtual void SetClipping(int *x);
220 
222  virtual void EnableClipping(bool enable);
223 
225  virtual void Begin(vtkViewport* viewport);
226 
228  virtual void End();
229 
233  virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
234 
239  virtual void BufferIdModeEnd();
240 
244  bool SetStringRendererToFreeType();
245 
248  bool SetStringRendererToQt();
249 
251  bool HasGLSL();
252 
254 
258 
262  virtual void ReleaseGraphicsResources(vtkWindow *window);
263 
264 //BTX
265 protected:
268 
270 
274  int GetNumberOfArcIterations(float rX,
275  float rY,
276  float startAngle,
277  float stopAngle);
279 
281  int Geometry[2];
282 
284  vtkRenderer *Renderer;
285 
287  vtkStringToImage *TextRenderer;
288 
290  bool InRender;
291 
293 
294  class Private;
295  Private *Storage;
297 
299  virtual bool LoadExtensions(vtkOpenGLExtensionManager *m);
300 
302  vtkOpenGLRenderWindow* RenderWindow;
303 
304 private:
305  vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
306  void operator=(const vtkOpenGLContextDevice2D &); // Not implemented.
307 
308  void AlignText(double orientation, float width, float height, float *p);
309 
315  vtkImageData *GetMarker(int shape, int size, bool highlight);
316 
317  class vtkMarkerCacheObject
318  {
319  public:
320  vtkTypeUInt64 Key;
321  vtkImageData *Value;
322  bool operator==(vtkTypeUInt64 key)
323  {
324  return this->Key == key;
325  }
326  };
327 
328  std::list<vtkMarkerCacheObject> MarkerCache;
329  int MaximumMarkerCacheSize;
330 
334  vtkImageData * GenerateMarker(int shape, int size, bool highlight);
335 
336 //ETX
337 };
338 
339 #endif //vtkOpenGLContextDevice2D_h
vtkOpenGLContextDevice2D::Private
Definition: vtkOpenGLContextDevice2DPrivate.h:235
vtkOpenGLContextDevice2D::DrawPoints
virtual void DrawPoints(float *points, int n, unsigned char *colors=0, int nc_comps=0)
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
vtkgl::m
const GLfloat * m
Definition: vtkgl.h:18169
vtkOpenGLContextDevice2D::DrawLines
virtual void DrawLines(float *f, int n, unsigned char *colors=0, int nc_comps=0)
VTKRENDERINGCONTEXTOPENGL_EXPORT
#define VTKRENDERINGCONTEXTOPENGL_EXPORT
Definition: vtkRenderingContextOpenGLModule.h:15
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkgl::scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: vtkgl.h:15942
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkOpenGLContextDevice2D::DrawPointSprites
virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n, unsigned char *colors=0, int nc_comps=0)
vtkStringToImage
uses Qt to render the supplied text to an image.
Definition: vtkStringToImage.h:36
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkgl::enable
GLboolean enable
Definition: vtkgl.h:18647
vtkgl::points
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:36
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkRenderingContextOpenGLModule.h
vtkAbstractContextBufferId
2D array of ids, used for picking.
Definition: vtkAbstractContextBufferId.h:46
vtkOpenGLContextDevice2D::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkOpenGLContextDevice2D
Class for drawing 2D primitives using OpenGL 1.1+.
Definition: vtkOpenGLContextDevice2D.h:48
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkUnicodeString
String class that stores Unicode text.
Definition: vtkUnicodeString.h:72
vtkOpenGLContextDevice2D::DrawMarkers
virtual void DrawMarkers(int shape, bool highlight, float *points, int n, unsigned char *colors=0, int nc_comps=0)
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkX3D::startAngle
@ startAngle
Definition: vtkX3D.h:486
vtkgl::color
GLuint color
Definition: vtkgl.h:12351
operator==
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkgl::f
GLclampf f
Definition: vtkgl.h:14181
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkContextDevice2D
Abstract class for drawing 2D primitives.
Definition: vtkContextDevice2D.h:48
vtkgl::width
GLint GLint GLsizei width
Definition: vtkgl.h:11316
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkOpenGLContextDevice2D::DrawPoly
virtual void DrawPoly(float *f, int n, unsigned char *colors=0, int nc_comps=0)
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:262
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkOpenGLContextDevice2D::New
static vtkOpenGLContextDevice2D * New()
vtkgl::p
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:48
vtkgl::type
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkRectf
Definition: vtkRect.h:97
vtkgl::image
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: vtkgl.h:11341
vtkContextDevice2D.h
vtkgl::size
GLsizeiptr size
Definition: vtkgl.h:11843
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316