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

Andrew Manson g.real.ate at gmail.com
Wed Jul 15 18:45:01 CEST 2009


SVN commit 997256 by mansona:

Adding the ability to convert text annotations to GeoData structures
and hense simplify the output to KML for annotations. Also more cleaning
of the API


 M  +5 -0      lib/geodata/data/GeoDataPoint.cpp  
 M  +1 -0      lib/geodata/data/GeoDataPoint.h  
 M  +1 -0      plugins/render/osmannotate/CMakeLists.txt  
 M  +4 -4      plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 A             plugins/render/osmannotate/PlacemarkTextAnnotation.cpp   [License: LGPL]
 A             plugins/render/osmannotate/PlacemarkTextAnnotation.h   [License: LGPL]
 M  +10 -106   plugins/render/osmannotate/TextAnnotation.cpp  
 M  +7 -13     plugins/render/osmannotate/TextAnnotation.h  
 M  +20 -6     plugins/render/osmannotate/TextEditor.cpp  
 M  +8 -1      plugins/render/osmannotate/TextEditor.h  
 M  +0 -7      plugins/render/osmannotate/TmpGraphicsItem.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPoint.cpp #997255:997256
@@ -40,6 +40,11 @@
 {
 }
 
+GeoDataPoint::GeoDataPoint( const GeoDataCoordinates& other )
+  : GeoDataCoordinates( other )
+{
+}
+
 GeoDataPoint::GeoDataPoint( const GeoDataGeometry& other )
   : GeoDataGeometry( other )
     
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPoint.h #997255:997256
@@ -51,6 +51,7 @@
     typedef GeoDataCoordinates::Unit Unit;
 
     GeoDataPoint( const GeoDataPoint& other );
