File indexing completed on 2024-05-12 15:31:07
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2011 Michael Henning <mikehenning@eclipse.net> 0006 // 0007 0008 // 0009 // MeasureToolPlugin enables Marble to set and display measure points 0010 // 0011 0012 #ifndef MARBLE_MEASURETOOLPLUGIN_H 0013 #define MARBLE_MEASURETOOLPLUGIN_H 0014 0015 #include "DialogConfigurationInterface.h" 0016 #include "GeoDataLatLonAltBox.h" 0017 #include "GeoDataLineString.h" 0018 #include "RenderPlugin.h" 0019 #include "MarbleWidget.h" 0020 0021 #include <QFont> 0022 #include <QPen> 0023 #include <QAction> 0024 #include <QPixmap> 0025 0026 namespace Marble 0027 { 0028 0029 class MeasureConfigDialog; 0030 class MeasureToolPlugin : public RenderPlugin, public DialogConfigurationInterface 0031 { 0032 Q_OBJECT 0033 Q_PLUGIN_METADATA(IID "org.kde.marble.MeasureToolPlugin") 0034 Q_INTERFACES( Marble::RenderPluginInterface ) 0035 Q_INTERFACES( Marble::DialogConfigurationInterface ) 0036 MARBLE_PLUGIN( MeasureToolPlugin ) 0037 0038 public: 0039 explicit MeasureToolPlugin( const MarbleModel *marbleModel = nullptr ); 0040 0041 enum PaintMode { 0042 Polygon = 0, 0043 Circular 0044 }; 0045 0046 QStringList backendTypes() const override; 0047 QString renderPolicy() const override; 0048 QStringList renderPosition() const override; 0049 QString name() const override; 0050 QString guiString() const override; 0051 QString nameId() const override; 0052 0053 QString version() const override; 0054 0055 QString description() const override; 0056 0057 QString copyrightYears() const override; 0058 0059 QVector<PluginAuthor> pluginAuthors() const override; 0060 0061 QIcon icon () const override; 0062 0063 void initialize () override; 0064 0065 bool isInitialized () const override; 0066 0067 bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = nullptr ) override; 0068 0069 QDialog *configDialog() override; 0070 QHash<QString,QVariant> settings() const override; 0071 void setSettings( const QHash<QString,QVariant> &settings ) override; 0072 0073 Q_SIGNALS: 0074 void numberOfMeasurePointsChanged( int newNumber ); 0075 0076 public Q_SLOTS: 0077 bool eventFilter( QObject *object, QEvent *event ) override; 0078 0079 private: 0080 void drawMeasurePoints( GeoPainter *painter ); 0081 void drawInfobox( GeoPainter *painter ) const; 0082 void drawSegments( GeoPainter *painter ); 0083 void addContextItems(); 0084 void removeContextItems(); 0085 0086 private Q_SLOTS: 0087 void setNumberOfMeasurePoints( int number ); 0088 void addMeasurePointEvent(); 0089 0090 void addMeasurePoint( qreal lon, qreal lat ); 0091 void removeLastMeasurePoint(); 0092 void removeMeasurePoints(); 0093 0094 void writeSettings(); 0095 0096 private: 0097 Q_DISABLE_COPY( MeasureToolPlugin ) 0098 0099 static QString meterToPreferredUnit(qreal meters, bool isSquare = false); 0100 0101 // The line strings in the distance path. 0102 GeoDataLineString m_measureLineString; 0103 GeoDataLatLonAltBox m_latLonAltBox; 0104 0105 QPixmap m_mark; 0106 QFont m_font_regular; 0107 int m_fontascent; 0108 0109 QPen m_pen; 0110 0111 QAction *m_addMeasurePointAction; 0112 QAction *m_removeLastMeasurePointAction; 0113 QAction *m_removeMeasurePointsAction; 0114 QAction *m_separator; 0115 0116 MarbleWidget* m_marbleWidget; 0117 0118 MeasureConfigDialog *m_configDialog; 0119 0120 bool m_showDistanceLabel; 0121 bool m_showBearingLabel; 0122 bool m_showBearingChangeLabel; 0123 0124 bool m_showPolygonArea; 0125 bool m_showCircularArea; 0126 bool m_showRadius; 0127 bool m_showPerimeter; 0128 bool m_showCircumference; 0129 0130 qreal m_totalDistance; 0131 qreal m_polygonArea; 0132 qreal m_circularArea; 0133 qreal m_radius; 0134 qreal m_perimeter; 0135 qreal m_circumference; 0136 0137 PaintMode m_paintMode; 0138 }; 0139 0140 } 0141 0142 #endif // MARBLE_MEASURETOOLPLUGIN_H