Marble

MarbleAbstractPresenter.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2006-2008 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2014 Adam Dabrowski <[email protected]>
6 //
7 
8 #ifndef MARBLEABSTRACTPRESENTER_H
9 #define MARBLEABSTRACTPRESENTER_H
10 
11 #include <QList>
12 
13 #include "GeoDataLatLonBox.h"
14 #include "MarblePhysics.h"
15 #include <marble_export.h>
16 
17 namespace Marble
18 {
19 
20 class GeoDataPlacemark;
21 class GeoDataLookAt;
22 class MarbleMap;
23 class MarbleModel;
24 class ViewportParams;
25 
26  class MARBLE_EXPORT MarbleAbstractPresenter : public QObject
27  {
28  Q_OBJECT
29 
30  Q_SIGNALS:
31  void zoomChanged(int zoom);
32  void distanceChanged(const QString& distanceString);
33 
34  /**
35  * This signal is emit when a new rectangle region is selected over the map.
36  *
37  * @param boundingBox The geographical coordinates of the selected region
38  */
39  void regionSelected(const GeoDataLatLonBox &boundingBox);
40 
41  public:
42  explicit MarbleAbstractPresenter(MarbleMap *map, QObject *parent = nullptr);
43  ~MarbleAbstractPresenter() override;
44 
45  qreal moveStep() const;
46  int radius() const;
47 
48  GeoDataLookAt lookAt() const;
49 
50  QString distanceString() const;
51 
52  /**
53  * @brief Approximated altitude of the camera in km
54  */
55  qreal distance() const;
56 
57  /**
58  * @brief An approximate distance from @p radius
59  * @param radius radius of planet disc in screen pixels
60  */
61  qreal distanceFromRadius(qreal radius) const;
62 
63  /**
64  * @brief The radius of the rendered planet disc derived from the approximate apparent @p distance
65  */
66  qreal radiusFromDistance(qreal distance) const;
67 
68  /**
69  * @brief Rotate the globe in the given direction in discrete steps
70  * @param stepsRight Number of steps to go right. Negative values go left.
71  * @param stepsDown Number of steps to go down. Negative values go up.
72  * @param mode Interpolation mode to use when traveling to the target
73  */
74  void moveByStep(int stepsRight, int stepsDown, FlyToMode mode = Automatic);
75 
76  int polarity() const;
77  int zoom() const;
78  int minimumZoom() const;
79  int maximumZoom() const;
80 
81  qreal distanceFromZoom(qreal zoom) const;
82  qreal zoomFromDistance(qreal distance) const;
83 
84  void zoomAt(const QPoint &pos, qreal newDistance);
85  void moveTo(const QPoint &pos, qreal factor);
86 
87  qreal centerLongitude() const;
88  qreal centerLatitude() const;
89 
90  ViewContext viewContext() const;
91 
92  qreal zoom(qreal radius) const;
93  qreal radius(qreal zoom) const;
94 
95  MarbleMap* map();
96  MarbleModel* model();
97 
98  const MarbleMap* map() const;
99  const MarbleModel* model() const;
100 
101  int logzoom() const;
102  void setLogzoom(int value);
103 
104  int zoomStep() const;
105  qreal viewAngle() const;
106 
107  bool animationsEnabled() const;
108 
109  ViewportParams *viewport();
110  const ViewportParams* viewport() const;
111 
112  public Q_SLOTS:
113  void rotateBy(const qreal deltaLon, const qreal deltaLat, FlyToMode mode = Instant);
114  void flyTo(const GeoDataLookAt &newLookAt, FlyToMode mode = Automatic);
115  void goHome(FlyToMode mode = Automatic);
116 
117  void setZoom(int newZoom, FlyToMode mode = Instant);
118  void zoomView(int zoom, FlyToMode mode = Instant);
119  void zoomViewBy(int zoomStep, FlyToMode mode = Instant);
120  void zoomIn(FlyToMode mode = Automatic);
121  void zoomOut(FlyToMode mode = Automatic);
122  void zoomAtBy(const QPoint &pos, int zoomStep);
123 
124  void setViewContext(ViewContext viewContext);
125 
126  void centerOn(const qreal lon, const qreal lat, bool animated = false);
127  void centerOn(const GeoDataCoordinates &point, bool animated = false);
128  void centerOn(const GeoDataLatLonBox& box, bool animated = false);
129  void centerOn(const GeoDataPlacemark& placemark, bool animated = false);
130  void headingOn(qreal heading);
131  void setCenterLatitude(qreal lat, FlyToMode mode);
132  void setCenterLongitude(qreal lon, FlyToMode mode);
133 
134  void setAnimationsEnabled(bool enabled);
135  void setRadius(int radius);
136  void setDistance(qreal newDistance);
137  void setSelection(const QRect& region);
138 
139  private:
140  MarbleMap *const m_map;
141  MarblePhysics m_physics;
142 
143  bool m_animationsEnabled;
144  int m_logzoom;
145  int m_zoomStep;
146  const qreal m_viewAngle;
147  };
148 }
149 
150 
151 #endif // MARBLEABSTRACTPRESENTER_H
ViewContext
This enum is used to choose context in which map quality gets used.
Definition: MarbleGlobal.h:66
QAction * zoomOut(const QObject *recvr, const char *slot, QObject *parent)
KOSM_EXPORT double distance(const std::vector< const OSM::Node * > &path, Coordinate coord)
QAction * zoom(const QObject *recvr, const char *slot, QObject *parent)
Binds a QML item to a specific geodetic location in screen coordinates.
FlyToMode
Describes possible flight mode (interpolation between source and target camera positions)
Definition: MarbleGlobal.h:162
@ Automatic
A sane value is chosen automatically depending on animation settings and the action.
Definition: MarbleGlobal.h:163
QAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
@ Instant
Change camera position immediately (no interpolation)
Definition: MarbleGlobal.h:164
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Oct 4 2023 04:09:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.