Marble

GeoPolyline.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2019 Torsten Rahn <[email protected]>
4 //
5 
6 #ifndef MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H
7 #define MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H
8 
9 #include "GeoDataCoordinates.h"
10 #include "GeoDataLineString.h"
11 #include <QQuickItem>
12 #include <QObject>
13 #include <QtQml>
14 
15 /**
16  * Represents a coordinate with the properties of a name and coordinates
17  *
18  * @todo: Introduce GeoDataCoordinates
19  */
20 namespace Marble
21 {
22  class MarbleQuickItem;
23 
24  class GeoPolyline : public QQuickItem
25  {
26  Q_OBJECT
27  Q_PROPERTY( qreal x READ readonlyX NOTIFY readonlyXChanged )
28  Q_PROPERTY( qreal y READ readonlyY NOTIFY readonlyYChanged )
29  Q_PROPERTY( qreal width READ readonlyWidth NOTIFY readonlyWidthChanged )
30  Q_PROPERTY( qreal height READ readonlyHeight NOTIFY readonlyHeightChanged )
31 
32  Q_PROPERTY( Marble::MarbleQuickItem* map READ map WRITE setMap NOTIFY mapChanged )
33 
34  Q_PROPERTY( QVariantList geoCoordinates READ geoCoordinates WRITE setGeoCoordinates NOTIFY geoCoordinatesChanged )
35  Q_PROPERTY( QVariantList screenCoordinates READ screenCoordinates NOTIFY screenCoordinatesChanged )
36  Q_PROPERTY( bool observable READ observable NOTIFY observableChanged )
37  Q_PROPERTY( bool tessellate READ tessellate WRITE setTessellate NOTIFY tessellateChanged )
38  Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged )
39  Q_PROPERTY( qreal lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged )
40 
41  // When enabled only those screenCoordinates are calculated and rendered that are visible on the screen.
42  // Setting this to false can severely reduce performance. Therefore this defaults to true.
43  Q_PROPERTY( bool clipScreenCoordinates READ clipScreenCoordinates WRITE setClipScreenCoordinates NOTIFY clipScreenCoordinatesChanged )
44 
45  public:
46  /** Constructor */
47  explicit GeoPolyline( QQuickItem *parent = nullptr );
48 
49  MarbleQuickItem* map() const;
50 
51  void setMap(MarbleQuickItem* map);
52 
53  bool observable() const;
54 
55  QVariantList geoCoordinates() const;
56 
57  void setGeoCoordinates(const QVariantList & geoCoordinates);
58 
59  QVariantList screenCoordinates() const;
60 
61  QColor lineColor() const;
62  qreal lineWidth() const;
63  bool tessellate() const;
64  bool clipScreenCoordinates() const;
65 
66  void setLineColor(const QColor& lineColor);
67  void setLineWidth(const qreal lineWidth);
68  void setTessellate(bool tessellate);
69  void setClipScreenCoordinates(bool clipped);
70 
71  qreal readonlyX() const;
72 
73  qreal readonlyY() const;
74 
75  qreal readonlyWidth() const;
76 
77  qreal readonlyHeight() const;
78 
79  Q_SIGNALS:
80  void mapChanged(MarbleQuickItem* map);
81  void observableChanged(bool observable);
82  void geoCoordinatesChanged();
83  void screenCoordinatesChanged();
84  void lineColorChanged(QColor lineColor);
85  void lineWidthChanged(qreal lineWidth);
86 
87  void tessellateChanged(bool tessellate);
88  void clipScreenCoordinatesChanged(bool enabled);
89 
90  void readonlyXChanged();
91  void readonlyYChanged();
92  void readonlyWidthChanged();
93  void readonlyHeightChanged();
94 
95  protected:
96  QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
97 
98  private:
99  MarbleQuickItem* m_map;
100  bool m_observable;
101  GeoDataLineString m_lineString;
102  QVariantList m_geoCoordinates;
103  QVector<QPolygonF> m_screenPolygons;
104  QVariantList m_screenCoordinates;
105  QColor m_lineColor;
106  qreal m_lineWidth;
107  bool m_tessellate;
108  bool m_clipScreenCoordinates;
109 
110  void updateScreenPositions();
111  };
112 }
113 
114 #endif // MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Binds a QML item to a specific geodetic location in screen coordinates.
Q_SIGNALSQ_SIGNALS
virtual QSGNode * updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData)
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.