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;
456 for(
const auto& pi : p.boxes())
462 const std::string _name;
463 Vector _pos {50,50}, _window_size {700,700};
464 std::vector<FigureAxis> _axes { axis(0,{0,1}), axis(1,{0,1}) };
465 std::vector<std::shared_ptr<OutputFigure2D>> _output_figures;
468 friend DefaultFigure;
490 if(_selected_fig ==
nullptr)
491 _selected_fig = _default_fig;
492 return _selected_fig;
500 static void set(std::shared_ptr<Figure2D> fig)
511 static Figure2D&
set_axes(
const FigureAxis& axis1,
const FigureAxis& axis2)
884 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
885 _default_fig->set_window_properties({20.,20.},
886 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
887 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
890 selected_fig()->draw_paving(p, boundary_style, outside_style);
908 double rx = p.tree()->hull()[0].diam(), ry = p.tree()->hull()[1].diam();
909 _default_fig->set_window_properties({20.,20.},
910 rx > ry ? Vector({800.,800.*ry/rx}) : Vector({800.*rx/ry,800.}));
911 _default_fig->set_axes(axis(0,p.tree()->hull()[0]),axis(1,p.tree()->hull()[1]));
914 selected_fig()->draw_paving(p, boundary_style, outside_style, inside_style);
933 static bool auto_init()
935 if(!_default_fig && !_selected_fig)
937 _default_fig = std::make_shared<Figure2D>(DEFAULT_FIG_NAME, GraphicOutput::VIBES);
938 _default_fig->set_window_properties({20.,20.}, {800.,800.});
939 _default_fig->set_axes(axis(0,{-10,10}),axis(1,{-10,10}));
940 _selected_fig = _default_fig;
949 static std::shared_ptr<Figure2D> _default_fig;
950 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
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.