23#define DEFAULT_FIG_NAME "Codac - default figure"
27 enum class GraphicOutput
33 constexpr int operator&(GraphicOutput a, GraphicOutput b)
34 {
return static_cast<int>(
static_cast<int>(a) &
static_cast<int>(b)); }
36 constexpr GraphicOutput operator|(GraphicOutput a, GraphicOutput b)
37 {
return static_cast<GraphicOutput
>(
static_cast<int>(a) |
static_cast<int>(b)); }
46 inline FigureAxis axis(Index dim_id,
const Interval& limits,
const std::string& label =
"")
48 assert_release(dim_id >= 0);
51 std::string axis_label = label;
52 if(axis_label.empty())
53 axis_label =
"x_" + std::to_string(dim_id);
55 return { dim_id, limits, axis_label };
76 class Figure2D :
public std::enable_shared_from_this<Figure2D>
94 const std::string&
name()
const;
108 const std::vector<FigureAxis>&
axes()
const;
116 void set_axes(
const FigureAxis& axis1,
const FigureAxis& axis2);
123 const Index&
i()
const;
130 const Index&
j()
const;
137 const Vector&
pos()
const;
422 for(
const auto& pi : p.boxes())
428 const std::string _name;
429 Vector _pos {50,50}, _window_size {500,500};
430 std::vector<FigureAxis> _axes { axis(0,{0,1}), axis(1,{0,1}) };
431 std::vector<std::shared_ptr<OutputFigure2D>> _output_figures;
434 friend DefaultFigure;
456 if(_selected_fig ==
nullptr)
457 _selected_fig = _default_fig;
458 return _selected_fig;
466 static void set(std::shared_ptr<Figure2D> fig)
477 static void set_axes(
const FigureAxis& axis1,
const FigureAxis& axis2)
792 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
793 _default_fig->set_window_properties({20.,20.},
794 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
795 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
798 selected_fig()->draw_paving(p, boundary_style, outside_style);
816 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
817 _default_fig->set_window_properties({20.,20.},
818 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
819 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
822 selected_fig()->draw_paving(p, boundary_style, outside_style, inside_style);
841 static bool auto_init()
843 if(!_default_fig && !_selected_fig)
845 _default_fig = std::make_shared<Figure2D>(DEFAULT_FIG_NAME, GraphicOutput::VIBES);
846 _default_fig->set_window_properties({20.,20.}, {800.,800.});
847 _default_fig->set_axes(axis(0,{-10,10}),axis(1,{-10,10}));
848 _selected_fig = _default_fig;
857 static std::shared_ptr<Figure2D> _default_fig;
858 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:62
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
Represents a set of RGB or HSV values.
Definition codac2_ColorMap.h:29
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 cyan fill.
static StyleProperties boundary()
Predefined "boundary" style, dark gray edge and yellow fill.