39 #ifndef PCL_VISUALUALIZATION_PCL_PAINTER2D_H_
40 #define PCL_VISUALUALIZATION_PCL_PAINTER2D_H_
45 #include <vtkRenderer.h>
46 #include <vtkRenderWindow.h>
47 #include <vtkRenderWindowInteractor.h>
48 #include <vtkSmartPointer.h>
49 #include <vtkObjectFactory.h>
50 #include <vtkContext2D.h>
51 #include <vtkTransform2D.h>
52 #include <vtkContextItem.h>
53 #include <vtkContextView.h>
54 #include <vtkContextScene.h>
57 #include <vtkTextProperty.h>
58 #include <vtkOpenGLContextDevice2D.h>
59 #include <vtkPoints2D.h>
60 #include "vtkCommand.h"
62 #include <vtkRegressionTestImage.h>
66 namespace visualization
80 Figure2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t)
82 this->
pen_ = vtkPen::New ();
83 this->
brush_ = vtkBrush::New ();
86 this->
pen_->DeepCopy (p);
87 this->
brush_->DeepCopy (b);
92 Figure2D (vtkPen *p, vtkBrush * b, vtkTransform2D *t)
94 this->
pen_ = vtkPen::New ();
95 this->
brush_ = vtkBrush::New ();
98 this->
pen_->DeepCopy (p);
99 this->
brush_->DeepCopy (b);
105 painter->ApplyPen (
pen_);
106 painter->ApplyBrush (
brush_);
107 painter->GetDevice ()->SetMatrix (
transform_->GetMatrix());
110 virtual void draw (vtkContext2D *) {}
118 FPolyLine2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
120 void draw (vtkContext2D * painter)
123 painter->DrawPoly (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
132 FPoints2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
134 void draw (vtkContext2D * painter)
137 painter->DrawPoints (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
146 FQuad2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
148 void draw (vtkContext2D * painter)
151 painter->DrawQuad (&
info_[0]);
160 FPolygon2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
162 void draw (vtkContext2D * painter)
165 painter->DrawPolygon (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
176 FEllipticArc2D (
float x,
float y,
float rx,
float ry,
float sa,
float ea, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (p, b, t)
187 void draw (vtkContext2D * painter)
215 Paint (vtkContext2D *painter);
224 addLine (
float x1,
float y1,
float x2,
float y2);
230 addLine (std::vector<float> p);
254 addRect (
float x,
float y,
float width,
float height);
260 addQuad (std::vector<float> p);
276 addEllipse (
float x,
float y,
float rx,
float ry);
295 addEllipticArc (
float x,
float y,
float rx,
float ry,
float start_angle,
float end_angle);
305 addArc (
float x,
float y,
float r,
float start_angle,
float end_angle);
352 void setPenColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
361 void setPen (vtkPen *pen);
368 void setBrushColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
412 void spinOnce (
const int spin_time = 0 );
422 std::vector<Figure2D *> figures_;
425 vtkPen *current_pen_;
426 vtkBrush *current_brush_;
427 vtkTransform2D *current_transform_;
428 int win_width_, win_height_;
429 double bkg_color_[3];
431 vtkContextView *view_;
434 struct ExitMainLoopTimerCallback :
public vtkCommand
436 static ExitMainLoopTimerCallback* New ()
438 return (
new ExitMainLoopTimerCallback);
441 Execute (vtkObject* vtkNotUsed (caller),
unsigned long event_id,
void* call_data)
443 if (event_id != vtkCommand::TimerEvent)
445 int timer_id = *(
reinterpret_cast<int*
> (call_data));
447 if (timer_id != right_timer_id)
451 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
452 interactor->stopLoop ();
454 interactor->TerminateApp ();
458 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
461 vtkRenderWindowInteractor *interactor;