00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00032 #ifndef __vtkContext2D_h
00033 #define __vtkContext2D_h
00034
00035 #include "vtkObject.h"
00036
00037 class vtkWindow;
00038
00039 class vtkStdString;
00040 class vtkUnicodeString;
00041 class vtkTextProperty;
00042
00043 class vtkPoints2D;
00044 class vtkVector2f;
00045 class vtkRectf;
00046 class vtkUnsignedCharArray;
00047 class vtkContextDevice2D;
00048 class vtkPen;
00049 class vtkBrush;
00050 class vtkImageData;
00051 class vtkTransform2D;
00052 class vtkAbstractContextBufferId;
00053
00054 class VTK_CHARTS_EXPORT vtkContext2D : public vtkObject
00055 {
00056 public:
00057 vtkTypeMacro(vtkContext2D, vtkObject);
00058 virtual void PrintSelf(ostream &os, vtkIndent indent);
00059
00061 static vtkContext2D *New();
00062
00063
00067 bool Begin(vtkContextDevice2D *device);
00068
00069 vtkGetObjectMacro(Device, vtkContextDevice2D);
00070
00074 bool End();
00075
00078 bool GetBufferIdMode() const;
00079
00082 void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId);
00083
00087 void BufferIdModeEnd();
00088
00090 void DrawLine(float x1, float y1, float x2, float y2);
00091
00093 void DrawLine(float p[4]);
00094
00097 void DrawLine(vtkPoints2D *points);
00098
00100 void DrawPoly(float *x, float *y, int n);
00101
00104 void DrawPoly(vtkPoints2D *points);
00105
00109 void DrawPoly(float *points, int n);
00110
00112
00117 void DrawPoly(float *points, int n,
00118 unsigned char *colors, int nc_comps);
00120
00122 void DrawPoint(float x, float y);
00123
00125 void DrawPoints(float *x, float *y, int n);
00126
00129 void DrawPoints(vtkPoints2D *points);
00130
00134 void DrawPoints(float *points, int n);
00135
00139 void DrawPointSprites(vtkImageData *sprite, vtkPoints2D *points);
00140
00142
00147 void DrawPointSprites(vtkImageData *sprite, vtkPoints2D *points,
00148 vtkUnsignedCharArray *colors);
00149 void DrawPointSprites(vtkImageData *sprite, float *points, int n,
00150 unsigned char *colors, int nc_comps);
00152
00156 void DrawPointSprites(vtkImageData *sprite, float *points, int n);
00157
00159 void DrawRect(float x, float y, float w, float h);
00160
00162
00164 void DrawQuad(float x1, float y1, float x2, float y2,
00165 float x3, float y3, float x4, float y4);
00166 void DrawQuad(float *p);
00168
00170
00171 void DrawQuadStrip(vtkPoints2D *points);
00172 void DrawQuadStrip(float *p, int n);
00174
00177 void DrawPolygon(float *x, float *y, int n);
00178
00181 void DrawPolygon(vtkPoints2D *points);
00182
00186 void DrawPolygon(float *points, int n);
00187
00190 void DrawEllipse(float x, float y, float rx, float ry);
00191
00193
00198 void DrawWedge(float x, float y, float outRadius,
00199 float inRadius,float startAngle,
00200 float stopAngle);
00202
00204
00210 void DrawEllipseWedge(float x, float y, float outRx, float outRy,
00211 float inRx, float inRy, float startAngle,
00212 float stopAngle);
00214
00215
00217
00220 void DrawArc(float x, float y, float r, float startAngle,
00221 float stopAngle);
00223
00225
00228 void DrawEllipticArc(float x, float y, float rX, float rY, float startAngle,
00229 float stopAngle);
00231
00232
00234 void DrawImage(float x, float y, vtkImageData *image);
00235
00238 void DrawImage(float x, float y, float scale, vtkImageData *image);
00239
00243 void DrawImage(const vtkRectf& pos, vtkImageData *image);
00244
00246
00249 void DrawStringRect(vtkPoints2D *rect, const vtkStdString &string);
00250 void DrawStringRect(vtkPoints2D *rect, const vtkUnicodeString &string);
00251 void DrawStringRect(vtkPoints2D *rect, const char* string);
00253
00255
00256 void DrawString(vtkPoints2D *point, const vtkStdString &string);
00257 void DrawString(float x, float y, const vtkStdString &string);
00258 void DrawString(vtkPoints2D *point, const vtkUnicodeString &string);
00259 void DrawString(float x, float y, const vtkUnicodeString &string);
00260 void DrawString(vtkPoints2D *point, const char* string);
00261 void DrawString(float x, float y, const char* string);
00263
00265
00270 void ComputeStringBounds(const vtkStdString &string, vtkPoints2D *bounds);
00271 void ComputeStringBounds(const vtkStdString &string, float bounds[4]);
00272 void ComputeStringBounds(const vtkUnicodeString &string, vtkPoints2D *bounds);
00273 void ComputeStringBounds(const vtkUnicodeString &string, float bounds[4]);
00274 void ComputeStringBounds(const char* string, vtkPoints2D *bounds);
00275 void ComputeStringBounds(const char* string, float bounds[4]);
00277
00282 void ApplyPen(vtkPen *pen);
00283
00287 vtkPen* GetPen();
00288
00293 void ApplyBrush(vtkBrush *brush);
00294
00297 vtkBrush* GetBrush();
00298
00302 void ApplyTextProp(vtkTextProperty *prop);
00303
00305 vtkTextProperty* GetTextProp();
00306
00310 void SetTransform(vtkTransform2D *transform);
00311
00313 vtkTransform2D* GetTransform();
00314
00319 void AppendTransform(vtkTransform2D *transform);
00320
00322
00324 void PushMatrix();
00325 void PopMatrix();
00327
00329 void ApplyId(vtkIdType id);
00330
00334 static int FloatToInt(float x);
00335
00336
00337 protected:
00338 vtkContext2D();
00339 ~vtkContext2D();
00340
00341 vtkContextDevice2D *Device;
00342 vtkTransform2D *Transform;
00343
00344 vtkAbstractContextBufferId *BufferId;
00345
00346 private:
00347 vtkContext2D(const vtkContext2D &);
00348 void operator=(const vtkContext2D &);
00349
00351 vtkVector2f CalculateTextPosition(vtkPoints2D* rect);
00352
00353
00354 };
00355
00356 inline int vtkContext2D::FloatToInt(float x)
00357 {
00358
00359
00360
00361
00362
00363
00364
00365
00366 float tol = 0.00390625;
00367 tol = (x >= 0 ? tol : -tol);
00368 return static_cast<int>(x + tol);
00369 }
00370
00371 #endif //__vtkContext2D_h