• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • layers
VectorTileLayer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Marble Virtual Globe.
3 
4  This program is free software licensed under the GNU LGPL. You can
5  find a copy of this license in LICENSE.txt in the top directory of
6  the source code.
7 
8  Copyright 2008-2009 Patrick Spendrin <ps_ml@gmx.de>
9  Copyright 2010 Thibaut Gridel <tgridel@free.fr>
10  Copyright 2012 Ander Pijoan <ander.pijoan@deusto.es>
11  Copyright 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
12 */
13 
14 #include "VectorTileLayer.h"
15 
16 #include <qmath.h>
17 #include <QThreadPool>
18 
19 #include "VectorTileModel.h"
20 #include "GeoPainter.h"
21 #include "GeoSceneGroup.h"
22 #include "GeoSceneTypes.h"
23 #include "GeoSceneVectorTile.h"
24 #include "MarbleDebug.h"
25 #include "TileLoader.h"
26 #include "ViewportParams.h"
27 #include "GeoDataLatLonAltBox.h"
28 
29 namespace Marble
30 {
31 
32 class VectorTileLayer::Private
33 {
34 public:
35  Private(HttpDownloadManager *downloadManager,
36  const PluginManager *pluginManager,
37  VectorTileLayer *parent,
38  GeoDataTreeModel *treeModel);
39 
40  ~Private();
41 
42  void updateTextureLayers();
43 
44 public:
45  VectorTileLayer *const m_parent;
46  TileLoader m_loader;
47  QVector<VectorTileModel *> m_texmappers;
48  QVector<VectorTileModel *> m_activeTexmappers;
49  const GeoSceneGroup *m_textureLayerSettings;
50 
51  // TreeModel for displaying GeoDataDocuments
52  GeoDataTreeModel *const m_treeModel;
53 
54  QThreadPool m_threadPool; // a shared thread pool for all layers to keep CPU usage sane
55 };
56 
57 VectorTileLayer::Private::Private(HttpDownloadManager *downloadManager,
58  const PluginManager *pluginManager,
59  VectorTileLayer *parent,
60  GeoDataTreeModel *treeModel) :
61  m_parent( parent ),
62  m_loader( downloadManager, pluginManager ),
63  m_texmappers(),
64  m_activeTexmappers(),
65  m_textureLayerSettings( 0 ),
66  m_treeModel( treeModel )
67 {
68  m_threadPool.setMaxThreadCount( 1 );
69 }
70 
71 VectorTileLayer::Private::~Private()
72 {
73  qDeleteAll( m_activeTexmappers );
74 }
75 
76 void VectorTileLayer::Private::updateTextureLayers()
77 {
78  m_activeTexmappers.clear();
79 
80  foreach ( VectorTileModel *candidate, m_texmappers ) {
81  // Check if the GeoSceneTiled is a TextureTile or VectorTile.
82  // Only VectorTiles have to be used.
83  bool enabled = true;
84  if ( m_textureLayerSettings ) {
85  const bool propertyExists = m_textureLayerSettings->propertyValue( candidate->name(), enabled );
86  enabled |= !propertyExists; // if property doesn't exist, enable texture nevertheless
87  }
88  if ( enabled ) {
89  m_activeTexmappers.append( candidate );
90  mDebug() << "enabling texture" << candidate->name();
91  } else {
92  candidate->clear();
93  mDebug() << "disabling texture" << candidate->name();
94  }
95  }
96 }
97 
98 VectorTileLayer::VectorTileLayer(HttpDownloadManager *downloadManager,
99  const PluginManager *pluginManager,
100  GeoDataTreeModel *treeModel )
101  : QObject()
102  , d( new Private( downloadManager, pluginManager, this, treeModel ) )
103 {
104  qRegisterMetaType<TileId>( "TileId" );
105  qRegisterMetaType<GeoDataDocument*>( "GeoDataDocument*" );
106 }
107 
108 VectorTileLayer::~VectorTileLayer()
109 {
110  delete d;
111 }
112 
113 QStringList VectorTileLayer::renderPosition() const
114 {
115  return QStringList() << "SURFACE";
116 }
117 
118 RenderState VectorTileLayer::renderState() const
119 {
120  return RenderState( "Vector Tiles" );
121 }
122 
123 bool VectorTileLayer::render( GeoPainter *painter, ViewportParams *viewport,
124  const QString &renderPos, GeoSceneLayer *layer )
125 {
126  Q_UNUSED( painter );
127  Q_UNUSED( renderPos );
128  Q_UNUSED( layer );
129 
130  foreach ( VectorTileModel *mapper, d->m_activeTexmappers ) {
131  mapper->setViewport( viewport->viewLatLonAltBox(), viewport->radius() );
132  }
133 
134  return true;
135 }
136 
137 void VectorTileLayer::reset()
138 {
139  foreach ( VectorTileModel *mapper, d->m_texmappers ) {
140  mapper->clear();
141  }
142 }
143 
144 void VectorTileLayer::setMapTheme( const QVector<const GeoSceneVectorTile *> &textures, const GeoSceneGroup *textureLayerSettings )
145 {
146  qDeleteAll( d->m_texmappers );
147  d->m_texmappers.clear();
148  d->m_activeTexmappers.clear();
149 
150  foreach ( const GeoSceneVectorTile *layer, textures ) {
151  d->m_texmappers << new VectorTileModel( &d->m_loader, layer, d->m_treeModel, &d->m_threadPool );
152  }
153 
154  d->m_textureLayerSettings = textureLayerSettings;
155 
156  if ( d->m_textureLayerSettings ) {
157  connect( d->m_textureLayerSettings, SIGNAL(valueChanged(QString,bool)),
158  this, SLOT(updateTextureLayers()) );
159  }
160 
161  d->updateTextureLayers();
162 }
163 
164 }
165 
166 #include "VectorTileLayer.moc"
GeoSceneTypes.h
TileLoader.h
Marble::PluginManager
The class that handles Marble's plugins.
Definition: PluginManager.h:45
Marble::GeoSceneVectorTile
Definition: GeoSceneVectorTile.h:23
Marble::GeoDataTreeModel
The representation of GeoData in a model This class represents all available data given by kml-data f...
Definition: GeoDataTreeModel.h:32
GeoSceneGroup.h
Marble::VectorTileModel::setViewport
void setViewport(const GeoDataLatLonBox &bbox, int radius)
Definition: VectorTileModel.cpp:66
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
QThreadPool
Marble::ViewportParams::viewLatLonAltBox
const GeoDataLatLonAltBox & viewLatLonAltBox() const
Definition: ViewportParams.cpp:305
Marble::VectorTileModel
Definition: VectorTileModel.h:50
MarbleDebug.h
Marble::VectorTileLayer::setMapTheme
void setMapTheme(const QVector< const GeoSceneVectorTile * > &textures, const GeoSceneGroup *textureLayerSettings)
Definition: VectorTileLayer.cpp:144
Marble::VectorTileLayer::renderState
RenderState renderState() const
Definition: VectorTileLayer.cpp:118
Marble::VectorTileLayer::~VectorTileLayer
~VectorTileLayer()
Definition: VectorTileLayer.cpp:108
Marble::GeoSceneLayer
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:43
Marble::VectorTileLayer::VectorTileLayer
VectorTileLayer(HttpDownloadManager *downloadManager, const PluginManager *pluginManager, GeoDataTreeModel *treeModel)
Definition: VectorTileLayer.cpp:98
QObject
Marble::GeoSceneGroup
Group inside the settings of a GeoScene document.
Definition: GeoSceneGroup.h:40
Marble::VectorTileLayer::reset
void reset()
Definition: VectorTileLayer.cpp:137
QString
GeoPainter.h
Marble::RenderState
Definition: RenderState.h:22
QStringList
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
GeoSceneVectorTile.h
ViewportParams.h
This file contains the headers for ViewportParams.
VectorTileLayer.h
QVector
Marble::ViewportParams::radius
int radius() const
Definition: ViewportParams.cpp:195
GeoDataLatLonAltBox.h
Marble::VectorTileLayer::render
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos="NONE", GeoSceneLayer *layer=0)
Definition: VectorTileLayer.cpp:123
Marble::VectorTileLayer::renderPosition
QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
Definition: VectorTileLayer.cpp:113
Marble::VectorTileModel::clear
void clear()
Definition: VectorTileModel.cpp:166
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::parent
QObject * parent() const
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
Marble::HttpDownloadManager
This class manages scheduled downloads.
Definition: HttpDownloadManager.h:44
VectorTileModel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal