Freeciv21
Develop your civilization from humble roots to a global empire
view_map_geometry.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2022-2023 Louis Moureaux <m_louis30@yahoo.com>
3  *
4  * SPDX-License-Identifier: GPLv3-or-later
5  */
6 
7 #pragma once
8 
9 #include <QRect>
10 
11 #include "tileset/layer.h"
12 
13 struct edge;
14 struct tile;
15 struct tileset;
16 
17 namespace freeciv {
18 
20 public:
21  gui_rect_iterator(const struct tileset *t, const QRect &rect);
22 
24  bool has_corner() const { return m_has_corner; }
25 
27  bool has_edge() const { return m_has_edge; }
28 
30  bool has_tile() const { return m_has_tile; }
31 
33  const tile_corner &corner() const { return m_corner; }
34 
36  const tile_edge &edge() const { return m_edge; }
37 
39  const ::tile *tile() const { return m_tile; }
40 
42  int x() const { return m_xi * m_w / m_r2 - m_w / 2; }
43 
45  int y() const { return m_yi * m_h / m_r2 - m_h / 2; }
46 
47  bool next();
48 
49 private:
52  int m_r1, m_r2, m_w, m_h;
53  int m_x0, m_y0, m_x1, m_y1;
54  int m_xi, m_yi;
55 
58  ::tile *m_tile = nullptr;
59  bool m_has_corner = false, m_has_edge = false, m_has_tile = false;
60 };
61 
62 } // namespace freeciv
Iterates over all map tiles that intersect with a rectangle in GUI coordinates.
bool has_edge() const
Checks whether the current iteration point has an edge.
gui_rect_iterator(const struct tileset *t, const QRect &rect)
Constructor.
bool has_corner() const
Checks whether the current iteration point has a corner.
const ::tile * tile() const
Retrieves the current tile. Only valid if has_tile is true.
int y() const
Retrieves the y position of the current item.
const tile_corner & corner() const
Retrieves the current corner. Only valid if has_corner is true.
int x() const
Retrieves the x position of the current item.
const tile_edge & edge() const
Retrieves the current edge. Only valid if has_edge is true.
bool has_tile() const
Checks whether the current iteration point has a non-null tile.
bool next()
Iterates to the next item.
Definition: path.cpp:10
Definition: tile.h:42