Graphic Calculator: FIDocalcus
Проект трёх первокурсников (по инженерному практикуму в первом семестре) по созданию графического калькулятора на FLTK C++
Loading...
Searching...
No Matches
Graphix_calc::Segmented_graphix Class Reference

Фигура, представляющая собой график мат. функции, поделенный на More...

#include <Segmented_Graphix.h>

Inheritance diagram for Graphix_calc::Segmented_graphix:
Collaboration diagram for Graphix_calc::Segmented_graphix:

Public Member Functions

 Segmented_graphix ()=default
 
 Segmented_graphix (Graphix_calc::Graphix *graphix)
 
 Segmented_graphix (std::function< double(double)> _calc, double unit_intr, Graph_lib::Point origin, Graph_lib::Point left_bottom, Graph_lib::Point right_top)
 Инициализирует новый экземпляр Segmented_graphix.
 
 ~Segmented_graphix ()
 
Color color () const
 
void draw () const
 
Color fill_color () const
 
Line_style get_style () const
 
virtual void move (int dx, int dy)
 
size_t number_of_points () const
 
Segmented_graphixoperator= (Graphix_calc::Graphix *graphix)
 
Point point (int i) const
 
void set_color (Graph_lib::Color c)
 
void set_fill_color (Color _color)
 
void set_style (Line_style sty)
 

Protected Member Functions

void add (Point p)
 
void set_point (int i, Point p)
 

Private Member Functions

void draw_lines () const override
 
std::vector< Graphix_calc::Graphix * > segmented_graphix (double unit_intr, Graph_lib::Point origin, Graph_lib::Point left_bottom, Graph_lib::Point right_top) const
 
std::vector< Math_calc::Segmentsegments (double unit_intr, Graph_lib::Point origin, Graph_lib::Point left_bottom, Graph_lib::Point right_top) const
 

Private Attributes

Color c {static_cast<Color>(fl_color())}
 
std::function< double(double)> calc
 Лямбда-выражение от мат. функции
 
Color f_c {Color::invisible}
 
Line_style ls {0}
 
std::vector< Point > points
 
std::vector< Graphix_calc::Graphix * > seged_graphix
 График мат. функции, поделенный на сегменты, связанные с ОДЗ
 
std::vector< Math_calc::Segmentsegs
 Вещественные отрезки, где мат. функция определена
 

Detailed Description

Фигура, представляющая собой график мат. функции, поделенный на

Constructor & Destructor Documentation

◆ Segmented_graphix() [1/3]

Graphix_calc::Segmented_graphix::Segmented_graphix ( )
default

◆ Segmented_graphix() [2/3]

Graphix_calc::Segmented_graphix::Segmented_graphix ( std::function< double(double)> _calc,
double unit_intr,
Graph_lib::Point origin,
Graph_lib::Point left_bottom,
Graph_lib::Point right_top )

Инициализирует новый экземпляр Segmented_graphix.

Деление на сегменты происходит на прямоугольной области краями которой и являются точки

Parameters
_calcлямбда-выражение от мат. функции
unit_intrдлина ед. отрезка
originначало координат
left_bottomлевая нижняя точка - начало области деления на сегменты
right_topправая верхняя точка - конец области деления на сегменты
28 : calc{_calc},
29 segs{segments(unit_intr, origin, left_bottom, right_top)},
31 segmented_graphix(unit_intr, origin, left_bottom, right_top)} {}
std::function< double(double)> calc
Лямбда-выражение от мат. функции
Definition Segmented_Graphix.h:57
std::vector< Graphix_calc::Graphix * > seged_graphix
График мат. функции, поделенный на сегменты, связанные с ОДЗ
Definition Segmented_Graphix.h:63
std::vector< Math_calc::Segment > segments(double unit_intr, Graph_lib::Point origin, Graph_lib::Point left_bottom, Graph_lib::Point right_top) const
Definition Segmented_Graphix.cpp:50
std::vector< Graphix_calc::Graphix * > segmented_graphix(double unit_intr, Graph_lib::Point origin, Graph_lib::Point left_bottom, Graph_lib::Point right_top) const
Definition Segmented_Graphix.cpp:69
std::vector< Math_calc::Segment > segs
Вещественные отрезки, где мат. функция определена
Definition Segmented_Graphix.h:60

