codac 2.0.5
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
80 void save(const std::string& filename);
81
88 void begin_path(const StyleProperties& style,bool tip = false);
89
90 /* For future doc:
91 https://github.com/codac-team/codac/pull/126#discussion_r1829030491
92 Pour les véhicules (draw_tank et draw_AUV) le header par défaut du begin_path n'est pas suffisant.
93 J'ai donc ajouté cette fonction qui fait le même travail que le begin_path, avec en plus le champ
94 "matrix" complété.
95 Ce champ contient 6 valeurs : les 4 premières sont la matrice de transformation 2D, rotation et
96 dilatation, "par colonne" (i.e. m11, m21, m12, m22) et les 2 autres valeurs sont la translation.
97 Le tout permet de scale le véhicule, l'orienter et le déplacer au bon endroit.
98 Cette fonction écrit dans le xml quelque chose dans le style :
99 <path layer="alpha"
100 stroke="codac_color_000000"
101 fill="codac_color_ffd32a"
102 opacity="100%"
103 stroke-opacity="100%"
104 pen="heavier"
105 matrix="0.00948009 11.9048 -11.9047 0.00948009 166.667 166.667">
106 */
107
115 void begin_path_with_matrix(const Vector& x, float length, const StyleProperties& style = StyleProperties());
116
125 void draw_tick_label(const Vector& c, const Vector& r, const std::string& text, const StyleProperties& style = StyleProperties());
126
130 void draw_axes();
131
132 // Geometric shapes
133
140 void draw_point(const Vector& c, const StyleProperties& style = StyleProperties());
141
148 void draw_box(const IntervalVector& x, const StyleProperties& style = StyleProperties());
149
157 void draw_circle(const Vector& c, double r, const StyleProperties& style = StyleProperties());
158
166 void draw_ring(const Vector& c, const Interval& r, const StyleProperties& style = StyleProperties());
167
175 void draw_polyline(const std::vector<Vector>& x, float tip_length, const StyleProperties& style = StyleProperties());
176
183 void draw_polygon(const std::vector<Vector>& x, const StyleProperties& style = StyleProperties());
184
193 void draw_pie(const Vector& c, const Interval& r, const Interval& theta, const StyleProperties& style = StyleProperties());
194
203 void draw_ellipse(const Vector& c, const Vector& ab, double theta, const StyleProperties& style = StyleProperties());
204
205 // Robots
206
214 void draw_tank(const Vector& x, float size, const StyleProperties& style = StyleProperties());
215
223 void draw_AUV(const Vector& x, float size, const StyleProperties& style = StyleProperties());
224
232 void draw_motor_boat(const Vector& x, float size, const StyleProperties& style = StyleProperties());
233
234 // Miscellaneous
235
244 void draw_text(const std::string& text, const Vector& ul, double scale, const StyleProperties& style = StyleProperties());
245
253 void draw_raster(const std::string& filename, const IntervalVector& bbox, const StyleProperties& style = StyleProperties());
254
255 protected:
256
257 double scale_x(double x) const;
258 double scale_y(double y) const;
259 double scale_length(double y) const;
260 void print_header_page();
261
262 std::ofstream _f;
263 std::string _working_item;
264 std::multimap<double,std::string> _items;
265 const double _ipe_grid_size = 500.;
266 Vector _ratio { 1., 1. };
267
268 std::vector<double> _x_ticks;
269 std::vector<double> _y_ticks;
270 double _x_offset;
271 double _y_offset;
272
273 std::map<std::string,Color> _colors;
274 };
275}
void draw_text(const std::string &text, const Vector &ul, double scale, const StyleProperties &style=StyleProperties())
Draws text on the figure.
void draw_raster(const std::string &filename, const IntervalVector &bbox, const StyleProperties &style=StyleProperties())
Draws a the bounding box and the name of the raster on the figure.
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_point(const Vector &c, const StyleProperties &style=StyleProperties())
Draws a point on the figure.
void draw_tick_label(const Vector &c, const Vector &r, const std::string &text, const StyleProperties &style=StyleProperties())
Draws a tick label 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 save(const std::string &filename)
Saves the figure to a file.
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:82
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
OutputFigure2D(const Figure2D &fig)
Creates a new OutputFigure2D object linked to a given figure.
Definition codac2_OutputFigure2D.h:39
Definition codac2_OctaSym.h:21
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Style properties structure, to specify the style of a shape.
Definition codac2_StyleProperties.h:27