18#include <QElapsedTimer>
22#include "layers/FloatItemsLayer.h"
23#include "layers/FogLayer.h"
24#include "layers/FpsLayer.h"
25#include "layers/GeometryLayer.h"
26#include "layers/GroundLayer.h"
27#include "layers/MarbleSplashLayer.h"
28#include "layers/PlacemarkLayer.h"
29#include "layers/TextureLayer.h"
30#include "layers/VectorTileLayer.h"
31#include "AbstractFloatItem.h"
32#include "DgmlAuxillaryDictionary.h"
33#include "FileManager.h"
34#include "GeoDataTreeModel.h"
35#include "GeoPainter.h"
36#include "GeoSceneDocument.h"
37#include "GeoSceneFilter.h"
38#include "GeoSceneGeodata.h"
39#include "GeoSceneHead.h"
40#include "GeoSceneLayer.h"
41#include "GeoSceneMap.h"
42#include "GeoScenePalette.h"
43#include "GeoSceneSettings.h"
44#include "GeoSceneVector.h"
45#include "GeoSceneVectorTileDataset.h"
46#include "GeoSceneTextureTileDataset.h"
47#include "GeoSceneZoom.h"
48#include "GeoDataDocument.h"
49#include "GeoDataFeature.h"
50#include "GeoDataStyle.h"
51#include "GeoDataStyleMap.h"
52#include "LayerManager.h"
53#include "MapThemeManager.h"
54#include "MarbleDebug.h"
55#include "MarbleDirs.h"
57#include "PluginManager.h"
58#include "RenderPlugin.h"
59#include "StyleBuilder.h"
60#include "SunLocator.h"
62#include "TileCoordsPyramid.h"
63#include "TileCreator.h"
64#include "TileCreatorDialog.h"
65#include "TileLoader.h"
68#include "RenderState.h"
69#include "BookmarkManager.h"
76class MarbleMap::CustomPaintLayer :
public LayerInterface
79 explicit CustomPaintLayer(
MarbleMap *map )
86 bool render( GeoPainter *painter, ViewportParams *viewport,
98 qreal zValue()
const override {
return 1.0e6; }
100 RenderState renderState()
const override {
return RenderState(QStringLiteral(
"Custom Map Paint")); }
102 QString runtimeTrace()
const override {
return QStringLiteral(
"CustomPaint"); }
109class MarbleMapPrivate
111 friend class MarbleWidget;
114 explicit MarbleMapPrivate( MarbleMap *parent, MarbleModel *model );
116 void updateMapTheme();
118 void updateProperty(
const QString &,
bool );
120 void setDocument(
const QString& key );
122 void updateTileLevel();
129 MarbleModel *
const m_model;
134 ViewportParams m_viewport;
135 bool m_showFrameRate;
136 bool m_showDebugPolygons;
137 bool m_showDebugBatchRender;
138 GeoDataRelation::RelationTypes m_visibleRelationTypes;
139 StyleBuilder m_styleBuilder;
143 LayerManager m_layerManager;
144 MarbleSplashLayer m_marbleSplashLayer;
145 MarbleMap::CustomPaintLayer m_customPaintLayer;
146 GeometryLayer m_geometryLayer;
147 FloatItemsLayer m_floatItemsLayer;
149 GroundLayer m_groundLayer;
150 TextureLayer m_textureLayer;
151 PlacemarkLayer m_placemarkLayer;
152 VectorTileLayer m_vectorTileLayer;
154 bool m_isLockedToSubSolarPoint;
155 bool m_isSubSolarPointIconVisible;
156 RenderState m_renderState;
159MarbleMapPrivate::MarbleMapPrivate( MarbleMap *parent, MarbleModel *model ) :
163 m_showFrameRate( false ),
164 m_showDebugPolygons( false ),
165 m_showDebugBatchRender( false ),
166 m_visibleRelationTypes(GeoDataRelation::RouteFerry),
168 m_layerManager( parent ),
169 m_customPaintLayer( parent ),
170 m_geometryLayer(model->treeModel(), &m_styleBuilder),
171 m_floatItemsLayer(parent),
172 m_textureLayer( model->downloadManager(), model->pluginManager(), model->sunLocator(), model->groundOverlayModel() ),
173 m_placemarkLayer( model->placemarkModel(), model->placemarkSelectionModel(), model->clock(), &m_styleBuilder ),
174 m_vectorTileLayer( model->downloadManager(), model->pluginManager(), model->treeModel() ),
175 m_isLockedToSubSolarPoint( false ),
176 m_isSubSolarPointIconVisible( false )
178 m_layerManager.addLayer(&m_floatItemsLayer);
179 m_layerManager.addLayer( &m_fogLayer );
180 m_layerManager.addLayer( &m_groundLayer );
181 m_layerManager.addLayer( &m_geometryLayer );
182 m_layerManager.addLayer( &m_placemarkLayer );
183 m_layerManager.addLayer( &m_customPaintLayer );
185 m_model->bookmarkManager()->setStyleBuilder(&m_styleBuilder);
188 parent, SLOT(updateMapTheme()) );
190 parent, SLOT(setDocument(
QString)) );
194 parent, SIGNAL(repaintNeeded()));
197 parent, SIGNAL(pluginSettingsChanged()) );
199 parent, SIGNAL(repaintNeeded(
QRegion)) );
200 QObject::connect ( &m_layerManager, SIGNAL(renderPluginInitialized(RenderPlugin*)),
201 parent, SIGNAL(renderPluginInitialized(RenderPlugin*)) );
203 parent, SLOT(setPropertyValue(
QString,
bool)) );
206 parent, SIGNAL(repaintNeeded()));
217 QObject::connect( parent, SIGNAL(highlightedPlacemarksChanged(qreal,qreal,GeoDataCoordinates::Unit)),
218 &m_geometryLayer, SLOT(handleHighlight(qreal,qreal,GeoDataCoordinates::Unit)) );
221 parent, SIGNAL(repaintNeeded(
QRegion)));
222 QObject::connect(&m_floatItemsLayer, SIGNAL(renderPluginInitialized(RenderPlugin*)),
223 parent, SIGNAL(renderPluginInitialized(RenderPlugin*)));
225 parent, SLOT(setPropertyValue(
QString,
bool)));
227 parent, SIGNAL(pluginSettingsChanged()));
230 parent, SLOT(updateTileLevel()) );
232 parent, SLOT(updateTileLevel()) );
234 parent, SLOT(updateTileLevel()) );
237 parent, SIGNAL(repaintNeeded()) );
238 QObject::connect( parent, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)),
239 parent, SIGNAL(repaintNeeded()) );
243 parent, SLOT(addPlugins()));
246void MarbleMapPrivate::updateProperty(
const QString &name,
bool show )
250 m_placemarkLayer.setShowPlaces( show );
252 m_placemarkLayer.setShowCities( show );
254 m_placemarkLayer.setShowTerrain( show );
256 m_placemarkLayer.setShowOtherPlaces( show );
261 m_placemarkLayer.setShowLandingSites( show );
263 m_placemarkLayer.setShowCraters( show );
265 m_placemarkLayer.setShowMaria( show );
269 m_textureLayer.setShowRelief( show );
272 for(RenderPlugin *renderPlugin: m_renderPlugins) {
273 if ( name == renderPlugin->nameId() ) {
274 if ( renderPlugin->visible() == show ) {
278 renderPlugin->setVisible( show );
285void MarbleMapPrivate::addPlugins()
287 for (
const RenderPlugin *factory: m_model->pluginManager()->renderPlugins()) {
288 bool alreadyCreated =
false;
289 for(
const RenderPlugin *existing: m_renderPlugins) {
290 if (existing->nameId() == factory->nameId()) {
291 alreadyCreated =
true;
296 if (alreadyCreated) {
300 RenderPlugin *
const renderPlugin = factory->newInstance(m_model);
301 Q_ASSERT(renderPlugin &&
"Plugin must not return null when requesting a new instance.");
302 m_renderPlugins << renderPlugin;
304 if (AbstractFloatItem *
const floatItem = qobject_cast<AbstractFloatItem *>(renderPlugin)) {
305 m_floatItemsLayer.addFloatItem(floatItem);
308 m_layerManager.addRenderPlugin(renderPlugin);
316MarbleMap::MarbleMap()
317 : d( new MarbleMapPrivate( this, new
MarbleModel( this ) ) )
323 : d( new MarbleMapPrivate( this, model ) )
325 d->m_modelIsOwned =
false;
328MarbleMap::~MarbleMap()
332 d->m_layerManager.
removeLayer( &d->m_customPaintLayer );
333 d->m_layerManager.
removeLayer( &d->m_geometryLayer );
334 d->m_layerManager.
removeLayer(&d->m_floatItemsLayer);
336 d->m_layerManager.
removeLayer( &d->m_placemarkLayer );
337 d->m_layerManager.
removeLayer( &d->m_textureLayer );
338 d->m_layerManager.
removeLayer( &d->m_groundLayer );
352 return &d->m_viewport;
355const ViewportParams *MarbleMap::viewport()
const
357 return &d->m_viewport;
361void MarbleMap::setMapQualityForViewContext( MapQuality quality, ViewContext viewContext )
363 d->m_viewParams.setMapQualityForViewContext( quality, viewContext );
366 d->m_textureLayer.setNeedsUpdate();
371 return d->m_viewParams.mapQuality( viewContext );
376 return d->m_viewParams.mapQuality();
379void MarbleMap::setViewContext(
ViewContext viewContext )
381 if ( d->m_viewParams.viewContext() == viewContext ) {
385 const MapQuality
oldQuality = d->m_viewParams.mapQuality();
386 d->m_viewParams.setViewContext( viewContext );
387 emit viewContextChanged( viewContext );
389 if ( d->m_viewParams.mapQuality() !=
oldQuality ) {
391 d->m_textureLayer.setNeedsUpdate();
397ViewContext MarbleMap::viewContext()
const
399 return d->m_viewParams.viewContext();
403void MarbleMap::setSize(
int width,
int height )
405 setSize(
QSize( width, height ) );
408void MarbleMap::setSize(
const QSize& size )
410 d->m_viewport.setSize( size );
415QSize MarbleMap::size()
const
417 return QSize( d->m_viewport.width(), d->m_viewport.height() );
420int MarbleMap::width()
const
422 return d->m_viewport.width();
425int MarbleMap::height()
const
427 return d->m_viewport.height();
432 return d->m_viewport.radius();
437 const int oldRadius = d->m_viewport.radius();
441 if (
oldRadius != d->m_viewport.radius() ) {
448int MarbleMap::preferredRadiusCeil(
int radius)
const
450 return d->m_textureLayer.preferredRadiusCeil(
radius );
454int MarbleMap::preferredRadiusFloor(
int radius)
const
456 return d->m_textureLayer.preferredRadiusFloor(
radius );
460int MarbleMap::tileZoomLevel()
const
462 auto const tileZoomLevel =
qMax(d->m_textureLayer.tileZoomLevel(), d->m_vectorTileLayer.tileZoomLevel());
463 return tileZoomLevel >= 0 ? tileZoomLevel :
qMin<int>(
qMax<int>(
qLn(d->m_viewport.radius()*4/256)/
qLn(2.0), 1), d->m_styleBuilder.maximumZoomLevel());
470 const qreal
centerLat = d->m_viewport.centerLatitude();
477 return d->m_placemarkLayer.hasPlacemarkAt(position) || d->m_geometryLayer.hasFeatureAt(position, viewport());
483 const qreal
centerLon = d->m_viewport.centerLongitude();
490 if ( d->m_model->mapTheme() )
491 return d->m_model->mapTheme()->head()->zoom()->minimum();
498 if ( d->m_model->mapTheme() )
499 return d->m_model->mapTheme()->head()->zoom()->maximum();
504bool MarbleMap::discreteZoom()
const
506 if ( d->m_model->mapTheme() )
507 return d->m_model->mapTheme()->head()->zoom()->discrete();
514 return d->m_placemarkLayer.whichPlacemarkAt(
curpos ) + d->m_geometryLayer.whichFeatureAt(
curpos, viewport() );
519 d->m_textureLayer.reload();
520 d->m_vectorTileLayer.reload();
540 for (
int level =
pyramid[first].bottomLevel(); level >=
pyramid[first].topLevel(); --level ) {
544 mDebug() <<
"MarbleMap::downloadRegion level:" << level <<
"tile coords:" << coords;
547 for (
int x = x1; x <= x2; ++x ) {
548 for (
int y = y1; y <= y2; ++y ) {
559 while(
i.hasNext() ) {
560 TileId
const tileId =
i.next();
561 d->m_textureLayer.downloadStackedTile(
tileId );
562 d->m_vectorTileLayer.downloadTile(
tileId);
563 mDebug() <<
"TileDownload" <<
tileId;
570 mDebug() <<
"MarbleMap::downloadRegion:" << tilesCount <<
"tiles, " <<
elapsedMs <<
"ms";
573void MarbleMap::highlightRouteRelation(qint64 osmId,
bool enabled)
575 d->m_geometryLayer.highlightRouteRelation(
osmId, enabled);
581 if ( d->m_model->mapTheme() ) {
582 d->m_model->mapTheme()->settings()->
propertyValue( name, value );
586 mDebug() <<
"WARNING: Failed to access a map theme! Property: " << name;
613 return d->m_viewParams.showClouds();
618 return d->m_textureLayer.showSunShading();
623 return d->m_textureLayer.showCityLights();
628 return d->m_isLockedToSubSolarPoint;
633 return d->m_isSubSolarPointIconVisible;
638 return d->m_viewParams.showAtmosphere();
643 bool visible =
false;
648 for (;
i != end; ++
i ) {
650 visible = (*i)->visible();
704 return d->m_showFrameRate;
707bool MarbleMap::showBackground()
const
709 return d->m_layerManager.showBackground();
712GeoDataRelation::RelationTypes MarbleMap::visibleRelationTypes()
const
714 return d->m_visibleRelationTypes;
719 return d->m_textureLayer.volatileCacheLimit();
726 d->m_viewport.centerLatitude() * RAD2DEG +
deltaLat );
732 d->m_viewport.centerOn( lon * DEG2RAD, lat * DEG2RAD );
749 return d->m_viewport.projection();
754 if ( d->m_viewport.projection() ==
projection )
761 d->m_textureLayer.setProjection(
projection );
768 qreal& x, qreal& y )
const
774 qreal& lon, qreal& lat,
780void MarbleMapPrivate::setDocument(
const QString& key )
782 if ( !m_model->mapTheme() ) {
793 GeoDataDocument* doc = m_model->fileManager()->at( key );
795 for (
const GeoSceneLayer *layer: m_model->mapTheme()->map()->layers() ) {
796 if ( layer->backend() != dgml::dgmlValue_geodata
797 && layer->backend() != dgml::dgmlValue_vector )
801 for (
const GeoSceneAbstractDataset *dataset: layer->datasets() ) {
802 const GeoSceneGeodata *data =
static_cast<const GeoSceneGeodata*
>( dataset );
803 QString containername = data->sourceFile();
804 QString colorize = data->colorize();
805 if( key == containername ) {
807 m_textureLayer.addLandDocument( doc );
810 m_textureLayer.addSeaDocument( doc );
814 if( !data->property().isEmpty() ) {
816 m_model->mapTheme()->settings()->
propertyValue( data->property(), value );
817 doc->setVisible( value );
818 m_model->
treeModel()->updateFeature( doc );
825void MarbleMapPrivate::updateTileLevel()
827 auto const tileZoomLevel = q->tileZoomLevel();
828 m_geometryLayer.setTileLevel(tileZoomLevel);
829 m_placemarkLayer.setTileLevel(tileZoomLevel);
830 emit q->tileLevelChanged(tileZoomLevel);
838 if (d->m_showDebugPolygons ) {
840 painter.setDebugPolygonsLevel(1);
843 painter.setDebugPolygonsLevel(2);
846 painter.setDebugBatchRender(d->m_showDebugBatchRender);
848 if ( !d->m_model->mapTheme() ) {
849 mDebug() <<
"No theme yet!";
850 d->m_marbleSplashLayer.render( &painter, &d->m_viewport );
858 d->m_layerManager.renderLayers( &painter, &d->m_viewport );
859 d->m_renderState = d->m_layerManager.renderState();
866 emit renderStateChanged( d->m_renderState );
868 if ( d->m_showFrameRate ) {
873 const qreal fps = 1000.0 / (qreal)(
t.elapsed() );
874 emit framesPerSecond( fps );
884 return d->m_model->mapThemeId();
892void MarbleMapPrivate::updateMapTheme()
896 m_vectorTileLayer.reset();
901 q, SLOT(updateProperty(
QString,
bool)) );
903 m_model, SLOT(updateProperty(
QString,
bool)) );
905 q->
setPropertyValue(QStringLiteral(
"clouds_data"), m_viewParams.showClouds());
907 QColor backgroundColor = m_styleBuilder.effectColor(m_model->mapTheme()->map()->backgroundColor());
908 m_groundLayer.setColor(backgroundColor);
913 const GeoSceneGroup *
const textureLayerSettings = settings ? settings->
group(
"Texture Layers" ) :
nullptr;
914 const GeoSceneGroup *
const vectorTileLayerSettings = settings ? settings->
group(
"VectorTile Layers" ) :
nullptr;
916 bool textureLayersOk =
true;
917 bool vectorTileLayersOk =
true;
924 for(
GeoSceneLayer* layer: m_model->mapTheme()->map()->layers() ){
925 if ( layer->backend() == dgml::dgmlValue_texture ){
928 const GeoSceneTextureTileDataset *
const texture =
dynamic_cast<GeoSceneTextureTileDataset
const *
>( pos );
932 const QString sourceDir = texture->sourceDir();
933 const QString installMap = texture->installMap();
934 const QString role = layer->role();
938 if ( !TileLoader::baseTilesAvailable( *texture )
941 mDebug() <<
"Base tiles not available. Creating Tiles ... \n"
942 <<
"SourceDir: " << sourceDir <<
"InstallMap:" << installMap;
944 TileCreator *tileCreator =
new TileCreator(
948 tileCreator->setTileFormat( texture->fileFormat().
toLower() );
951 tileCreatorDlg->setSummary( m_model->mapTheme()->head()->name(),
952 m_model->mapTheme()->head()->description() );
953 tileCreatorDlg->exec();
954 if ( TileLoader::baseTilesAvailable( *texture ) ) {
955 mDebug() <<
"Base tiles for" << sourceDir <<
"successfully created.";
957 qWarning() <<
"Some or all base tiles for" << sourceDir <<
"could not be created.";
960 delete tileCreatorDlg;
963 if ( TileLoader::baseTilesAvailable( *texture ) ) {
964 textures.
append( texture );
966 qWarning() <<
"Base tiles for" << sourceDir <<
"not available. Skipping all texture layers.";
967 textureLayersOk =
false;
971 else if ( layer->backend() == dgml::dgmlValue_vectortile ){
973 for (
const GeoSceneAbstractDataset *pos: layer->datasets() ) {
974 const GeoSceneVectorTileDataset *
const vectorTile =
dynamic_cast<GeoSceneVectorTileDataset
const *
>( pos );
978 const QString sourceDir = vectorTile->sourceDir();
979 const QString installMap = vectorTile->installMap();
980 const QString role = layer->role();
984 if ( !TileLoader::baseTilesAvailable( *vectorTile )
987 mDebug() <<
"Base tiles not available. Creating Tiles ... \n"
988 <<
"SourceDir: " << sourceDir <<
"InstallMap:" << installMap;
990 TileCreator *tileCreator =
new TileCreator(
994 tileCreator->setTileFormat( vectorTile->fileFormat().toLower() );
997 tileCreatorDlg->setSummary( m_model->mapTheme()->head()->name(),
998 m_model->mapTheme()->head()->description() );
999 tileCreatorDlg->exec();
1000 if ( TileLoader::baseTilesAvailable( *vectorTile ) ) {
1001 qDebug() <<
"Base tiles for" << sourceDir <<
"successfully created.";
1003 qDebug() <<
"Some or all base tiles for" << sourceDir <<
"could not be created.";
1006 delete tileCreatorDlg;
1009 if ( TileLoader::baseTilesAvailable( *vectorTile ) ) {
1010 vectorTiles.
append( vectorTile );
1012 qWarning() <<
"Base tiles for" << sourceDir <<
"not available. Skipping all texture layers.";
1013 vectorTileLayersOk =
false;
1020 if( !m_model->mapTheme()->map()->
filters().isEmpty() ) {
1021 const GeoSceneFilter *
filter= m_model->mapTheme()->map()->
filters().first();
1026 for (
const GeoScenePalette *curPalette: palette ) {
1029 seafile = MarbleDirs::path( curPalette->file() );
1031 landfile = MarbleDirs::path( curPalette->file() );
1036 seafile = MarbleDirs::path(QStringLiteral(
"seacolors.leg"));
1038 landfile = MarbleDirs::path(QStringLiteral(
"landcolors.leg"));
1042 m_textureLayer.setMapTheme( textures, textureLayerSettings, seafile, landfile );
1043 m_textureLayer.setProjection( m_viewport.projection() );
1044 m_textureLayer.setShowRelief( q->
showRelief() );
1046 m_vectorTileLayer.setMapTheme( vectorTiles, vectorTileLayerSettings );
1048 if (m_textureLayer.layerCount() == 0) {
1049 m_layerManager.
addLayer( &m_groundLayer );
1052 if ( textureLayersOk )
1053 m_layerManager.
addLayer( &m_textureLayer );
1054 if ( vectorTileLayersOk && !vectorTiles.
isEmpty() )
1055 m_layerManager.
addLayer( &m_vectorTileLayer );
1058 m_layerManager.
addLayer( &m_groundLayer );
1064 m_placemarkLayer.setShowPlaces( q->
showPlaces() );
1066 m_placemarkLayer.setShowCities( q->
showCities() );
1067 m_placemarkLayer.setShowTerrain( q->
showTerrain() );
1069 m_placemarkLayer.setShowLandingSites(q->
propertyValue(QStringLiteral(
"landingsites")));
1070 m_placemarkLayer.setShowCraters(q->
propertyValue(QStringLiteral(
"craters")));
1071 m_placemarkLayer.setShowMaria(q->
propertyValue(QStringLiteral(
"maria")));
1073 m_styleBuilder.setDefaultLabelColor(m_model->mapTheme()->map()->labelColor());
1074 m_placemarkLayer.requestStyleReset();
1076 for (RenderPlugin *renderPlugin: m_renderPlugins) {
1077 bool propertyAvailable =
false;
1078 m_model->mapTheme()->settings()->
propertyAvailable( renderPlugin->nameId(), propertyAvailable );
1079 bool propertyValue =
false;
1080 m_model->mapTheme()->settings()->
propertyValue( renderPlugin->nameId(), propertyValue );
1082 if ( propertyAvailable ) {
1083 renderPlugin->setVisible( propertyValue );
1087 emit q->
themeChanged( m_model->mapTheme()->head()->mapThemeId() );
1092 mDebug() <<
"In MarbleMap the property " << name <<
"was set to " << value;
1093 if ( d->m_model->mapTheme() ) {
1095 d->m_textureLayer.setNeedsUpdate();
1096 emit propertyValueChanged(name, value);
1099 mDebug() <<
"WARNING: Failed to access a map theme! Property: " << name;
1101 if (d->m_textureLayer.layerCount() == 0) {
1102 d->m_layerManager.
addLayer( &d->m_groundLayer );
1105 d->m_layerManager.
removeLayer( &d->m_groundLayer );
1128 plugin->setVisible( visible );
1132 d->m_viewParams.setShowAtmosphere( visible );
1140 for (;
i != end; ++
i ) {
1142 (*i)->setVisible( visible );
1149 d->m_viewParams.setShowClouds( visible );
1156 d->m_textureLayer.setShowSunShading( visible );
1161 d->m_textureLayer.setShowCityLights( visible );
1167 disconnect( d->m_model->sunLocator(),
SIGNAL(positionChanged(qreal,qreal)),
1171 d->m_isLockedToSubSolarPoint = visible;
1175 connect( d->m_model->sunLocator(),
SIGNAL(positionChanged(qreal,qreal)),
1178 centerOn( d->m_model->sunLocator()->getLon(), d->m_model->sunLocator()->getLat() );
1179 }
else if ( visible ) {
1180 mDebug() <<
"Ignoring centering on sun, since the sun plugin is not loaded.";
1187 d->m_isSubSolarPointIconVisible = visible;
1193 d->m_textureLayer.setShowTileId( visible );
1248 d->m_showFrameRate = visible;
1251void MarbleMap::setShowRuntimeTrace(
bool visible )
1253 if (visible != d->m_layerManager.showRuntimeTrace()) {
1254 d->m_layerManager.setShowRuntimeTrace(visible);
1259bool MarbleMap::showRuntimeTrace()
const
1261 return d->m_layerManager.showRuntimeTrace();
1266 if (visible != d->m_showDebugPolygons) {
1267 d->m_showDebugPolygons = visible;
1272bool MarbleMap::showDebugPolygons()
const
1274 return d->m_showDebugPolygons;
1280 if (visible != d->m_showDebugBatchRender) {
1281 d->m_showDebugBatchRender = visible;
1286bool MarbleMap::showDebugBatchRender()
const
1288 return d->m_showDebugBatchRender;
1293 if (visible != d->m_placemarkLayer.isDebugModeEnabled()) {
1294 d->m_placemarkLayer.setDebugModeEnabled(visible);
1299bool MarbleMap::showDebugPlacemarks()
const
1301 return d->m_placemarkLayer.isDebugModeEnabled();
1306 if (visible != d->m_geometryLayer.levelTagDebugModeEnabled()) {
1307 d->m_geometryLayer.setLevelTagDebugModeEnabled(visible);
1308 d->m_placemarkLayer.setLevelTagDebugModeEnabled(visible);
1313bool MarbleMap::levelTagDebugModeEnabled()
const
1315 return d->m_geometryLayer.levelTagDebugModeEnabled() &&
1316 d->m_placemarkLayer.levelTagDebugModeEnabled();
1319void MarbleMap::setDebugLevelTag(
int level)
1321 d->m_geometryLayer.setDebugLevelTag(level);
1322 d->m_placemarkLayer.setDebugLevelTag(level);
1325int MarbleMap::debugLevelTag()
const
1327 return d->m_geometryLayer.debugLevelTag();
1330void MarbleMap::setShowBackground(
bool visible )
1332 d->m_layerManager.setShowBackground( visible );
1335void MarbleMap::setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes)
1340 emit visibleRelationTypesChanged(d->m_visibleRelationTypes);
1349 const bool valid =
geoCoordinates( x, y, lon, lat, GeoDataCoordinates::Radian );
1352 emit mouseClickGeoPosition( lon, lat, GeoDataCoordinates::Radian );
1356void MarbleMap::clearVolatileTileCache()
1358 d->m_vectorTileLayer.reset();
1359 d->m_textureLayer.reset();
1360 mDebug() <<
"Cleared Volatile Cache!";
1366 d->m_textureLayer.setVolatileCacheLimit(
kilobytes );
1369AngleUnit MarbleMap::defaultAngleUnit()
const
1380void MarbleMap::setDefaultAngleUnit(
AngleUnit angleUnit )
1385 }
else if ( angleUnit ==
UTM ) {
1393QFont MarbleMap::defaultFont()
const
1395 return d->m_styleBuilder.defaultFont();
1398void MarbleMap::setDefaultFont(
const QFont& font )
1400 d->m_styleBuilder.setDefaultFont(font);
1401 d->m_placemarkLayer.requestStyleReset();
1406 return d->m_renderPlugins;
1447 return d->m_layerManager.renderState().status();
1450RenderState MarbleMap::renderState()
const
1452 return d->m_layerManager.renderState();
1457 return textureLayer()->addTextureLayer(texture);
1462 textureLayer()->removeTextureLayer(key);
1466TextureLayer *MarbleMap::textureLayer()
const
1468 return &d->m_textureLayer;
1471VectorTileLayer *MarbleMap::vectorTileLayer()
const
1473 return &d->m_vectorTileLayer;
1478 return &d->m_styleBuilder;
1481qreal MarbleMap::heading()
const
1483 return d->m_viewport.heading() * RAD2DEG;
1486void MarbleMap::setHeading( qreal heading )
1488 d->m_viewport.setHeading( heading * DEG2RAD );
1489 d->m_textureLayer.setNeedsUpdate();
1496#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.
Contents used inside a layer.
Group inside the settings of a GeoScene document.
Layer of a GeoScene document.
bool hasTextureLayers() const
Checks for valid layers that contain texture data.
QVector< GeoSceneFilter * > filters() const
Return all filters.
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.
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.
@ 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.
void append(QList< T > &&value)
const_iterator constBegin() const const
const_iterator constEnd() const const
bool isEmpty() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
T qobject_cast(QObject *object)
void getCoords(int *x1, int *y1, int *x2, int *y2) const const
bool isEmpty() const const
QString toLower() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)