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

Andrew Manson g.real.ate at gmail.com
Mon Jul 13 11:44:33 CEST 2009


SVN commit 995740 by mansona:

begin implementing the Graphics Item functionality in the GeoParser
Also fixing a flaw with the GeoGraphicsItem API


 M  +0 -1      lib/GeoGraphicsItem.h  
 M  +9 -9      lib/geodata/handlers/osm/OsmBoundsTagHandler.cpp  
 M  +17 -0     lib/geodata/parser/GeoParser.cpp  
 M  +5 -0      lib/geodata/parser/GeoParser.h  
 M  +12 -9     plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +1 -1      plugins/render/osmannotate/OsmAnnotatePlugin.h  


--- trunk/KDE/kdeedu/marble/src/lib/GeoGraphicsItem.h #995739:995740
@@ -83,7 +83,6 @@
      */
     QList<QPoint> positions();
 
- protected:
     /**
      * Paints the item in item coordinates
      */
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/osm/OsmBoundsTagHandler.cpp #995739:995740
@@ -46,16 +46,16 @@
     bound.append( botRight );
     bound.append( botLeft );
 
-    GeoDataDocument* doc = geoDataDoc( parser );
+    QList<GeoGraphicsItem*>* model = parser.activeModel();
+//
+//    GeoDataPlacemark* place = new GeoDataPlacemark;
+//
+//    place->setCoordinate( topLeft.longitude(), topLeft.latitude(), topLeft.altitude() );
+//
+//    place->setGeometry( GeoDataLinearRing( bound ) );
+//
+//    model->append( dynamic_cast<GeoGraphicsItem*>( place ) );
 
-    GeoDataPlacemark place;
-
-    place.setCoordinate( topLeft.longitude(), topLeft.latitude(), topLeft.altitude() );
-
-    place.setGeometry( GeoDataLinearRing( bound ) );
-
-    doc->append( place );
-
     return 0;
 
 }
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoParser.cpp #995739:995740
@@ -39,6 +39,7 @@
 GeoParser::GeoParser( GeoDataGenericSourceType source )
     : QXmlStreamReader(),
       m_document( 0 ),
+      m_itemModel( 0 ),
       m_source( source )
 {
 }
@@ -208,4 +209,20 @@
     return document;
 }
 
+QList<GeoGraphicsItem*>* GeoParser::activeModel()
+{
+    if( ! m_itemModel ) {
+        m_itemModel = new QList<GeoGraphicsItem*>();
+    }
+    Q_ASSERT(m_itemModel);
+    return m_itemModel;
 }
+
+QList<GeoGraphicsItem*>* GeoParser::releaseModel()
+{
+    QList<GeoGraphicsItem*>* model = m_itemModel;
+    m_itemModel = 0;
+    return model;
+}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/parser/GeoParser.h #995739:995740
@@ -34,6 +34,7 @@
 typedef int GeoDataGenericSourceType;
 
 class GeoDocument;
+class GeoGraphicsItem;
 class GeoStackItem;
 
 class GEODATA_EXPORT GeoParser : public QXmlStreamReader
@@ -50,6 +51,9 @@
     GeoDocument* releaseDocument();
     GeoDocument* activeDocument() { return m_document; }
 
+    QList<GeoGraphicsItem*>* releaseModel();
+    QList<GeoGraphicsItem*>* activeModel();
+
     // Used by tag handlers, to be overridden by GeoDataParser/GeoSceneParser
     virtual bool isValidElement( const QString& tagName ) const;
 
@@ -71,6 +75,7 @@
 
 protected:
     GeoDocument* m_document;
+    QList<GeoGraphicsItem*>* m_itemModel;
     GeoDataGenericSourceType m_source;
 
 private:
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #995739:995740
@@ -111,7 +111,7 @@
 
     widgetInitalised= false;
     tmp_lineString = 0;
-    m_document = 0;
+    m_itemModel = 0;
     m_addPlacemark =0;
     m_drawPolygon = 0;
 }
@@ -175,12 +175,15 @@
 
     //Figure out how to add the data parsed to a scene for rendering
     //FIXME: this is a terrible hack intended just to test!
-    if( m_document ) {
-        GeoDataPlacemark p(m_document->at(0));
-        GeoDataLinearRing ring(* p.geometry() );
+    if( m_itemModel ) {
+        QListIterator<GeoGraphicsItem*> it( *m_itemModel );
 
-        painter->drawPolygon( ring );
+        while( it.hasNext() ) {
+            it.next()->paint( painter, viewport, renderPos, layer );
+        }
 
+//        painter->drawPolygon( ring );
+
     }
 
     return true;
@@ -232,14 +235,14 @@
             //do not quit on a failed read!
             //return
         }
-        GeoDocument* document = parser.releaseDocument();
-        Q_ASSERT( document );
+        QList<GeoGraphicsItem*>* model = parser.releaseModel();
+        Q_ASSERT( model );
 
-        m_document = static_cast<GeoDataDocument*>( document );
+        m_itemModel = model;
 
         file.close();
 
-        qDebug() << "size of container is " << m_document->size();
+        qDebug() << "size of container is " << model->size();
     }
 }
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #995739:995740
@@ -93,7 +93,7 @@
     void setupActions(MarbleWidget* m);
 
     GeoDataLineString* tmp_lineString;
-    GeoDataDocument* m_document;
+    QList<GeoGraphicsItem*>* m_itemModel;
 };
 
 }


More information about the Marble-commits mailing list