codac 2.0.0
Loading...
Searching...
No Matches
codac2_Figure2D_IPE_.h
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{
29 class Figure2D_IPE : public OutputFigure2D
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
119 void draw_tick_label(const Vector& c, const Vector& r, const std::string& text, const StyleProperties& style = StyleProperties(), const std::string& halign = "left");
120
124 void draw_axes();
125
126 // Geometric shapes
127
134 void draw_point(const Vector& c, const StyleProperties& style = StyleProperties());
135
142 void draw_box(const IntervalVector& x, const StyleProperties& style = StyleProperties());
143
151 void draw_circle(const Vector& c, double r, const StyleProperties& style = StyleProperties());
152
160 void draw_ring(const Vector& c, const Interval& r, const StyleProperties& style = StyleProperties());
161
169 void draw_polyline(const std::vector<Vector>& x, float tip_length, const StyleProperties& style = StyleProperties());
170
177 void draw_polygon(const std::vector<Vector>& x, const StyleProperties& style = StyleProperties());
178
187 void draw_pie(const Vector& c, const Interval& r, const Interval& theta, const StyleProperties& style = StyleProperties());
188
197 void draw_ellipse(const Vector& c, const Vector& ab, double theta, const StyleProperties& style = StyleProperties());
198
199 // Robots
200
208 void draw_tank(const Vector& x, float size, const StyleProperties& style = StyleProperties());
209
217 void draw_AUV(const Vector& x, float size, const StyleProperties& style = StyleProperties());
218
226 void draw_motor_boat(const Vector& x, float size, const StyleProperties& style = StyleProperties());
227
228 // Miscellaneous
229
238 void draw_text(const std::string& text, const Vector& ul, double scale, const StyleProperties& style = StyleProperties());
239
247 void draw_raster(const std::string& filename, const IntervalVector& bbox, const StyleProperties& style = StyleProperties());
248
249 protected:
250
251 double scale_x(double x) const;
252 double scale_y(double y) const;
253 double scale_length(double y) const;
254 void print_header_page();
255
256 std::ofstream _f;
257 std::string _working_item;
258 std::multimap<double,std::string> _items;
259 const double _ipe_grid_size = 500.;
260 Vector _ratio { 1., 1. };
261
262 std::vector<double> _x_ticks;
263 std::vector<double> _y_ticks;
264 double _x_offset;
265 double _y_offset;
266
267 std::map<std::string,Color> _colors;
268 };
269}
IPE output class.
Definition codac2_Figure2D_IPE.h:30
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_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.
void draw_tick_label(const Vector &c, const Vector &r, const std::string &text, const StyleProperties &style=StyleProperties(), const std::string &halign="left")
Draws a tick label on 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:82
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
Output figure class, used to manage the output figures.
Definition codac2_OutputFigure2D.h:31
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