Marble

MarbleModel.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 2005-2007 Torsten Rahn <[email protected]>
9 // Copyright 2007 Inge Wallin <[email protected]>
10 // Copyright 2010-2013 Bernhard Beschow <[email protected]>
11 //
12 
13 //
14 // MarbleModel is the data store and index class for the MarbleWidget.
15 //
16 
17 #ifndef MARBLE_MARBLEMODEL_H
18 #define MARBLE_MARBLEMODEL_H
19 
20 
21 /** @file
22  * This file contains the headers for MarbleModel
23  *
24  * @author Torsten Rahn <[email protected]>
25  * @author Inge Wallin <[email protected]>
26  */
27 
28 
29 
30 #include "marble_export.h"
31 
32 #include <QObject>
33 #include <QString>
34 
35 #include "MarbleGlobal.h"
36 
38 class QAbstractItemModel;
39 class QTextDocument;
40 class QDateTime;
41 
42 namespace Marble
43 {
44 
45 class GeoDataPlacemark;
46 class GeoPainter;
47 class MeasureTool;
48 class PositionTracking;
49 class HttpDownloadManager;
50 class MarbleModelPrivate;
51 class MarbleClock;
52 class SunLocator;
53 class TileCreator;
54 class PluginManager;
55 class GeoDataCoordinates;
56 class GeoDataTreeModel;
57 class GeoSceneDocument;
58 class Planet;
59 class RoutingManager;
60 class BookmarkManager;
61 class FileManager;
62 class ElevationModel;
63 
64 /**
65  * @short The data model (not based on QAbstractModel) for a MarbleWidget.
66  *
67  * This class provides a data storage and indexer that can be
68  * displayed in a MarbleWidget. It contains 3 different datatypes:
69  * <b>tiles</b> which provide the background, <b>vectors</b> which
70  * provide things like country borders and coastlines and
71  * <b>placemarks</b> which can show points of interest, such as
72  * cities, mountain tops or the poles.
73  *
74  * The <b>tiles</b> provide the background of the image and can be for
75  * instance height and depth fields, magnetic strength, topographic
76  * data or anything else that is area based.
77  *
78  * The <b>vectors</b> provide things like country borders and
79  * coastlines. They are stored in separate files and can be added or
80  * removed at anytime.
81  *
82  * The <b>placemarks</b> contain points of interest, such as cities,
83  * mountain tops or the poles. These are sorted by size (for cities)
84  * and category (capitals, other important cities, less important
85  * cities, etc) and are displayed with different color or shape like
86  * square or round.
87  *
88  * @see MarbleWidget
89  */
90 
91 class MARBLE_EXPORT MarbleModel : public QObject
92 {
93  friend class MarbleModelPrivate;
94 
95  Q_OBJECT
96 
97  Q_PROPERTY( QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY themeChanged )
98  Q_PROPERTY( bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged )
99 
100  public:
101  /**
102  * @brief Construct a new MarbleModel.
103  * @param parent the parent widget
104  */
105  explicit MarbleModel( QObject *parent = nullptr );
106  ~MarbleModel() override;
107 
108  /**
109  * @brief Return the list of Placemarks as a QAbstractItemModel *
110  * @return a list of all Placemarks in the MarbleModel.
111  */
112  GeoDataTreeModel *treeModel();
113  const GeoDataTreeModel *treeModel() const;
114 
115  QAbstractItemModel *groundOverlayModel();
116  const QAbstractItemModel *groundOverlayModel() const;
117 
118  QAbstractItemModel *placemarkModel();
119  const QAbstractItemModel *placemarkModel() const;
120 
121  QItemSelectionModel *placemarkSelectionModel();
122 
123  /**
124  * @brief Return the name of the current map theme.
125  * @return the identifier of the current MapTheme.
126  * To ensure that a unique identifier is being used the theme does NOT
127  * get represented by its name but the by relative location of the file
128  * that specifies the theme:
129  *
130  * Example:
131  * maptheme = "earth/bluemarble/bluemarble.dgml"
132  */
133  QString mapThemeId() const;
134 
135  GeoSceneDocument *mapTheme();
136  const GeoSceneDocument *mapTheme() const;
137  void setMapTheme( GeoSceneDocument * document );
138 
139  /**
140  * @brief Set a new map theme to use.
141  * @param mapThemeId the identifier of the new map theme
142  *
143  * This function sets the map theme, i.e. combination of tile set
144  * and color scheme to use. If the map theme is not previously
145  * used, some basic tiles are created and a progress dialog is
146  * shown.
147  *
148  * The ID of the new maptheme. To ensure that a unique
149  * identifier is being used the theme does NOT get represented by its
150  * name but the by relative location of the file that specifies the theme:
151  *
152  * Example:
153  * maptheme = "earth/bluemarble/bluemarble.dgml"
154  */
155  void setMapThemeId( const QString &mapThemeId );
156 
157  /**
158  * @brief get the home point
159  * @param lon the longitude of the home point.
160  * @param lat the latitude of the home point.
161  * @param zoom the default zoom level of the home point.
162  */
163  void home( qreal &lon, qreal &lat, int& zoom ) const;
164  /**
165  * @brief Set the home point
166  * @param lon the longitude of the new home point.
167  * @param lat the latitude of the new home point.
168  * @param zoom the default zoom level for the new home point.
169  */
170  void setHome( qreal lon, qreal lat, int zoom = 1050 );
171  /**
172  * @brief Set the home point
173  * @param homePoint the new home point.
174  * @param zoom the default zoom level for the new home point.
175  */
176  void setHome( const GeoDataCoordinates& homePoint, int zoom = 1050 );
177 
178  /**
179  * @brief Return the downloadmanager to load missing tiles
180  * @return the HttpDownloadManager instance.
181  */
182  HttpDownloadManager *downloadManager();
183  const HttpDownloadManager *downloadManager() const;
184 
185 
186  /**
187  * @brief Handle file loading into the treeModel
188  * @param filename the file to load
189  */
190  void addGeoDataFile( const QString& filename );
191 
192  /**
193  * @brief Handle raw data loading into the treeModel
194  * @param data the raw data to load
195  * @param key the name to remove this raw data later
196  */
197  void addGeoDataString( const QString& data, const QString& key = QLatin1String("data") );
198 
199  /**
200  * @brief Remove the file or raw data from the treeModel
201  * @param key either the file name or the key for raw data
202  */
203  void removeGeoData( const QString& key );
204 
205  FileManager *fileManager();
206 
207  PositionTracking *positionTracking() const;
208 
209  qreal planetRadius() const;
210  QString planetName() const;
211  QString planetId() const;
212 
213  MarbleClock *clock();
214  const MarbleClock *clock() const;
215 
216  SunLocator *sunLocator();
217  const SunLocator *sunLocator() const;
218 
219  /**
220  * @brief Returns the limit in kilobytes of the persistent (on hard disc) tile cache.
221  * @return the limit of persistent tile cache in kilobytes.
222  */
223  quint64 persistentTileCacheLimit() const;
224 
225  /**
226  * @brief Returns the limit of the volatile (in RAM) tile cache.
227  * @return the cache limit in kilobytes
228  */
229  quint64 volatileTileCacheLimit() const;
230 
231  const PluginManager* pluginManager() const;
232 
233  PluginManager* pluginManager();
234 
235  /**
236  * @brief Returns the planet object for the current map.
237  * @return the planet object for the current map
238  */
239  const Planet *planet() const;
240 
241  RoutingManager* routingManager();
242  const RoutingManager* routingManager() const;
243 
244  void setClockDateTime( const QDateTime& datetime );
245 
246  QDateTime clockDateTime() const;
247 
248  int clockSpeed() const;
249 
250  void setClockSpeed( int speed );
251 
252  void setClockTimezone( int timeInSec );
253 
254  int clockTimezone() const;
255 
256  /**
257  * return instance of BookmarkManager
258  */
259  BookmarkManager *bookmarkManager();
260 
261  QTextDocument * legend();
262 
263  /**
264  * @brief Uses the given text document as the new content of the legend
265  * Any previous legend content is overwritten. MarbleModel takes ownership
266  * of the passed document.
267  */
268  void setLegend( QTextDocument * document );
269 
270  bool workOffline() const;
271 
272  void setWorkOffline( bool workOffline );
273 
274  ElevationModel* elevationModel();
275  const ElevationModel* elevationModel() const;
276 
277  /**
278  * Returns the placemark being tracked by this model or 0 if no
279  * placemark is currently tracked.
280  * @see setTrackedPlacemark(), trackedPlacemarkChanged()
281  */
282  const GeoDataPlacemark *trackedPlacemark() const;
283 
284  public Q_SLOTS:
285  void clearPersistentTileCache();
286 
287  /**
288  * @brief Set the limit of the persistent (on hard disc) tile cache.
289  * @param kiloBytes The limit in kilobytes, 0 means no limit.
290  */
291  void setPersistentTileCacheLimit( quint64 kiloBytes );
292 
293  /**
294  * @brief Change the placemark tracked by this model
295  * @see trackedPlacemark(), trackedPlacemarkChanged()
296  */
297  void setTrackedPlacemark( const GeoDataPlacemark *placemark );
298 
299  void updateProperty( const QString &property, bool value );
300 
301  Q_SIGNALS:
302 
303  /**
304  * @brief Signal that the MarbleModel has started to create a new set of tiles.
305  * @param name name of the set
306  * @param description the set description
307  */
308  void creatingTilesStart( TileCreator*, const QString& name, const QString& description );
309 
310  /**
311  * @brief Signal that the map theme has changed, and to which theme.
312  * @param mapTheme the identifier of the new map theme.
313  * @see mapTheme
314  * @see setMapTheme
315  */
316  void themeChanged( const QString &mapTheme );
317 
318  void workOfflineChanged();
319 
320  /**
321  * @brief Emitted when the placemark tracked by this model has changed
322  * @see setTrackedPlacemark(), trackedPlacemark()
323  */
324  void trackedPlacemarkChanged( const GeoDataPlacemark *placemark );
325 
326  /** @brief Emitted when the home location is changed
327  * @see home(), setHome()
328  */
329  void homeChanged( const GeoDataCoordinates &newHomePoint );
330 
331  private:
332  Q_DISABLE_COPY( MarbleModel )
333 
334  Q_PRIVATE_SLOT( d, void assignFillColors( const QString &filePath ) )
335 
336  void addDownloadPolicies( const GeoSceneDocument *mapTheme );
337  MarbleModelPrivate * const d;
338 };
339 
340 }
341 
342 #endif
A 3d point representation.
The class that handles Marble&#39;s plugins.
Definition: PluginManager.h:44
The representation of GeoData in a model This class represents all available data given by kml-data f...
Binds a QML item to a specific geodetic location in screen coordinates.
This class is responsible for loading the book mark objects from the files and various book mark oper...
This class is responsible for loading the different files into Geodata model.
Definition: FileManager.h:37
Delegates data retrieval and model updates to the appropriate routing provider.
A container for features parsed from the DGML file.
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:91
a class representing a point of interest on the map
This class manages scheduled downloads.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Jun 20 2021 23:20:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.