VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.h
Go to the documentation of this file.
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 
00029 #ifndef vtkOpenGLContextDevice2D_h
00030 #define vtkOpenGLContextDevice2D_h
00031 
00032 #include "vtkRenderingContextOpenGL2Module.h" // For export macro
00033 #include "vtkContextDevice2D.h"
00034 
00035 #include <list> // for std::list
00036 
00037 class vtkWindow;
00038 class vtkViewport;
00039 class vtkRenderer;
00040 class vtkStringToImage;
00041 class vtkOpenGLRenderWindow;
00042 class vtkOpenGLExtensionManager;
00043 
00044 class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice2D : public vtkContextDevice2D
00045 {
00046 public:
00047   vtkTypeMacro(vtkOpenGLContextDevice2D, vtkContextDevice2D);
00048   virtual void PrintSelf(ostream &os, vtkIndent indent);
00049 
00051   static vtkOpenGLContextDevice2D *New();
00052 
00054 
00057   virtual void DrawPoly(float *f, int n, unsigned char *colors = 0,
00058                         int nc_comps = 0);
00060 
00062 
00065   virtual void DrawPoints(float *points, int n, unsigned char* colors = 0,
00066                           int nc_comps = 0);
00068 
00070 
00075   virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
00076                                 unsigned char* colors = 0, int nc_comps = 0);
00078 
00080 
00086   virtual void DrawMarkers(int shape, bool highlight, float *points, int n,
00087                            unsigned char *colors = 0, int nc_comps = 0);
00089 
00091 
00095   vtkSetMacro(MaximumMarkerCacheSize, int)
00096   vtkGetMacro(MaximumMarkerCacheSize, int)
00098 
00100   virtual void DrawQuad(float *points, int n);
00101 
00103   virtual void DrawQuadStrip(float *points, int n);
00104 
00106   virtual void DrawPolygon(float *, int);
00107 
00109 
00115   virtual void DrawEllipseWedge(float x, float y, float outRx, float outRy,
00116                                 float inRx, float inRy, float startAngle,
00117                                 float stopAngle);
00119 
00121 
00124   virtual void DrawEllipticArc(float x, float y, float rX, float rY,
00125                                float startAngle, float stopAngle);
00127 
00128 
00130   virtual void DrawString(float *point, const vtkStdString &string);
00131 
00133 
00140   virtual void ComputeStringBounds(const vtkStdString &string,
00141                                    float bounds[4]);
00143 
00145   virtual void DrawString(float *point, const vtkUnicodeString &string);
00146 
00148 
00155   virtual void ComputeStringBounds(const vtkUnicodeString &string,
00156                                    float bounds[4]);
00158 
00162   virtual void DrawMathTextString(float point[2], const vtkStdString &string);
00163 
00166   virtual void DrawImage(float p[2], float scale, vtkImageData *image);
00167 
00171   void DrawImage(const vtkRectf& pos, vtkImageData *image);
00172 
00174   virtual void SetColor4(unsigned char color[4]);
00175 
00177   virtual void SetColor(unsigned char color[3]);
00178 
00180   virtual void SetTexture(vtkImageData* image, int properties = 0);
00181 
00183   virtual void SetPointSize(float size);
00184 
00186   virtual void SetLineWidth(float width);
00187 
00189   virtual void SetLineType(int type);
00190 
00192   virtual void MultiplyMatrix(vtkMatrix3x3 *m);
00193 
00195   virtual void SetMatrix(vtkMatrix3x3 *m);
00196 
00198   virtual void GetMatrix(vtkMatrix3x3 *m);
00199 
00201   virtual void PushMatrix();
00202 
00204   virtual void PopMatrix();
00205 
00208   virtual void SetClipping(int *x);
00209 
00211   virtual void EnableClipping(bool enable);
00212 
00214   virtual void Begin(vtkViewport* viewport);
00215 
00217   virtual void End();
00218 
00222   virtual void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
00223 
00228   virtual void BufferIdModeEnd();
00229 
00233   bool SetStringRendererToFreeType();
00234 
00237   bool SetStringRendererToQt();
00238 
00240   bool HasGLSL();
00241 
00243 
00245   vtkGetObjectMacro(RenderWindow, vtkOpenGLRenderWindow);
00247 
00251   virtual void ReleaseGraphicsResources(vtkWindow *window);
00252 
00253 //BTX
00254 protected:
00255   vtkOpenGLContextDevice2D();
00256   virtual ~vtkOpenGLContextDevice2D();
00257 
00259 
00263   int GetNumberOfArcIterations(float rX,
00264                                float rY,
00265                                float startAngle,
00266                                float stopAngle);
00268 
00270   int Geometry[2];
00271 
00273   vtkRenderer *Renderer;
00274 
00276   vtkStringToImage *TextRenderer;
00277 
00279   bool InRender;
00280 
00282 
00283   class Private;
00284   Private *Storage;
00286 
00288   vtkOpenGLRenderWindow* RenderWindow;
00289 
00290 private:
00291   vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
00292   void operator=(const vtkOpenGLContextDevice2D &);   // Not implemented.
00293 
00294   void AlignText(double orientation, float width, float height, float *p);
00295 
00301   vtkImageData *GetMarker(int shape, int size, bool highlight);
00302 
00303   class vtkMarkerCacheObject
00304   {
00305   public:
00306     vtkTypeUInt64 Key;
00307     vtkImageData *Value;
00308     bool operator==(vtkTypeUInt64 key)
00309     {
00310       return this->Key == key;
00311     }
00312   };
00313 
00314   std::list<vtkMarkerCacheObject> MarkerCache;
00315   int MaximumMarkerCacheSize;
00316 
00320   vtkImageData * GenerateMarker(int shape, int size, bool highlight);
00321 
00322 //ETX
00323 };
00324 
00325 #endif //vtkOpenGLContextDevice2D_h