Point Cloud Library (PCL)
1.11.1
|
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);
252 addRect (
float x,
float y,
float width,
float height);
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);
349 void setPenColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
365 void setBrushColor (
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a);
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;
unsigned char * getBrushColor()
int * getWindowSize() const
set/get method for the window size.
void draw(vtkContext2D *painter) override
void setPenColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
set/get methods for current working vtkPen
FPolygon2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
PCL Painter2D main class.
void addPoint(float x, float y)
Draw specified point(s).
void addPoints(std::vector< float > points)
Draw specified point(s).
PCLPainter2D(char const *name="PCLPainter2D")
Constructor of the class.
double * getBackgroundColor()
set/get method for the viewport's background color.
void rotatePen(double angle)
Create a rotation matrix and concatenate it with the current transformation.
void setBrush(vtkBrush *brush)
set/get methods for current working vtkBrush
void addRect(float x, float y, float width, float height)
Draw a rectangle based on the given points.
void addEllipse(float x, float y, float rx, float ry)
Draw an ellipse based on the inputs.
vtkMatrix3x3 * getTransform()
Returns the current transformation matrix.
void clearFigures()
remove all the figures from the window
void setBrushColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
FQuad2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void scalePen(double x, double y)
Create a scale matrix and concatenate it with the current transformation.
void draw(vtkContext2D *painter) override
void setBackgroundColor(const double r, const double g, const double b)
set/get method for the viewport's background color.
bool Paint(vtkContext2D *painter) override
Paint event for the chart, called whenever the chart needs to be drawn.
void addPolygon(std::vector< float > p)
Draw a polygon between the specified points.
void draw(vtkContext2D *painter) override
void setPenWidth(float w)
void addCircle(float x, float y, float r)
Draw a circle based on the inputs.
Class for storing Points.
void setWindowSize(int w, int h)
set/get method for the window size.
void addEllipticArc(float x, float y, float rx, float ry, float start_angle, float end_angle)
Draw an elliptic arc based on the inputs.
void setBackgroundColor(const double color[3])
set/get method for the viewport's background color.
void setPenType(int type)
void draw(vtkContext2D *painter) override
void setTransform(vtkMatrix3x3 *matrix)
Create a translation matrix and concatenate it with the current transformation.
Class for storing EllipticArc; every ellipse , circle are covered by this.
void spin()
spins (runs the event loop) the interactor indefinitely.
vtkTypeMacro(PCLPainter2D, vtkContextItem)
void translatePen(double x, double y)
Create a translation matrix and concatenate it with the current transformation.
FEllipticArc2D(float x, float y, float rx, float ry, float sa, float ea, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
FEllipticArc2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
FPoints2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void clearTransform()
Clears all the transformation applied.
void addLine(float x1, float y1, float x2, float y2)
Draw a line between the specified points.
void spinOnce(const int spin_time=0)
spins (runs the event loop) the interactor for spin_time amount of time.
FPolyLine2D(std::vector< float > info, vtkPen *p, vtkBrush *b, vtkTransform2D *t)
void display()
displays all the figures added in a window.
void addQuad(std::vector< float > p)
Draw a quadrilateral based on the given points.
void addArc(float x, float y, float r, float start_angle, float end_angle)
Draw an arc based on the inputs.
void addLine(std::vector< float > p)
Draw line(s) between the specified points.
void draw(vtkContext2D *painter) override
unsigned char * getPenColor()
set/get methods for current working vtkPen