Marble

MarbleMap.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2009 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5// SPDX-FileCopyrightText: 2008 Carlos Licea <carlos.licea@kdemail.net>
6// SPDX-FileCopyrightText: 2009 Jens-Michael Hoffmann <jensmh@gmx.de>
7// SPDX-FileCopyrightText: 2010-2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
8//
9
10// Own
11#include "MarbleMap.h"
12
13// Posix
14#include <cmath>
15
16// Qt
17#include <QElapsedTimer>
18#include <QtMath>
19
20// Marble
21#include "AbstractFloatItem.h"
22#include "BookmarkManager.h"
23#include "DgmlAuxillaryDictionary.h"
24#include "FileManager.h"
25#include "GeoDataDocument.h"
26#include "GeoDataFeature.h"
27#include "GeoDataStyle.h"
28#include "GeoDataStyleMap.h"
29#include "GeoDataTreeModel.h"
30#include "GeoPainter.h"
31#include "GeoSceneDocument.h"
32#include "GeoSceneFilter.h"
33#include "GeoSceneGeodata.h"
34#include "GeoSceneHead.h"
35#include "GeoSceneLayer.h"
36#include "GeoSceneMap.h"
37#include "GeoScenePalette.h"
38#include "GeoSceneSettings.h"
39#include "GeoSceneTextureTileDataset.h"
40#include "GeoSceneVector.h"
41#include "GeoSceneVectorTileDataset.h"
42#include "GeoSceneZoom.h"
43#include "LayerManager.h"
44#include "MapThemeManager.h"
45#include "MarbleDebug.h"
46#include "MarbleDirs.h"
47#include "MarbleModel.h"
48#include "PluginManager.h"
49#include "RenderPlugin.h"
50#include "RenderState.h"
51#include "StyleBuilder.h"
52#include "SunLocator.h"
53#include "TileCoordsPyramid.h"
54#include "TileCreator.h"
55#include "TileCreatorDialog.h"
56#include "TileId.h"
57#include "TileLoader.h"
58#include "ViewParams.h"
59#include "ViewportParams.h"
60#include "layers/FloatItemsLayer.h"
61#include "layers/FogLayer.h"
62#include "layers/FpsLayer.h"
63#include "layers/GeometryLayer.h"
64#include "layers/GroundLayer.h"
65#include "layers/MarbleSplashLayer.h"
66#include "layers/PlacemarkLayer.h"
67#include "layers/TextureLayer.h"
68#include "layers/VectorTileLayer.h"
69
70namespace Marble
71{
72
73class MarbleMap::CustomPaintLayer : public LayerInterface
74{
75public:
76 explicit CustomPaintLayer(MarbleMap *map)
77 : m_map(map)
78 {
79 }
80
81 QStringList renderPosition() const override
82 {
83 return QStringList() << QStringLiteral("USER_TOOLS");
84 }
85
86 bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos, GeoSceneLayer *layer) override
87 {
88 Q_UNUSED(viewport);
89 Q_UNUSED(renderPos);
90 Q_UNUSED(layer);
91
92 m_map->customPaint(painter);
93
94 return true;
95 }
96
97 qreal zValue() const override
98 {
99 return 1.0e6;
100 }
101
102 RenderState renderState() const override
103 {
104 return RenderState(QStringLiteral("Custom Map Paint"));
105 }
106
107 QString runtimeTrace() const override
108 {
109 return QStringLiteral("CustomPaint");
110 }
111
112private:
113 MarbleMap *const m_map;
114};
115
116class MarbleMapPrivate
117{
118 friend class MarbleWidget;
119
120public:
121 explicit MarbleMapPrivate(MarbleMap *parent, MarbleModel *model);
122
123 void updateMapTheme();
124
125 void updateProperty(const QString &, bool);
126
127 void setDocument(const QString &key);
128
129 void updateTileLevel();
130
131 void addPlugins();
132
133 MarbleMap *const q;
134
135 // The model we are showing.
136 MarbleModel *const m_model;
137 bool m_modelIsOwned;
138
139 // Parameters for the maps appearance.
140 ViewParams m_viewParams;
141 ViewportParams m_viewport;
142 bool m_showFrameRate;
143 bool m_showDebugPolygons;
144 bool m_showDebugBatchRender;
145 GeoDataRelation::RelationTypes m_visibleRelationTypes;
146 StyleBuilder m_styleBuilder;
147
148 QList<RenderPlugin *> m_renderPlugins;
149
150 LayerManager m_layerManager;
151 MarbleSplashLayer m_marbleSplashLayer;
152 MarbleMap::CustomPaintLayer m_customPaintLayer;
153 GeometryLayer m_geometryLayer;
154 FloatItemsLayer m_floatItemsLayer;
155 FogLayer m_fogLayer;
156 GroundLayer m_groundLayer;
157 TextureLayer m_textureLayer;
158 PlacemarkLayer m_placemarkLayer;
159 VectorTileLayer m_vectorTileLayer;
160
161 bool m_isLockedToSubSolarPoint;
162 bool m_isSubSolarPointIconVisible;
163 RenderState m_renderState;
164};
165
166MarbleMapPrivate::MarbleMapPrivate(MarbleMap *parent, MarbleModel *model)
167 : q(parent)
168 , m_model(model)
169 , m_viewParams()
170 , m_showFrameRate(false)
171 , m_showDebugPolygons(false)
172 , m_showDebugBatchRender(false)
173 , m_visibleRelationTypes(GeoDataRelation::RouteFerry)
174 , m_styleBuilder()
175 , m_layerManager(parent)
176 , m_customPaintLayer(parent)
177 , m_geometryLayer(model->treeModel(), &m_styleBuilder)
178 , m_floatItemsLayer(parent)
179 , m_textureLayer(model->downloadManager(), model->pluginManager(), model->sunLocator(), model->groundOverlayModel())
180 , m_placemarkLayer(model->placemarkModel(), model->placemarkSelectionModel(), model->clock(), &m_styleBuilder)
181 , m_vectorTileLayer(model->downloadManager(), model->pluginManager(), model->treeModel())
182 , m_isLockedToSubSolarPoint(false)
183 , m_isSubSolarPointIconVisible(false)
184{
185 m_layerManager.addLayer(&m_floatItemsLayer);
186 m_layerManager.addLayer(&m_fogLayer);
187 m_layerManager.addLayer(&m_groundLayer);
188 m_layerManager.addLayer(&m_geometryLayer);
189 m_layerManager.addLayer(&m_placemarkLayer);
190 m_layerManager.addLayer(&m_customPaintLayer);
191
192 m_model->bookmarkManager()->setStyleBuilder(&m_styleBuilder);
193
194 QObject::connect(m_model, SIGNAL(themeChanged(QString)), parent, SLOT(updateMapTheme()));
195 QObject::connect(m_model->fileManager(), SIGNAL(fileAdded(QString)), parent, SLOT(setDocument(QString)));
196
197 QObject::connect(&m_placemarkLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
198
199 QObject::connect(&m_layerManager, SIGNAL(pluginSettingsChanged()), parent, SIGNAL(pluginSettingsChanged()));
200 QObject::connect(&m_layerManager, SIGNAL(repaintNeeded(QRegion)), parent, SIGNAL(repaintNeeded(QRegion)));
201 QObject::connect(&m_layerManager, SIGNAL(renderPluginInitialized(RenderPlugin *)), parent, SIGNAL(renderPluginInitialized(RenderPlugin *)));
202 QObject::connect(&m_layerManager, SIGNAL(visibilityChanged(QString, bool)), parent, SLOT(setPropertyValue(QString, bool)));
203
204 QObject::connect(&m_geometryLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
205
206 /*
207 * Slot handleHighlight finds all placemarks
208 * that contain the clicked point.
209 * The placemarks under the clicked position may
210 * have their styleUrl set to a style map which
211 * doesn't specify any highlight styleId. Such
212 * placemarks will be fletered out in GeoGraphicsScene
213 * and will not be highlighted.
214 */
215 QObject::connect(parent,
216 SIGNAL(highlightedPlacemarksChanged(qreal, qreal, GeoDataCoordinates::Unit)),
217 &m_geometryLayer,
218 SLOT(handleHighlight(qreal, qreal, GeoDataCoordinates::Unit)));
219
220 QObject::connect(&m_floatItemsLayer, SIGNAL(repaintNeeded(QRegion)), parent, SIGNAL(repaintNeeded(QRegion)));
221 QObject::connect(&m_floatItemsLayer, SIGNAL(renderPluginInitialized(RenderPlugin *)), parent, SIGNAL(renderPluginInitialized(RenderPlugin *)));
222 QObject::connect(&m_floatItemsLayer, SIGNAL(visibilityChanged(QString, bool)), parent, SLOT(setPropertyValue(QString, bool)));
223 QObject::connect(&m_floatItemsLayer, SIGNAL(pluginSettingsChanged()), parent, SIGNAL(pluginSettingsChanged()));
224
225 QObject::connect(&m_textureLayer, SIGNAL(tileLevelChanged(int)), parent, SLOT(updateTileLevel()));
226 QObject::connect(&m_vectorTileLayer, SIGNAL(tileLevelChanged(int)), parent, SLOT(updateTileLevel()));
227 QObject::connect(parent, SIGNAL(radiusChanged(int)), parent, SLOT(updateTileLevel()));
228
229 QObject::connect(&m_textureLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
230 QObject::connect(parent, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)), parent, SIGNAL(repaintNeeded()));
231
232 addPlugins();
233 QObject::connect(model->pluginManager(), SIGNAL(renderPluginsChanged()), parent, SLOT(addPlugins()));
234}
235
236void MarbleMapPrivate::updateProperty(const QString &name, bool show)
237{
238 // earth
239 if (name == QLatin1StringView("places")) {
240 m_placemarkLayer.setShowPlaces(show);
241 } else if (name == QLatin1StringView("cities")) {
242 m_placemarkLayer.setShowCities(show);
243 } else if (name == QLatin1StringView("terrain")) {
244 m_placemarkLayer.setShowTerrain(show);
245 } else if (name == QLatin1StringView("otherplaces")) {
246 m_placemarkLayer.setShowOtherPlaces(show);
247 }
248
249 // other planets
250 else if (name == QLatin1StringView("landingsites")) {
251 m_placemarkLayer.setShowLandingSites(show);
252 } else if (name == QLatin1StringView("craters")) {
253 m_placemarkLayer.setShowCraters(show);
254 } else if (name == QLatin1StringView("maria")) {
255 m_placemarkLayer.setShowMaria(show);
256 }
257
258 else if (name == QLatin1StringView("relief")) {
259 m_textureLayer.setShowRelief(show);
260 }
261
262 for (RenderPlugin *renderPlugin : std::as_const(m_renderPlugins)) {
263 if (name == renderPlugin->nameId()) {
264 if (renderPlugin->visible() == show) {
265 break;
266 }
267
268 renderPlugin->setVisible(show);
269
270 break;
271 }
272 }
273}
274
275void MarbleMapPrivate::addPlugins()
276{
277 for (const RenderPlugin *factory : m_model->pluginManager()->renderPlugins()) {
278 bool alreadyCreated = false;
279 for (const RenderPlugin *existing : std::as_const(m_renderPlugins)) {
280 if (existing->nameId() == factory->nameId()) {
281 alreadyCreated = true;
282 break;
283 }
284 }
285
286 if (alreadyCreated) {
287 continue;
288 }
289
290 RenderPlugin *const renderPlugin = factory->newInstance(m_model);
291 Q_ASSERT(renderPlugin && "Plugin must not return null when requesting a new instance.");
292 m_renderPlugins << renderPlugin;
293
294 if (auto const floatItem = qobject_cast<AbstractFloatItem *>(renderPlugin)) {
295 m_floatItemsLayer.addFloatItem(floatItem);
296 } else {
297 m_layerManager.addRenderPlugin(renderPlugin);
298 }
299 }
300}
301
302// ----------------------------------------------------------------
303
304MarbleMap::MarbleMap()
305 : d(new MarbleMapPrivate(this, new MarbleModel(this)))
306{
307 // nothing to do
308}
309
311 : d(new MarbleMapPrivate(this, model))
312{
313 d->m_modelIsOwned = false;
314}
315
316MarbleMap::~MarbleMap()
317{
318 MarbleModel *model = d->m_modelIsOwned ? d->m_model : nullptr;
319
320 d->m_layerManager.removeLayer(&d->m_customPaintLayer);
321 d->m_layerManager.removeLayer(&d->m_geometryLayer);
322 d->m_layerManager.removeLayer(&d->m_floatItemsLayer);
323 d->m_layerManager.removeLayer(&d->m_fogLayer);
324 d->m_layerManager.removeLayer(&d->m_placemarkLayer);
325 d->m_layerManager.removeLayer(&d->m_textureLayer);
326 d->m_layerManager.removeLayer(&d->m_groundLayer);
327 qDeleteAll(d->m_renderPlugins);
328 delete d;
329
330 delete model; // delete the model after private data
331}
332
334{
335 return d->m_model;
336}
337
338ViewportParams *MarbleMap::viewport()
339{
340 return &d->m_viewport;
341}
342
343const ViewportParams *MarbleMap::viewport() const
344{
345 return &d->m_viewport;
346}
347
348void MarbleMap::setMapQualityForViewContext(MapQuality quality, ViewContext viewContext)
349{
350 d->m_viewParams.setMapQualityForViewContext(quality, viewContext);
351
352 // Update texture map during the repaint that follows:
353 d->m_textureLayer.setNeedsUpdate();
354}
355
356MapQuality MarbleMap::mapQuality(ViewContext viewContext) const
357{
358 return d->m_viewParams.mapQuality(viewContext);
359}
360
362{
363 return d->m_viewParams.mapQuality();
364}
365
366void MarbleMap::setViewContext(ViewContext viewContext)
367{
368 if (d->m_viewParams.viewContext() == viewContext) {
369 return;
370 }
371
372 const MapQuality oldQuality = d->m_viewParams.mapQuality();
373 d->m_viewParams.setViewContext(viewContext);
374 Q_EMIT viewContextChanged(viewContext);
375
376 if (d->m_viewParams.mapQuality() != oldQuality) {
377 // Update texture map during the repaint that follows:
378 d->m_textureLayer.setNeedsUpdate();
379
381 }
382}
383
384ViewContext MarbleMap::viewContext() const
385{
386 return d->m_viewParams.viewContext();
387}
388
389void MarbleMap::setSize(int width, int height)
390{
391 setSize(QSize(width, height));
392}
393
394void MarbleMap::setSize(const QSize &size)
395{
396 d->m_viewport.setSize(size);
397
398 Q_EMIT visibleLatLonAltBoxChanged(d->m_viewport.viewLatLonAltBox());
399}
400
401QSize MarbleMap::size() const
402{
403 return {d->m_viewport.width(), d->m_viewport.height()};
404}
405
406int MarbleMap::width() const
407{
408 return d->m_viewport.width();
409}
410
411int MarbleMap::height() const
412{
413 return d->m_viewport.height();
414}
415
417{
418 return d->m_viewport.radius();
419}
420
421void MarbleMap::setRadius(int radius)
422{
423 const int oldRadius = d->m_viewport.radius();
424
425 d->m_viewport.setRadius(radius);
426
427 if (oldRadius != d->m_viewport.radius()) {
428 Q_EMIT radiusChanged(radius);
429 Q_EMIT visibleLatLonAltBoxChanged(d->m_viewport.viewLatLonAltBox());
430 }
431}
432
433int MarbleMap::preferredRadiusCeil(int radius) const
434{
435 return d->m_textureLayer.preferredRadiusCeil(radius);
436}
437
438int MarbleMap::preferredRadiusFloor(int radius) const
439{
440 return d->m_textureLayer.preferredRadiusFloor(radius);
441}
442
443int MarbleMap::tileZoomLevel() const
444{
445 auto const tileZoomLevel = qMax(d->m_textureLayer.tileZoomLevel(), d->m_vectorTileLayer.tileZoomLevel());
446 return tileZoomLevel >= 0 ? tileZoomLevel : qMin<int>(qMax<int>(qLn(d->m_viewport.radius() * 4 / 256) / qLn(2.0), 1), d->m_styleBuilder.maximumZoomLevel());
447}
448
450{
451 // Calculate translation of center point
452 const qreal centerLat = d->m_viewport.centerLatitude();
453
454 return centerLat * RAD2DEG;
455}
456
457bool MarbleMap::hasFeatureAt(const QPoint &position) const
458{
459 return d->m_placemarkLayer.hasPlacemarkAt(position) || d->m_geometryLayer.hasFeatureAt(position, viewport());
460}
461
463{
464 // Calculate translation of center point
465 const qreal centerLon = d->m_viewport.centerLongitude();
466
467 return centerLon * RAD2DEG;
468}
469
471{
472 if (d->m_model->mapTheme())
473 return d->m_model->mapTheme()->head()->zoom()->minimum();
474
475 return 950;
476}
477
479{
480 if (d->m_model->mapTheme())
481 return d->m_model->mapTheme()->head()->zoom()->maximum();
482
483 return 2100;
484}
485
486bool MarbleMap::discreteZoom() const
487{
488 if (d->m_model->mapTheme())
489 return d->m_model->mapTheme()->head()->zoom()->discrete();
490
491 return false;
492}
493
494QList<const GeoDataFeature *> MarbleMap::whichFeatureAt(const QPoint &curpos) const
495{
496 return d->m_placemarkLayer.whichPlacemarkAt(curpos) + d->m_geometryLayer.whichFeatureAt(curpos, viewport());
497}
498
500{
501 d->m_textureLayer.reload();
502 d->m_vectorTileLayer.reload();
503}
504
505void MarbleMap::downloadRegion(QList<TileCoordsPyramid> const &pyramid)
506{
507 Q_ASSERT(textureLayer());
508 Q_ASSERT(!pyramid.isEmpty());
510 t.start();
511
512 // When downloading a region (the author of these lines thinks) most users probably expect
513 // the download to begin with the low resolution tiles and then procede level-wise to
514 // higher resolution tiles. In order to achieve this, we start requesting downloads of
515 // high resolution tiles and request the low resolution tiles at the end because
516 // DownloadQueueSet (silly name) is implemented as stack.
517
518 int const first = 0;
519 int tilesCount = 0;
520
521 for (int level = pyramid[first].bottomLevel(); level >= pyramid[first].topLevel(); --level) {
522 QSet<TileId> tileIdSet;
523 for (int i = 0; i < pyramid.size(); ++i) {
524 QRect const coords = pyramid[i].coords(level);
525 mDebug() << "MarbleMap::downloadRegion level:" << level << "tile coords:" << coords;
526 int x1, y1, x2, y2;
527 coords.getCoords(&x1, &y1, &x2, &y2);
528 for (int x = x1; x <= x2; ++x) {
529 for (int y = y1; y <= y2; ++y) {
530 TileId const stackedTileId(0, level, x, y);
531 tileIdSet.insert(stackedTileId);
532 // FIXME: use lazy evaluation to not generate up to 100k tiles in one go
533 // this can take considerable time even on very fast systems
534 // in contrast generating the TileIds on the fly when they are needed
535 // does not seem to affect download speed.
536 }
537 }
538 }
539 QSetIterator<TileId> i(tileIdSet);
540 while (i.hasNext()) {
541 TileId const tileId = i.next();
542 d->m_textureLayer.downloadStackedTile(tileId);
543 d->m_vectorTileLayer.downloadTile(tileId);
544 mDebug() << "TileDownload" << tileId;
545 }
546 tilesCount += tileIdSet.count();
547 }
548 // Needed for downloading unique tiles only. Much faster than if tiles for each level is downloaded separately
549
550 int const elapsedMs = t.elapsed();
551 mDebug() << "MarbleMap::downloadRegion:" << tilesCount << "tiles, " << elapsedMs << "ms";
552}
553
554void MarbleMap::highlightRouteRelation(qint64 osmId, bool enabled)
555{
556 d->m_geometryLayer.highlightRouteRelation(osmId, enabled);
557}
558
559bool MarbleMap::propertyValue(const QString &name) const
560{
561 bool value;
562 if (d->m_model->mapTheme()) {
563 d->m_model->mapTheme()->settings()->propertyValue(name, value);
564 } else {
565 value = false;
566 mDebug() << "WARNING: Failed to access a map theme! Property: " << name;
567 }
568 return value;
569}
570
572{
573 return propertyValue(QStringLiteral("overviewmap"));
574}
575
577{
578 return propertyValue(QStringLiteral("scalebar"));
579}
580
582{
583 return propertyValue(QStringLiteral("compass"));
584}
585
587{
588 return propertyValue(QStringLiteral("coordinate-grid"));
589}
590
592{
593 return d->m_viewParams.showClouds();
594}
595
597{
598 return d->m_textureLayer.showSunShading();
599}
600
602{
603 return d->m_textureLayer.showCityLights();
604}
605
607{
608 return d->m_isLockedToSubSolarPoint;
609}
610
612{
613 return d->m_isSubSolarPointIconVisible;
614}
615
617{
618 return d->m_viewParams.showAtmosphere();
619}
620
622{
623 bool visible = false;
624
627 QList<RenderPlugin *>::const_iterator const end = pluginList.constEnd();
628 for (; i != end; ++i) {
629 if ((*i)->nameId() == QLatin1StringView("crosshairs")) {
630 visible = (*i)->visible();
631 }
632 }
633
634 return visible;
635}
636
638{
639 return propertyValue(QStringLiteral("places"));
640}
641
643{
644 return propertyValue(QStringLiteral("cities"));
645}
646
648{
649 return propertyValue(QStringLiteral("terrain"));
650}
651
653{
654 return propertyValue(QStringLiteral("otherplaces"));
655}
656
658{
659 return propertyValue(QStringLiteral("relief"));
660}
661
663{
664 return propertyValue(QStringLiteral("ice"));
665}
666
668{
669 return propertyValue(QStringLiteral("borders"));
670}
671
673{
674 return propertyValue(QStringLiteral("rivers"));
675}
676
678{
679 return propertyValue(QStringLiteral("lakes"));
680}
681
683{
684 return d->m_showFrameRate;
685}
686
687bool MarbleMap::showBackground() const
688{
689 return d->m_layerManager.showBackground();
690}
691
692GeoDataRelation::RelationTypes MarbleMap::visibleRelationTypes() const
693{
694 return d->m_visibleRelationTypes;
695}
696
698{
699 return d->m_textureLayer.volatileCacheLimit();
700}
701
702void MarbleMap::rotateBy(qreal deltaLon, qreal deltaLat)
703{
704 centerOn(d->m_viewport.centerLongitude() * RAD2DEG + deltaLon, d->m_viewport.centerLatitude() * RAD2DEG + deltaLat);
705}
706
707void MarbleMap::centerOn(const qreal lon, const qreal lat)
708{
709 d->m_viewport.centerOn(lon * DEG2RAD, lat * DEG2RAD);
710
711 Q_EMIT visibleLatLonAltBoxChanged(d->m_viewport.viewLatLonAltBox());
712}
713
715{
717}
718
720{
721 centerOn(lon, centerLatitude());
722}
723
725{
726 return d->m_viewport.projection();
727}
728
730{
731 if (d->m_viewport.projection() == projection)
732 return;
733
734 Q_EMIT projectionChanged(projection);
735
736 d->m_viewport.setProjection(projection);
737
738 d->m_textureLayer.setProjection(projection);
739
740 Q_EMIT visibleLatLonAltBoxChanged(d->m_viewport.viewLatLonAltBox());
741}
742
743bool MarbleMap::screenCoordinates(qreal lon, qreal lat, qreal &x, qreal &y) const
744{
745 return d->m_viewport.screenCoordinates(lon * DEG2RAD, lat * DEG2RAD, x, y);
746}
747
748bool MarbleMap::geoCoordinates(int x, int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit) const
749{
750 return d->m_viewport.geoCoordinates(x, y, lon, lat, unit);
751}
752
753void MarbleMapPrivate::setDocument(const QString &key)
754{
755 if (!m_model->mapTheme()) {
756 // Happens if no valid map theme is set or at application startup
757 // if a file is passed via command line parameters and the last
758 // map theme has not been loaded yet
759 /**
760 * @todo Do we need to queue the document and process it once a map
761 * theme becomes available?
762 */
763 return;
764 }
765
766 GeoDataDocument *doc = m_model->fileManager()->at(key);
767
768 const auto layers = m_model->mapTheme()->map()->layers();
769 for (const GeoSceneLayer *layer : layers) {
770 if (layer->backend() != QString::fromLatin1(dgml::dgmlValue_geodata) && layer->backend() != QString::fromLatin1(dgml::dgmlValue_vector))
771 continue;
772
773 // look for documents
774 const auto datasets = layer->datasets();
775 for (const GeoSceneAbstractDataset *dataset : datasets) {
776 const auto data = static_cast<const GeoSceneGeodata *>(dataset);
777 QString containername = data->sourceFile();
778 QString colorize = data->colorize();
779 if (key == containername) {
780 if (colorize == QLatin1StringView("land")) {
781 m_textureLayer.addLandDocument(doc);
782 }
783 if (colorize == QLatin1StringView("sea")) {
784 m_textureLayer.addSeaDocument(doc);
785 }
786
787 // set visibility according to theme property
788 if (!data->property().isEmpty()) {
789 bool value;
790 m_model->mapTheme()->settings()->propertyValue(data->property(), value);
791 doc->setVisible(value);
792 m_model->treeModel()->updateFeature(doc);
793 }
794 }
795 }
796 }
797}
798
799void MarbleMapPrivate::updateTileLevel()
800{
801 auto const tileZoomLevel = q->tileZoomLevel();
802 m_geometryLayer.setTileLevel(tileZoomLevel);
803 m_placemarkLayer.setTileLevel(tileZoomLevel);
804 Q_EMIT q->tileLevelChanged(tileZoomLevel);
805}
806
807// Used to be paintEvent()
808void MarbleMap::paint(GeoPainter &painter, const QRect &dirtyRect)
809{
810 Q_UNUSED(dirtyRect);
811
812 if (d->m_showDebugPolygons) {
813 if (viewContext() == Animation) {
814 painter.setDebugPolygonsLevel(1);
815 } else {
816 painter.setDebugPolygonsLevel(2);
817 }
818 }
819 painter.setDebugBatchRender(d->m_showDebugBatchRender);
820
821 if (!d->m_model->mapTheme()) {
822 mDebug() << "No theme yet!";
823 d->m_marbleSplashLayer.render(&painter, &d->m_viewport);
824 return;
825 }
826
828 t.start();
829
830 RenderStatus const oldRenderStatus = d->m_renderState.status();
831 d->m_layerManager.renderLayers(&painter, &d->m_viewport);
832 d->m_renderState = d->m_layerManager.renderState();
833 bool const parsing = d->m_model->fileManager()->pendingFiles() > 0;
834 d->m_renderState.addChild(RenderState(QStringLiteral("Files"), parsing ? WaitingForData : Complete));
835 RenderStatus const newRenderStatus = d->m_renderState.status();
836 if (oldRenderStatus != newRenderStatus) {
837 Q_EMIT renderStatusChanged(newRenderStatus);
838 }
839 Q_EMIT renderStateChanged(d->m_renderState);
840
841 if (d->m_showFrameRate) {
842 FpsLayer fpsPainter(&t);
843 fpsPainter.paint(&painter);
844 }
845
846 const qreal fps = 1000.0 / (qreal)(t.elapsed());
847 Q_EMIT framesPerSecond(fps);
848}
849
851{
852 Q_UNUSED(painter);
853}
854
856{
857 return d->m_model->mapThemeId();
858}
859
860void MarbleMap::setMapThemeId(const QString &mapThemeId)
861{
862 d->m_model->setMapThemeId(mapThemeId);
863}
864
865void MarbleMapPrivate::updateMapTheme()
866{
867 m_layerManager.removeLayer(&m_textureLayer);
868 // FIXME Find a better way to do this reset. Maybe connect to themeChanged SIGNAL?
869 m_vectorTileLayer.reset();
870 m_layerManager.removeLayer(&m_vectorTileLayer);
871 m_layerManager.removeLayer(&m_groundLayer);
872
873 QObject::connect(m_model->mapTheme()->settings(), SIGNAL(valueChanged(QString, bool)), q, SLOT(updateProperty(QString, bool)));
874 QObject::connect(m_model->mapTheme()->settings(), SIGNAL(valueChanged(QString, bool)), m_model, SLOT(updateProperty(QString, bool)));
875
876 q->setPropertyValue(QStringLiteral("clouds_data"), m_viewParams.showClouds());
877
878 QColor backgroundColor = m_styleBuilder.effectColor(m_model->mapTheme()->map()->backgroundColor());
879 m_groundLayer.setColor(backgroundColor);
880
881 // Check whether there is a texture layer and vectortile layer available:
882 if (m_model->mapTheme()->map()->hasTextureLayers()) {
883 const GeoSceneSettings *const settings = m_model->mapTheme()->settings();
884 const GeoSceneGroup *const textureLayerSettings = settings ? settings->group(QStringLiteral("Texture Layers")) : nullptr;
885 const GeoSceneGroup *const vectorTileLayerSettings = settings ? settings->group(QStringLiteral("VectorTile Layers")) : nullptr;
886
887 bool textureLayersOk = true;
888 bool vectorTileLayersOk = true;
889
890 // textures will contain texture layers and
891 // vectorTiles vectortile layers
894
895 for (GeoSceneLayer *layer : m_model->mapTheme()->map()->layers()) {
896 if (layer->backend() == QString::fromLatin1(dgml::dgmlValue_texture)) {
897 const auto datasets = layer->datasets();
898 for (const GeoSceneAbstractDataset *pos : datasets) {
899 auto const *texture = dynamic_cast<GeoSceneTextureTileDataset const *>(pos);
900 if (!texture)
901 continue;
902
903 const QString sourceDir = texture->sourceDir();
904 const QString installMap = texture->installMap();
905 const QString role = layer->role();
906
907 // If the tiles aren't already there, put up a progress dialog
908 // while creating them.
909 if (!TileLoader::baseTilesAvailable(*texture) && !installMap.isEmpty()) {
910 mDebug() << "Base tiles not available. Creating Tiles ... \n"
911 << "SourceDir: " << sourceDir << "InstallMap:" << installMap;
912
913 auto tileCreator =
914 new TileCreator(sourceDir, installMap, (role == QLatin1StringView("dem")) ? QStringLiteral("true") : QStringLiteral("false"));
915 tileCreator->setTileFormat(texture->fileFormat().toLower());
916
917 QPointer<TileCreatorDialog> tileCreatorDlg = new TileCreatorDialog(tileCreator, nullptr);
918 tileCreatorDlg->setSummary(m_model->mapTheme()->head()->name(), m_model->mapTheme()->head()->description());
919 tileCreatorDlg->exec();
920 if (TileLoader::baseTilesAvailable(*texture)) {
921 mDebug() << "Base tiles for" << sourceDir << "successfully created.";
922 } else {
923 qWarning() << "Some or all base tiles for" << sourceDir << "could not be created.";
924 }
925
926 delete tileCreatorDlg;
927 }
928
929 if (TileLoader::baseTilesAvailable(*texture)) {
930 textures.append(texture);
931 } else {
932 qWarning() << "Base tiles for" << sourceDir << "not available. Skipping all texture layers.";
933 textureLayersOk = false;
934 }
935 }
936 } else if (layer->backend() == QString::fromLatin1(dgml::dgmlValue_vectortile)) {
937 const auto datasets = layer->datasets();
938 for (const GeoSceneAbstractDataset *pos : datasets) {
939 auto const *vectorTile = dynamic_cast<GeoSceneVectorTileDataset const *>(pos);
940 if (!vectorTile)
941 continue;
942
943 const QString sourceDir = vectorTile->sourceDir();
944 const QString installMap = vectorTile->installMap();
945 const QString role = layer->role();
946
947 // If the tiles aren't already there, put up a progress dialog
948 // while creating them.
949 if (!TileLoader::baseTilesAvailable(*vectorTile) && !installMap.isEmpty()) {
950 mDebug() << "Base tiles not available. Creating Tiles ... \n"
951 << "SourceDir: " << sourceDir << "InstallMap:" << installMap;
952
953 auto tileCreator =
954 new TileCreator(sourceDir, installMap, (role == QLatin1StringView("dem")) ? QStringLiteral("true") : QStringLiteral("false"));
955 tileCreator->setTileFormat(vectorTile->fileFormat().toLower());
956
957 QPointer<TileCreatorDialog> tileCreatorDlg = new TileCreatorDialog(tileCreator, nullptr);
958 tileCreatorDlg->setSummary(m_model->mapTheme()->head()->name(), m_model->mapTheme()->head()->description());
959 tileCreatorDlg->exec();
960 if (TileLoader::baseTilesAvailable(*vectorTile)) {
961 qDebug() << "Base tiles for" << sourceDir << "successfully created.";
962 } else {
963 qDebug() << "Some or all base tiles for" << sourceDir << "could not be created.";
964 }
965
966 delete tileCreatorDlg;
967 }
968
969 if (TileLoader::baseTilesAvailable(*vectorTile)) {
970 vectorTiles.append(vectorTile);
971 } else {
972 qWarning() << "Base tiles for" << sourceDir << "not available. Skipping all texture layers.";
973 vectorTileLayersOk = false;
974 }
975 }
976 }
977 }
978
979 QString seafile, landfile;
980 if (!m_model->mapTheme()->map()->filters().isEmpty()) {
981 const GeoSceneFilter *filter = m_model->mapTheme()->map()->filters().first();
982
983 if (filter->type() == QLatin1StringView("colorize")) {
984 // no need to look up with MarbleDirs twice so they are left null for now
985 QList<const GeoScenePalette *> palette = filter->palette();
986 for (const GeoScenePalette *curPalette : std::as_const(palette)) {
987 if (curPalette->type() == QLatin1StringView("sea")) {
988 seafile = MarbleDirs::path(curPalette->file());
989 } else if (curPalette->type() == QLatin1StringView("land")) {
990 landfile = MarbleDirs::path(curPalette->file());
991 }
992 }
993 // look up locations if they are empty
994 if (seafile.isEmpty())
995 seafile = MarbleDirs::path(QStringLiteral("seacolors.leg"));
996 if (landfile.isEmpty())
997 landfile = MarbleDirs::path(QStringLiteral("landcolors.leg"));
998 }
999 }
1000
1001 m_textureLayer.setMapTheme(textures, textureLayerSettings, seafile, landfile);
1002 m_textureLayer.setProjection(m_viewport.projection());
1003 m_textureLayer.setShowRelief(q->showRelief());
1004
1005 m_vectorTileLayer.setMapTheme(vectorTiles, vectorTileLayerSettings);
1006
1007 if (m_textureLayer.layerCount() == 0) {
1008 m_layerManager.addLayer(&m_groundLayer);
1009 }
1010
1011 if (textureLayersOk)
1012 m_layerManager.addLayer(&m_textureLayer);
1013 if (vectorTileLayersOk && !vectorTiles.isEmpty())
1014 m_layerManager.addLayer(&m_vectorTileLayer);
1015 } else {
1016 m_layerManager.addLayer(&m_groundLayer);
1017 m_textureLayer.setMapTheme(QList<const GeoSceneTextureTileDataset *>(), nullptr, QString(), QString());
1018 m_vectorTileLayer.setMapTheme(QList<const GeoSceneVectorTileDataset *>(), nullptr);
1019 }
1020
1021 // earth
1022 m_placemarkLayer.setShowPlaces(q->showPlaces());
1023
1024 m_placemarkLayer.setShowCities(q->showCities());
1025 m_placemarkLayer.setShowTerrain(q->showTerrain());
1026 m_placemarkLayer.setShowOtherPlaces(q->showOtherPlaces());
1027 m_placemarkLayer.setShowLandingSites(q->propertyValue(QStringLiteral("landingsites")));
1028 m_placemarkLayer.setShowCraters(q->propertyValue(QStringLiteral("craters")));
1029 m_placemarkLayer.setShowMaria(q->propertyValue(QStringLiteral("maria")));
1030
1031 m_styleBuilder.setDefaultLabelColor(m_model->mapTheme()->map()->labelColor());
1032 m_placemarkLayer.requestStyleReset();
1033
1034 for (RenderPlugin *renderPlugin : std::as_const(m_renderPlugins)) {
1035 bool propertyAvailable = false;
1036 m_model->mapTheme()->settings()->propertyAvailable(renderPlugin->nameId(), propertyAvailable);
1037 bool propertyValue = false;
1038 m_model->mapTheme()->settings()->propertyValue(renderPlugin->nameId(), propertyValue);
1039
1040 if (propertyAvailable) {
1041 renderPlugin->setVisible(propertyValue);
1042 }
1043 }
1044
1045 Q_EMIT q->themeChanged(m_model->mapTheme()->head()->mapThemeId());
1046}
1047
1048void MarbleMap::setPropertyValue(const QString &name, bool value)
1049{
1050 mDebug() << "In MarbleMap the property " << name << "was set to " << value;
1051 if (d->m_model->mapTheme()) {
1052 d->m_model->mapTheme()->settings()->setPropertyValue(name, value);
1053 d->m_textureLayer.setNeedsUpdate();
1054 Q_EMIT propertyValueChanged(name, value);
1055 } else {
1056 mDebug() << "WARNING: Failed to access a map theme! Property: " << name;
1057 }
1058 if (d->m_textureLayer.layerCount() == 0) {
1059 d->m_layerManager.addLayer(&d->m_groundLayer);
1060 } else {
1061 d->m_layerManager.removeLayer(&d->m_groundLayer);
1062 }
1063}
1064
1066{
1067 setPropertyValue(QStringLiteral("overviewmap"), visible);
1068}
1069
1071{
1072 setPropertyValue(QStringLiteral("scalebar"), visible);
1073}
1074
1076{
1077 setPropertyValue(QStringLiteral("compass"), visible);
1078}
1079
1081{
1082 const auto plugins = renderPlugins();
1083 for (RenderPlugin *plugin : plugins) {
1084 if (plugin->nameId() == QLatin1StringView("atmosphere")) {
1085 plugin->setVisible(visible);
1086 }
1087 }
1088
1089 d->m_viewParams.setShowAtmosphere(visible);
1090}
1091
1093{
1094 QList<RenderPlugin *> pluginList = renderPlugins();
1096 QList<RenderPlugin *>::const_iterator const end = pluginList.constEnd();
1097 for (; i != end; ++i) {
1098 if ((*i)->nameId() == QLatin1StringView("crosshairs")) {
1099 (*i)->setVisible(visible);
1100 }
1101 }
1102}
1103
1105{
1106 d->m_viewParams.setShowClouds(visible);
1107
1108 setPropertyValue(QStringLiteral("clouds_data"), visible);
1109}
1110
1112{
1113 d->m_textureLayer.setShowSunShading(visible);
1114}
1115
1117{
1118 d->m_textureLayer.setShowCityLights(visible);
1119 setPropertyValue(QStringLiteral("citylights"), visible);
1120}
1121
1123{
1124 disconnect(d->m_model->sunLocator(), SIGNAL(positionChanged(qreal, qreal)), this, SLOT(centerOn(qreal, qreal)));
1125
1126 if (isLockedToSubSolarPoint() != visible) {
1127 d->m_isLockedToSubSolarPoint = visible;
1128 }
1129
1131 connect(d->m_model->sunLocator(), SIGNAL(positionChanged(qreal, qreal)), this, SLOT(centerOn(qreal, qreal)));
1132
1133 centerOn(d->m_model->sunLocator()->getLon(), d->m_model->sunLocator()->getLat());
1134 } else if (visible) {
1135 mDebug() << "Ignoring centering on sun, since the sun plugin is not loaded.";
1136 }
1137}
1138
1140{
1141 if (isSubSolarPointIconVisible() != visible) {
1142 d->m_isSubSolarPointIconVisible = visible;
1143 }
1144}
1145
1147{
1148 d->m_textureLayer.setShowTileId(visible);
1149}
1150
1151void MarbleMap::setShowGrid(bool visible)
1152{
1153 setPropertyValue(QStringLiteral("coordinate-grid"), visible);
1154}
1155
1157{
1158 setPropertyValue(QStringLiteral("places"), visible);
1159}
1160
1162{
1163 setPropertyValue(QStringLiteral("cities"), visible);
1164}
1165
1167{
1168 setPropertyValue(QStringLiteral("terrain"), visible);
1169}
1170
1172{
1173 setPropertyValue(QStringLiteral("otherplaces"), visible);
1174}
1175
1177{
1178 setPropertyValue(QStringLiteral("relief"), visible);
1179}
1180
1182{
1183 setPropertyValue(QStringLiteral("ice"), visible);
1184}
1185
1187{
1188 setPropertyValue(QStringLiteral("borders"), visible);
1189}
1190
1192{
1193 setPropertyValue(QStringLiteral("rivers"), visible);
1194}
1195
1196void MarbleMap::setShowLakes(bool visible)
1197{
1198 setPropertyValue(QStringLiteral("lakes"), visible);
1199}
1200
1202{
1203 d->m_showFrameRate = visible;
1204}
1205
1206void MarbleMap::setShowRuntimeTrace(bool visible)
1207{
1208 if (visible != d->m_layerManager.showRuntimeTrace()) {
1209 d->m_layerManager.setShowRuntimeTrace(visible);
1211 }
1212}
1213
1214bool MarbleMap::showRuntimeTrace() const
1215{
1216 return d->m_layerManager.showRuntimeTrace();
1217}
1218
1220{
1221 if (visible != d->m_showDebugPolygons) {
1222 d->m_showDebugPolygons = visible;
1224 }
1225}
1226
1227bool MarbleMap::showDebugPolygons() const
1228{
1229 return d->m_showDebugPolygons;
1230}
1231
1233{
1234 qDebug() << visible;
1235 if (visible != d->m_showDebugBatchRender) {
1236 d->m_showDebugBatchRender = visible;
1238 }
1239}
1240
1241bool MarbleMap::showDebugBatchRender() const
1242{
1243 return d->m_showDebugBatchRender;
1244}
1245
1247{
1248 if (visible != d->m_placemarkLayer.isDebugModeEnabled()) {
1249 d->m_placemarkLayer.setDebugModeEnabled(visible);
1251 }
1252}
1253
1254bool MarbleMap::showDebugPlacemarks() const
1255{
1256 return d->m_placemarkLayer.isDebugModeEnabled();
1257}
1258
1260{
1261 if (visible != d->m_geometryLayer.levelTagDebugModeEnabled()) {
1262 d->m_geometryLayer.setLevelTagDebugModeEnabled(visible);
1263 d->m_placemarkLayer.setLevelTagDebugModeEnabled(visible);
1265 }
1266}
1267
1268bool MarbleMap::levelTagDebugModeEnabled() const
1269{
1270 return d->m_geometryLayer.levelTagDebugModeEnabled() && d->m_placemarkLayer.levelTagDebugModeEnabled();
1271}
1272
1273void MarbleMap::setDebugLevelTag(int level)
1274{
1275 d->m_geometryLayer.setDebugLevelTag(level);
1276 d->m_placemarkLayer.setDebugLevelTag(level);
1277}
1278
1279int MarbleMap::debugLevelTag() const
1280{
1281 return d->m_geometryLayer.debugLevelTag();
1282}
1283
1284void MarbleMap::setShowBackground(bool visible)
1285{
1286 d->m_layerManager.setShowBackground(visible);
1287}
1288
1289void MarbleMap::setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes)
1290{
1291 if (d->m_visibleRelationTypes != relationTypes) {
1292 d->m_visibleRelationTypes = relationTypes;
1293 d->m_geometryLayer.setVisibleRelationTypes(relationTypes);
1294 Q_EMIT visibleRelationTypesChanged(d->m_visibleRelationTypes);
1295 }
1296}
1297
1299{
1300 qreal lon = 0;
1301 qreal lat = 0;
1302
1303 const bool valid = geoCoordinates(x, y, lon, lat, GeoDataCoordinates::Radian);
1304
1305 if (valid) {
1306 Q_EMIT mouseClickGeoPosition(lon, lat, GeoDataCoordinates::Radian);
1307 }
1308}
1309
1310void MarbleMap::clearVolatileTileCache()
1311{
1312 d->m_vectorTileLayer.reset();
1313 d->m_textureLayer.reset();
1314 mDebug() << "Cleared Volatile Cache!";
1315}
1316
1318{
1319 mDebug() << "kiloBytes" << kilobytes;
1320 d->m_textureLayer.setVolatileCacheLimit(kilobytes);
1321}
1322
1323AngleUnit MarbleMap::defaultAngleUnit() const
1324{
1326 return DecimalDegree;
1327 } else if (GeoDataCoordinates::defaultNotation() == GeoDataCoordinates::UTM) {
1328 return UTM;
1329 }
1330
1331 return DMSDegree;
1332}
1333
1334void MarbleMap::setDefaultAngleUnit(AngleUnit angleUnit)
1335{
1336 if (angleUnit == DecimalDegree) {
1338 return;
1339 } else if (angleUnit == UTM) {
1340 GeoDataCoordinates::setDefaultNotation(GeoDataCoordinates::UTM);
1341 return;
1342 }
1343
1345}
1346
1347QFont MarbleMap::defaultFont() const
1348{
1349 return d->m_styleBuilder.defaultFont();
1350}
1351
1352void MarbleMap::setDefaultFont(const QFont &font)
1353{
1354 d->m_styleBuilder.setDefaultFont(font);
1355 d->m_placemarkLayer.requestStyleReset();
1356}
1357
1359{
1360 return d->m_renderPlugins;
1361}
1362
1363QList<AbstractFloatItem *> MarbleMap::floatItems() const
1364{
1365 return d->m_floatItemsLayer.floatItems();
1366}
1367
1369{
1370 const auto items = floatItems();
1371 for (AbstractFloatItem *floatItem : items) {
1372 if (floatItem && floatItem->nameId() == nameId) {
1373 return floatItem;
1374 }
1375 }
1376
1377 return nullptr; // No item found
1378}
1379
1381{
1382 return d->m_layerManager.dataPlugins();
1383}
1384
1386{
1387 return d->m_layerManager.whichItemAt(curpos);
1388}
1389
1390void MarbleMap::addLayer(LayerInterface *layer)
1391{
1392 d->m_layerManager.addLayer(layer);
1393}
1394
1395void MarbleMap::removeLayer(LayerInterface *layer)
1396{
1397 d->m_layerManager.removeLayer(layer);
1398}
1399
1400RenderStatus MarbleMap::renderStatus() const
1401{
1402 return d->m_layerManager.renderState().status();
1403}
1404
1405RenderState MarbleMap::renderState() const
1406{
1407 return d->m_layerManager.renderState();
1408}
1409
1410QString MarbleMap::addTextureLayer(GeoSceneTextureTileDataset *texture)
1411{
1412 return textureLayer()->addTextureLayer(texture);
1413}
1414
1416{
1417 textureLayer()->removeTextureLayer(key);
1418}
1419
1420// this method will only temporarily "pollute" the MarbleModel class
1421TextureLayer *MarbleMap::textureLayer() const
1422{
1423 return &d->m_textureLayer;
1424}
1425
1426VectorTileLayer *MarbleMap::vectorTileLayer() const
1427{
1428 return &d->m_vectorTileLayer;
1429}
1430
1431const StyleBuilder *MarbleMap::styleBuilder() const
1432{
1433 return &d->m_styleBuilder;
1434}
1435
1436qreal MarbleMap::heading() const
1437{
1438 return d->m_viewport.heading() * RAD2DEG;
1439}
1440
1441void MarbleMap::setHeading(qreal heading)
1442{
1443 d->m_viewport.setHeading(heading * DEG2RAD);
1444 d->m_textureLayer.setNeedsUpdate();
1445
1446 Q_EMIT visibleLatLonAltBoxChanged(d->m_viewport.viewLatLonAltBox());
1447}
1448
1449}
1450
1451#include "moc_MarbleMap.cpp"
This file contains the headers for MarbleMap.
This file contains the headers for MarbleModel.
This file contains the headers for ViewParameters.
This file contains the headers for ViewportParams.
The abstract class for float item plugins.
int pendingFiles() const
Returns the number of files being opened at the moment.
QList< AbstractFloatItem * > floatItems() const
Returns a list of all FloatItems of the layer.
@ DMS
"Sexagesimal DMS" notation (base-60)
@ Decimal
"Decimal" notation (base-10)
static void setDefaultNotation(GeoDataCoordinates::Notation notation)
set the Notation of the string representation
static GeoDataCoordinates::Notation defaultNotation()
return Notation of string representation
Unit
enum used constructor to specify the units used
A painter that allows to draw geometric primitives on the map.
Definition GeoPainter.h:86
Contents used inside a layer.
Group inside the settings of a GeoScene document.
Layer of a GeoScene document.
QList< GeoSceneFilter * > filters() const
Return all filters.
QList< GeoSceneLayer * > layers() const
Return all layers.
bool hasTextureLayers() const
Checks for valid layers that contain texture data.
Settings of a GeoScene document.
bool propertyValue(const QString &name, bool &value) const
Get the value of a property across groups.
bool setPropertyValue(const QString &name, bool value)
Set the value of a property across groups.
bool propertyAvailable(const QString &name, bool &available) const
Get the availability of a property across groups.
const GeoSceneGroup * group(const QString &name) const
Get a group from the settings.
void addLayer(LayerInterface *layer)
Add a layer to be included in rendering.
QList< AbstractDataPlugin * > dataPlugins() const
Returns a list of all DataPlugins on the layer.
QList< AbstractDataPluginItem * > whichItemAt(const QPoint &curpos) const
Returns all items of dataPlugins on the position curpos.
void removeLayer(LayerInterface *layer)
Remove a layer from being included in rendering.
QList< AbstractDataPlugin * > dataPlugins() const
Returns a list of all DataPlugins on the layer.
void setShowSunShading(bool visible)
Set whether the night shadow is visible.
void paint(GeoPainter &painter, const QRect &dirtyRect)
Paint the map using a give painter.
bool propertyValue(const QString &name) const
Return the property value by name.
bool showIceLayer() const
Return whether the ice layer is visible.
void setShowCrosshairs(bool visible)
Set whether the crosshairs are visible.
QString addTextureLayer(GeoSceneTextureTileDataset *texture)
Adds a texture sublayer.
void setCenterLongitude(qreal lon)
Set the longitude for the center point.
void setShowRivers(bool visible)
Set whether the rivers are visible.
void themeChanged(const QString &theme)
Signal that the theme has changed.
void setShowDebugPolygons(bool visible)
Set whether to enter the debug mode for polygon node drawing.
bool showCities() const
Return whether the city place marks are visible.
void setShowClouds(bool visible)
Set whether the cloud cover is visible.
void setShowBorders(bool visible)
Set whether the borders visible.
void setShowIceLayer(bool visible)
Set whether the ice layer is visible.
void removeTextureLayer(const QString &key)
Removes a texture sublayer.
void centerOn(const qreal lon, const qreal lat)
Center the view on a geographical point.
qreal centerLongitude() const
Return the longitude of the center point.
void setShowRelief(bool visible)
Set whether the relief is visible.
MarbleModel * model() const
Return the model that this view shows.
MapQuality mapQuality() const
Return the current map quality.
void setShowTileId(bool visible)
Set whether the is tile is visible NOTE: This is part of the transitional debug API and might be subj...
void setRadius(int radius)
Set the radius of the globe in pixels.
MarbleMap()
Construct a new MarbleMap.
void setProjection(Projection projection)
Set the Projection used for the map.
bool showScaleBar() const
Return whether the scale bar is visible.
void addLayer(LayerInterface *layer)
Add a layer to be included in rendering.
void visibleLatLonAltBoxChanged(const GeoDataLatLonAltBox &visibleLatLonAltBox)
This signal is emitted when the visible region of the map changes.
bool showCityLights() const
Return whether the city lights are shown instead of the night shadow.
quint64 volatileTileCacheLimit() const
Returns the limit in kilobytes of the volatile (in RAM) tile cache.
void setShowGrid(bool visible)
Set whether the coordinate grid overlay is visible.
void setPropertyValue(const QString &name, bool value)
Sets the value of a map theme property.
void removeLayer(LayerInterface *layer)
Remove a layer from being included in rendering.
bool showTerrain() const
Return whether the terrain place marks are visible.
void setShowDebugPlacemarks(bool visible)
Set whether to enter the debug mode for placemark drawing.
bool showBorders() const
Return whether the borders are visible.
bool showLakes() const
Return whether the lakes are visible.
int minimumZoom() const
return the minimum zoom value for the current map theme.
void setShowCompass(bool visible)
Set whether the compass overlay is visible.
bool screenCoordinates(qreal lon, qreal lat, qreal &x, qreal &y) const
Get the screen coordinates corresponding to geographical coordinates in the map.
void setShowScaleBar(bool visible)
Set whether the scale bar overlay is visible.
bool showSunShading() const
Return whether the night shadow is visible.
virtual void customPaint(GeoPainter *painter)
Enables custom drawing onto the MarbleMap straight after.
bool isLockedToSubSolarPoint() const
Return whether the globe is locked to the sub solar point.
QString mapThemeId() const
Get the ID of the current map theme To ensure that a unique identifier is being used the theme does N...
void setShowCityLights(bool visible)
Set whether city lights instead of night shadow are visible.
void notifyMouseClick(int x, int y)
used to notify about the position of the mouse click
bool hasFeatureAt(const QPoint &) const
bool showOtherPlaces() const
Return whether other places are visible.
void setShowFrameRate(bool visible)
Set whether the frame rate gets shown.
bool showOverviewMap() const
Return whether the overview map is visible.
void setMapThemeId(const QString &maptheme)
Set a new map theme.
qreal centerLatitude() const
Return the latitude of the center point.
void setSubSolarPointIconVisible(bool visible)
Set whether the sun icon is shown in the sub solar point.
bool showRelief() const
Return whether the relief is visible.
void setShowTerrain(bool visible)
Set whether the terrain place mark overlay is visible.
Projection projection() const
Get the Projection used for the map.
bool showAtmosphere() const
Return whether the atmospheric glow is visible.
void setLockToSubSolarPoint(bool visible)
Set the globe locked to the sub solar point.
bool showCrosshairs() const
Return whether the crosshairs are visible.
bool showClouds() const
Return whether the cloud cover is visible.
int radius() const
Return the radius of the globe in pixels.
void setShowDebugBatchRender(bool visible)
Set whether to enter the debug mode for visualizing batch rendering.
void setShowOtherPlaces(bool visible)
Set whether the other places overlay is visible.
QList< AbstractDataPluginItem * > whichItemAt(const QPoint &curpos) const
Returns all widgets of dataPlugins on the position curpos.
void rotateBy(qreal deltaLon, qreal deltaLat)
Rotate the view by the two angles phi and theta.
void setShowAtmosphere(bool visible)
Set whether the atmospheric glow is visible.
bool showPlaces() const
Return whether the place marks are visible.
QList< RenderPlugin * > renderPlugins() const
Returns a list of all RenderPlugins in the model, this includes float items.
void reload()
Reload the currently displayed map by reloading texture tiles from the Internet.
bool showGrid() const
Return whether the coordinate grid is visible.
void setShowOverviewMap(bool visible)
Set whether the overview map overlay is visible.
bool isSubSolarPointIconVisible() const
Return whether the sun icon is shown in the sub solar point.
bool showCompass() const
Return whether the compass bar is visible.
void setVolatileTileCacheLimit(quint64 kiloBytes)
Set the limit of the volatile (in RAM) tile cache.
void renderStatusChanged(RenderStatus status)
Emitted when the layer rendering status has changed.
void setLevelTagDebugModeEnabled(bool visible)
Set whether to enter the debug mode for level tags.
const StyleBuilder * styleBuilder() const
void setCenterLatitude(qreal lat)
Set the latitude for the center point.
void setShowPlaces(bool visible)
Set whether the place mark overlay is visible.
bool showRivers() const
Return whether the rivers are visible.
int maximumZoom() const
return the minimum zoom value for the current map theme.
AbstractFloatItem * floatItem(const QString &nameId) const
Returns a list of all FloatItems in the model.
bool showFrameRate() const
Return whether the frame rate gets displayed.
void setShowLakes(bool visible)
Set whether the lakes are visible.
bool geoCoordinates(int x, int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit=GeoDataCoordinates::Degree) const
Get the earth coordinates corresponding to a pixel in the map.
void setShowCities(bool visible)
Set whether the city place mark overlay is visible.
void repaintNeeded(const QRegion &dirtyRegion=QRegion())
This signal is emitted when the repaint of the view was requested.
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition MarbleModel.h:84
void setMapThemeId(const QString &mapThemeId)
Set a new map theme to use.
GeoDataTreeModel * treeModel()
Return the list of Placemarks as a QAbstractItemModel *.
The abstract class that creates a renderable item.
A public class that controls what is visible in the viewport of a Marble map.
bool screenCoordinates(const qreal lon, const qreal lat, qreal &x, qreal &y) const
Get the screen coordinates corresponding to geographical coordinates in the map.
void setRadius(int radius)
Change the radius of the planet.
bool geoCoordinates(const int x, const int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Degree) const
Get the earth coordinates corresponding to a pixel in the map.
Binds a QML item to a specific geodetic location in screen coordinates.
ViewContext
This enum is used to choose context in which map quality gets used.
@ Animation
animated view (e.g. while rotating the globe)
AngleUnit
This enum is used to choose the unit chosen to measure angles.
@ UTM
UTM.
@ DMSDegree
Degrees in DMS notation.
@ DecimalDegree
Degrees in decimal notation.
Projection
This enum is used to choose the projection shown in the view.
@ WaitingForData
Rendering is based on no or partial data, more data was requested (e.g. pending network queries)
@ Complete
All data is there and up to date.
MapQuality
This enum is used to choose the map quality shown in the view.
qint64 elapsed() const const
void append(QList< T > &&value)
const_iterator constBegin() const const
const_iterator constEnd() const const
bool isEmpty() const const
qsizetype size() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
void getCoords(int *x1, int *y1, int *x2, int *y2) const const
qsizetype count() const const
iterator insert(const T &value)
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.