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 
29 #ifndef vtkOpenGLContextDevice2D_h
30 #define vtkOpenGLContextDevice2D_h
31 
32 #include "vtkRenderingContextOpenGLModule.h" // For export macro
33 #include "vtkContextDevice2D.h"
34 
35 #include <list> // for std::list
36 
37 class vtkWindow;
38 class vtkViewport;
39 class vtkRenderer;
40 class vtkStringToImage;
43 
45 {
46 public:
48  virtual void PrintSelf(ostream &os, vtkIndent indent);
49 
51  static vtkOpenGLContextDevice2D *New();
52 
54 
57  virtual void DrawPoly(float *f, int n, unsigned char *colors = 0,
58  int nc_comps = 0);
60 
62 
65  virtual void DrawPoints(float *points, int n, unsigned char* colors = 0,
66  int nc_comps = 0);
68 
70 
75  virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
76  unsigned char* colors = 0, int nc_comps = 0);
78 
80 
86  virtual void DrawMarkers(int shape, bool highlight, float *points, int n,
87  unsigned char *colors = 0, int nc_comps = 0);
89 
91 
95  vtkSetMacro(MaximumMarkerCacheSize, int)
96  vtkGetMacro(MaximumMarkerCacheSize, int)
98 
100  virtual void DrawQuad(float *points, int n);
101 
103  virtual void DrawQuadStrip(float *points, int n);
104 
106  virtual void DrawPolygon(float *, int);
107 
109 
115  virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy,
116  float inRx, float inRy, float startAngle,
117  float stopAngle);
119 
121 
124  virtual void DrawEllipticArc(float x, float y, float rX, float rY,
125  float startAngle, float stopAngle);
127 
128 
130  virtual void DrawString(float *point, const vtkStdString &string);
131 
133 
140  virtual void ComputeStringBounds(const vtkStdString &string,
141  float bounds[4]);
143 
145  virtual void DrawString(float *point, const vtkUnicodeString &string);
146 
148 
155  virtual void ComputeStringBounds(const vtkUnicodeString &string,
156  float bounds[4]);
158 
162  virtual void DrawMathTextString(float point[2], const vtkStdString &string);
163 
166  virtual void DrawImage(float p[2], float scale, vtkImageData *image);
167 
171  void DrawImage(const vtkRectf& pos, vtkImageData *image);
172 
174  virtual void SetColor4(unsigned char color[4]);
175 
177  virtual void SetColor(unsigned char color[3]);
178 
180  virtual void SetTexture(vtkImageData* image, int properties = 0);
181 
183  virtual void SetPointSize(float size);
184 
186  virtual void SetLineWidth(float width);
187 
189  virtual void SetLineType(int type);
190 
192  virtual void MultiplyMatrix(vtkMatrix3x3 *m);
193 
195  virtual void SetMatrix(vtkMatrix3x3 *m);
196 
198  virtual void GetMatrix(vtkMatrix3x3 *m);
199 
201  virtual void PushMatrix();
202 
204  virtual void PopMatrix();
205 
208  virtual void SetClipping(int *x);
209 
211  virtual void EnableClipping(bool enable);
212 
214  virtual void Begin(vtkViewport* viewport);
215 
217  virtual void End();
218 
222  virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
223 
228  virtual void BufferIdModeEnd();
229 
233  bool SetStringRendererToFreeType();
234 
237  bool SetStringRendererToQt();
238 
240  bool HasGLSL();
241 
243 
247 
251  virtual void ReleaseGraphicsResources(vtkWindow *window);
252 
253 //BTX
254 protected:
256  virtual ~vtkOpenGLContextDevice2D();
257 
259 
263  int GetNumberOfArcIterations(float rX,
264  float rY,
265  float startAngle,
266  float stopAngle);
268 
270  int Geometry[2];
271 
273  vtkRenderer *Renderer;
274 
276  vtkStringToImage *TextRenderer;
277 
279  bool InRender;
280 
282 
283  class Private;
284  Private *Storage;
286 
288  virtual bool LoadExtensions(vtkOpenGLExtensionManager *m);
289 
291  vtkOpenGLRenderWindow* RenderWindow;
292 
293 private:
294  vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
295  void operator=(const vtkOpenGLContextDevice2D &); // Not implemented.
296 
297  void AlignText(double orientation, float width, float height, float *p);
298 
304  vtkImageData *GetMarker(int shape, int size, bool highlight);
305 
306  class vtkMarkerCacheObject
307  {
308  public:
309  vtkTypeUInt64 Key;
310  vtkImageData *Value;
311  bool operator==(vtkTypeUInt64 key)
312  {
313  return this->Key == key;
314  }
315  };
316 
317  std::list<vtkMarkerCacheObject> MarkerCache;
318  int MaximumMarkerCacheSize;
319 
323  vtkImageData * GenerateMarker(int shape, int size, bool highlight);
324 
325 //ETX
326 };
327 
328 #endif //vtkOpenGLContextDevice2D_h
OpenGL rendering window.
GLsizeiptr size
Definition: vtkgl.h:11843
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
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
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:83
Class for drawing 2D primitives using OpenGL 1.1+.
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
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
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.
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
#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
Abstract class for drawing 2D primitives.
Interface class for querying and using OpenGL extensions.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
2D array of ids, used for picking.
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
GLboolean enable
Definition: vtkgl.h:18647
GLuint color
Definition: vtkgl.h:12351
GLclampd n
Definition: vtkgl.h:14370
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 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:69