codac 1.5.6
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{
29 class Figure2D_IPE : public OutputFigure2D
30 {
31 public:
32
33 Figure2D_IPE(const Figure2D& fig);
34 virtual ~Figure2D_IPE();
37 void center_viewbox(const Vector& c, const Vector& r);
38 void begin_path(const StyleProperties& s,bool tip = false);
39
40 /* For future doc:
41 https://github.com/codac-team/codac/pull/126#discussion_r1829030491
42 Pour les véhicules (draw_tank et draw_AUV) le header par défaut du begin_path n'est pas suffisant.
43 J'ai donc ajouté cette fonction qui fait le même travail que le begin_path, avec en plus le champ
44 "matrix" complété.
45 Ce champ contient 6 valeurs : les 4 premières sont la matrice de transformation 2D, rotation et
46 dilatation, "par colonne" (i.e. m11, m21, m12, m22) et les 2 autres valeurs sont la translation.
47 Le tout permet de scale le véhicule, l'orienter et le déplacer au bon endroit.
48 Cette fonction écrit dans le xml quelque chose dans le style :
49 <path layer="alpha"
50 stroke="codac_color_000000"
51 fill="codac_color_ffd32a"
52 opacity="100%"
53 stroke-opacity="100%"
54 pen="heavier"
55 matrix="0.00948009 11.9048 -11.9047 0.00948009 166.667 166.667">
56 */
57 void begin_path_with_matrix(const Vector& x, float length, const StyleProperties& s = StyleProperties());
58
59 void draw_text(const Vector& c,const Vector& r, const std::string& text, const StyleProperties& s = StyleProperties());
60 void draw_axes();
61
62 // Geometric shapes
63 void draw_point(const Vector& c, const StyleProperties& s = StyleProperties());
64 void draw_box(const IntervalVector& x, const StyleProperties& s = StyleProperties());
65 void draw_circle(const Vector& c, double r, const StyleProperties& s = StyleProperties());
66 void draw_ring(const Vector& c, const Interval& r, const StyleProperties& s = StyleProperties());
67 void draw_polyline(const std::vector<Vector>& x, float tip_length, const StyleProperties& s = StyleProperties());
68 void draw_polygon(const std::vector<Vector>& x, const StyleProperties& s = StyleProperties());
69 void draw_pie(const Vector& c, const Interval& r, const Interval& theta, const StyleProperties& s = StyleProperties());
70 void draw_ellipse(const Vector& c, const Vector& ab, double theta, const StyleProperties& s = StyleProperties());
71
72 // Robots
73 void draw_tank(const Vector& x, float size, const StyleProperties& s = StyleProperties());
74 void draw_AUV(const Vector& x, float size, const StyleProperties& s = StyleProperties());
75 void draw_motor_boat(const Vector& x, float size, const StyleProperties& s = StyleProperties());
76
77 protected:
78
79 double scale_x(double x) const;
80 double scale_y(double y) const;
81 double scale_length(double y) const;
82 void print_header_page();
83
84 std::ofstream _f, _f_temp_content;
85 const double _ipe_grid_size = 500.;
86 Vector _ratio { 1., 1. };
87
88 std::vector<double> _x_ticks;
89 std::vector<double> _y_ticks;
90 double _x_offset;
91 double _y_offset;
92
93 std::map<std::string,Color> _colors;
94 };
95}
void draw_ring(const Vector &c, const Interval &r, const StyleProperties &s=StyleProperties())
Draws a ring on the figure.
void draw_motor_boat(const Vector &x, float size, const StyleProperties &s=StyleProperties())
Draws a motor boat on the figure.
void draw_point(const Vector &c, const StyleProperties &s=StyleProperties())
Draws a point on the figure.
void draw_tank(const Vector &x, float size, const StyleProperties &s=StyleProperties())
Draws a tank on the figure.
void draw_polygon(const std::vector< Vector > &x, const StyleProperties &s=StyleProperties())
Draws a polygone on the figure.
void update_axes()
Updates the axes of the figure.
void draw_box(const IntervalVector &x, const StyleProperties &s=StyleProperties())
Draws a box on the figure.
void draw_AUV(const Vector &x, float size, const StyleProperties &s=StyleProperties())
Draws an AUV on the figure.
void draw_pie(const Vector &c, const Interval &r, const Interval &theta, const StyleProperties &s=StyleProperties())
Draws a pie on the figure.
void draw_circle(const Vector &c, double r, const StyleProperties &s=StyleProperties())
Draws a circle on the figure.
void update_window_properties()
Updates the position and size of the window.
void center_viewbox(const Vector &c, const Vector &r)
Centers the viewbox.
void draw_polyline(const std::vector< Vector > &x, float tip_length, const StyleProperties &s=StyleProperties())
Draws a polyline on the figure.
void draw_ellipse(const Vector &c, const Vector &ab, double theta, const StyleProperties &s=StyleProperties())
Draws an ellipse 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:62
OutputFigure2D(const Figure2D &fig)
Creates a new OutputFigure2D object linked to a given figure.
Definition codac2_OutputFigure2D.h:39
Style properties structure, to specify the style of a shape.
Definition codac2_StyleProperties.h:26