◆ Segmented_graphix() [3/3]

Graphix_calc::Segmented_graphix::Segmented_graphix ( Graphix_calc::Graphix * graphix)
34 : seged_graphix{std::vector<Graphix_calc::Graphix*>{graphix}} {}

◆ ~Segmented_graphix()

Graphix_calc::Segmented_graphix::~Segmented_graphix ( )
36 {
37 for (const auto& graphix_part : seged_graphix) delete graphix_part;
38}

Member Function Documentation

◆ add()

void Graph_lib::Shape::add ( Point p)
inlineprotectedinherited
176{ points.push_back(p); }
std::vector< Point > points
Definition Shapes.h:212
Here is the caller graph for this function:

◆ color()

Color Graph_lib::Shape::color ( ) const
inlineinherited
191{ return c; }
Color c
Definition Shapes.h:213
Here is the caller graph for this function:

◆ draw()

void Graph_lib::Shape::draw ( ) const
inherited
10 {
11 Fl_Color prev_color = fl_color(); // не существует хорошего портативного
12 // способа получения текущего стиля
15 draw_lines();
16 fl_color(prev_color); // reset color (к предыдущему) and style (к дефолтному)
18}
Line_style ls
Definition Shapes.h:214
virtual void draw_lines() const
Definition Shapes.cpp:20
W & reference_to(void *ptr_wid)
Definition Widgets.h:16
unsigned int as_uint() const
Definition Shapes.h:57
pix_amount w() const
Definition Shapes.h:94
unsigned int style() const
Definition Shapes.h:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_lines()

void Graphix_calc::Segmented_graphix::draw_lines ( ) const
overrideprivatevirtual

Reimplemented from Graph_lib::Shape.

40 {
41 Shape::draw_lines();
42 for (const auto& graphix_part : seged_graphix) graphix_part->draw();
43}
void draw() const
Definition Shapes.cpp:10

◆ fill_color()

Color Graph_lib::Shape::fill_color ( ) const
inlineinherited
199{ return f_c; }
Color f_c
Definition Shapes.h:215
Here is the caller graph for this function:

◆ get_style()

Line_style Graph_lib::Shape::get_style ( ) const
inlineinherited
195{ return ls; }

◆ move()

void Graph_lib::Shape::move ( int dx,
int dy )
virtualinherited

Reimplemented in Graph_lib::Image.

28 {
29 for (unsigned int i = 0; i < points.size(); ++i) {
30 points[i].x += dx;
31 points[i].y += dy;
32 }
33}
Here is the caller graph for this function:

◆ number_of_points()

size_t Graph_lib::Shape::number_of_points ( ) const
inlineinherited
203{ return points.size(); }
Here is the caller graph for this function:

◆ operator=()

Segmented_graphix & Graphix_calc::Segmented_graphix::operator= ( Graphix_calc::Graphix * graphix)
inline
46 {
47 seged_graphix = std::vector<Graphix_calc::Graphix*>{graphix};
48 return *this;
49 }

◆ point()

Point Graph_lib::Shape::point ( int i) const
inlineinherited
201{ return points[i]; }
Here is the caller graph for this function:

◆ segmented_graphix()

