1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Siddharth Srivastava <akssps011@gmail.com>
4 //
5 
6 #ifndef MARBLE_AUTONAVIGATION_H
7 #define MARBLE_AUTONAVIGATION_H
8 
9 #include "marble_export.h"
10 #include "MarbleGlobal.h"
11 
12 #include <QObject>
13 
14 namespace Marble
15 {
16 
17 class GeoDataCoordinates;
18 class MarbleModel;
19 class ViewportParams;
20 
21 class MARBLE_EXPORT AutoNavigation : public QObject
22 {
23     Q_OBJECT
24 
25 public:
26 
27     /**
28      * @brief Constructor
29      * @param widget the marble widget. It cannot be null.
30      * @param parent optional parent object
31      */
32     explicit AutoNavigation( MarbleModel *model, const ViewportParams *viewport, QObject *parent = nullptr );
33 
34     /** Destructor */
35     ~AutoNavigation() override;
36 
37     /**
38     * An enum type
39     * Represents which recentering method is selected
40     */
41     enum CenterMode {
42             DontRecenter = 0,
43             AlwaysRecenter = 1,    /**< Enum Value AlwaysRecenter. Recenter always to the map center */
44             RecenterOnBorder = 2   /**< Enum Value RecenterOnBorder. Recenter when reaching map border */
45     };
46 
47     /**
48      * @brief For Auto Centering adjustment of map in Navigation Mode
49      * @param recenterMode toggles among the recenteing method chosen
50      * @see CenterMode
51      */
52     void setRecenter( CenterMode recenterMode );
53 
54     /**
55      * @brief For Auto Zooming adjustment of map in Navigation Mode
56      * @param activate true to enable auto zooming
57      */
58      void setAutoZoom( bool activate );
59 
60      AutoNavigation::CenterMode recenterMode() const;
61 
62      bool autoZoom() const;
63 
64 public Q_SLOTS:
65 
66     /**
67      * @brief For adjusting the gps location (recentering) or map(autozooming)
68      * @param position current gps location
69      * @param speed of the gps device
70      */
71      void adjust( const GeoDataCoordinates &position, qreal speed );
72 
73     /**
74      * Temporarily inhibits auto-centering and auto-zooming
75      */
76     void inhibitAutoAdjustments();
77 
78 Q_SIGNALS:
79     /**
80      * signal emitted when auto center is turned on (Always re-center, re-center when required ) or off(Disabled)
81      * @param recenterMode the mode for re-centering selected
82      */
83      void recenterModeChanged( AutoNavigation::CenterMode mode );
84 
85     /**
86      * signal emitted when auto zoom is toggled
87      */
88      void autoZoomToggled( bool enabled );
89 
90     void zoomIn( FlyToMode );
91 
92     void zoomOut( FlyToMode );
93 
94     void centerOn( const GeoDataCoordinates &position, bool animated );
95 
96 private:
97     class Private;
98     Private * const d;
99 };
100 } //namespace marble
101 
102 #endif // MARBLE_AUTONAVIGATION_H
103