[Marble-commits] KDE/kdeedu/marble/src

Thibaut Gridel tgridel at free.fr
Fri Aug 13 00:36:25 CEST 2010


SVN commit 1162872 by tgridel:

GeometryLayer: a permanent layer which replaces Georender plugin

The GeometryLayer is added as a permanent layer in MarbleModel, because we
need to rely on this layer without a plugin.
There are many fixes compared to the GeoRender code:
 - it is not a Model/View class anymore as that brought a lot of unused
   boilerplate and we don't react to model signals anyway
 - no more hacks to try and determine styling on the fly, this is
   delegated after file loading in PlacemarkManager
 - internal data in private class

GeoDataFeature::style now points at the current style identified in the
document. The setStyle doesn't do it (yet).

 M  +1 -0      lib/CMakeLists.txt  
 M  +0 -12     lib/FileManager.cpp  
 M  +0 -2      lib/FileManager.h  
 A             lib/GeometryLayer.cpp   [License: LGPL]
 A             lib/GeometryLayer.h   [License: LGPL]
 M  +7 -0      lib/MarbleModel.cpp  
 M  +24 -0     lib/PlacemarkManager.cpp  
 M  +1 -0      lib/PlacemarkManager.h  
 M  +5 -5      lib/geodata/data/GeoDataFeature.cpp  
 M  +0 -1      plugins/render/CMakeLists.txt  
 D             plugins/render/geodata/CMakeLists.txt  
 D             plugins/render/geodata/GeoRendererPlugin.cpp  
 D             plugins/render/geodata/GeoRendererPlugin.h  
 D             plugins/render/geodata/GeoRendererView.cpp  
 D             plugins/render/geodata/GeoRendererView.h  


--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1162871:1162872
@@ -116,6 +116,7 @@
     PlacemarkLayout.cpp
     PlacemarkPainter.cpp
     PlacemarkInfoDialog.cpp
+    GeometryLayer.cpp
     Planet.cpp
     Quaternion.cpp
     TextureColorizer.cpp
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.cpp #1162871:1162872
@@ -183,20 +183,8 @@
     {
         doc->setName( doc->fileName() );
     }
-    // remove the hashes in front of the styles.
-    QVector<GeoDataFeature*>::Iterator end = doc->end();
-    QVector<GeoDataFeature*>::Iterator itr = doc->begin();
-    for ( ; itr != end; ++itr ) {
-        // use *itr (or itr.value()) here
-        QString styleUrl = (*itr)->styleUrl().remove('#');
-        if ( ! styleUrl.isEmpty() )
-        {
-            (*itr)->setStyle( &doc->style( styleUrl ) );
         }
-    }
 
