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 <QRect>
17#include <QSet>
18#include <QMap>
19#include <QVector>
20#include <QPointer>
21
22#include "GeoDataPlacemark.h"
23#include <GeoDataStyle.h>
24
27class QPoint;
28class QModelIndex;
29
30
31namespace Marble
32{
33
34class GeoDataCoordinates;
35class GeoPainter;
36class MarbleClock;
37class PlacemarkPainter;
38class TileId;
39class VisiblePlacemark;
40class ViewportParams;
41class StyleBuilder;
42
43/**
44 * Layouts the place marks with a passed QPainter.
45 */
46
47
48
50{
52
53 public:
54 /**
55 * Creates a new place mark layout.
56 */
57 PlacemarkLayout( QAbstractItemModel *placemarkModel,
58 QItemSelectionModel *selectionModel,
59 MarbleClock *clock,
60 const StyleBuilder* styleBuilder,
61 QObject *parent = nullptr );
62
63 /**
64 * Destroys the place mark painter.
65 */
66 ~PlacemarkLayout() override;
67
68 /**
69 * @reimp
70 */
71 QVector<VisiblePlacemark *> generateLayout(const ViewportParams *viewport , int tileLevel);
72
73 /**
74 * Returns a list of model indexes that are at position @p pos.
75 */
77
78 QString runtimeTrace() const;
79
80 QList<VisiblePlacemark *> visiblePlacemarks() const;
81
82 bool hasPlacemarkAt(const QPoint &pos);
83
84 public Q_SLOTS:
85 // earth
86 void setShowPlaces( bool show );
87 void setShowCities( bool show );
88 void setShowTerrain( bool show );
89 void setShowOtherPlaces( bool show );
90
91 // other planets
92 void setShowLandingSites( bool show );
93 void setShowCraters( bool show );
94 void setShowMaria( bool show );
95
96 void requestStyleReset();
97 void addPlacemarks( const QModelIndex& index, int first, int last );
98 void removePlacemarks( const QModelIndex& index, int first, int last );
99 void resetCacheData();
100
101 Q_SIGNALS:
102 void repaintNeeded();
103
104 private:
105 /**
106 * Returns a the maximum height of all possible labels.
107 * WARNING: This is a really slow method as it traverses all placemarks
108 * to check the labelheight.
109 * FIXME: Once a StyleManager that manages all styles has been implemented
110 * just traverse all existing styles.
111 */
112 static int maxLabelHeight();
113
114 void styleReset();
115 void clearCache();
116
117 static QSet<TileId> visibleTiles(const ViewportParams &viewport, int tileLevel);
118 bool layoutPlacemark(const GeoDataPlacemark *placemark, const GeoDataCoordinates &coordinates, qreal x, qreal y, bool selected );
119
120 /**
121 * Returns the coordinates at which an icon should be drawn for the @p placemark.
122 * @p ok is set to true if the coordinates are valid and should be used for drawing,
123 * it is set to false otherwise.
124 */
125 GeoDataCoordinates placemarkIconCoordinates( const GeoDataPlacemark *placemark ) const;
126
127 QRectF roomForLabel(const GeoDataStyle::ConstPtr &style,
128 const qreal x, const qreal y,
129 const QString &labelText , const VisiblePlacemark *placemark) const;
130 bool hasRoomForPixmap(const qreal y, const VisiblePlacemark *placemark) const;
131
132 bool placemarksOnScreenLimit( const QSize &screenSize ) const;
133
134 private:
135 Q_DISABLE_COPY( PlacemarkLayout )
136 QAbstractItemModel* m_placemarkModel;
137 QItemSelectionModel *const m_selectionModel;
138 MarbleClock *const m_clock;
139
140 QVector<VisiblePlacemark*> m_paintOrder;
141 QString m_runtimeTrace;
142 int m_labelArea;
145
146 /// map providing the list of placemark belonging in TileId as key
148 QSet<qint64> m_osmIds;
149
150 const QSet<GeoDataPlacemark::GeoDataVisualCategory> m_acceptedVisualCategories;
151
152 // earth
153 bool m_showPlaces;
154 bool m_showCities;
155 bool m_showTerrain;
156 bool m_showOtherPlaces;
157
158 // other planets
159 bool m_showLandingSites;
160 bool m_showCraters;
161 bool m_showMaria;
162
163 int m_maxLabelHeight;
164 bool m_styleResetRequested;
165 const StyleBuilder* m_styleBuilder;
166 // Referencing these properties by value
167 // instead of using a more fragile pointer
168 bool m_lastPlacemarkAvailable;
169 QRectF m_lastPlacemarkLabelRect;
170 QRectF m_lastPlacemarkSymbolRect;
171};
172
173}
174
175#endif
A 3d point representation.
a class representing a point of interest on the map
Layouts the place marks with a passed QPainter.
QVector< VisiblePlacemark * > generateLayout(const ViewportParams *viewport, int tileLevel)
QVector< 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.
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 Fri May 24 2024 11:50:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.