24#define DEFAULT_FIG_NAME "Codac - default figure"
28 enum class GraphicOutput
34 constexpr int operator&(GraphicOutput a, GraphicOutput b)
35 {
return static_cast<int>(
static_cast<int>(a) &
static_cast<int>(b)); }
37 constexpr GraphicOutput operator|(GraphicOutput a, GraphicOutput b)
38 {
return static_cast<GraphicOutput
>(
static_cast<int>(a) |
static_cast<int>(b)); }
47 inline FigureAxis axis(Index dim_id,
const Interval& limits,
const std::string& label =
"")
49 assert_release(dim_id >= 0);
52 std::string axis_label = label;
53 if(axis_label.empty())
54 axis_label =
"x_" + std::to_string(dim_id);
56 return { dim_id, limits, axis_label };
77 class Figure2D :
public std::enable_shared_from_this<Figure2D>
95 const std::string&
name()
const;
109 const std::vector<FigureAxis>&
axes()
const;
124 const Index&
i()
const;
131 const Index&
j()
const;
461 for(
const auto& pi : p.boxes())
467 const std::string _name;
468 Vector _pos {50,50}, _window_size {700,700};
469 std::vector<FigureAxis> _axes { axis(0,{0,1}), axis(1,{0,1}) };
470 std::vector<std::shared_ptr<OutputFigure2D>> _output_figures;
473 friend DefaultFigure;
495 if(_selected_fig ==
nullptr)
496 _selected_fig = _default_fig;
497 return _selected_fig;
505 static void set(std::shared_ptr<Figure2D> fig)
516 static Figure2D&
set_axes(
const FigureAxis& axis1,
const FigureAxis& axis2)
898 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
899 _default_fig->set_window_properties({20.,20.},
900 rx > ry ?
Vector({800.,800.*ry/rx}) :
Vector({800.*rx/ry,800.}));
901 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
904 selected_fig()->draw_paving(p, boundary_style, outside_style);
922 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
923 _default_fig->set_window_properties({20.,20.},
924 rx > ry ?
Vector({800.,800.*ry/rx}) :
Vector({800.*rx/ry,800.}));
925 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
928 selected_fig()->draw_paving(p, boundary_style, outside_style, inside_style);
947 static bool auto_init()
949 if(!_default_fig && !_selected_fig)
951 _default_fig = std::make_shared<Figure2D>(DEFAULT_FIG_NAME, GraphicOutput::VIBES);
952 _default_fig->set_window_properties({20.,20.}, {800.,800.});
953 _default_fig->set_axes(axis(0,{-10,10}),axis(1,{-10,10}));
954 _selected_fig = _default_fig;
963 static std::shared_ptr<Figure2D> _default_fig;
964 static std::shared_ptr<Figure2D> _selected_fig;
Ellipsoid representation.
Definition codac2_Ellipsoid.h:43
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Represents a polygon (convex or non-convex) defined by its vertices enclosed in IntervalVectors.
Definition codac2_Polygon.h:29
Represents a geometric segment defined by two points enclosed in IntervalVectors.
Definition codac2_Segment.h:28
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 > Matrix
Alias for a dynamic-size matrix of doubles.
Definition codac2_Matrix.h:26
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
Represents a set of RGB or HSV values.
Definition codac2_ColorMap.h:29
static ColorMap blue_tube()
Blue tube color map.
Definition codac2_ColorMap.h:131
Style properties structure, to specify the style of a shape.
Definition codac2_StyleProperties.h:26
static StyleProperties inside()
Predefined "inside" style, dark gray edge and green fill.
static StyleProperties outside()
Predefined "outside" style, dark gray edge and light blue fill.
static StyleProperties boundary()
Predefined "boundary" style, dark gray edge and yellow fill.