+    GeoDataPoint( const GeoDataCoordinates& other );
     GeoDataPoint( const GeoDataGeometry& other );
     GeoDataPoint();
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/CMakeLists.txt #997255:997256
@@ -11,6 +11,7 @@
 
 set( osmannotate_SRCS
         OsmAnnotatePlugin.cpp
+        PlacemarkTextAnnotation.cpp
         TmpGraphicsItem.cpp
         TextAnnotation.cpp
         AreaAnnotation.cpp
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #997255:997256
@@ -24,6 +24,7 @@
 #include <QtGui/QAction>
 #include "ViewportParams.h"
 #include "AbstractProjection.h"
+#include "AreaAnnotation.h"
 #include "MarbleDirs.h"
 #include "GeoPainter.h"
 #include "GeoDataDocument.h"
@@ -31,10 +32,9 @@
 #include "GeoDataLineString.h"
 #include "GeoDataLinearRing.h"
 #include "GeoDataPlacemark.h"
-#include "TextAnnotation.h"
 #include "GeoDataParser.h"
-#include "AreaAnnotation.h"
 #include "MarbleWidget.h"
+#include "PlacemarkTextAnnotation.h"
 
 namespace Marble
 {
@@ -85,7 +85,7 @@
 
     //Setup the model
     GeoDataCoordinates madrid( -13.7, 40.4, 0.0, GeoDataCoordinates::Degree );
-    TextAnnotation* annon = new TextAnnotation();
+    PlacemarkTextAnnotation* annon = new PlacemarkTextAnnotation();
 
     annon->setCoordinate(madrid);
     
@@ -230,7 +230,7 @@
                                                                   lon, lat, GeoDataCoordinates::Radian);
             if ( valid ) {
                 GeoDataCoordinates point( lon, lat );
-                TextAnnotation* t = new TextAnnotation();
+                PlacemarkTextAnnotation* t = new PlacemarkTextAnnotation();
                 t->setCoordinate(point);
                 model.append(t);
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.cpp #997255:997256
@@ -9,124 +9,28 @@
 //
 
 #include "TextAnnotation.h"
-#include "GeoPainter.h"
-#include "ViewportParams.h"
-#include "MarbleDirs.h"
-#include "GeoWidgetBubble.h"
-#include "TextEditor.h"
-#include "AbstractProjection.h"
 
-#include <QtCore/QDebug>
-#include <QtGui/QPixmap>
-#include <QtGui/QTextEdit>
-#include <QtGui/QPushButton>
-#include <QtCore/QVariant>
+#include "GeoDataPlacemark.h"
 
+
 namespace Marble{
 
 TextAnnotation::TextAnnotation()
 {
-   bubble = new GeoWidgetBubble();
-
-   //FIXME decide who actually owns this widget and setup destruction
-   //accordingly
-   m_textEditor = new TextEditor();
-   bubble->setGeoWidget( m_textEditor );
 }
 
-QRect TextAnnotation::screenBounding()
+GeoDataPlacemark TextAnnotation::toGeoData()
 {
-    //FIXME the first 2 should actually offset it
-    return QRect(-5,-5,20,20);
-}
+    GeoDataPlacemark placemark;
 
-void TextAnnotation::paint( GeoPainter *painter,
-                            ViewportParams *viewport,
-                            const QString& renderPos,
-                            GeoSceneLayer * layer )
-{
-    qreal degPix = viewport->angularResolution() * RAD2DEG;
+    placemark.setName( name() );
+    placemark.setDescription( description() );
 
-    painter->drawEllipse(coordinate(), screenBounding().width(), screenBounding().height(), true);
-    //Would it not be useful to have a draw latlongbox?
-//    painter->drawRect(geoBounding());
-    qreal north, south, east, west;
+    //FIXME: make this work for all geometries and not just points
+//    placemark.setGeometry( geometry() );
+    placemark.setGeometry( GeoDataPoint( geometry() ) );
 
-    //don't need this if its done by the painter soon
-//    geoBounding(viewport->angularResolution());
-//    north = m_regions.at(0).boundingRect().top();
-//    south = m_regions.at(0).boundingRect().bottom();
-//    east = m_regions.at(0).boundingRect().right();
-//    west = m_regions.at(0).boundingRect().left();
-
-    //would like a method to draw a QRegion ;)
-//    painter->drawRect(GeoDataCoordinates((west + east) /2 , (north + south) / 2, 0 ),
-//                      m_regions.at(0).boundingRect().width() * RAD2DEG,
-//                      m_regions.at(0).boundingRect().height() * RAD2DEG,true);
-
-
-    painter->drawPoint( GeoDataCoordinates((west + east) /2 , (north + south) / 2, 0 ) );
-
-    painter->drawPixmap( coordinate(), QPixmap( MarbleDirs::path( "bitmaps/annotation.png" ) )  );
-
-    qreal x, y;
-    bool hidden;
-    bool visable = viewport->currentProjection()->screenCoordinates( coordinate(), viewport, x, y, hidden );
-
-    if( visable && !hidden ) {
-        QList<QRegion> list;
-        list.append( QRegion( x -10 , y-10 , 20 , 20 ) );
-        setRegions( list );
-        painter->drawRect( regions().at(0).boundingRect() );
-        bubble->moveTo( QPoint( x, y ) );
-        bubble->paint( painter, viewport, renderPos, layer );
-    } else {
-        bubble->hide();
-    }
-
-    //FIXME This shouldn't really be a part of this method at all as each item should
-    //be a part of the scene regardless if it has a parent or not!
-    //Parent - Child relationship should only be used in the paint function to decide
-    //if the coordinate of the object should be an offset of the parent or an actual
-    //coordinate.
-    QListIterator<TmpGraphicsItem*> it(getChildren());
-
-    if( it.hasNext() ) {
-        TmpGraphicsItem* p = it.next();
-        p->paint(painter, viewport, renderPos, layer );
-    }
-
-
-
-
+    return placemark;
 }
 
-QVariant TextAnnotation::itemChange(GeoGraphicsItemChange change, QVariant v )
-{
-    switch ( change ) {
-        case TmpGraphicsItem::ItemSelectChange :
-        if ( v.toBool() ) {
-            //make the bubble visable
-        } else {
-            //hide the bubble
-        }
-        break;
-
-        default:
-        //do nothing
-        break;
-    }
-    return TmpGraphicsItem::itemChange( change, v );
 }
-
-bool TextAnnotation::mousePressEvent( QMouseEvent* event )
-{
-    if( bubble->isHidden() ) {
-        bubble->setHidden( false );
-    } else {
-        bubble->setHidden( true );
-    }
-    return true;
-}
-
-}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.h #997255:997256
@@ -11,29 +11,23 @@
 #ifndef TEXTANNOTATION_H
 #define TEXTANNOTATION_H
 
-
 #include "TmpGraphicsItem.h"
+
 namespace Marble{
 
-class GeoWidgetBubble;
-class TextEditor;
+class GeoDataPlacemark;
 
-class TextAnnotation : public TmpGraphicsItem
+class TextAnnotation
 {
 public:
     TextAnnotation();
 
-    virtual QRect screenBounding();
-    virtual void paint( GeoPainter *painter, ViewportParams *viewport,
-                        const QString& renderPos, GeoSceneLayer * layer = 0 );
-    virtual QVariant itemChange(GeoGraphicsItemChange c, QVariant v);
+    virtual QString name() = 0 ;
+    virtual QString description() = 0;
+    virtual GeoDataGeometry geometry() = 0;
 
-protected:
-    virtual bool mousePressEvent( QMouseEvent *event );
+    GeoDataPlacemark toGeoData();
 
-private:
-    GeoWidgetBubble* bubble;
-    TextEditor* m_textEditor;
 };
 
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextEditor.cpp #997255:997256
@@ -13,6 +13,7 @@
 #include <QtCore/QDebug>
 #include <QtGui/QAction>
 #include <QtGui/QApplication>
+#include <QtGui/QLineEdit>
 #include <QtGui/QToolButton>
 #include <QtGui/QTextEdit>
 #include <QtGui/QHBoxLayout>
@@ -28,8 +29,14 @@
     m_buttonLayout = new QHBoxLayout;
     m_layout = new QVBoxLayout;
 
-    m_textEditor = new QTextEdit;
+    m_description = new QTextEdit;
+    m_description->viewport()->setAutoFillBackground( true );
+    QApplication::setPalette( QPalette() );
+    m_description->setBackgroundRole( QPalette::Window );
 
+    m_name = new QLineEdit;
+    m_name->setText(tr("Placemark Name"));
+
     // setup the actions and create the buttons
     m_boldAction = new QAction( this );
     m_boldAction->setText(tr("Bold"));
@@ -51,13 +58,10 @@
     m_buttonLayout->addWidget( m_italicButton );
     m_buttonLayout->addWidget( m_underLineButton );
 
+    m_layout->addWidget( m_name );
     m_layout->addLayout( m_buttonLayout );
-    m_layout->addWidget( m_textEditor );
+    m_layout->addWidget( m_description );
 
-    m_textEditor->viewport()->setAutoFillBackground( true );
-    QApplication::setPalette( QPalette() );
-    m_textEditor->setBackgroundRole( QPalette::Window );
-
     setLayout( m_layout );
 }
 
@@ -66,4 +70,14 @@
 
 }
 
+QString TextEditor::name()
+{
+    return m_name->text();
 }
+
+QString TextEditor::description()
+{
+    return m_description->toHtml();
+}
+
+}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextEditor.h #997255:997256
@@ -13,6 +13,7 @@
 
 #include <QWidget>
 