-}
-
 void FileManager::cleanupLoader( FileLoader* loader )
 {
     d->m_loaderList.removeAll( loader );
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.h #1162871:1162872
@@ -98,8 +98,6 @@
 
  private:
 
-    int indexStart( int index );
-
     void appendLoader( FileLoader *loader );
 
     /**
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1162871:1162872
@@ -59,6 +59,7 @@
 #include "MergedLayerDecorator.h"
 #include "FileManager.h"
 #include "GeoDataTreeModel.h"
+#include "GeometryLayer.h"
 #include "PlacemarkManager.h"
 #include "PlacemarkLayout.h"
 #include "PlacemarkPainter.h"
@@ -144,6 +145,7 @@
     PlacemarkManager        *m_placemarkmanager;
     PlacemarkLayout         *m_placemarkLayout;
     QSortFilterProxyModel   *m_popSortModel;
+    GeometryLayer           *m_geometryLayer;
 
     // Misc stuff.
     MarbleClock             *m_clock;
@@ -239,6 +241,11 @@
     connect ( d->m_layerManager, SIGNAL( renderPluginInitialized( RenderPlugin * ) ),
               this,              SIGNAL( renderPluginInitialized( RenderPlugin * ) ) );
 
+    GeoDataObject *object = static_cast<GeoDataObject*>(d->m_dataFacade->treeModel()->index(0, 0, QModelIndex()).internalPointer());
+    GeoDataDocument *document = dynamic_cast<GeoDataDocument*>( object->parent() );
+    d->m_geometryLayer = new GeometryLayer( document );
+    d->m_layerManager->addLayer( d->m_geometryLayer );
+
     d->m_clock       = new MarbleClock();
     /* Assume we are dealing with the earth */
     d->m_planet = new Planet( "earth" );
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1162871:1162872
@@ -29,6 +29,7 @@
 #include "GeoDataFolder.h"
 #include "GeoDataParser.h"
 #include "GeoDataPlacemark.h"
+#include "GeoDataStyleMap.h"
 
 
 using namespace Marble;
@@ -94,6 +95,7 @@
         if (!result.isEmpty())
         {
             createFilterProperties( result );
+            setupStyle( file->document(), result );
             int start = d->m_placemarkContainer.size();
             d->m_placemarkContainer << result;
             d->m_sizeForDocument.resize(index+1);
@@ -146,6 +148,28 @@
     return results;
 }
 
+void PlacemarkManager::setupStyle( GeoDataDocument *doc, QVector<GeoDataPlacemark*> &container )
+{
+    // remove the hashes in front of the styles.
+    QVector<GeoDataPlacemark*>::Iterator itr = container.begin();
+    QVector<GeoDataPlacemark*>::Iterator end = container.end();
+    for ( ; itr != end; ++itr ) {
+        GeoDataPlacemark *placemark = *itr;
+        QString styleUrl = placemark->styleUrl().remove('#');
+        if ( ! styleUrl.isEmpty() )
+        {
+            const GeoDataStyleMap& styleMap = doc->styleMap( styleUrl );
+            /// hard coded to use only the "normal" style
+            if( !styleMap.value( QString( "normal" ) ).isEmpty() ) {
+                styleUrl = styleMap.value( QString( "normal" ) );
+            }
+            styleUrl.remove( '#' );
+            mDebug() << "feature " << placemark->name() << " " << styleUrl;
+            placemark->setStyle( &doc->style( styleUrl ) );
+        }
+    }
+}
+
 void PlacemarkManager::createFilterProperties( QVector<GeoDataPlacemark*> &container )
 {
 
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.h #1162871:1162872
@@ -77,6 +77,7 @@
 
  private:
     QVector<GeoDataPlacemark*> recurseContainer(GeoDataContainer *container);
+    void setupStyle( GeoDataDocument *doc, QVector<GeoDataPlacemark*> &container );
     void createFilterProperties( QVector<GeoDataPlacemark*> &container );
     int cityPopIdx( qint64 population ) const;
     int spacePopIdx( qint64 diameter ) const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature.cpp #1162871:1162872
@@ -120,7 +120,7 @@
 
     s_defaultStyle[Default]
         = new GeoDataStyle( QPixmap( MarbleDirs::path( "bitmaps/default_location.png" ) ), 
-              QFont( defaultFamily, defaultSize, 50, false ), QColor( Qt::black ) );
+              QFont( defaultFamily, defaultSize, 50, false ), QColor( Qt::white ) );
 
     s_defaultStyle[Unknown]
         = new GeoDataStyle( QPixmap(), 
@@ -449,6 +449,10 @@
 
 GeoDataStyle* GeoDataFeature::style() const
 {
+    if ( d->m_style != 0 ) {
+        return d->m_style;
+    } else
+    {
     if ( s_defaultStyleInitialized == false )
         initializeDefaultStyles();
 
@@ -458,10 +462,6 @@
     }
     else
     {
-        if ( d->m_style != 0 ) {
-            return d->m_style;
-        } else
-        {
             // This should not happen
             mDebug() << "No Style got assigned!";
             return new GeoDataStyle( QPixmap(), 
--- trunk/KDE/kdeedu/marble/src/plugins/render/CMakeLists.txt #1162871:1162872
@@ -1,6 +1,5 @@
 # add_subdirectory( test )
 add_subdirectory( crosshairs )
-add_subdirectory( geodata )
 add_subdirectory( compass )
 add_subdirectory( graticule )
 # add_subdirectory( satellites )


More information about the Marble-commits mailing list