File indexing completed on 2024-12-08 06:35:35
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011-2012 Florian Eßer <f.esser@rwth-aachen.de> 0004 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0005 // SPDX-FileCopyrightText: 2013 Roman Karlstetter <roman.karlstetter@googlemail.com> 0006 // 0007 0008 #ifndef ELEVATIONPROFILEDATASOURCE_H 0009 #define ELEVATIONPROFILEDATASOURCE_H 0010 0011 #include <QObject> 0012 0013 #include <QHash> 0014 #include <QList> 0015 #include <QPointF> 0016 #include <QStringList> 0017 0018 namespace Marble 0019 { 0020 0021 class ElevationModel; 0022 class GeoDataCoordinates; 0023 class GeoDataLineString; 0024 class GeoDataObject; 0025 class GeoDataTrack; 0026 class GeoDataTreeModel; 0027 class RoutingModel; 0028 0029 class ElevationProfileDataSource : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit ElevationProfileDataSource( QObject *parent = nullptr ); 0035 0036 /** 0037 * @brief isDataAvailable 0038 * @return true if data is available to display 0039 */ 0040 virtual bool isDataAvailable() const = 0; 0041 0042 public Q_SLOTS: 0043 virtual void requestUpdate() = 0; 0044 0045 Q_SIGNALS: 0046 void sourceCountChanged(); 0047 void dataUpdated(const GeoDataLineString &points, const QVector<QPointF> &elevationData); 0048 0049 protected: 0050 QVector<QPointF> calculateElevationData(const GeoDataLineString &lineString) const; 0051 virtual qreal getElevation(const GeoDataCoordinates &coordinates) const = 0; 0052 }; 0053 0054 /** 0055 * @brief The ElevationProfileTrackDataSource provides elevation profile of GeoDataTrack Objects in the marblemodel 0056 */ 0057 class ElevationProfileTrackDataSource : public ElevationProfileDataSource 0058 { 0059 Q_OBJECT 0060 0061 public: 0062 explicit ElevationProfileTrackDataSource( const GeoDataTreeModel *treeModel, QObject *parent = nullptr ); 0063 0064 bool isDataAvailable() const override; 0065 0066 QStringList sourceDescriptions() const; 0067 0068 void setSourceIndex(int index); 0069 0070 int currentSourceIndex() const; 0071 0072 public Q_SLOTS: 0073 void requestUpdate() override; 0074 0075 protected: 0076 qreal getElevation(const GeoDataCoordinates &coordinates) const override; 0077 0078 private Q_SLOTS: 0079 void handleObjectAdded( GeoDataObject *object ); 0080 void handleObjectRemoved( GeoDataObject *object ); 0081 0082 private: 0083 QHash<QString, QList<const GeoDataTrack *> > m_trackHash; 0084 QStringList m_trackChooserList; 0085 QList<const GeoDataTrack *> m_trackList; 0086 int m_currentSourceIndex; 0087 }; 0088 0089 /** 0090 * @brief The ElevationProfileRouteDataSource provides elevation profile of the current route 0091 */ 0092 class ElevationProfileRouteDataSource : public ElevationProfileDataSource 0093 { 0094 Q_OBJECT 0095 0096 public: 0097 ElevationProfileRouteDataSource( const RoutingModel *routingModel, const ElevationModel *elevationModel, QObject *parent = nullptr ); 0098 0099 bool isDataAvailable() const override; 0100 0101 public Q_SLOTS: 0102 void requestUpdate() override; 0103 0104 protected: 0105 qreal getElevation(const GeoDataCoordinates &coordinates) const override; 0106 0107 private: 0108 const RoutingModel *const m_routingModel; 0109 const ElevationModel *const m_elevationModel; 0110 bool m_routeAvailable; // save state if route is available to notify FloatItem when this changes 0111 }; 0112 0113 } 0114 0115 #endif // ELEVATIONPROFILEDATASOURCE_H