Marble

ViewportParams.h
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Inge Wallin <[email protected]>
9 // Copyright 2008 Jens-Michael Hoffmann <[email protected]>
10 //
11 
12 #ifndef MARBLE_VIEWPORTPARAMS_H
13 #define MARBLE_VIEWPORTPARAMS_H
14 
15 
22 #include <QSize>
23 
24 #include "GeoDataCoordinates.h"
25 #include "Quaternion.h"
26 #include "MarbleGlobal.h"
27 #include "marble_export.h"
28 
29 class QPolygonF;
30 class QPainterPath;
31 
32 namespace Marble
33 {
34 
35 class GeoDataLatLonAltBox;
36 class GeoDataLatLonBox;
37 class GeoDataLineString;
38 class AbstractProjection;
39 class ViewportParamsPrivate;
40 
46 class MARBLE_EXPORT ViewportParams
47 {
48  public:
49  ViewportParams( );
50  explicit ViewportParams( Projection projection,
51  qreal centerLongitude = 0, qreal centerLatitude = 0,
52  int radius = 2000,
53  const QSize &size = QSize( 100, 100 ) );
54  ~ViewportParams();
55 
56  // Getters and setters
57  Projection projection() const;
58  const AbstractProjection *currentProjection() const;
59  void setProjection(Projection newProjection);
60 
61  int polarity() const;
62 
63  const GeoDataLatLonAltBox& viewLatLonAltBox() const;
64 
65  GeoDataLatLonAltBox latLonAltBox( const QRect &screenRect ) const;
66 
67  // Calculates an educated guess for the average angle in radians covered per pixel.
68  // Given a certain resolution it doesn't make much sense
69  // - to display an object that covers an angle that is smaller than that.
70  // - to display two points as distinct points if they are separated by a
71  // an angular distance that is smaller. Instead only one point should be shown.
72  // So this method helps to filter out details.
73  // It's somewhat related to https://en.wikipedia.org/wiki/Angular_resolution
74 
75  qreal angularResolution() const;
76 
77  // Determines whether a geographical feature is big enough so that it should
78  // represent a single point on the screen already.
79  // See angularResolution()
80 
81  bool resolves ( const GeoDataLatLonBox &latLonBox, qreal pixel = 2.0 ) const;
82 
83  bool resolves ( const GeoDataLatLonAltBox &latLonAltBox, qreal pixel = 2.0, qreal altitude = 10000.0 ) const;
84 
85  // Determines whether two points are located enough apart so that it makes
86  // sense to display them as distinct points. If this is not the case
87  // calculation and drawing of one point can be skipped as only a single
88  // point will be displayed on the screen.
89 
90  bool resolves ( const GeoDataCoordinates &coord1, const GeoDataCoordinates &coord2 ) const;
91 
92  int radius() const;
93 
98  void setRadius(int radius);
99 
100  void centerOn( qreal lon, qreal lat );
101  void setHeading( qreal heading );
102 
103  Quaternion planetAxis() const;
104  const matrix &planetAxisMatrix() const;
105 
106  int width() const;
107  int height() const;
108  QSize size() const;
109 
110  void setWidth(int newWidth);
111  void setHeight(int newHeight);
112  void setSize(const QSize& newSize);
113 
114  qreal centerLongitude() const;
115  qreal centerLatitude() const;
116 
128  bool screenCoordinates( const qreal lon, const qreal lat,
129  qreal &x, qreal &y ) const;
130 
144  bool screenCoordinates( const GeoDataCoordinates &geopoint,
145  qreal &x, qreal &y,
146  bool &globeHidesPoint ) const;
147 
148  // Will just call the virtual version with a dummy globeHidesPoint.
149  bool screenCoordinates( const GeoDataCoordinates &geopoint,
150  qreal &x, qreal &y ) const;
151 
168  bool screenCoordinates( const GeoDataCoordinates &coordinates,
169  qreal *x, qreal &y, int &pointRepeatNum,
170  const QSizeF& size,
171  bool &globeHidesPoint ) const;
172 
173 
174  bool screenCoordinates( const GeoDataLineString &lineString,
175  QVector<QPolygonF*> &polygons ) const;
176 
187  bool geoCoordinates( const int x, const int y,
188  qreal &lon, qreal &lat,
189  GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const;
190 
191  qreal heading() const;
192  bool mapCoversViewport() const;
193 
194  QPainterPath mapShape() const;
195 
196  QRegion mapRegion() const;
197 
204  GeoDataCoordinates focusPoint() const;
205 
211  void setFocusPoint(const GeoDataCoordinates &focusPoint);
212 
217  void resetFocusPoint();
218 
219  private:
220  Q_DISABLE_COPY( ViewportParams )
221  ViewportParamsPrivate * const d;
222 };
223 
224 }
225 
226 #endif
Unit
enum used constructor to specify the units used
A 3d point representation.
Binds a QML item to a specific geodetic location in screen coordinates.
A LineString that allows to store a contiguous set of line segments.
A public class that controls what is visible in the viewport of a Marble map.
A base class for all projections in Marble.
Projection
This enum is used to choose the projection shown in the view.
Definition: MarbleGlobal.h:45
A class that defines a 3D bounding box for geographic data.
A class that defines a 2D bounding box for geographic data.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 6 2020 23:18:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.