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;
138 const Vector&
pos()
const;
448 for(
const auto& pi : p.boxes())
454 const std::string _name;
455 Vector _pos {50,50}, _window_size {500,500};
456 std::vector<FigureAxis> _axes { axis(0,{0,1}), axis(1,{0,1}) };
457 std::vector<std::shared_ptr<OutputFigure2D>> _output_figures;
460 friend DefaultFigure;
482 if(_selected_fig ==
nullptr)
483 _selected_fig = _default_fig;
484 return _selected_fig;
492 static void set(std::shared_ptr<Figure2D> fig)
503 static Figure2D&
set_axes(
const FigureAxis& axis1,
const FigureAxis& axis2)
864 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
865 _default_fig->set_window_properties({20.,20.},
866 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
867 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
870 selected_fig()->draw_paving(p, boundary_style, outside_style);
888 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
889 _default_fig->set_window_properties({20.,20.},
890 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
891 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
894 selected_fig()->draw_paving(p, boundary_style, outside_style, inside_style);
913 static bool auto_init()
915 if(!_default_fig && !_selected_fig)
917 _default_fig = std::make_shared<Figure2D>(DEFAULT_FIG_NAME, GraphicOutput::VIBES);
918 _default_fig->set_window_properties({20.,20.}, {800.,800.});
919 _default_fig->set_axes(axis(0,{-10,10}),axis(1,{-10,10}));
920 _selected_fig = _default_fig;
929 static std::shared_ptr<Figure2D> _default_fig;
930 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 light blue fill.
static StyleProperties boundary()
Predefined "boundary" style, dark gray edge and yellow fill.