File indexing completed on 2024-05-05 03:49:16
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2019 Torsten Rahn <rahn@kde.org> 0004 // 0005 0006 #ifndef MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H 0007 #define MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H 0008 0009 #include "GeoDataCoordinates.h" 0010 #include "GeoDataLineString.h" 0011 #include <QQuickItem> 0012 #include <QObject> 0013 #include <QtQml> 0014 0015 /** 0016 * Represents a coordinate with the properties of a name and coordinates 0017 * 0018 * @todo: Introduce GeoDataCoordinates 0019 */ 0020 namespace Marble 0021 { 0022 class MarbleQuickItem; 0023 0024 class GeoPolyline : public QQuickItem 0025 { 0026 Q_OBJECT 0027 Q_PROPERTY( qreal x READ readonlyX NOTIFY readonlyXChanged ) 0028 Q_PROPERTY( qreal y READ readonlyY NOTIFY readonlyYChanged ) 0029 Q_PROPERTY( qreal width READ readonlyWidth NOTIFY readonlyWidthChanged ) 0030 Q_PROPERTY( qreal height READ readonlyHeight NOTIFY readonlyHeightChanged ) 0031 0032 Q_PROPERTY( Marble::MarbleQuickItem* map READ map WRITE setMap NOTIFY mapChanged ) 0033 0034 Q_PROPERTY( QVariantList geoCoordinates READ geoCoordinates WRITE setGeoCoordinates NOTIFY geoCoordinatesChanged ) 0035 Q_PROPERTY( QVariantList screenCoordinates READ screenCoordinates NOTIFY screenCoordinatesChanged ) 0036 Q_PROPERTY( bool observable READ observable NOTIFY observableChanged ) 0037 Q_PROPERTY( bool tessellate READ tessellate WRITE setTessellate NOTIFY tessellateChanged ) 0038 Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged ) 0039 Q_PROPERTY( qreal lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged ) 0040 0041 // When enabled only those screenCoordinates are calculated and rendered that are visible on the screen. 0042 // Setting this to false can severely reduce performance. Therefore this defaults to true. 0043 Q_PROPERTY( bool clipScreenCoordinates READ clipScreenCoordinates WRITE setClipScreenCoordinates NOTIFY clipScreenCoordinatesChanged ) 0044 0045 public: 0046 /** Constructor */ 0047 explicit GeoPolyline( QQuickItem *parent = nullptr ); 0048 0049 MarbleQuickItem* map() const; 0050 0051 void setMap(MarbleQuickItem* map); 0052 0053 bool observable() const; 0054 0055 QVariantList geoCoordinates() const; 0056 0057 void setGeoCoordinates(const QVariantList & geoCoordinates); 0058 0059 QVariantList screenCoordinates() const; 0060 0061 QColor lineColor() const; 0062 qreal lineWidth() const; 0063 bool tessellate() const; 0064 bool clipScreenCoordinates() const; 0065 0066 void setLineColor(const QColor& lineColor); 0067 void setLineWidth(const qreal lineWidth); 0068 void setTessellate(bool tessellate); 0069 void setClipScreenCoordinates(bool clipped); 0070 0071 qreal readonlyX() const; 0072 0073 qreal readonlyY() const; 0074 0075 qreal readonlyWidth() const; 0076 0077 qreal readonlyHeight() const; 0078 0079 Q_SIGNALS: 0080 void mapChanged(MarbleQuickItem* map); 0081 void observableChanged(bool observable); 0082 void geoCoordinatesChanged(); 0083 void screenCoordinatesChanged(); 0084 void lineColorChanged(QColor lineColor); 0085 void lineWidthChanged(qreal lineWidth); 0086 0087 void tessellateChanged(bool tessellate); 0088 void clipScreenCoordinatesChanged(bool enabled); 0089 0090 void readonlyXChanged(); 0091 void readonlyYChanged(); 0092 void readonlyWidthChanged(); 0093 void readonlyHeightChanged(); 0094 0095 protected: 0096 QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override; 0097 0098 private: 0099 MarbleQuickItem* m_map; 0100 bool m_observable; 0101 GeoDataLineString m_lineString; 0102 QVariantList m_geoCoordinates; 0103 QVector<QPolygonF> m_screenPolygons; 0104 QVariantList m_screenCoordinates; 0105 QColor m_lineColor; 0106 qreal m_lineWidth; 0107 bool m_tessellate; 0108 bool m_clipScreenCoordinates; 0109 0110 void updateScreenPositions(); 0111 }; 0112 } 0113 0114 #endif // MARBLE_DECLARATIVE_GEOPOLYLINEITEM_H