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 
256  vtkGetObjectMacro(RenderWindow, vtkOpenGLRenderWindow);
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 
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
OpenGL rendering window.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
abstract specification for Viewports
Definition: vtkViewport.h:46
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
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:36
#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
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.
vtkWeakPointer< vtkRenderWindow > RenderWindow
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.