39 #ifndef PCL_VISUALUALIZATION_PCL_PAINTER2D_H_ 40 #define PCL_VISUALUALIZATION_PCL_PAINTER2D_H_ 45 #include <pcl/pcl_exports.h> 46 #include <vtkRenderer.h> 47 #include <vtkRenderWindow.h> 48 #include <vtkRenderWindowInteractor.h> 49 #include <vtkSmartPointer.h> 50 #include <vtkObjectFactory.h> 51 #include <vtkContext2D.h> 52 #include <vtkTransform2D.h> 53 #include <vtkContextItem.h> 54 #include <vtkContextView.h> 55 #include <vtkContextScene.h> 58 #include <vtkTextProperty.h> 59 #include <vtkOpenGLContextDevice2D.h> 60 #include <vtkPoints2D.h> 61 #include "vtkCommand.h" 65 namespace visualization
79 Figure2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t)
81 this->pen_ = vtkPen::New ();
82 this->brush_ = vtkBrush::New ();
83 this->transform_ = vtkTransform2D::New();
85 this->pen_->DeepCopy (p);
86 this->brush_->DeepCopy (b);
87 this->transform_->SetMatrix (t->GetMatrix());
91 Figure2D (vtkPen *p, vtkBrush * b, vtkTransform2D *t)
93 this->pen_ = vtkPen::New ();
94 this->brush_ = vtkBrush::New ();
95 this->transform_ = vtkTransform2D::New();
97 this->pen_->DeepCopy (p);
98 this->brush_->DeepCopy (b);
99 this->transform_->SetMatrix (t->GetMatrix());
104 painter->ApplyPen (
pen_);
105 painter->ApplyBrush (
brush_);
106 painter->GetDevice ()->SetMatrix (
transform_->GetMatrix());
109 virtual void draw (vtkContext2D *) {}
117 FPolyLine2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
119 void draw (vtkContext2D * painter)
122 painter->DrawPoly (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
131 FPoints2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
133 void draw (vtkContext2D * painter)
136 painter->DrawPoints (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
145 FQuad2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t) {}
147 void draw (vtkContext2D * painter)
150 painter->DrawQuad (&
info_[0]);
159 FPolygon2D (std::vector<float> info, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (info, p, b, t){}
161 void draw (vtkContext2D * painter)
164 painter->DrawPolygon (&
info_[0], static_cast<unsigned int> (
info_.size ()) / 2);
175 FEllipticArc2D (
float x,
float y,
float rx,
float ry,
float sa,
float ea, vtkPen *p, vtkBrush * b, vtkTransform2D *t) :
Figure2D (p, b, t)
186 void draw (vtkContext2D * painter)
214 Paint (vtkContext2D *painter);
223 addLine (
float x1,
float y1,
float x2,
float y2);
229 addLine (std::vector<float> p);
237 addPoint (
float x,
float y);
243 addPoints (std::vector<float> points);
253 addRect (
float x,
float y,
float width,
float height);
259 addQuad (std::vector<float> p);
265 addPolygon (std::vector<float> p);
275 addEllipse (
float x,
float y,
float rx,
float ry);
283 addCircle (
float x,
float y,
float r);
294 addEllipticArc (
float x,
float y,
float rx,
float ry,
float start_angle,
float end_angle);
304 addArc (
float x,
float y,
float r,
float start_angle,
float end_angle);
312 translatePen (
double x,
double y);
318 rotatePen(
double angle);
325 scalePen(
double x,
double y);
331 setTransform(vtkMatrix3x3 *matrix);
350 void setPenColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
351 void setPenWidth (
float w);
352 void setPenType (
int type);
356 unsigned char* getPenColor ();
357 float getPenWidth ();
359 void setPen (vtkPen *pen);
364 void setBrush (vtkBrush *brush);
365 vtkBrush* getBrush ();
366 void setBrushColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
367 unsigned char* getBrushColor ();
375 setBackgroundColor (
const double r,
const double g,
const double b);
381 setBackgroundColor (
const double color[3]);
387 getBackgroundColor ();
395 setWindowSize (
int w,
int h);
410 void spinOnce (
const int spin_time = 0 );
420 std::vector<Figure2D *> figures_;
423 vtkPen *current_pen_;
424 vtkBrush *current_brush_;
425 vtkTransform2D *current_transform_;
426 int win_width_, win_height_;
427 double bkg_color_[3];
429 vtkContextView *view_;
432 struct ExitMainLoopTimerCallback :
public vtkCommand
434 static ExitMainLoopTimerCallback* New ()
436 return (
new ExitMainLoopTimerCallback);
439 Execute (vtkObject* vtkNotUsed (caller),
unsigned long event_id,
void* call_data)
441 if (event_id != vtkCommand::TimerEvent)
443 int timer_id = *(reinterpret_cast<int*> (call_data));
445 if (timer_id != right_timer_id)
449 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 450 interactor->stopLoop ();
452 interactor->TerminateApp ();
456 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4)) 459 vtkRenderWindowInteractor *interactor;
void draw(vtkContext2D *painter)
void draw(vtkContext2D *painter)
The PCLVisualizer interactor.
FQuad2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
PCL Painter2D main class.
void draw(vtkContext2D *painter)
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)
FEllipticArc2D(float x, float y, float rx, float ry, float sa, float ea, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void draw(vtkContext2D *painter)
FEllipticArc2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
Class for storing EllipticArc; every ellipse , circle are covered by this.
FPolygon2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)