VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Charts
vtkContext2D.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkContext2D.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 __vtkContext2D_h
33
#define __vtkContext2D_h
34
35
#include "
vtkObject.h
"
36
37
class
vtkWindow
;
38
39
class
vtkStdString
;
40
class
vtkUnicodeString
;
41
class
vtkTextProperty
;
42
43
class
vtkPoints2D
;
44
class
vtkVector2f
;
45
class
vtkRectf
;
46
class
vtkUnsignedCharArray
;
47
class
vtkContextDevice2D
;
48
class
vtkPen
;
49
class
vtkBrush
;
50
class
vtkImageData
;
51
class
vtkTransform2D
;
52
class
vtkAbstractContextBufferId
;
53
54
class
VTK_CHARTS_EXPORT
vtkContext2D
:
public
vtkObject
55
{
56
public
:
57
vtkTypeMacro(
vtkContext2D
,
vtkObject
);
58
virtual
void
PrintSelf
(ostream &os,
vtkIndent
indent);
59
61
static
vtkContext2D
*
New
();
62
63
//BTX
67
bool
Begin(
vtkContextDevice2D
*device);
68
69
vtkGetObjectMacro(Device,
vtkContextDevice2D
);
70
74
bool
End();
75
78
bool
GetBufferIdMode()
const
;
79
82
void
BufferIdModeBegin(
vtkAbstractContextBufferId
*bufferId);
83
87
void
BufferIdModeEnd();
88
90
void
DrawLine(
float
x1,
float
y1,
float
x2,
float
y2);
91
93
void
DrawLine(
float
p[4]);
94
97
void
DrawLine(
vtkPoints2D
*
points
);
98
100
void
DrawPoly(
float
*x,
float
*y,
int
n);
101
104
void
DrawPoly(
vtkPoints2D
*
points
);
105
109
void
DrawPoly(
float
*
points
,
int
n);
110
112
117
void
DrawPoly(
float
*
points
,
int
n,
118
unsigned
char
*colors,
int
nc_comps);
120
122
void
DrawPoint(
float
x,
float
y);
123
125
void
DrawPoints(
float
*x,
float
*y,
int
n);
126
129
void
DrawPoints(
vtkPoints2D
*
points
);
130
134
void
DrawPoints(
float
*
points
,
int
n);
135
139
void
DrawPointSprites(
vtkImageData
*sprite,
vtkPoints2D
*
points
);
140
142
147
void
DrawPointSprites(
vtkImageData
*sprite,
vtkPoints2D
*
points
,
148
vtkUnsignedCharArray
*colors);
149
void
DrawPointSprites(
vtkImageData
*sprite,
float
*
points
,
int
n,
150
unsigned
char
*colors,
int
nc_comps);
152
156
void
DrawPointSprites(
vtkImageData
*sprite,
float
*
points
,
int
n);
157
159
void
DrawRect(
float
x,
float
y,
float
w,
float
h);
160
162
164
void
DrawQuad(
float
x1,
float
y1,
float
x2,
float
y2,
165
float
x3,
float
y3,
float
x4,
float
y4);
166
void
DrawQuad(
float
*p);
168
170
171
void
DrawQuadStrip(
vtkPoints2D
*
points
);
172
void
DrawQuadStrip(
float
*p,
int
n);
174
177
void
DrawPolygon(
float
*x,
float
*y,
int
n);
178
181
void
DrawPolygon(
vtkPoints2D
*
points
);
182
186
void
DrawPolygon(
float
*
points
,
int
n);
187
190
void
DrawEllipse(
float
x,
float
y,
float
rx,
float
ry);
191
193
198
void
DrawWedge(
float
x,
float
y,
float
outRadius,
199
float
inRadius,
float
startAngle
,
200
float
stopAngle);
202
204
210
void
DrawEllipseWedge(
float
x,
float
y,
float
outRx,
float
outRy,
211
float
inRx,
float
inRy,
float
startAngle
,
212
float
stopAngle);
214
215
217
220
void
DrawArc(
float
x,
float
y,
float
r,
float
startAngle
,
221
float
stopAngle);
223
225
228
void
DrawEllipticArc(
float
x,
float
y,
float
rX,
float
rY,
float
startAngle
,
229
float
stopAngle);
231
232
234
void
DrawImage(
float
x,
float
y,
vtkImageData
*
image
);
235
238
void
DrawImage(
float
x,
float
y,
float
scale
,
vtkImageData
*
image
);
239
243
void
DrawImage(
const
vtkRectf
& pos,
vtkImageData
*
image
);
244
246
249
void
DrawStringRect(
vtkPoints2D
*rect,
const
vtkStdString
&
string
);
250
void
DrawStringRect(
vtkPoints2D
*rect,
const
vtkUnicodeString
&
string
);
251
void
DrawStringRect(
vtkPoints2D
*rect,
const
char
*
string
);
253
255
256
void
DrawString(
vtkPoints2D
*
point
,
const
vtkStdString
&
string
);
257
void
DrawString(
float
x,
float
y,
const
vtkStdString
&
string
);
258
void
DrawString(
vtkPoints2D
*
point
,
const
vtkUnicodeString
&
string
);
259
void
DrawString(
float
x,
float
y,
const
vtkUnicodeString
&
string
);
260
void
DrawString(
vtkPoints2D
*
point
,
const
char
*
string
);
261
void
DrawString(
float
x,
float
y,
const
char
*
string
);
263
265
270
void
ComputeStringBounds(
const
vtkStdString
&
string
,
vtkPoints2D
*bounds);
271
void
ComputeStringBounds(
const
vtkStdString
&
string
,
float
bounds[4]);
272
void
ComputeStringBounds(
const
vtkUnicodeString
&
string
,
vtkPoints2D
*bounds);
273
void
ComputeStringBounds(
const
vtkUnicodeString
&
string
,
float
bounds[4]);
274
void
ComputeStringBounds(
const
char
*
string
,
vtkPoints2D
*bounds);
275
void
ComputeStringBounds(
const
char
*
string
,
float
bounds[4]);
277
282
void
ApplyPen(
vtkPen
*pen);
283
287
vtkPen
* GetPen();
288
293
void
ApplyBrush(
vtkBrush
*brush);
294
297
vtkBrush
* GetBrush();
298
302
void
ApplyTextProp(
vtkTextProperty
*prop);
303
305
vtkTextProperty
* GetTextProp();
306
310
void
SetTransform(
vtkTransform2D
*transform);
311
313
vtkTransform2D
* GetTransform();
314
319
void
AppendTransform(
vtkTransform2D
*transform);
320
322
324
void
PushMatrix();
325
void
PopMatrix();
327
329
void
ApplyId(
vtkIdType
id
);
330
334
static
int
FloatToInt(
float
x);
335
336
//BTX
337
protected
:
338
vtkContext2D
();
339
~
vtkContext2D
();
340
341
vtkContextDevice2D
*
Device
;
// The underlying device
342
vtkTransform2D
*
Transform
;
// Current transform
343
344
vtkAbstractContextBufferId
*
BufferId
;
345
346
private
:
347
vtkContext2D
(
const
vtkContext2D
&);
// Not implemented.
348
void
operator=(
const
vtkContext2D
&);
// Not implemented.
349
351
vtkVector2f
CalculateTextPosition(
vtkPoints2D
* rect);
352
353
//ETX
354
};
355
356
inline
int
vtkContext2D::FloatToInt
(
float
x)
357
{
358
// Use a tolerance of 1/256 of a pixel when converting.
359
// A float has only 24 bits of precision, so we cannot
360
// make the tolerance too small. For example, a tolerance
361
// of 2^-8 means that the tolerance will be significant
362
// for float values up to 2^16 or 65536.0. But a
363
// tolerance of 2^-16 would only be significant for
364
// float values up to 2^8 or 256.0. A small tolerance
365
// disappears into insignificance when added to a large float.
366
float
tol = 0.00390625;
// 1.0/256.0
367
tol = (x >= 0 ? tol : -tol);
368
return
static_cast<
int
>
(x + tol);
369
}
370
371
#endif //__vtkContext2D_h
Generated on Sun Sep 9 2012 13:03:25 for VTK by
1.8.1.2