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

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

#include <Graphix.h>

Inheritance diagram for Graphix_calc::Graphix:
Collaboration diagram for Graphix_calc::Graphix:

Public Member Functions

 Graphix (std::function< double(double)> calc, double min_x, double max_x, Graph_lib::Point origin, unsigned int point_amount, double unit_intr)
 Инициализирует новый экземпляр Graphix (область определения [min_x:max_x))
 
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
 
Point point (int i) const
 
void set_color (Color _color)
 
void set_fill_color (Color _color)
 
void set_style (Line_style sty)
 

Protected Member Functions

void add (Point p)
 
virtual void draw_lines () const
 
void set_point (int i, Point p)
 

Private Attributes

Color c {static_cast<Color>(fl_color())}
 
Color f_c {Color::invisible}
 
Line_style ls {0}
 
std::vector< Point > points
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Graphix()

Graphix_calc::Graphix::Graphix ( std::function< double(double)> calc,
double min_x,
double max_x,
Graph_lib::Point origin,
unsigned int point_amount,
double unit_intr )

Инициализирует новый экземпляр Graphix (область определения [min_x:max_x))

Parameters
calcлямбда-выр. от мат. функции
min_xмин. знач. x
max_xмакс. знач. x
originначало координат
point_amountкол-во точек
unit_intrединичный отрезок

Перебираемое значение x мат. функции

16 {
17 if (max_x - min_x <= 0) invalid_argument("bad graphing range");
18
19 if (point_amount < 2) invalid_argument("graphing point_amount must be >= 2");
20
21 // (в том случае, если график - простая линия)
22 else if (point_amount == 2) {
23 add(converted_to_pix({min_x, calc(min_x)}, origin, unit_intr));
24 add(converted_to_pix({max_x, calc(max_x)}, origin, unit_intr));
25 } else {
26 /// @brief Перебираемое значение x мат. функции
27 double x = min_x;
28 // (цикл нужен только, чтобы считать сколько точек уже было добавлено)
29 for (unsigned int i = 0; i < point_amount; i++) {
30 add(converted_to_pix({x, calc(x)}, origin, unit_intr));
31 x += (max_x - min_x) / double(point_amount);
32 }
33 }
34}
void add(Point p)
Definition Shapes.h:176
Graph_lib::Point converted_to_pix(Math_calc::Point p, Graph_lib::Point origin, double unit_intr)
Definition utilities.cpp:27
Here is the call graph for this function:

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 Graph_lib::Shape::draw_lines ( ) const
protectedvirtualinherited

Reimplemented in Graph_lib::Open_polyline, Graph_lib::Closed_polyline, Graph_lib::Lines, Graph_lib::Text, Graph_lib::Marked_polyline, Graph_lib::Image, Graphix_calc::Axis, and Graphix_calc::Segmented_graphix.

20 {
21 // (точек должно быть больше одной)
22 if (color().visibility() && 1 < points.size())
23 for (unsigned int i = 1; i < points.size(); ++i)
24 fl_line(int(points[i - 1].x), int(points[i - 1].y), int(points[i].x),
25 int(points[i].y));
26}
Color color() const
Definition Shapes.h:191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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:

◆ point()

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

◆ set_color()

void Graph_lib::Shape::set_color ( Color _color)
inlineinherited
189{ c = _color; }
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())};

◆ 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

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