![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
Renders the map on widgets. More...
#include <renderer.h>
Inheritance diagram for freeciv::renderer:
Collaboration diagram for freeciv::renderer:Signals | |
| void | repaint_needed (const QRegion &where) |
Public Member Functions | |
| renderer (QObject *parent=nullptr) | |
| Constructor. More... | |
| virtual | ~renderer ()=default |
| QPointF | origin () const |
| The origin of the view (the point at the top left corner) More... | |
| void | set_origin (const QPointF &origin) |
| Changes the origin of the canvas (the point at the top left of the view). More... | |
| double | scale () const |
| The scale (zoom) at which rendering is performed. More... | |
| void | set_scale (double scale) |
| Changes the scale of the rendering (zooms in or out). More... | |
| QSize | viewport_size () const |
| The current dimensions of the viewport. More... | |
| void | set_viewport_size (const QSize &size) |
| Instructs the renderer to draw a viewport with a different size. More... | |
| void | render (QPainter &painter, const QRegion ®ion) const |
Renders the specified region of the visible portion of the map on painter. More... | |
| void | render (QPainter &painter, const QRect &area) const |
Renders the specified area of the visible portion of the map on painter. More... | |
Properties | |
| QPointF | origin |
| double | scale |
Private Slots | |
| void | unqueue_updates () |
| Processes all pending map updates and writes them to the map buffer. More... | |
Private Attributes | |
| QPointF | m_origin |
| double | m_scale = 1.0 |
| QSize | m_viewport_size |
| map_updates_handler * | m_updates |
Renders the map on widgets.
This class is used to draw the map. The position of the mapview is given by origin and zoom is set via the scale property.
Definition at line 20 of file renderer.h.
|
explicit |
Constructor.
Definition at line 26 of file renderer.cpp.
|
virtualdefault |
|
inline |
The origin of the view (the point at the top left corner)
Definition at line 30 of file renderer.h.
| void freeciv::renderer::render | ( | QPainter & | painter, |
| const QRect & | area | ||
| ) | const |
Renders the specified area of the visible portion of the map on painter.
This is meant to be used directly from paintEvent, so the position of area is relative to the viewport. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 88 of file renderer.cpp.
| void freeciv::renderer::render | ( | QPainter & | painter, |
| const QRegion & | region | ||
| ) | const |
Renders the specified region of the visible portion of the map on painter.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 75 of file renderer.cpp.
Referenced by map_view::paintEvent().
|
signal |
Referenced by map_view::map_view(), mr_menu::save_image(), set_origin(), and unqueue_updates().
|
inline |
The scale (zoom) at which rendering is performed.
Definition at line 34 of file renderer.h.
| void freeciv::renderer::set_origin | ( | const QPointF & | origin | ) |
Changes the origin of the canvas (the point at the top left of the view).
Definition at line 36 of file renderer.cpp.
Referenced by map_view::center_on_tile(), and map_view::wheelEvent().
| void freeciv::renderer::set_scale | ( | double | scale | ) |
Changes the scale of the rendering (zooms in or out).
A scale of 2 means that everything is 2x bigger.
Definition at line 47 of file renderer.cpp.
Referenced by map_view::set_scale_now().
| void freeciv::renderer::set_viewport_size | ( | const QSize & | size | ) |
Instructs the renderer to draw a viewport with a different size.
Definition at line 60 of file renderer.cpp.
Referenced by map_view::resizeEvent(), and mr_menu::save_image().
|
privateslot |
Processes all pending map updates and writes them to the map buffer.
Definition at line 103 of file renderer.cpp.
Referenced by renderer().
|
inline |
The current dimensions of the viewport.
Definition at line 38 of file renderer.h.
|
private |
Definition at line 51 of file renderer.h.
Referenced by origin(), and set_origin().
|
private |
Definition at line 52 of file renderer.h.
Referenced by scale(), set_scale(), and set_viewport_size().
|
private |
Definition at line 54 of file renderer.h.
Referenced by renderer(), and unqueue_updates().
|
private |
Definition at line 53 of file renderer.h.
Referenced by set_origin(), set_scale(), set_viewport_size(), and viewport_size().
|
readwrite |
Definition at line 1 of file renderer.h.
Referenced by set_origin(), and map_view::wheelEvent().
|
readwrite |
Definition at line 1 of file renderer.h.
Referenced by render(), map_view::scale(), set_scale(), and unqueue_updates().