+class QLineEdit;
 class QToolButton;
 class QTextEdit;
 class QHBoxLayout;
@@ -26,6 +27,11 @@
     TextEditor();
     ~TextEditor();
 
+    //return the plain text name
+    QString name();
+    //return the HTML description
+    QString description();
+
 private:
     QAction* m_boldAction;
     QAction* m_underLineAction;
@@ -35,7 +41,8 @@
     QToolButton* m_underLineButton;
     QToolButton* m_italicButton;
 
-    QTextEdit* m_textEditor;
+    QLineEdit* m_name;
+    QTextEdit* m_description;
 
     QHBoxLayout* m_buttonLayout;
     QVBoxLayout* m_layout;
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TmpGraphicsItem.h #997255:997256
@@ -55,13 +55,6 @@
     TmpGraphicsItem* getParent();
     void setParent( TmpGraphicsItem* p );
 
-    //determines if this object is offset from its parent
-    //by geocoorninates. If it is not then then it is drawn as screen
-    //coordinate offset from its parent.
-    //ONLY valid if there is a parent object.
-    //FIXME remove this? is this needed at all?
-    bool isGeoOffset();
-
     //Start dealing with the event stuff
     //is this the best thing to call the event distributer?
     bool sceneEvent( QEvent* event );


More information about the Marble-commits mailing list