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 DrawLines(float *f, int n, unsigned char *colors = 0,
66  int nc_comps = 0);
68 
70 
73  virtual void DrawPoints(float *points, int n, unsigned char* colors = 0,
74  int nc_comps = 0);
76 
78 
83  virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
84  unsigned char* colors = 0, int nc_comps = 0);
86 
88 
94  virtual void DrawMarkers(int shape, bool highlight, float *points, int n,
95  unsigned char *colors = 0, int nc_comps = 0);
97 
99 
103  vtkSetMacro(MaximumMarkerCacheSize, int)
104  vtkGetMacro(MaximumMarkerCacheSize, int)
106 
108  virtual void DrawQuad(float *points, int n);
109 
111  virtual void DrawQuadStrip(float *points, int n);
112 
114  virtual void DrawPolygon(float *, int);
115 
117 
123  virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy,
124  float inRx, float inRy, float startAngle,
125  float stopAngle);
127 
129 
132  virtual void DrawEllipticArc(float x, float y, float rX, float rY,
133  float startAngle, float stopAngle);
135 
136 
138  virtual void DrawString(float *point, const vtkStdString &string);
139 
141 
148  virtual void ComputeStringBounds(const vtkStdString &string,
149  float bounds[4]);
151 
153  virtual void DrawString(float *point, const vtkUnicodeString &string);
154 
156 
163  virtual void ComputeStringBounds(const vtkUnicodeString &string,
164  float bounds[4]);
166 
170  virtual void DrawMathTextString(float point[2], const vtkStdString &string);
171 
174  virtual void DrawImage(float p[2], float scale, vtkImageData *image);
175 
179  void DrawImage(const vtkRectf& pos, vtkImageData *image);
180 
182  virtual void SetColor4(unsigned char color[4]);
183 
185  virtual void SetColor(unsigned char color[3]);
186 
188  virtual void SetTexture(vtkImageData* image, int properties = 0);
189 
191  virtual void SetPointSize(float size);
192 
194  virtual void SetLineWidth(float width);
195 
197  virtual void SetLineType(int type);
198 
200  virtual void MultiplyMatrix(vtkMatrix3x3 *m);
201 
203  virtual void SetMatrix(vtkMatrix3x3 *m);
204 
206  virtual void GetMatrix(vtkMatrix3x3 *m);
207 
209  virtual void PushMatrix();
210 
212  virtual void PopMatrix();
213 
216  virtual void SetClipping(int *x);
217 
219  virtual void EnableClipping(bool enable);
220 
222  virtual void Begin(vtkViewport* viewport);
223 
225  virtual void End();
226 
230  virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
231 
236  virtual void BufferIdModeEnd();
237 
241  bool SetStringRendererToFreeType();
242 
245  bool SetStringRendererToQt();
246 
248  bool HasGLSL();
249 
251 
255 
259  virtual void ReleaseGraphicsResources(vtkWindow *window);
260 
261 //BTX
262 protected:
264  virtual ~vtkOpenGLContextDevice2D();
265 
267 
271  int GetNumberOfArcIterations(float rX,
272  float rY,
273  float startAngle,
274  float stopAngle);
276 
278  int Geometry[2];
279 
281  vtkRenderer *Renderer;
282 
284  vtkStringToImage *TextRenderer;
285 
287  bool InRender;
288 
290 
291  class Private;
292  Private *Storage;
294 
296  virtual bool LoadExtensions(vtkOpenGLExtensionManager *m);
297 
299  vtkOpenGLRenderWindow* RenderWindow;
300 
301 private:
302  vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
303  void operator=(const vtkOpenGLContextDevice2D &); // Not implemented.
304 
305  void AlignText(double orientation, float width, float height, float *p);
306 
312  vtkImageData *GetMarker(int shape, int size, bool highlight);
313 
314  class vtkMarkerCacheObject
315  {
316  public:
317  vtkTypeUInt64 Key;
318  vtkImageData *Value;
319  bool operator==(vtkTypeUInt64 key)
320  {
321  return this->Key == key;
322  }
323  };
324 
325  std::list<vtkMarkerCacheObject> MarkerCache;
326  int MaximumMarkerCacheSize;
327 
331  vtkImageData * GenerateMarker(int shape, int size, bool highlight);
332 
333 //ETX
334 };
335 
336 #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
#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()
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
#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.
#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.
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:79