Marble

PlacemarkLayout.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5// SPDX-FileCopyrightText: 2010-2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
6//
7
8//
9// PlacemarkLayout is responsible for drawing the Placemarks on the map
10//
11
12#ifndef MARBLE_PLACEMARKLAYOUT_H
13#define MARBLE_PLACEMARKLAYOUT_H
14
15#include <QHash>
16#include <QList>
17#include <QMap>
18#include <QPointer>
19#include <QRect>
20#include <QSet>
21
22#include "GeoDataPlacemark.h"
23#include <GeoDataStyle.h>
24
27class QPoint;
28class QModelIndex;
29
30namespace Marble
31{
32
33class GeoDataCoordinates;
34class GeoPainter;
35class MarbleClock;
36class PlacemarkPainter;
37class TileId;
38class VisiblePlacemark;
39class ViewportParams;
40class StyleBuilder;
41
42/**
43 * Layouts the place marks with a passed QPainter.
44 */
45
47{
49
50public:
51 /**
52 * Creates a new place mark layout.
53 */
54 PlacemarkLayout(QAbstractItemModel *placemarkModel,
55 QItemSelectionModel *selectionModel,
56 MarbleClock *clock,
57 const StyleBuilder *styleBuilder,
58 QObject *parent = nullptr);
59
60 /**
61 * Destroys the place mark painter.
62 */
63 ~PlacemarkLayout() override;
64
65 /**
66 * @reimp
67 */
68 QList<VisiblePlacemark *> generateLayout(const ViewportParams *viewport, int tileLevel);
69
70 /**
71 * Returns a list of model indexes that are at position @p pos.
72 */
74
75 QString runtimeTrace() const;
76
77 QList<VisiblePlacemark *> visiblePlacemarks() const;
78
79 bool hasPlacemarkAt(const QPoint &pos);
80
81public Q_SLOTS:
82 // earth
83 void setShowPlaces(bool show);
84 void setShowCities(bool show);
85 void setShowTerrain(bool show);
86 void setShowOtherPlaces(bool show);
87
88 // other planets
89 void setShowLandingSites(bool show);
90 void setShowCraters(bool show);
91 void setShowMaria(bool show);
92
93 void requestStyleReset();
94 void addPlacemarks(const QModelIndex &index, int first, int last);
95 void removePlacemarks(const QModelIndex &index, int first, int last);
96 void resetCacheData();
97
99 void repaintNeeded();
100
101private:
102 /**
103 * Returns a the maximum height of all possible labels.
104 * WARNING: This is a really slow method as it traverses all placemarks
105 * to check the labelheight.
106 * FIXME: Once a StyleManager that manages all styles has been implemented
107 * just traverse all existing styles.
108 */
109 static int maxLabelHeight();
110
111 void styleReset();
112 void clearCache();
113
114 static QSet<TileId> visibleTiles(const ViewportParams &viewport, int tileLevel);
115 bool layoutPlacemark(const GeoDataPlacemark *placemark, const GeoDataCoordinates &coordinates, qreal x, qreal y, bool selected);
116
117 /**
118 * Returns the coordinates at which an icon should be drawn for the @p placemark.
119 * @p ok is set to true if the coordinates are valid and should be used for drawing,
120 * it is set to false otherwise.
121 */
122 GeoDataCoordinates placemarkIconCoordinates(const GeoDataPlacemark *placemark) const;
123
124 QRectF roomForLabel(const GeoDataStyle::ConstPtr &style, const qreal x, const qreal y, const QString &labelText, const VisiblePlacemark *placemark) const;
125 bool hasRoomForPixmap(const qreal y, const VisiblePlacemark *placemark) const;
126
127 bool placemarksOnScreenLimit(const QSize &screenSize) const;
128
129private:
130 Q_DISABLE_COPY(PlacemarkLayout)
131 QAbstractItemModel *m_placemarkModel;
132 QItemSelectionModel *const m_selectionModel;
133 MarbleClock *const m_clock;
134
135 QList<VisiblePlacemark *> m_paintOrder;
136 QString m_runtimeTrace;
137 int m_labelArea;
140
141 /// map providing the list of placemark belonging in TileId as key
143 QSet<qint64> m_osmIds;
144
145 const QSet<GeoDataPlacemark::GeoDataVisualCategory> m_acceptedVisualCategories;
146
147 // earth
148 bool m_showPlaces;
149 bool m_showCities;
150 bool m_showTerrain;
151 bool m_showOtherPlaces;
152
153 // other planets
154 bool m_showLandingSites;
155 bool m_showCraters;
156 bool m_showMaria;
157
158 int m_maxLabelHeight;
159 bool m_styleResetRequested;
160 const StyleBuilder *m_styleBuilder;
161 // Referencing these properties by value
162 // instead of using a more fragile pointer
163 bool m_lastPlacemarkAvailable;
164 QRectF m_lastPlacemarkLabelRect;
165 QRectF m_lastPlacemarkSymbolRect;
166};
167
168}
169
170#endif
A 3d point representation.
a class representing a point of interest on the map
Layouts the place marks with a passed QPainter.
QList< const GeoDataFeature * > whichPlacemarkAt(const QPoint &pos)
Returns a list of model indexes that are at position pos.
PlacemarkLayout(QAbstractItemModel *placemarkModel, QItemSelectionModel *selectionModel, MarbleClock *clock, const StyleBuilder *styleBuilder, QObject *parent=nullptr)
Creates a new place mark layout.
QList< VisiblePlacemark * > generateLayout(const ViewportParams *viewport, int tileLevel)
void addPlacemarks(const QModelIndex &index, int first, int last)
feed an internal QMap of placemarks with TileId as key when model changes
~PlacemarkLayout() override
Destroys the place mark painter.
A public class that controls what is visible in the viewport of a Marble map.
A class which represents the visible place marks on a map.
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.