44 #include <pcl/pcl_exports.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" 64 namespace visualization
78 Figure2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t)
80 this->pen_ = vtkPen::New ();
81 this->brush_ = vtkBrush::New ();
82 this->transform_ = vtkTransform2D::New();
84 this->pen_->DeepCopy (p);
85 this->brush_->DeepCopy (b);
86 this->transform_->SetMatrix (t->GetMatrix());
90 Figure2D (vtkPen *p, vtkBrush * b, vtkTransform2D *t)
92 this->pen_ = vtkPen::New ();
93 this->brush_ = vtkBrush::New ();
94 this->transform_ = vtkTransform2D::New();
96 this->pen_->DeepCopy (p);
97 this->brush_->DeepCopy (b);
98 this->transform_->SetMatrix (t->GetMatrix());
103 painter->ApplyPen (
pen_);
104 painter->ApplyBrush (
brush_);
105 painter->GetDevice ()->SetMatrix (
transform_->GetMatrix());
108 virtual void draw (vtkContext2D *) {}
116 FPolyLine2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
118 void draw (vtkContext2D * painter)
override 121 painter->DrawPoly (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
130 FPoints2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
132 void draw (vtkContext2D * painter)
override 135 painter->DrawPoints (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
144 FQuad2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
146 void draw (vtkContext2D * painter)
override 149 painter->DrawQuad (&
info_[0]);
158 FPolygon2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
160 void draw (vtkContext2D * painter)
override 163 painter->DrawPolygon (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
174 FEllipticArc2D (
float x,
float y,
float rx,
float ry,
float sa,
float ea, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (p, b, t)
185 void draw (vtkContext2D * painter)
override 213 Paint (vtkContext2D *painter)
override;
222 addLine (
float x1,
float y1,
float x2,
float y2);
228 addLine (std::vector<float> p);
236 addPoint (
float x,
float y);
242 addPoints (std::vector<float> points);
252 addRect (
float x,
float y,
float width,
float height);
258 addQuad (std::vector<float> p);
264 addPolygon (std::vector<float> p);
274 addEllipse (
float x,
float y,
float rx,
float ry);
282 addCircle (
float x,
float y,
float r);
293 addEllipticArc (
float x,
float y,
float rx,
float ry,
float start_angle,
float end_angle);
303 addArc (
float x,
float y,
float r,
float start_angle,
float end_angle);
311 translatePen (
double x,
double y);
317 rotatePen(
double angle);
324 scalePen(
double x,
double y);
330 setTransform(vtkMatrix3x3 *matrix);
349 void setPenColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
350 void setPenWidth (
float w);
351 void setPenType (
int type);
355 unsigned char* getPenColor ();
356 float getPenWidth ();
358 void setPen (vtkPen *pen);
363 void setBrush (vtkBrush *brush);
364 vtkBrush* getBrush ();
365 void setBrushColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
366 unsigned char* getBrushColor ();
374 setBackgroundColor (
const double r,
const double g,
const double b);
380 setBackgroundColor (
const double color[3]);
386 getBackgroundColor ();
394 setWindowSize (
int w,
int h);
400 getWindowSize ()
const;
409 void spinOnce (
const int spin_time = 0 );
419 std::vector<Figure2D *> figures_;
422 vtkPen *current_pen_;
423 vtkBrush *current_brush_;
424 vtkTransform2D *current_transform_;
425 int win_width_, win_height_;
426 double bkg_color_[3];
428 vtkContextView *view_;
431 struct ExitMainLoopTimerCallback :
public vtkCommand
433 static ExitMainLoopTimerCallback* New ()
435 return (
new ExitMainLoopTimerCallback);
438 Execute (vtkObject* vtkNotUsed (caller),
unsigned long event_id,
void* call_data)
override 440 if (event_id != vtkCommand::TimerEvent)
442 int timer_id = *(
reinterpret_cast<int*
> (call_data));
444 if (timer_id != right_timer_id)
448 interactor->TerminateApp ();
451 vtkRenderWindowInteractor *interactor;
FQuad2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
PCL Painter2D main class.
void draw(vtkContext2D *painter) override
FPolyLine2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
Class for storing Points.
FPoints2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void draw(vtkContext2D *painter) override
FEllipticArc2D(float x, float y, float rx, float ry, float sa, float ea, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void draw(vtkContext2D *painter) override
FEllipticArc2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void draw(vtkContext2D *painter) override
Class for storing EllipticArc; every ellipse , circle are covered by this.
void draw(vtkContext2D *painter) override
FPolygon2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)