17#include <QElapsedTimer> 
   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" 
   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" 
   57#include "TileLoader.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" 
   73class MarbleMap::CustomPaintLayer : 
public LayerInterface
 
   81    QStringList renderPosition()
 const override 
   83        return QStringList() << QStringLiteral(
"USER_TOOLS");
 
   86    bool render(GeoPainter *painter, ViewportParams *viewport, 
const QString &renderPos, GeoSceneLayer *layer)
 override 
   92        m_map->customPaint(painter);
 
   97    qreal zValue()
 const override 
  102    RenderState renderState()
 const override 
  104        return RenderState(QStringLiteral(
"Custom Map Paint"));
 
  107    QString runtimeTrace()
 const override 
  109        return QStringLiteral(
"CustomPaint");
 
  116class MarbleMapPrivate
 
  118    friend class MarbleWidget;
 
  121    explicit MarbleMapPrivate(MarbleMap *parent, MarbleModel *model);
 
  123    void updateMapTheme();
 
  125    void updateProperty(
const QString &, 
bool);
 
  127    void setDocument(
const QString &key);
 
  129    void updateTileLevel();
 
  136    MarbleModel *
const m_model;
 
  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;
 
  148    QList<RenderPlugin *> m_renderPlugins;
 
  150    LayerManager m_layerManager;
 
  151    MarbleSplashLayer m_marbleSplashLayer;
 
  152    MarbleMap::CustomPaintLayer m_customPaintLayer;
 
  153    GeometryLayer m_geometryLayer;
 
  154    FloatItemsLayer m_floatItemsLayer;
 
  156    GroundLayer m_groundLayer;
 
  157    TextureLayer m_textureLayer;
 
  158    PlacemarkLayer m_placemarkLayer;
 
  159    VectorTileLayer m_vectorTileLayer;
 
  161    bool m_isLockedToSubSolarPoint;
 
  162    bool m_isSubSolarPointIconVisible;
 
  163    RenderState m_renderState;
 
  170    , m_showFrameRate(false)
 
  171    , m_showDebugPolygons(false)
 
  172    , m_showDebugBatchRender(false)
 
  173    , m_visibleRelationTypes(GeoDataRelation::RouteFerry)
 
  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)
 
  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);
 
  192    m_model->bookmarkManager()->setStyleBuilder(&m_styleBuilder);
 
  197    QObject::connect(&m_placemarkLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
 
  199    QObject::connect(&m_layerManager, SIGNAL(pluginSettingsChanged()), parent, SIGNAL(pluginSettingsChanged()));
 
  201    QObject::connect(&m_layerManager, SIGNAL(renderPluginInitialized(RenderPlugin *)), parent, SIGNAL(renderPluginInitialized(RenderPlugin *)));
 
  204    QObject::connect(&m_geometryLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
 
  221    QObject::connect(&m_floatItemsLayer, SIGNAL(renderPluginInitialized(RenderPlugin *)), parent, SIGNAL(renderPluginInitialized(RenderPlugin *)));
 
  223    QObject::connect(&m_floatItemsLayer, SIGNAL(pluginSettingsChanged()), parent, SIGNAL(pluginSettingsChanged()));
 
  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()));
 
  229    QObject::connect(&m_textureLayer, SIGNAL(repaintNeeded()), parent, SIGNAL(repaintNeeded()));
 
  230    QObject::connect(parent, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)), parent, SIGNAL(repaintNeeded()));
 
  233    QObject::connect(model->pluginManager(), SIGNAL(renderPluginsChanged()), parent, SLOT(addPlugins()));
 
  236void MarbleMapPrivate::updateProperty(
const QString &name, 
bool show)
 
  240        m_placemarkLayer.setShowPlaces(show);
 
  242        m_placemarkLayer.setShowCities(show);
 
  244        m_placemarkLayer.setShowTerrain(show);
 
  246        m_placemarkLayer.setShowOtherPlaces(show);
 
  251        m_placemarkLayer.setShowLandingSites(show);
 
  253        m_placemarkLayer.setShowCraters(show);
 
  255        m_placemarkLayer.setShowMaria(show);
 
  259        m_textureLayer.setShowRelief(show);
 
  262    for (RenderPlugin *renderPlugin : std::as_const(m_renderPlugins)) {
 
  263        if (name == renderPlugin->nameId()) {
 
  264            if (renderPlugin->visible() == show) {
 
  268            renderPlugin->setVisible(show);
 
  275void MarbleMapPrivate::addPlugins()
 
  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;
 
  286        if (alreadyCreated) {
 
  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;
 
  294        if (
auto const floatItem = qobject_cast<AbstractFloatItem *>(renderPlugin)) {
 
  295            m_floatItemsLayer.addFloatItem(floatItem);
 
  297            m_layerManager.addRenderPlugin(renderPlugin);
 
  305    : d(new MarbleMapPrivate(this, new 
MarbleModel(this)))
 
 
  311    : d(new MarbleMapPrivate(this, 
model))
 
  313    d->m_modelIsOwned = 
false;
 
 
  316MarbleMap::~MarbleMap()
 
  320    d->m_layerManager.
removeLayer(&d->m_customPaintLayer);
 
  321    d->m_layerManager.
removeLayer(&d->m_geometryLayer);
 
  322    d->m_layerManager.
removeLayer(&d->m_floatItemsLayer);
 
  324    d->m_layerManager.
removeLayer(&d->m_placemarkLayer);
 
  327    qDeleteAll(d->m_renderPlugins);
 
  340    return &d->m_viewport;
 
  343const ViewportParams *MarbleMap::viewport()
 const 
  345    return &d->m_viewport;
 
  350    d->m_viewParams.setMapQualityForViewContext(quality, viewContext);
 
  353    d->m_textureLayer.setNeedsUpdate();
 
  358    return d->m_viewParams.mapQuality(viewContext);
 
  363    return d->m_viewParams.mapQuality();
 
 
  366void MarbleMap::setViewContext(
ViewContext viewContext)
 
  368    if (d->m_viewParams.viewContext() == viewContext) {
 
  372    const MapQuality oldQuality = d->m_viewParams.mapQuality();
 
  373    d->m_viewParams.setViewContext(viewContext);
 
  374    Q_EMIT viewContextChanged(viewContext);
 
  376    if (d->m_viewParams.mapQuality() != oldQuality) {
 
  378        d->m_textureLayer.setNeedsUpdate();
 
  386    return d->m_viewParams.viewContext();
 
  389void MarbleMap::setSize(
int width, 
int height)
 
  391    setSize(QSize(width, height));
 
  394void MarbleMap::setSize(
const QSize &size)
 
  396    d->m_viewport.setSize(size);
 
  401QSize MarbleMap::size()
 const 
  403    return {d->m_viewport.width(), d->m_viewport.height()};
 
  406int MarbleMap::width()
 const 
  408    return d->m_viewport.width();
 
  411int MarbleMap::height()
 const 
  413    return d->m_viewport.height();
 
  418    return d->m_viewport.radius();
 
 
  423    const int oldRadius = d->m_viewport.radius();
 
  425    d->m_viewport.setRadius(
radius);
 
  427    if (oldRadius != d->m_viewport.radius()) {
 
 
  433int MarbleMap::preferredRadiusCeil(
int radius)
 const 
  435    return d->m_textureLayer.preferredRadiusCeil(
radius);
 
  438int MarbleMap::preferredRadiusFloor(
int radius)
 const 
  440    return d->m_textureLayer.preferredRadiusFloor(
radius);
 
  443int MarbleMap::tileZoomLevel()
 const 
  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());
 
  452    const qreal centerLat = d->m_viewport.centerLatitude();
 
  454    return centerLat * RAD2DEG;
 
 
  459    return d->m_placemarkLayer.hasPlacemarkAt(position) || d->m_geometryLayer.hasFeatureAt(position, viewport());
 
 
  465    const qreal centerLon = d->m_viewport.centerLongitude();
 
  467    return centerLon * RAD2DEG;
 
 
  472    if (d->m_model->mapTheme())
 
  473        return d->m_model->mapTheme()->head()->zoom()->minimum();
 
 
  480    if (d->m_model->mapTheme())
 
  481        return d->m_model->mapTheme()->head()->zoom()->maximum();
 
 
  486bool MarbleMap::discreteZoom()
 const 
  488    if (d->m_model->mapTheme())
 
  489        return d->m_model->mapTheme()->head()->zoom()->discrete();
 
  496    return d->m_placemarkLayer.whichPlacemarkAt(curpos) + d->m_geometryLayer.whichFeatureAt(curpos, viewport());
 
  501    d->m_textureLayer.reload();
 
  502    d->m_vectorTileLayer.reload();
 
 
  507    Q_ASSERT(textureLayer());
 
  521    for (
int level = pyramid[first].bottomLevel(); level >= pyramid[first].topLevel(); --level) {
 
  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;
 
  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);
 
  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;
 
  546        tilesCount += tileIdSet.
count();
 
  550    int const elapsedMs = t.
elapsed();
 
  551    mDebug() << 
"MarbleMap::downloadRegion:" << tilesCount << 
"tiles, " << elapsedMs << 
"ms";
 
  554void MarbleMap::highlightRouteRelation(qint64 osmId, 
bool enabled)
 
  556    d->m_geometryLayer.highlightRouteRelation(osmId, enabled);
 
  562    if (d->m_model->mapTheme()) {
 
  563        d->m_model->mapTheme()->settings()->propertyValue(name, value);
 
  566        mDebug() << 
"WARNING: Failed to access a map theme! Property: " << name;
 
 
  593    return d->m_viewParams.showClouds();
 
 
  598    return d->m_textureLayer.showSunShading();
 
 
  603    return d->m_textureLayer.showCityLights();
 
 
  608    return d->m_isLockedToSubSolarPoint;
 
 
  613    return d->m_isSubSolarPointIconVisible;
 
 
  618    return d->m_viewParams.showAtmosphere();
 
 
  623    bool visible = 
false;
 
  628    for (; i != end; ++i) {
 
  630            visible = (*i)->visible();
 
 
  684    return d->m_showFrameRate;
 
 
  687bool MarbleMap::showBackground()
 const 
  689    return d->m_layerManager.showBackground();
 
  692GeoDataRelation::RelationTypes MarbleMap::visibleRelationTypes()
 const 
  694    return d->m_visibleRelationTypes;
 
  699    return d->m_textureLayer.volatileCacheLimit();
 
 
  704    centerOn(d->m_viewport.centerLongitude() * RAD2DEG + deltaLon, d->m_viewport.centerLatitude() * RAD2DEG + deltaLat);
 
 
  709    d->m_viewport.centerOn(lon * DEG2RAD, lat * DEG2RAD);
 
 
  726    return d->m_viewport.projection();
 
 
  745    return d->m_viewport.screenCoordinates(lon * DEG2RAD, lat * DEG2RAD, x, y);
 
 
  750    return d->m_viewport.geoCoordinates(x, y, lon, lat, unit);
 
 
  753void MarbleMapPrivate::setDocument(
const QString &key)
 
  755    if (!m_model->mapTheme()) {
 
  766    GeoDataDocument *doc = m_model->fileManager()->at(key);
 
  768    const auto layers = m_model->mapTheme()->map()->
layers();
 
  769    for (
const GeoSceneLayer *layer : layers) {
 
  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) {
 
  781                    m_textureLayer.addLandDocument(doc);
 
  783                if (colorize == QLatin1StringView(
"sea")) {
 
  784                    m_textureLayer.addSeaDocument(doc);
 
  788                if (!data->property().isEmpty()) {
 
  790                    m_model->mapTheme()->settings()->propertyValue(data->property(), value);
 
  791                    doc->setVisible(value);
 
  792                    m_model->treeModel()->updateFeature(doc);
 
  799void MarbleMapPrivate::updateTileLevel()
 
  801    auto const tileZoomLevel = q->tileZoomLevel();
 
  802    m_geometryLayer.setTileLevel(tileZoomLevel);
 
  803    m_placemarkLayer.setTileLevel(tileZoomLevel);
 
  804    Q_EMIT q->tileLevelChanged(tileZoomLevel);
 
  812    if (d->m_showDebugPolygons) {
 
  814            painter.setDebugPolygonsLevel(1);
 
  816            painter.setDebugPolygonsLevel(2);
 
  819    painter.setDebugBatchRender(d->m_showDebugBatchRender);
 
  821    if (!d->m_model->mapTheme()) {
 
  822        mDebug() << 
"No theme yet!";
 
  823        d->m_marbleSplashLayer.render(&painter, &d->m_viewport);
 
  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;
 
  835    RenderStatus const newRenderStatus = d->m_renderState.status();
 
  836    if (oldRenderStatus != newRenderStatus) {
 
  839    Q_EMIT renderStateChanged(d->m_renderState);
 
  841    if (d->m_showFrameRate) {
 
  842        FpsLayer fpsPainter(&t);
 
  843        fpsPainter.paint(&painter);
 
  846    const qreal fps = 1000.0 / (qreal)(t.
elapsed());
 
  847    Q_EMIT framesPerSecond(fps);
 
 
  857    return d->m_model->mapThemeId();
 
 
  865void MarbleMapPrivate::updateMapTheme()
 
  869    m_vectorTileLayer.reset();
 
  876    q->
setPropertyValue(QStringLiteral(
"clouds_data"), m_viewParams.showClouds());
 
  878    QColor backgroundColor = m_styleBuilder.effectColor(m_model->mapTheme()->map()->backgroundColor());
 
  879    m_groundLayer.setColor(backgroundColor);
 
  884        const GeoSceneGroup *
const textureLayerSettings = settings ? settings->
group(QStringLiteral(
"Texture Layers")) : 
nullptr;
 
  885        const GeoSceneGroup *
const vectorTileLayerSettings = settings ? settings->
group(QStringLiteral(
"VectorTile Layers")) : 
nullptr;
 
  887        bool textureLayersOk = 
true;
 
  888        bool vectorTileLayersOk = 
true;
 
  897                const auto datasets = layer->datasets();
 
  899                    auto const *texture = 
dynamic_cast<GeoSceneTextureTileDataset 
const *
>(pos);
 
  903                    const QString sourceDir = texture->sourceDir();
 
  904                    const QString installMap = texture->installMap();
 
  905                    const QString role = layer->role();
 
  909                    if (!TileLoader::baseTilesAvailable(*texture) && !installMap.
isEmpty()) {
 
  910                        mDebug() << 
"Base tiles not available. Creating Tiles ... \n" 
  911                                 << 
"SourceDir: " << sourceDir << 
"InstallMap:" << installMap;
 
  914                            new TileCreator(sourceDir, installMap, (role == 
QLatin1StringView(
"dem")) ? QStringLiteral(
"true") : QStringLiteral(
"false"));
 
  915                        tileCreator->setTileFormat(texture->fileFormat().toLower());
 
  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.";
 
  923                            qWarning() << 
"Some or all base tiles for" << sourceDir << 
"could not be created.";
 
  926                        delete tileCreatorDlg;
 
  929                    if (TileLoader::baseTilesAvailable(*texture)) {
 
  932                        qWarning() << 
"Base tiles for" << sourceDir << 
"not available. Skipping all texture layers.";
 
  933                        textureLayersOk = 
false;
 
  937                const auto datasets = layer->datasets();
 
  938                for (
const GeoSceneAbstractDataset *pos : datasets) {
 
  939                    auto const *vectorTile = 
dynamic_cast<GeoSceneVectorTileDataset 
const *
>(pos);
 
  943                    const QString sourceDir = vectorTile->sourceDir();
 
  944                    const QString installMap = vectorTile->installMap();
 
  945                    const QString role = layer->role();
 
  949                    if (!TileLoader::baseTilesAvailable(*vectorTile) && !installMap.
isEmpty()) {
 
  950                        mDebug() << 
"Base tiles not available. Creating Tiles ... \n" 
  951                                 << 
"SourceDir: " << sourceDir << 
"InstallMap:" << installMap;
 
  954                            new TileCreator(sourceDir, installMap, (role == QLatin1StringView(
"dem")) ? QStringLiteral(
"true") : QStringLiteral(
"false"));
 
  955                        tileCreator->setTileFormat(vectorTile->fileFormat().toLower());
 
  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.";
 
  963                            qDebug() << 
"Some or all base tiles for" << sourceDir << 
"could not be created.";
 
  966                        delete tileCreatorDlg;
 
  969                    if (TileLoader::baseTilesAvailable(*vectorTile)) {
 
  970                        vectorTiles.
append(vectorTile);
 
  972                        qWarning() << 
"Base tiles for" << sourceDir << 
"not available. Skipping all texture layers.";
 
  973                        vectorTileLayersOk = 
false;
 
  979        QString seafile, landfile;
 
  980        if (!m_model->mapTheme()->map()->filters().isEmpty()) {
 
  981            const GeoSceneFilter *
filter = m_model->mapTheme()->map()->filters().first();
 
  983            if (
filter->type() == QLatin1StringView(
"colorize")) {
 
  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());
 
  995                    seafile = MarbleDirs::path(QStringLiteral(
"seacolors.leg"));
 
  997                    landfile = MarbleDirs::path(QStringLiteral(
"landcolors.leg"));
 
 1001        m_textureLayer.setMapTheme(textures, textureLayerSettings, seafile, landfile);
 
 1002        m_textureLayer.setProjection(m_viewport.projection());
 
 1003        m_textureLayer.setShowRelief(q->showRelief());
 
 1005        m_vectorTileLayer.setMapTheme(vectorTiles, vectorTileLayerSettings);
 
 1007        if (m_textureLayer.layerCount() == 0) {
 
 1008            m_layerManager.addLayer(&m_groundLayer);
 
 1011        if (textureLayersOk)
 
 1012            m_layerManager.addLayer(&m_textureLayer);
 
 1013        if (vectorTileLayersOk && !vectorTiles.
isEmpty())
 
 1014            m_layerManager.addLayer(&m_vectorTileLayer);
 
 1016        m_layerManager.addLayer(&m_groundLayer);
 
 1017        m_textureLayer.setMapTheme(QList<const GeoSceneTextureTileDataset *>(), 
nullptr, QString(), QString());
 
 1018        m_vectorTileLayer.setMapTheme(QList<const GeoSceneVectorTileDataset *>(), 
nullptr);
 
 1022    m_placemarkLayer.setShowPlaces(q->showPlaces());
 
 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")));
 
 1031    m_styleBuilder.setDefaultLabelColor(m_model->mapTheme()->map()->labelColor());
 
 1032    m_placemarkLayer.requestStyleReset();
 
 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);
 
 1040        if (propertyAvailable) {
 
 1041            renderPlugin->setVisible(propertyValue);
 
 1045    Q_EMIT q->themeChanged(m_model->mapTheme()->head()->mapThemeId());
 
 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);
 
 1056        mDebug() << 
"WARNING: Failed to access a map theme! Property: " << name;
 
 1058    if (d->m_textureLayer.layerCount() == 0) {
 
 1059        d->m_layerManager.addLayer(&d->m_groundLayer);
 
 1061        d->m_layerManager.removeLayer(&d->m_groundLayer);
 
 
 1085            plugin->setVisible(visible);
 
 1089    d->m_viewParams.setShowAtmosphere(visible);
 
 
 1097    for (; i != end; ++i) {
 
 1099            (*i)->setVisible(visible);
 
 
 1106    d->m_viewParams.setShowClouds(visible);
 
 
 1113    d->m_textureLayer.setShowSunShading(visible);
 
 
 1118    d->m_textureLayer.setShowCityLights(visible);
 
 
 1124    disconnect(d->m_model->sunLocator(), SIGNAL(positionChanged(qreal, qreal)), 
this, SLOT(
centerOn(qreal, qreal)));
 
 1127        d->m_isLockedToSubSolarPoint = visible;
 
 1131        connect(d->m_model->sunLocator(), SIGNAL(positionChanged(qreal, qreal)), 
this, SLOT(
centerOn(qreal, qreal)));
 
 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.";
 
 
 1142        d->m_isSubSolarPointIconVisible = visible;
 
 
 1148    d->m_textureLayer.setShowTileId(visible);
 
 
 1203    d->m_showFrameRate = visible;
 
 
 1206void MarbleMap::setShowRuntimeTrace(
bool visible)
 
 1208    if (visible != d->m_layerManager.showRuntimeTrace()) {
 
 1209        d->m_layerManager.setShowRuntimeTrace(visible);
 
 1214bool MarbleMap::showRuntimeTrace()
 const 
 1216    return d->m_layerManager.showRuntimeTrace();
 
 1221    if (visible != d->m_showDebugPolygons) {
 
 1222        d->m_showDebugPolygons = visible;
 
 
 1227bool MarbleMap::showDebugPolygons()
 const 
 1229    return d->m_showDebugPolygons;
 
 1234    qDebug() << visible;
 
 1235    if (visible != d->m_showDebugBatchRender) {
 
 1236        d->m_showDebugBatchRender = visible;
 
 
 1241bool MarbleMap::showDebugBatchRender()
 const 
 1243    return d->m_showDebugBatchRender;
 
 1248    if (visible != d->m_placemarkLayer.isDebugModeEnabled()) {
 
 1249        d->m_placemarkLayer.setDebugModeEnabled(visible);
 
 
 1254bool MarbleMap::showDebugPlacemarks()
 const 
 1256    return d->m_placemarkLayer.isDebugModeEnabled();
 
 1261    if (visible != d->m_geometryLayer.levelTagDebugModeEnabled()) {
 
 1262        d->m_geometryLayer.setLevelTagDebugModeEnabled(visible);
 
 1263        d->m_placemarkLayer.setLevelTagDebugModeEnabled(visible);
 
 
 1268bool MarbleMap::levelTagDebugModeEnabled()
 const 
 1270    return d->m_geometryLayer.levelTagDebugModeEnabled() && d->m_placemarkLayer.levelTagDebugModeEnabled();
 
 1273void MarbleMap::setDebugLevelTag(
int level)
 
 1275    d->m_geometryLayer.setDebugLevelTag(level);
 
 1276    d->m_placemarkLayer.setDebugLevelTag(level);
 
 1279int MarbleMap::debugLevelTag()
 const 
 1281    return d->m_geometryLayer.debugLevelTag();
 
 1284void MarbleMap::setShowBackground(
bool visible)
 
 1286    d->m_layerManager.setShowBackground(visible);
 
 1289void MarbleMap::setVisibleRelationTypes(GeoDataRelation::RelationTypes relationTypes)
 
 1291    if (d->m_visibleRelationTypes != relationTypes) {
 
 1292        d->m_visibleRelationTypes = relationTypes;
 
 1293        d->m_geometryLayer.setVisibleRelationTypes(relationTypes);
 
 1294        Q_EMIT visibleRelationTypesChanged(d->m_visibleRelationTypes);
 
 1303    const bool valid = 
geoCoordinates(x, y, lon, lat, GeoDataCoordinates::Radian);
 
 1306        Q_EMIT mouseClickGeoPosition(lon, lat, GeoDataCoordinates::Radian);
 
 
 1310void MarbleMap::clearVolatileTileCache()
 
 1312    d->m_vectorTileLayer.reset();
 
 1313    d->m_textureLayer.reset();
 
 1314    mDebug() << 
"Cleared Volatile Cache!";
 
 1319    mDebug() << 
"kiloBytes" << kilobytes;
 
 1320    d->m_textureLayer.setVolatileCacheLimit(kilobytes);
 
 
 1323AngleUnit MarbleMap::defaultAngleUnit()
 const 
 1334void MarbleMap::setDefaultAngleUnit(
AngleUnit angleUnit)
 
 1339    } 
else if (angleUnit == 
UTM) {
 
 1347QFont MarbleMap::defaultFont()
 const 
 1349    return d->m_styleBuilder.defaultFont();
 
 1352void MarbleMap::setDefaultFont(
const QFont &font)
 
 1354    d->m_styleBuilder.setDefaultFont(font);
 
 1355    d->m_placemarkLayer.requestStyleReset();
 
 1360    return d->m_renderPlugins;
 
 
 1370    const auto items = floatItems();
 
 
 1382    return d->m_layerManager.dataPlugins();
 
 
 1387    return d->m_layerManager.whichItemAt(curpos);
 
 
 1392    d->m_layerManager.addLayer(layer);
 
 
 1397    d->m_layerManager.removeLayer(layer);
 
 
 1402    return d->m_layerManager.renderState().status();
 
 1405RenderState MarbleMap::renderState()
 const 
 1407    return d->m_layerManager.renderState();
 
 1412    return textureLayer()->addTextureLayer(texture);
 
 
 1417    textureLayer()->removeTextureLayer(key);
 
 
 1421TextureLayer *MarbleMap::textureLayer()
 const 
 1423    return &d->m_textureLayer;
 
 1426VectorTileLayer *MarbleMap::vectorTileLayer()
 const 
 1428    return &d->m_vectorTileLayer;
 
 1433    return &d->m_styleBuilder;
 
 
 1436qreal MarbleMap::heading()
 const 
 1438    return d->m_viewport.heading() * RAD2DEG;
 
 1441void MarbleMap::setHeading(qreal heading)
 
 1443    d->m_viewport.setHeading(heading * DEG2RAD);
 
 1444    d->m_textureLayer.setNeedsUpdate();
 
 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.
 
static GeoDataCoordinates::Notation defaultNotation()
return Notation of string representation
 
Unit
enum used constructor to specify the units used
 
The abstract class for float item plugins.
 
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.
 
QList< GeoSceneLayer * > layers() const
Return all layers.
 
bool hasTextureLayers() const
Checks for valid layers that contain texture data.
 
Settings of a GeoScene document.
 
const GeoSceneGroup * group(const QString &name) const
Get a group from the settings.
 
void removeLayer(LayerInterface *layer)
Remove a layer from being included in rendering.
 
A class that can paint a view of the earth.
 
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 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.
 
The abstract class that creates a renderable item.
 
A public class that controls what is visible in the viewport of a Marble 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.
 
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
 
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)