10 #include "vtkAbstractContextItem.h"
11 #include "vtkContext2D.h"
12 #include "vtkImageData.h"
14 #include "vtkObjectFactory.h"
16 #include "vtkStdString.h"
23 : Initialized(false), DelegateDevice(
NULL) {
36 void vtkBoundingRectContextDevice2D::PrintSelf(ostream& os, vtkIndent indent) {
37 this->Superclass::PrintSelf(os, indent);
48 vtkAbstractContextItem* item, vtkViewport* viewport) {
49 if (!item || !viewport) {
53 vtkNew<vtkContextDevice2D> contextDevice;
54 vtkNew<vtkBoundingRectContextDevice2D> bbDevice;
55 bbDevice->SetDelegateDevice(contextDevice.Get());
56 bbDevice->Begin(viewport);
63 return bbDevice->GetBoundingRect();
73 const vtkStdString&
string) {
75 vtkWarningMacro(<<
"No DelegateDevice defined");
80 this->
DelegateDevice->ComputeJustifiedStringBounds(
string.c_str(), bounds);
82 this->
AddPoint(point[0] + bounds[0], point[1] + bounds[1]);
83 this->
AddPoint(point[0] + bounds[0] + bounds[2],
84 point[1] + bounds[1] + bounds[3]);
89 float* point,
const vtkStdString&
string) {
91 vtkWarningMacro(<<
"No DelegateDevice defined");
97 this->
DelegateDevice->ComputeJustifiedStringBounds(
string.c_str(), bounds);
99 this->
AddPoint(point[0] + bounds[0], point[1] + bounds[1]);
100 this->
AddPoint(point[0] + bounds[0] + bounds[2],
101 point[1] + bounds[1] + bounds[3]);
107 vtkImageData*
image) {
109 int* extent =
image->GetExtent();
110 this->
AddPoint(p[0] + scale * extent[1], p[1] + scale * extent[3]);
115 const vtkRectf& pos, vtkImageData* vtkNotUsed(
image)) {
116 this->
AddPoint(pos.GetX(), pos.GetY());
117 this->
AddPoint(pos.GetX() + pos.GetWidth(), pos.GetY() + pos.GetHeight());
265 unsigned char* vtkNotUsed(
colors),
266 int vtkNotUsed(nc_comps)) {
271 for (
int i = 0; i < n; ++i) {
280 unsigned char* vtkNotUsed(
colors),
281 int vtkNotUsed(nc_comps)) {
286 for (
int i = 0; i < n; ++i) {
293 vtkImageData* vtkNotUsed(sprite),
296 unsigned char* vtkNotUsed(
colors),
297 int vtkNotUsed(nc_comps)) {
304 float halfWidth = 0.5 * penWidth;
305 for (
int i = 0; i < n; ++i) {
308 this->
AddPoint(x - halfWidth,
y - halfWidth);
309 this->
AddPoint(x + halfWidth,
y - halfWidth);
310 this->
AddPoint(x - halfWidth,
y + halfWidth);
311 this->
AddPoint(x + halfWidth,
y + halfWidth);
317 bool vtkNotUsed(highlight),
338 if (outRy == 0.0f && outRx == 0.0f) {
344 while (startAngle <= stopAngle) {
345 double a = vtkMath::RadiansFromDegrees(startAngle);
360 while (startAngle <= stopAngle) {
361 double a = vtkMath::RadiansFromDegrees(startAngle);
369 const vtkStdString&
string,
float bounds[4]) {
377 const char*
string,
float bounds[4]) {
379 this->
DelegateDevice->ComputeJustifiedStringBounds(
string, bounds);
407 vtkAbstractContextBufferId* bufferId) {
422 float point[2] = {
x,
y};
432 this->
BoundingRect = vtkRectf(pt[0], pt[1], 0.0f, 0.0f);
std::shared_ptr< core::Tensor > image
void DrawLines(float *f, int n, unsigned char *colors=0, int nc_comps=0) override
void PopMatrix() override
void PushMatrix() override
void SetTexture(vtkImageData *image, int properties) override
void ComputeJustifiedStringBounds(const char *string, float bounds[4]) override
void AddPoint(float x, float y)
void ComputeStringBounds(const vtkStdString &string, float bounds[4]) override
bool GetBufferIdMode() const override
void SetClipping(int *x) override
vtkRectf GetBoundingRect()
vtkBoundingRectContextDevice2D()
void Begin(vtkViewport *) override
void SetMatrix(vtkMatrix3x3 *m) override
void BufferIdModeEnd() override
vtkPen * GetPen() override
~vtkBoundingRectContextDevice2D() override
void DrawImage(float p[2], float scale, vtkImageData *image) override
void DrawMathTextString(float *point, const vtkStdString &string) override
void ApplyTextProp(vtkTextProperty *prop) override
void BufferIdModeBegin(vtkAbstractContextBufferId *bufferId) override
void AddRect(const vtkRectf &rect)
void DrawString(float *point, const vtkStdString &string) override
void SetPointSize(float size) override
void DrawPointSprites(vtkImageData *sprite, float *points, int n, unsigned char *colors=0, int nc_comps=0) override
void EnableClipping(bool enable) override
void ApplyPen(vtkPen *pen) override
void DrawPoly(float *points, int n, unsigned char *colors=0, int nc_comps=0) override
void DrawEllipticArc(float x, float y, float rX, float rY, float startAngle, float stopAngle) override
void ApplyBrush(vtkBrush *brush) override
void DrawPoints(float *points, int n, unsigned char *colors=0, int nc_comps=0) override
void SetLineWidth(float width) override
void DrawEllipseWedge(float x, float y, float outRx, float outRy, float inRx, float inRy, float startAngle, float stopAngle) override
vtkContextDevice2D * DelegateDevice
void MultiplyMatrix(vtkMatrix3x3 *m) override
vtkTextProperty * GetTextProp() override
void SetColor4(unsigned char color[4]) override
void GetMatrix(vtkMatrix3x3 *m) override
vtkBrush * GetBrush() override
void SetLineType(int type) override
void DrawMarkers(int shape, bool highlight, float *points, int n, unsigned char *colors=0, int nc_comps=0) override
vtkStandardNewMacro(vtkBoundingRectContextDevice2D) vtkBoundingRectContextDevice2D