Marble

GeoGraphicsItem.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Bastian Holst <[email protected]>
4 // SPDX-FileCopyrightText: 2009 Andrew Manson <[email protected]>
5 //
6 
7 #ifndef MARBLE_GEOGRAPHICSITEM_H
8 #define MARBLE_GEOGRAPHICSITEM_H
9 
10 // Marble
11 #include "marble_export.h"
12 #include "GeoDataStyle.h"
13 
14 class QString;
15 
16 namespace Marble
17 {
18 
19 class GeoDataFeature;
20 class GeoDataLatLonAltBox;
21 class GeoDataCoordinates;
22 class GeoGraphicsItemPrivate;
23 class GeoPainter;
24 class StyleBuilder;
25 class ViewportParams;
26 class GeoDataRelation;
27 
28 class RenderContext
29 {
30 public:
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 
37 private:
38  int m_tileLevel;
39 };
40 
41 class MARBLE_EXPORT GeoGraphicsItem
42 {
43  public:
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 
161  protected:
162  virtual void handleRelationUpdate(const QVector<const GeoDataRelation *> &relations);
163 
164  GeoGraphicsItemPrivate *const d;
165 };
166 
167 } // Namespace Marble
168 Q_DECLARE_OPERATORS_FOR_FLAGS(Marble::GeoGraphicsItem::GeoGraphicsItemFlags)
169 
170 #endif
KCRASH_EXPORT void setFlags(KCrash::CrashFlags flags)
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
ItemIsSelectable
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Oct 3 2023 04:09:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.