File indexing completed on 2024-05-05 03:50:49

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Andrew Manson <g.real.ate@gmail.com>
0004 // SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
0005 // SPDX-FileCopyrightText: 2010 Thibaut Gridel <tgridel@free.fr>
0006 //
0007 
0008 #ifndef POSITION_MARKER_H
0009 #define POSITION_MARKER_H
0010 
0011 #include <QHash>
0012 #include <QVector>
0013 #include <QColor>
0014 #include <QPolygon>
0015 #include <QPixmap>
0016 
0017 #include "DialogConfigurationInterface.h"
0018 #include "RenderPlugin.h"
0019 #include "GeoDataCoordinates.h"
0020 #include "GeoDataLatLonAltBox.h"
0021 
0022 namespace Ui
0023 {
0024     class PositionMarkerConfigWidget;
0025 }
0026 
0027 namespace Marble
0028 {
0029 
0030 class PositionMarker  : public RenderPlugin, public DialogConfigurationInterface
0031 {
0032     Q_OBJECT
0033     Q_PLUGIN_METADATA(IID "org.kde.marble.PositionMarker")
0034     Q_INTERFACES( Marble::RenderPluginInterface )
0035     Q_INTERFACES( Marble::DialogConfigurationInterface )
0036     MARBLE_PLUGIN( PositionMarker )
0037  public:
0038     explicit PositionMarker(const MarbleModel *marbleModel = nullptr );
0039     ~PositionMarker () override;
0040 
0041     QStringList renderPosition() const override;
0042 
0043     QString renderPolicy() const override;
0044 
0045     QStringList backendTypes() const override;
0046 
0047     QString name() const override;
0048 
0049     QString guiString() const override;
0050 
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     QDialog *configDialog() override;
0064 
0065     void initialize () override;
0066 
0067     bool isInitialized () const override;
0068 
0069     bool render( GeoPainter *painter, ViewportParams *viewport,
0070                  const QString& renderPos, GeoSceneLayer * layer = nullptr ) override;
0071 
0072     // Overriding LayerInterface to paint on top of the route
0073     qreal zValue() const override;
0074 
0075     /**
0076      * @return: The settings of the item.
0077      */
0078     QHash<QString,QVariant> settings() const override;
0079 
0080     /**
0081      * Set the settings of the item.
0082      */
0083     void setSettings( const QHash<QString,QVariant> &settings ) override;
0084 
0085 
0086  public Q_SLOTS:
0087     void readSettings();
0088     void writeSettings();
0089 
0090     void setPosition( const GeoDataCoordinates &position );
0091     void chooseCustomCursor();
0092     void chooseColor();
0093     void resizeCursor( int step );
0094 
0095  private:
0096     Q_DISABLE_COPY( PositionMarker )
0097 
0098     void loadCustomCursor( const QString& filename, bool useCursor );
0099     void loadDefaultCursor();
0100 
0101     const MarbleModel *m_marbleModel;
0102 
0103     bool           m_isInitialized;
0104     bool           m_useCustomCursor;
0105 
0106     const QString m_defaultCursorPath;
0107     GeoDataLatLonAltBox m_lastBoundingBox;
0108     GeoDataCoordinates  m_currentPosition;
0109     GeoDataCoordinates  m_previousPosition;
0110     
0111     Ui::PositionMarkerConfigWidget *ui_configWidget;
0112     QDialog *m_configDialog;
0113     QString m_cursorPath;
0114 
0115     QPolygonF           m_arrow;
0116     QPolygonF           m_previousArrow;
0117     QRegion             m_dirtyRegion;
0118     QPixmap             m_customCursor;
0119     QPixmap             m_customCursorTransformed;
0120     QPixmap             m_defaultCursor;
0121     float               m_cursorSize;
0122     QColor              m_accuracyColor;
0123     QColor              m_trailColor;
0124     qreal               m_heading;
0125     QVector<GeoDataCoordinates> m_trail;
0126     static const int    sm_numTrailPoints = 6;
0127     bool                m_showTrail;
0128 
0129     static const int sm_defaultSizeStep;
0130     static const int sm_numResizeSteps;
0131     static const float sm_resizeSteps[];
0132 };
0133 
0134 }
0135 
0136 #endif