77 for (
const auto &rect : region) {
91 painter.setRenderHint(QPainter::SmoothPixmapTransform);
95 QRectF(area.left() /
scale(), area.top() /
scale(),
96 area.width() /
scale(), area.height() /
scale());
123 for (
const auto &[
tile, upd_types] : updates) {
124 for (
const auto &[type, rect] : rects) {
125 if (upd_types & type) {
128 to_update |= rect.translated(xl, yt);
133 if (to_update.intersects(
135 const auto aligned = to_update.toAlignedRect();
139 const auto scaled_aligned =
140 QRectF(aligned.x() *
scale(), aligned.y() *
scale(),
141 aligned.width() *
scale(), aligned.height() *
scale())
Records regions of the map that should be updated.
bool full() const
Returns true if the whole map should be updated.
void clear()
Clears all pending updates.
auto list() const
Returns the list of pending updates.
void unqueue_updates()
Processes all pending map updates and writes them to the map buffer.
void repaint_needed(const QRegion &where)
void set_viewport_size(const QSize &size)
Instructs the renderer to draw a viewport with a different size.
void set_scale(double scale)
Changes the scale of the rendering (zooms in or out).
map_updates_handler * m_updates
void set_origin(const QPointF &origin)
Changes the origin of the canvas (the point at the top left of the view).
void render(QPainter &painter, const QRegion ®ion) const
Renders the specified region of the visible portion of the map on painter.
renderer(QObject *parent=nullptr)
Constructor.
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
void set_mapview_origin(float gui_x0, float gui_y0)
Change the mapview origin, clip it, and update everything.
void map_canvas_resized(int width, int height)
Called if the map in the GUI is resized.
void update_map_canvas(int canvas_x, int canvas_y, int width, int height)
Update (refresh) the map canvas starting at the given tile (in map coordinates) and with the given di...
bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, const tile *ptile)
Finds the canvas coordinates for a map position.
std::map< freeciv::map_updates_handler::update_type, QRectF > update_rects()
Calculates the area covered by each update type.