VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkOpenGLContextDevice2D.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 00032 #ifndef __vtkOpenGLContextDevice2D_h 00033 #define __vtkOpenGLContextDevice2D_h 00034 00035 #include "vtkRenderingContext2DModule.h" // For export macro 00036 #include "vtkContextDevice2D.h" 00037 00038 #include <list> // for std::list 00039 00040 class vtkWindow; 00041 class vtkViewport; 00042 class vtkRenderer; 00043 class vtkStringToImage; 00044 class vtkOpenGLRenderWindow; 00045 class vtkOpenGLExtensionManager; 00046 00047 class VTKRENDERINGCONTEXT2D_EXPORT vtkOpenGLContextDevice2D : public vtkContextDevice2D 00048 { 00049 public: 00050 vtkTypeMacro(vtkOpenGLContextDevice2D, vtkContextDevice2D); 00051 virtual void PrintSelf(ostream &os, vtkIndent indent); 00052 00054 static vtkOpenGLContextDevice2D *New(); 00055 00057 00060 virtual void DrawPoly(float *f, int n, unsigned char *colors = 0, 00061 int nc_comps = 0); 00063 00065 00068 virtual void DrawPoints(float *points, int n, unsigned char* colors = 0, 00069 int nc_comps = 0); 00071 00073 00078 virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n, 00079 unsigned char* colors = 0, int nc_comps = 0); 00081 00083 00089 virtual void DrawMarkers(int shape, bool highlight, float *points, int n, 00090 unsigned char *colors = 0, int nc_comps = 0); 00092 00094 00098 vtkSetMacro(MaximumMarkerCacheSize, int) 00099 vtkGetMacro(MaximumMarkerCacheSize, int) 00101 00103 virtual void DrawQuad(float *points, int n); 00104 00106 virtual void DrawQuadStrip(float *points, int n); 00107 00109 virtual void DrawPolygon(float *, int); 00110 00112 00118 virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy, 00119 float inRx, float inRy, float startAngle, 00120 float stopAngle); 00122 00124 00127 virtual void DrawEllipticArc(float x, float y, float rX, float rY, 00128 float startAngle, float stopAngle); 00130 00131 00133 virtual void DrawString(float *point, const vtkStdString &string); 00134 00136 00143 virtual void ComputeStringBounds(const vtkStdString &string, 00144 float bounds[4]); 00146 00148 virtual void DrawString(float *point, const vtkUnicodeString &string); 00149 00151 00158 virtual void ComputeStringBounds(const vtkUnicodeString &string, 00159 float bounds[4]); 00161 00165 virtual void DrawMathTextString(float point[2], const vtkStdString &string); 00166 00169 virtual void DrawImage(float p[2], float scale, vtkImageData *image); 00170 00174 void DrawImage(const vtkRectf& pos, vtkImageData *image); 00175 00177 virtual void SetColor4(unsigned char color[4]); 00178 00180 virtual void SetColor(unsigned char color[3]); 00181 00183 virtual void SetTexture(vtkImageData* image, int properties = 0); 00184 00186 virtual void SetPointSize(float size); 00187 00189 virtual void SetLineWidth(float width); 00190 00192 virtual void SetLineType(int type); 00193 00195 virtual void MultiplyMatrix(vtkMatrix3x3 *m); 00196 00198 virtual void SetMatrix(vtkMatrix3x3 *m); 00199 00201 virtual void GetMatrix(vtkMatrix3x3 *m); 00202 00204 virtual void PushMatrix(); 00205 00207 virtual void PopMatrix(); 00208 00211 virtual void SetClipping(int *x); 00212 00214 virtual void EnableClipping(bool enable); 00215 00217 virtual void Begin(vtkViewport* viewport); 00218 00220 virtual void End(); 00221 00225 virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId); 00226 00231 virtual void BufferIdModeEnd(); 00232 00236 bool SetStringRendererToFreeType(); 00237 00240 bool SetStringRendererToQt(); 00241 00243 bool HasGLSL(); 00244 00246 00248 vtkGetObjectMacro(RenderWindow, vtkOpenGLRenderWindow); 00250 00254 virtual void ReleaseGraphicsResources(vtkWindow *window); 00255 00256 //BTX 00257 protected: 00258 vtkOpenGLContextDevice2D(); 00259 virtual ~vtkOpenGLContextDevice2D(); 00260 00262 00266 int GetNumberOfArcIterations(float rX, 00267 float rY, 00268 float startAngle, 00269 float stopAngle); 00271 00273 int Geometry[2]; 00274 00276 vtkRenderer *Renderer; 00277 00279 vtkStringToImage *TextRenderer; 00280 00282 bool InRender; 00283 00285 00286 class Private; 00287 Private *Storage; 00289 00291 virtual bool LoadExtensions(vtkOpenGLExtensionManager *m); 00292 00294 vtkOpenGLRenderWindow* RenderWindow; 00295 00296 private: 00297 vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented. 00298 void operator=(const vtkOpenGLContextDevice2D &); // Not implemented. 00299 00300 void AlignText(double orientation, float width, float height, float *p); 00301 00307 vtkImageData *GetMarker(int shape, int size, bool highlight); 00308 00309 class vtkMarkerCacheObject 00310 { 00311 public: 00312 vtkTypeUInt64 Key; 00313 vtkImageData *Value; 00314 bool operator==(vtkTypeUInt64 key) 00315 { 00316 return this->Key == key; 00317 } 00318 }; 00319 00320 std::list<vtkMarkerCacheObject> MarkerCache; 00321 int MaximumMarkerCacheSize; 00322 00326 vtkImageData * GenerateMarker(int shape, int size, bool highlight); 00327 00328 //ETX 00329 }; 00330 00331 #endif //__vtkOpenGLContextDevice2D_h