9 #include <vtkContext2D.h>
10 #include <vtkImageData.h>
11 #include <vtkObjectFactory.h>
13 #include <vtkSmartPointer.h>
14 #include <vtkTextProperty.h>
21 namespace visualization {
25 namespace context_items {
52 vtkImageData* _image) {
55 image->DeepCopy(_image);
61 painter->DrawImage(
x,
y,
image);
80 params[3] = radius - 1;
110 const std::string& _text) {
119 painter->GetBrush()->SetColor(
121 static_cast<unsigned char>((255.0 * GetOpacity())));
122 painter->GetPen()->SetColor(
124 static_cast<unsigned char>((255.0 * GetOpacity())));
125 painter->DrawWedge(params[0], params[1], params[2], params[3], 0.0, 360.0);
131 painter->GetBrush()->SetColor(
133 static_cast<unsigned char>((255.0 * GetOpacity())));
134 painter->GetPen()->SetColor(
136 static_cast<unsigned char>((255.0 * GetOpacity())));
137 painter->DrawEllipse(params[0], params[1], params[2], params[2]);
143 vtkContext2D* painter) {
144 painter->GetPen()->SetColor(
146 static_cast<unsigned char>((255.0 * GetOpacity())));
147 float p[] = {params[0], params[1], params[2], params[1], params[2],
148 params[3], params[0], params[3], params[0], params[1]};
150 painter->DrawPoly(p, 5);
156 vtkContext2D* painter) {
157 painter->GetBrush()->SetColor(
159 static_cast<unsigned char>((255.0 * GetOpacity())));
160 painter->GetPen()->SetColor(
162 static_cast<unsigned char>((255.0 * GetOpacity())));
163 painter->DrawRect(params[0], params[1], params[2], params[3]);
169 painter->GetPen()->SetColor(
171 static_cast<unsigned char>((255.0 * GetOpacity())));
172 painter->DrawLine(params[0], params[1], params[2], params[3]);
178 painter->GetBrush()->SetColor(
180 static_cast<unsigned char>((255.0 * GetOpacity())));
181 painter->GetPen()->SetColor(
183 static_cast<unsigned char>((255.0 * GetOpacity())));
184 painter->DrawPolygon(¶ms[0],
static_cast<int>(params.size() / 2));
190 painter->GetPen()->SetColor(
192 static_cast<unsigned char>((255.0 * GetOpacity())));
193 painter->DrawPoint(params[0], params[1]);
199 painter->GetPen()->SetColor(
201 static_cast<unsigned char>((255.0 * GetOpacity())));
202 painter->DrawPoints(¶ms[0],
static_cast<int>(params.size() / 2));
208 vtkTextProperty* text_property = painter->GetTextProp();
209 text_property->SetColor(255.0 *
colors[0], 255.0 *
colors[1],
211 text_property->SetOpacity(GetOpacity());
212 text_property->SetFontFamilyToArial();
213 text_property->SetFontSize(10);
214 text_property->SetJustificationToLeft();
215 text_property->BoldOff();
216 text_property->ShadowOff();
217 painter->DrawString(params[0], params[1], text.c_str());
223 unsigned char r,
unsigned char g,
unsigned char b) {
231 unsigned char rgb[3]) {
232 memcpy(point_colors,
rgb, 3 *
sizeof(
unsigned char));
237 int nb_points(params.size() / 2);
238 if (
size <= 0)
size = 2.3 * painter->GetPen()->GetWidth();
240 painter->GetPen()->SetWidth(
size);
241 painter->GetPen()->SetColor(
243 static_cast<unsigned char>((255.0 * GetOpacity())));
244 painter->DrawPointSprites(
nullptr, ¶ms[0], nb_points);
245 painter->GetPen()->SetWidth(1);
246 painter->GetPen()->SetColor(
247 point_colors[0], point_colors[1], point_colors[2],
248 static_cast<unsigned char>((255.0 * GetOpacity())));
249 painter->DrawPointSprites(
nullptr, ¶ms[0], nb_points);
std::shared_ptr< core::Tensor > image
vtkStandardNewMacro(Point)
vtkStandardNewMacro(ImageViewerInteractorStyle)
void set(float _x, float _y, vtkImageData *_image)
bool Paint(vtkContext2D *painter) override
void setColors(unsigned char r, unsigned char g, unsigned char b)
virtual void set(float _x, float _y, float _r)
bool Paint(vtkContext2D *painter) override
bool Paint(vtkContext2D *painter) override
bool Paint(vtkContext2D *painter) override
virtual void set(float _x_1, float _y_1, float _x_2, float _y_2)
bool Paint(vtkContext2D *painter) override
void setPointColors(unsigned char r, unsigned char g, unsigned char b)
bool Paint(vtkContext2D *painter) override
virtual void set(float _x, float _y)
bool Paint(vtkContext2D *painter) override
bool Paint(vtkContext2D *painter) override
bool Paint(vtkContext2D *painter) override
virtual void set(float _x, float _y, float _w, float _h)
bool Paint(vtkContext2D *painter) override
bool Paint(vtkContext2D *painter) override
virtual void set(float x, float y, const std::string &_text)