12 #include "vtkObjectFactory.h"
13 #include "vtkViewport.h"
16 #if defined(DEBUG_BOUNDING_BOX)
18 #include "vtkContext2D.h"
19 #include "vtkContextDevice2D.h"
38 vtkContext2DScalarBarActor::SafeDownCast(this->GetScalarBarActor());
41 <<
"Actor expected to be of type vtkContext2DScalarBarActor");
47 #if defined(DEBUG_BOUNDING_BOX)
49 vtkNew<vtkContextDevice2D> contextDevice;
50 contextDevice->Begin(viewport);
51 context->Begin(contextDevice.Get());
52 vtkPen* pen =
context->GetPen();
53 pen->SetColor(255, 255, 255);
54 vtkBrush* brush =
context->GetBrush();
55 brush->SetOpacityF(0.0);
56 double xx = this->PositionCoordinate->GetValue()[0];
57 double yy = this->PositionCoordinate->GetValue()[1];
58 viewport->NormalizedViewportToViewport(xx, yy);
59 viewport->ViewportToNormalizedDisplay(xx, yy);
60 viewport->NormalizedDisplayToDisplay(xx, yy);
61 context->DrawRect(xx + boundingRect.GetX(), yy + boundingRect.GetY(),
62 boundingRect.GetWidth(), boundingRect.GetHeight());
68 int* displaySize = viewport->GetSize();
81 x = displaySize[0] - 1.0 - boundingRect.GetWidth() - pad;
86 x = 0.5 * (displaySize[0] - boundingRect.GetWidth());
92 y = displaySize[1] - 1.0 - boundingRect.GetHeight() - pad;
96 x = displaySize[0] - 1.0 - boundingRect.GetWidth() - pad;
97 y = displaySize[1] - 1.0 - boundingRect.GetHeight() - pad;
101 x = 0.5 * (displaySize[0] - boundingRect.GetWidth());
102 y = displaySize[1] - 1.0 - boundingRect.GetHeight() - pad;
108 x -= boundingRect.GetX();
109 y -= boundingRect.GetY();
111 viewport->DisplayToNormalizedDisplay(
x,
y);
113 this->PositionCoordinate->SetValue(
x,
y);
116 return this->Superclass::RenderOverlay(viewport);
120 void vtkScalarBarRepresentationCustom::PrintSelf(ostream& os,
122 this->Superclass::PrintSelf(os, indent);
124 os << indent <<
"WindowLocation: ";
131 os <<
"LowerLeftCorner";
135 os <<
"LowerRightCorner";
143 os <<
"UpperLeftCorner";
147 os <<
"UpperRightCorner";
vtkRectf GetBoundingRect()
~vtkScalarBarRepresentationCustom() override
vtkScalarBarRepresentationCustom()
int RenderOverlay(vtkViewport *) override
QTextStream & endl(QTextStream &stream)
vtkStandardNewMacro(vtkScalarBarRepresentationCustom)