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 
54  static vtkOpenGLContextDevice2D *New();
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:
267  virtual ~vtkOpenGLContextDevice2D();
268 
270 
274  int GetNumberOfArcIterations(float rX,
275  float rY,
276  float startAngle,
277  float stopAngle);
279 
281  int Geometry[2];
282 
285 
288 
290  bool InRender;
291 
293 
294  class Private;
295  Private *Storage;
297 
299  virtual bool LoadExtensions(vtkOpenGLExtensionManager *m);
300 
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
OpenGL rendering window.
GLsizeiptr size
Definition: vtkgl.h:11843
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
virtual void SetMatrix(vtkMatrix3x3 *m)=0
GLclampf f
Definition: vtkgl.h:14181
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: vtkgl.h:11341
virtual void SetClipping(int *x)=0
virtual void BufferIdModeEnd()
abstract specification for Viewports
Definition: vtkViewport.h:46
GLenum GLenum GLenum GLenum GLenum scale
Definition: vtkgl.h:15942
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
Class for drawing 2D primitives using OpenGL 1.1+.
virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId)
abstract specification for renderers
Definition: vtkRenderer.h:63
static vtkContextDevice2D * New()
virtual void DrawPoints(float *points, int n, unsigned char *colors=0, int nc_comps=0)=0
virtual void Begin(vtkViewport *)
virtual void DrawPolygon(float *, int)
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#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.
virtual void SetColor4(unsigned char color[4])=0
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
window superclass for vtkRenderWindow
Definition: vtkWindow.h:33
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
virtual void EnableClipping(bool enable)=0
virtual void SetLineWidth(float width)=0
#define VTKRENDERINGCONTEXTOPENGL_EXPORT
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
const GLfloat * m
Definition: vtkgl.h:18169
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
GLint GLint GLsizei width
Definition: vtkgl.h:11316
virtual void DrawQuadStrip(float *, int)
Abstract class for drawing 2D primitives.
virtual void PopMatrix()=0
virtual void SetTexture(vtkImageData *image, int properties)=0
virtual void DrawMathTextString(float *point, const vtkStdString &string)=0
vtkOpenGLRenderWindow * RenderWindow
Interface class for querying and using OpenGL extensions.
virtual void SetPointSize(float size)=0
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
virtual void DrawQuad(float *, int)
2D array of ids, used for picking.
virtual void DrawEllipticArc(float x, float y, float rX, float rY, float startAngle, float stopAngle)=0
virtual void MultiplyMatrix(vtkMatrix3x3 *m)=0
virtual void DrawString(float *point, const vtkStdString &string)=0
virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy, float inRx, float inRy, float startAngle, float stopAngle)=0
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
GLboolean enable
Definition: vtkgl.h:18647
GLuint color
Definition: vtkgl.h:12351
virtual void GetMatrix(vtkMatrix3x3 *m)=0
GLclampd n
Definition: vtkgl.h:14370
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void ComputeStringBounds(const vtkStdString &string, float bounds[4])=0
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
virtual void PushMatrix()=0
virtual void DrawImage(float p[2], float scale, vtkImageData *image)=0
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:35
virtual void SetLineType(int type)=0
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.
GLfloat GLfloat p
Definition: vtkgl.h:15717
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:79