vector< Graphix * > Graphix_calc::Segmented_graphix::segmented_graphix ( double unit_intr,
Graph_lib::Point origin,
Graph_lib::Point left_bottom,
Graph_lib::Point right_top ) const
private
Returns
std::vector<Graphix_calc::Graphix*>: график мат. функции, поделенный на сегменты, связанные с ОДЗ
Parameters
unit_intrдлина ед. отрезка
originначало координат
left_bottomлевая нижняя точка - начало области деления на сегменты
right_topправая верхняя точка - конец области деления на сегменты
71 {
72 vector<Graphix*> res;
73 // это количество точек идеально подходит под наши задачи
74 // (по-хорошему тут геометрическая прогрессия, но ресурсов она требует)
75 unsigned int point_amount = (4 / 3) * right_top.x * sqrt(unit_intr);
76 for (const auto& seg : segs) {
77 Graphix* f =
78 new Graphix{calc, seg.start, seg.end, origin, point_amount, unit_intr};
79 res.push_back(f);
80 }
81 return res;
82}

◆ segments()

vector< Segment > Graphix_calc::Segmented_graphix::segments ( double unit_intr,
Graph_lib::Point origin,
Graph_lib::Point left_bottom,
Graph_lib::Point right_top ) const
private
Parameters
unit_intrдлина ед. отрезка,
originначало координат
left_bottomлевая нижняя точка - начало области деления на сегменты
right_topправая верхняя точка - конец области деления на сегменты
Returns
std::vector<Math_calc::Segment>: вещественные отрезки, где мат. функция определена
53 {
54 // экспериментально вычисленная удачная точность для деления на сегменты
55 // (говно неработающее)
56 // double prec_seg = ((double(r_border) / sqrt(unit_intr))) /
57 // (abs(max_unit_intr - unit_intr));
58
59 // FIXME: естественно, она не должна быть константой (надо исправить код выше)
60 double prec_seg = 0.0001;
61
62 // использование функции из бэкенда, которая дробит на веществ. числа
63 vector<Segment> res = domain_segments(
64 calc, converted_to_real(left_bottom, origin, unit_intr),
65 converted_to_real(right_top, origin, unit_intr), prec_seg);
66 return res;
67}
Math_calc::Point converted_to_real(Graph_lib::Point p, Graph_lib::Point origin, double unit_intr)
Definition utilities.cpp:33
Here is the call graph for this function:

◆ set_color()

void Graphix_calc::Segmented_graphix::set_color ( Graph_lib::Color c)
45 {
46 Shape::set_color(c);
47 for (const auto& graphix_part : seged_graphix) graphix_part->set_color(c);
48}
void set_color(Graph_lib::Color c)
Definition Segmented_Graphix.cpp:45
Here is the caller graph for this function:

◆ set_fill_color()

void Graph_lib::Shape::set_fill_color ( Color _color)
inlineinherited
197{ f_c = _color; }

◆ set_point()

void Graph_lib::Shape::set_point ( int i,
Point p )
inlineprotectedinherited
178{ points[i] = p; }

◆ set_style()

void Graph_lib::Shape::set_style ( Line_style sty)
inlineinherited
193{ ls = sty; }

Member Data Documentation

◆ c

Color Graph_lib::Shape::c {static_cast<Color>(fl_color())}
privateinherited
213{static_cast<Color>(fl_color())};

◆ calc

std::function<double(double)> Graphix_calc::Segmented_graphix::calc
private

Лямбда-выражение от мат. функции

◆ f_c

Color Graph_lib::Shape::f_c {Color::invisible}
privateinherited
@ invisible
Definition Shapes.h:41

◆ ls

Line_style Graph_lib::Shape::ls {0}
privateinherited
214{0};

◆ points

std::vector<Point> Graph_lib::Shape::points
privateinherited

◆ seged_graphix

std::vector<Graphix_calc::Graphix*> Graphix_calc::Segmented_graphix::seged_graphix
private

График мат. функции, поделенный на сегменты, связанные с ОДЗ

◆ segs

std::vector<Math_calc::Segment> Graphix_calc::Segmented_graphix::segs
private

Вещественные отрезки, где мат. функция определена


The documentation for this class was generated from the following files: