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

#include <Shapes.h>

Inheritance diagram for Graph_lib::Image:
Collaboration diagram for Graph_lib::Image:

Public Member Functions

 Image (Point _loc, const std::string &s, Suffix::Encoding e=Suffix::none)
 
 ~Image ()
 
Color color () const
 
void draw () const
 
void draw_lines () const override
 
Color fill_color () const
 
Line_style get_style () const
 
void move (int dx, int dy) override
 
size_t number_of_points () const
 
Point point (int i) const
 
void set_color (Color _color)
 
void set_fill_color (Color _color)
 
void set_mask (Point _loc, pix_amount _width, pix_amount _height)
 
void set_style (Line_style sty)
 

Protected Member Functions

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

Private Attributes

Color c {static_cast<Color>(fl_color())}
 
pix_amount cx
 
pix_amount cy
 
Color f_c {Color::invisible}
 
pix_amount height
 
Fl_Image * img_ptr
 
Line_style ls {0}
 
std::vector< Pointpoints
 
Text text
 
pix_amount width
 

Constructor & Destructor Documentation

◆ Image()

Graph_lib::Image::Image ( Point _loc,
const std::string & s,
Suffix::Encoding e = Suffix::none )
141 : width{0}, height{0}, text{_loc, ""} {
142 add(_loc);
143
144 if (!can_open(s)) {
145 text.set_label("cannot open \"" + s + '\"');
146 img_ptr = new Bad_image{30, 20}; // the "error image"
147 return;
148 }
149
150 if (e == Suffix::none) e = get_encoding(s);
151
152 switch (e) {
153 case Suffix::png:
154 img_ptr = new Fl_PNG_Image{s.c_str()};
155 break;
156 case Suffix::jpg:
157 img_ptr = new Fl_JPEG_Image{s.c_str()};
158 break;
159 case Suffix::gif:
160 img_ptr = new Fl_GIF_Image{s.c_str()};
161 break;
162 default: // Unsupported image encoding
163 text.set_label("unsupported file type \"" + s + '\"');
164 img_ptr = new Bad_image{30, 20}; // the "error image"
165 }
166}
Text text
Definition Shapes.h:415
pix_amount width
Definition Shapes.h:411
pix_amount height
Definition Shapes.h:411
Fl_Image * img_ptr
Definition Shapes.h:414
void add(Point p)
Definition Shapes.h:176
void set_label(const std::string &s)
Definition Shapes.h:296
Suffix::Encoding get_encoding(const std::string &s)
Definition Shapes.cpp:117
W & reference_to(void *ptr_wid)
Definition Widgets.h:16
bool can_open(const std::string &s)
Definition Shapes.cpp:130
@ png
Definition Shapes.h:380
@ none
Definition Shapes.h:380
@ gif
Definition Shapes.h:380
@ jpg
Definition Shapes.h:380
Here is the call graph for this function:

◆ ~Image()

Graph_lib::Image::~Image ( )
inline
391{ delete img_ptr; }

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
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::Image::draw_lines ( ) const
overridevirtual

Reimplemented from Graph_lib::Shape.

168 {
169 if (text.label() != "") text.draw_lines();
170
171 if (width && height)
172 img_ptr->Fl_Image::draw(point(0).x, point(0).y, width, height, cx, cy);
173 else
174 img_ptr->Fl_Image::draw(point(0).x, point(0).y);
175}
pix_amount cy
Definition Shapes.h:413
pix_amount cx
Definition Shapes.h:412
Point point(int i) const
Definition Shapes.h:201
void draw_lines() const override
Definition Shapes.cpp:71
std::string label() const
Definition Shapes.h:298
Here is the call 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::Image::move ( int dx,
int dy )
overridevirtual

Reimplemented from Graph_lib::Shape.

177 {
178 Shape::move(dx, dy);
179 img_ptr->Fl_Image::draw(point(0).x, point(0).y);
180}
virtual void move(int dx, int dy)
Definition Shapes.cpp:28
Here is the call 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_mask()

void Graph_lib::Image::set_mask ( Point _loc,
pix_amount _width,
pix_amount _height )
inline
397 {
398 width = _width;
399 height = _height;
400 cx = _loc.x;
401 cy = _loc.y;
402 }

◆ 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())};

◆ cx

pix_amount Graph_lib::Image::cx
private

◆ cy

pix_amount Graph_lib::Image::cy
private

◆ f_c

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

◆ height

pix_amount Graph_lib::Image::height
private

◆ img_ptr

Fl_Image* Graph_lib::Image::img_ptr
private

◆ ls

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

◆ points

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

◆ text

Text Graph_lib::Image::text
private

◆ width

pix_amount Graph_lib::Image::width
private

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