codac 2.0.0
Loading...
Searching...
No Matches
codac2_Figure2D_IPE.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <vector>
13#include <fstream>
14#include "codac2_Figure2D.h"
16#include "codac2_Vector.h"
18#include "codac2_Ellipsoid.h"
19#include "vibes.h"
20
21namespace codac2
22{
30 {
31 public:
32
39
43 virtual ~Figure2D_IPE();
44
49
54
59
66 void center_viewbox(const Vector& c, const Vector& r);
67
73 void clear();
74
81 void begin_path(const StyleProperties& style,bool tip = false);
82
83 /* For future doc:
84 https://github.com/codac-team/codac/pull/126#discussion_r1829030491
85 Pour les véhicules (draw_tank et draw_AUV) le header par défaut du begin_path n'est pas suffisant.
86 J'ai donc ajouté cette fonction qui fait le même travail que le begin_path, avec en plus le champ
87 "matrix" complété.
88 Ce champ contient 6 valeurs : les 4 premières sont la matrice de transformation 2D, rotation et
89 dilatation, "par colonne" (i.e. m11, m21, m12, m22) et les 2 autres valeurs sont la translation.
90 Le tout permet de scale le véhicule, l'orienter et le déplacer au bon endroit.
91 Cette fonction écrit dans le xml quelque chose dans le style :
92 <path layer="alpha"
93 stroke="codac_color_000000"
94 fill="codac_color_ffd32a"
95 opacity="100%"
96 stroke-opacity="100%"
97 pen="heavier"
98 matrix="0.00948009 11.9048 -11.9047 0.00948009 166.667 166.667">
99 */
100
108 void begin_path_with_matrix(const Vector& x, float length, const StyleProperties& style = StyleProperties());
109
118 void draw_text(const Vector& c, const Vector& r, const std::string& text, const StyleProperties& style = StyleProperties());
119
123 void draw_axes();
124
125 // Geometric shapes
126
133 void draw_point(const Vector& c, const StyleProperties& style = StyleProperties());
134
141 void draw_box(const IntervalVector& x, const StyleProperties& style = StyleProperties());
142
150 void draw_circle(const Vector& c, double r, const StyleProperties& style = StyleProperties());
151
159 void draw_ring(const Vector& c, const Interval& r, const StyleProperties& style = StyleProperties());
160
168 void draw_polyline(const std::vector<Vector>& x, float tip_length, const StyleProperties& style = StyleProperties());
169
176 void draw_polygon(const std::vector<Vector>& x, const StyleProperties& style = StyleProperties());
177
186 void draw_pie(const Vector& c, const Interval& r, const Interval& theta, const StyleProperties& style = StyleProperties());
187
196 void draw_ellipse(const Vector& c, const Vector& ab, double theta, const StyleProperties& style = StyleProperties());
197
198 // Robots
199
207 void draw_tank(const Vector& x, float size, const StyleProperties& style = StyleProperties());
208
216 void draw_AUV(const Vector& x, float size, const StyleProperties& style = StyleProperties());
217
225 void draw_motor_boat(const Vector& x, float size, const StyleProperties& style = StyleProperties());
226
227 protected:
228
229 double scale_x(double x) const;
230 double scale_y(double y) const;
231 double scale_length(double y) const;
232 void print_header_page();
233
234 std::ofstream _f, _f_temp_content;
235 const double _ipe_grid_size = 500.;
236 Vector _ratio { 1., 1. };
237
238 std::vector<double> _x_ticks;
239 std::vector<double> _y_ticks;
240 double _x_offset;
241 double _y_offset;
242
243 std::map<std::string,Color> _colors;
244 };
245}
void begin_path(const StyleProperties &style, bool tip=false)
Begins a new path in the IPE file.
void draw_polygon(const std::vector< Vector > &x, const StyleProperties &style=StyleProperties())
Draws a polygone on the figure.
void draw_circle(const Vector &c, double r, const StyleProperties &style=StyleProperties())
Draws a circle on the figure.
void draw_motor_boat(const Vector &x, float size, const StyleProperties &style=StyleProperties())
Draws a motor boat on the figure.
void draw_box(const IntervalVector &x, const StyleProperties &style=StyleProperties())
Draws a box on the figure.
void draw_text(const Vector &c, const Vector &r, const std::string &text, const StyleProperties &style=StyleProperties())
Draws a text on the figure.
void draw_point(const Vector &c, const StyleProperties &style=StyleProperties())
Draws a point on the figure.
void draw_ring(const Vector &c, const Interval &r, const StyleProperties &style=StyleProperties())
Draws a ring on the figure.
void begin_path_with_matrix(const Vector &x, float length, const StyleProperties &style=StyleProperties())
Begins a new path in the IPE file with a transformation matrix, used for vehicles.
void update_axes()
Updates the axes of the figure.
void draw_AUV(const Vector &x, float size, const StyleProperties &style=StyleProperties())
Draws an AUV on the figure.
void clear()
Clears the figure.
void draw_pie(const Vector &c, const Interval &r, const Interval &theta, const StyleProperties &style=StyleProperties())
Draws a pie on the figure.
void draw_axes()
Draws the axes of the figure.
Figure2D_IPE(const Figure2D &fig)
Creates a new Figure2D_IPE object linked to a given figure.
void draw_ellipse(const Vector &c, const Vector &ab, double theta, const StyleProperties &style=StyleProperties())
Draws an ellipse on the figure.
void draw_polyline(const std::vector< Vector > &x, float tip_length, const StyleProperties &style=StyleProperties())
Draws a polyline on the figure.
void update_window_properties()
Updates the drawing properties : colors, line style, line width and layer.
void center_viewbox(const Vector &c, const Vector &r)
Centers the viewbox on a given point with a given radius.
virtual ~Figure2D_IPE()
Destructor for the Figure2D_IPE object.
void init_figure()
Initializes the figure.
void draw_tank(const Vector &x, float size, const StyleProperties &style=StyleProperties())
Draws a tank on the figure.
Figure2D class, used for 2D display.
Definition codac2_Figure2D.h:78
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
OutputFigure2D(const Figure2D &fig)
Creates a new OutputFigure2D object linked to a given figure.
Definition codac2_OutputFigure2D.h:39
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
Style properties structure, to specify the style of a shape.
Definition codac2_StyleProperties.h:26