File indexing completed on 2024-04-14 03:47:51
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2008 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2014 Adam Dabrowski <adamdbrw@gmail.com> 0006 // 0007 0008 #ifndef MARBLEABSTRACTPRESENTER_H 0009 #define MARBLEABSTRACTPRESENTER_H 0010 0011 #include <QList> 0012 0013 #include "GeoDataLatLonBox.h" 0014 #include "MarblePhysics.h" 0015 #include <marble_export.h> 0016 0017 namespace Marble 0018 { 0019 0020 class GeoDataPlacemark; 0021 class GeoDataLookAt; 0022 class MarbleMap; 0023 class MarbleModel; 0024 class ViewportParams; 0025 0026 class MARBLE_EXPORT MarbleAbstractPresenter : public QObject 0027 { 0028 Q_OBJECT 0029 0030 Q_SIGNALS: 0031 void zoomChanged(int zoom); 0032 void distanceChanged(const QString& distanceString); 0033 0034 /** 0035 * This signal is emit when a new rectangle region is selected over the map. 0036 * 0037 * @param boundingBox The geographical coordinates of the selected region 0038 */ 0039 void regionSelected(const GeoDataLatLonBox &boundingBox); 0040 0041 public: 0042 explicit MarbleAbstractPresenter(MarbleMap *map, QObject *parent = nullptr); 0043 ~MarbleAbstractPresenter() override; 0044 0045 qreal moveStep() const; 0046 int radius() const; 0047 0048 GeoDataLookAt lookAt() const; 0049 0050 QString distanceString() const; 0051 0052 /** 0053 * @brief Approximated altitude of the camera in km 0054 */ 0055 qreal distance() const; 0056 0057 /** 0058 * @brief An approximate distance from @p radius 0059 * @param radius radius of planet disc in screen pixels 0060 */ 0061 qreal distanceFromRadius(qreal radius) const; 0062 0063 /** 0064 * @brief The radius of the rendered planet disc derived from the approximate apparent @p distance 0065 */ 0066 qreal radiusFromDistance(qreal distance) const; 0067 0068 /** 0069 * @brief Rotate the globe in the given direction in discrete steps 0070 * @param stepsRight Number of steps to go right. Negative values go left. 0071 * @param stepsDown Number of steps to go down. Negative values go up. 0072 * @param mode Interpolation mode to use when traveling to the target 0073 */ 0074 void moveByStep(int stepsRight, int stepsDown, FlyToMode mode = Automatic); 0075 0076 int polarity() const; 0077 int zoom() const; 0078 int minimumZoom() const; 0079 int maximumZoom() const; 0080 0081 qreal distanceFromZoom(qreal zoom) const; 0082 qreal zoomFromDistance(qreal distance) const; 0083 0084 void zoomAt(const QPoint &pos, qreal newDistance); 0085 void moveTo(const QPoint &pos, qreal factor); 0086 0087 qreal centerLongitude() const; 0088 qreal centerLatitude() const; 0089 0090 ViewContext viewContext() const; 0091 0092 qreal zoom(qreal radius) const; 0093 qreal radius(qreal zoom) const; 0094 0095 MarbleMap* map(); 0096 MarbleModel* model(); 0097 0098 const MarbleMap* map() const; 0099 const MarbleModel* model() const; 0100 0101 int logzoom() const; 0102 void setLogzoom(int value); 0103 0104 int zoomStep() const; 0105 qreal viewAngle() const; 0106 0107 bool animationsEnabled() const; 0108 0109 ViewportParams *viewport(); 0110 const ViewportParams* viewport() const; 0111 0112 public Q_SLOTS: 0113 void rotateBy(const qreal deltaLon, const qreal deltaLat, FlyToMode mode = Instant); 0114 void flyTo(const GeoDataLookAt &newLookAt, FlyToMode mode = Automatic); 0115 void goHome(FlyToMode mode = Automatic); 0116 0117 void setZoom(int newZoom, FlyToMode mode = Instant); 0118 void zoomView(int zoom, FlyToMode mode = Instant); 0119 void zoomViewBy(int zoomStep, FlyToMode mode = Instant); 0120 void zoomIn(FlyToMode mode = Automatic); 0121 void zoomOut(FlyToMode mode = Automatic); 0122 void zoomAtBy(const QPoint &pos, int zoomStep); 0123 0124 void setViewContext(ViewContext viewContext); 0125 0126 void centerOn(const qreal lon, const qreal lat, bool animated = false); 0127 void centerOn(const GeoDataCoordinates &point, bool animated = false); 0128 void centerOn(const GeoDataLatLonBox& box, bool animated = false); 0129 void centerOn(const GeoDataPlacemark& placemark, bool animated = false); 0130 void headingOn(qreal heading); 0131 void setCenterLatitude(qreal lat, FlyToMode mode); 0132 void setCenterLongitude(qreal lon, FlyToMode mode); 0133 0134 void setAnimationsEnabled(bool enabled); 0135 void setRadius(int radius); 0136 void setDistance(qreal newDistance); 0137 void setSelection(const QRect& region); 0138 0139 private: 0140 MarbleMap *const m_map; 0141 MarblePhysics m_physics; 0142 0143 bool m_animationsEnabled; 0144 int m_logzoom; 0145 int m_zoomStep; 0146 const qreal m_viewAngle; 0147 }; 0148 } 0149 0150 0151 #endif // MARBLEABSTRACTPRESENTER_H