Marble

GeoGraphicsItem.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
4// SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
5//
6
7#ifndef MARBLE_GEOGRAPHICSITEM_H
8#define MARBLE_GEOGRAPHICSITEM_H
9
10// Marble
11#include "GeoDataStyle.h"
12#include "marble_export.h"
13
14class QString;
15
16namespace Marble
17{
18
19class GeoDataFeature;
20class GeoDataLatLonAltBox;
21class GeoDataCoordinates;
22class GeoGraphicsItemPrivate;
23class GeoPainter;
24class StyleBuilder;
25class ViewportParams;
26class GeoDataRelation;
27
28class RenderContext
29{
30public:
31 bool operator==(const RenderContext &other) const;
32 bool operator!=(const RenderContext &other) const;
33
34 explicit RenderContext(int tileLevel = -1);
35 int tileLevel() const;
36
37private:
38 int m_tileLevel;
39};
40
41class MARBLE_EXPORT GeoGraphicsItem
42{
43public:
44 explicit GeoGraphicsItem(const GeoDataFeature *feature);
45 virtual ~GeoGraphicsItem();
46
47 enum GeoGraphicsItemFlag {
48 NoOptions = 0x0,
49 ItemIsMovable = 0x1,
50 ItemIsSelectable = 0x2,
51 ItemIsVisible = 0x4
52 };
53
54 Q_DECLARE_FLAGS(GeoGraphicsItemFlags, GeoGraphicsItemFlag)
55
56 bool visible() const;
57
58 void setVisible(bool visible);
59
60 /**
61 * Get the GeoGraphicItemFlags value that describes which flags are set on
62 * this item. @see QFlags
63 */
64 GeoGraphicsItemFlags flags() const;
65
66 /**
67 * Set or unset a single flag
68 * @param flag the flag
69 * @param enabled sets if the flag is to be set or unset
70 */
71 void setFlag(GeoGraphicsItemFlag flag, bool enabled = true);
72
73 /**
74 * Replace all of the current flags.
75 * @param flags is the new value for this item's flags.
76 */
77 void setFlags(GeoGraphicsItemFlags flags);
78
79 /**
80 * Returns the minim zoom level on which item will be active.
81 */
82 int minZoomLevel() const;
83
84 /**
85 * Sets the minimum zoom level
86 */
87 void setMinZoomLevel(int zoomLevel);
88
89 /**
90 * Returns the placemark for that item.
91 */
92 const GeoDataFeature *feature() const;
93
94 /**
95 * Returns the bounding box covered by the item.
96 */
97 virtual const GeoDataLatLonAltBox &latLonAltBox() const = 0;
98
99 /**
100 * Returns the style of item.
101 */
102 GeoDataStyle::ConstPtr style() const;
103
104 /**
105 * Set the style for the item.
106 */
107 void setStyleBuilder(const StyleBuilder *styleBuilder);
108
109 void resetStyle();
110
111 /**
112 * Set the style which will be used when
113 * placemark is highlighted.
114 * GeoGraphicsItem takes ownership of the
115 * passed style and deletes it when appropriate.
116 */
117 void setHighlightStyle(const GeoDataStyle::ConstPtr &highlightStyle);
118
119 /**
120 * Returns the z value of the item
121 */
122 qreal zValue() const;
123
124 /**
125 * Set the z value of the item
126 */
127 void setZValue(qreal z);
128
129 static bool zValueLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two);
130 static bool styleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two);
131 static bool zValueAndStyleLessThan(GeoGraphicsItem *one, GeoGraphicsItem *two);
132
133 /**
134 * Paints the item using the given GeoPainter.
135 *
136 * Note that depending on the projection and zoom level, the item may be visible more than once,
137 * which is taken care of by GeoPainter.
138 */
139 virtual void paint(GeoPainter *painter, const ViewportParams *viewport, const QString &layer, int tileZoomLevel) = 0;
140
141 void setHighlighted(bool highlight);
142
143 bool isHighlighted() const;
144
145 QStringList paintLayers() const;
146
147 void setPaintLayers(const QStringList &paintLayers);
148
149 void setRenderContext(const RenderContext &renderContext);
150
151 /**
152 * @brief contains Returns true if the item contains the given coordinates
153 * @param screenPosition
154 * @param viewport
155 * @return
156 */
157 virtual bool contains(const QPoint &screenPosition, const ViewportParams *viewport) const;
158
159 void setRelations(const QSet<const GeoDataRelation *> &relations);
160
161protected:
162 virtual void handleRelationUpdate(const QList<const GeoDataRelation *> &relations);
163
164 GeoGraphicsItemPrivate *const d;
165};
166
167} // Namespace Marble
168Q_DECLARE_OPERATORS_FOR_FLAGS(Marble::GeoGraphicsItem::GeoGraphicsItemFlags)
169
170#endif
KCRASH_EXPORT void setFlags(KCrash::CrashFlags flags)
Binds a QML item to a specific geodetic location in screen coordinates.
ItemIsSelectable
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.