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

Thibaut Gridel tgridel at free.fr
Sat Jun 19 18:13:47 CEST 2010


SVN commit 1139955 by tgridel:

PositionMarker plugin replaces PositionTracking drawing of the gps position

 M  +2 -2      MarbleTest.cpp  
 M  +5 -0      lib/MarbleDataFacade.cpp  
 M  +3 -0      lib/MarbleDataFacade.h  
 M  +0 -15     lib/MarbleMap.cpp  
 M  +0 -5      lib/MarbleMap.h  
 M  +0 -14     lib/MarbleModel.cpp  
 M  +0 -8      lib/MarbleModel.h  
 M  +0 -9      lib/MarbleWidget.cpp  
 M  +0 -5      lib/MarbleWidget.h  
 M  +2 -86     lib/gps/PositionTracking.cpp  
 M  +1 -34     lib/gps/PositionTracking.h  
 M  +1 -0      plugins/render/CMakeLists.txt  
 A             plugins/render/positionmarker (directory)  
 A             plugins/render/positionmarker/CMakeLists.txt  
 A             plugins/render/positionmarker/PositionMarker.cpp   [License: LGPL]
 A             plugins/render/positionmarker/PositionMarker.h   [License: LGPL]


--- trunk/KDE/kdeedu/marble/src/MarbleTest.cpp #1139954:1139955
@@ -128,7 +128,7 @@
                 m_marbleWidget->moveRight();
             }
             t.start();
-            m_marbleWidget->updateGps();
+//            m_marbleWidget->updateGps();
             temp = t.elapsed();
 //             qDebug("time elapsed moving %d",temp);
             totalMoving += temp;
@@ -138,7 +138,7 @@
         
         for( int i = 0; i< 10 ;i++ ){
             t.start();
-            m_marbleWidget->updateGps();
+//            m_marbleWidget->updateGps();
             temp=t.elapsed();
 //             qDebug("time elapsed static %d",t.elapsed());
             totalStatic+=temp;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.cpp #1139954:1139955
@@ -100,6 +100,11 @@
     return QString();
 }
 
+PositionTracking* MarbleDataFacade::positionTracking() const
+{
+    return d->m_model->positionTracking();
+}
+
 MarbleGeoDataModel* MarbleDataFacade::geoDataModel()
 {
     return d->m_geodatamodel;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.h #1139954:1139955
@@ -44,6 +44,7 @@
 class MarbleDataFacadePrivate;
 class Planet;
 class PluginManager;
+class PositionTracking;
 
 /**
  * @short A read-only interface to internal Marble data.
@@ -76,6 +77,8 @@
 
     QString target() const;
 
+    PositionTracking* positionTracking() const;
+
     MarbleGeoDataModel* geoDataModel();
     
     MarbleGeometryModel* geometryModel();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1139954:1139955
@@ -91,10 +91,7 @@
     
     m_measureTool = new MeasureTool( m_model, m_parent );
 
-    m_parent->connect( m_model, SIGNAL( timeout() ),
-                       m_parent, SLOT( updateGps() ) );
 
-
     m_logzoom  = 0;
     m_zoomStep = 40;
 
@@ -1135,18 +1132,6 @@
     }
 }
 
-void MarbleMap::updateGps()
-{
-    QRegion temp;
-//    const bool draw = 
-    d->m_model->positionTracking()->update( size(),&d->m_viewParams, temp );
-#if 0  // FIXME: move to MarbleWidget?
-    if ( draw ) {
-        update(temp);
-    }
-#endif
-}
-
 void MarbleMap::openGpxFile( const QString &filename )
 {
     d->m_model->openGpxFile( filename );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1139954:1139955
@@ -745,11 +745,6 @@
     void notifyMouseClick( int x, int y );
 
     /**
-     * @brief updates the gps tracking point by polling
-     */
-    void updateGps();
-
-    /**
      * @brief Opens a gpx file for viewing on the Marble Map
      */
     void openGpxFile( const QString &filename );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1139954:1139955
@@ -145,9 +145,6 @@
     PositionTracking        *m_positionTracking;
     GpxFileModel            *m_gpxFileModel;
 
-    QTimer                  *m_timer;
-
-
     Planet                  *m_planet;
 };
 
@@ -226,12 +223,6 @@
     connect ( d->m_layerManager, SIGNAL( renderPluginInitialized( RenderPlugin * ) ),
               this,              SIGNAL( renderPluginInitialized( RenderPlugin * ) ) );
 
-    d->m_timer = new QTimer( this );
-    d->m_timer->start( 1000 );
-
-    connect( d->m_timer, SIGNAL( timeout() ),
-             this,       SIGNAL( timeout() ) );
-
     d->m_dateTime       = new ExtDateTime();
     /* Assume we are dealing with the earth */
     d->m_planet = new Planet( "earth" );
@@ -260,7 +251,6 @@
     delete d->m_placemarkmanager;
     delete d->m_fileManager;
     delete d->m_mapTheme;
-    delete d->m_timer;
     delete d->m_layerManager;
     delete d->m_dataFacade;
     delete d->m_layerDecorator;
@@ -643,10 +633,6 @@
     painter->save();
     QSize canvasSize = viewParams->canvasImage()->size();
     if ( viewParams->showGps() ) {
-        QRegion temp; // useless variable
-        d->m_positionTracking->update( canvasSize, viewParams, temp );
-        d->m_positionTracking->draw( painter, canvasSize, viewParams );
-
         const QVector<GpxFile*> * const allFiles = d->m_gpxFileModel->allFiles();
         QVector<GpxFile*>::const_iterator it;
         for( it = allFiles->constBegin();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1139954:1139955
@@ -323,14 +323,6 @@
     void modelChanged();
 
     /**
-     * @brief Signal that a timer has gone off.
-     *
-     * This is currently used only for GPS things right now, but will
-     * likely be used for more things in the future.
-     */
-    void timeout();
-
-    /**
      * This signal is emit when the settings of a plugin changed.
      */
     void pluginSettingsChanged();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1139954:1139955
@@ -223,10 +223,6 @@
     // displayed on the widget background.
     m_widget->setAutoFillBackground( true );
 
-    // Track the GPS current point at timely intervals.
-    m_widget->connect( m_model, SIGNAL( timeout() ),
-                       m_widget, SLOT( updateGps() ) );
-
     // Show a progress dialog when the model calculates new map tiles.
     m_widget->connect( m_model, SIGNAL( creatingTilesStart( TileCreator*, const QString&,
                                                             const QString& ) ),
@@ -1060,11 +1056,6 @@
     }
 }
 
-void MarbleWidget::updateGps()
-{
-    update();
-}
-
 void MarbleWidget::openGpxFile( const QString &filename )
 {
     d->m_map->openGpxFile( filename );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1139954:1139955
@@ -852,11 +852,6 @@
     void notifyMouseClick( int x, int y );
 
     /**
-     * @brief Updates the gps tracking point by polling
-     */
-    void updateGps();
-
-    /**
      * @brief Opens a gpx file for viewing on the Marble Widget
      */
     void openGpxFile( const QString &filename );
--- trunk/KDE/kdeedu/marble/src/lib/gps/PositionTracking.cpp #1139954:1139955
@@ -7,18 +7,17 @@
 //
 // Copyright 2007   Andrew Manson   <g.real.ate at gmail.com>
 // Copyright 2009   Eckhart Wörner  <ewoerner at kde.org>
+// Copyright 2010   Thibaut Gridel  <tgridel at free.fr>
 //
 
 #include "PositionTracking.h"
 
 #include "GeoDataDocument.h"
 #include "GeoDataPlacemark.h"
-#include "ClipPainter.h"
 #include "AbstractProjection.h"
 #include "MarbleMath.h"
 #include "MarbleDebug.h"
 #include "MarbleGeometryModel.h"
-#include "ViewParams.h"
 
 using namespace Marble;
 
@@ -46,40 +45,6 @@
 {
 }
 
-
-void PositionTracking::construct( const QSize &canvasSize,
-                             ViewParams *viewParams )
-{
-    QPointF position;
-    QPointF previousPosition;
-
-    viewParams->currentProjection()->screenCoordinates(m_gpsCurrentPosition,
-                                                       viewParams->viewport(),
-                                                       position);
-    viewParams->currentProjection()->screenCoordinates(m_gpsPreviousPosition,
-                                                       viewParams->viewport(),
-                                                       previousPosition);
-
-    QPointF unitVector = ( position - previousPosition  ) ;
-
-    if( unitVector.x() || unitVector.y() ) {
-        qreal magnitude = sqrt( (unitVector.x() * unitVector.x() )
-                          + ( unitVector.y() * unitVector.y() ) );
-        unitVector = unitVector / magnitude;
-        QPointF unitVector2 = QPointF ( -unitVector.y(), unitVector.x() );
-        m_relativeLeft = ( position - ( unitVector * 9   ) + ( unitVector2 * 9 ) ) - position ;
-        m_relativeRight = ( position - ( unitVector * 9 ) - ( unitVector2 * 9 ) ) - position;
-        m_relativeTip = ( position + ( unitVector * 19.0 ) ) - position;
-    }
-
-    m_currentDraw.clear();
-    m_currentDraw << position
-            << position + m_relativeLeft
-            << position + m_relativeTip
-            << position + m_relativeRight;
-}
-
-
 void PositionTracking::updateSpeed( GeoDataCoordinates& previous, GeoDataCoordinates next )
 {
     //This function makes the assumption that the update stage happens once
@@ -112,62 +77,13 @@
                 position ) )
         {
 
+            updateSpeed( m_gpsCurrentPosition, position );
             m_gpsCurrentPosition = position;
             emit gpsLocation( position, m_speed );
         }
     }
 }
 
-bool PositionTracking::update(const QSize &canvasSize, ViewParams *viewParams,
-                         QRegion &reg) 
-{
-    if ( m_positionProvider && m_positionProvider->status() ==
-        PositionProviderStatusAvailable )
-    {
-        //updateSpeed updates the speed to radians and needs
-        //to be multiplied by the radius
-        updateSpeed( m_gpsPreviousPosition, m_gpsCurrentPosition );
-        m_speed *= viewParams->radius();
-
-        //if the position has moved then update the current position
-        if ( !( m_gpsPreviousPosition ==
-                m_gpsCurrentPosition ) )
-        {
-            construct( canvasSize, viewParams );
-
-            QList<QPolygonF> items;
-            items << m_previousDraw << m_currentDraw;
-            foreach(const QPolygonF &polygon, items)
-            {
-                QRect rect = polygon.boundingRect().toRect();
-                rect.adjust( -5, -5, 10, 10 );
-                reg |= rect ;
-            }
-            m_gpsPreviousPosition = m_gpsCurrentPosition;
-            return true;
-        } else {
-            return false;
-        }
-    }
-    return false;
-}
-
-void PositionTracking::draw( ClipPainter *painter,
-                        const QSize &canvasSize, 
-                        ViewParams *viewParams )
-{
-    // Needed to have the current position stick to the gps position
-    // when dragging the map. See bug 199858.
-    construct( canvasSize, viewParams );
-
-    painter->save();
-    painter->setPen( Qt::black );
-    painter->setBrush( Qt::white );
-    painter->drawPolygon( m_currentDraw );
-    painter->restore();
-    m_previousDraw = m_currentDraw;
-}
-
 void PositionTracking::setPositionProviderPlugin( PositionProviderPlugin* plugin )
 {
     if ( m_positionProvider ) {
--- trunk/KDE/kdeedu/marble/src/lib/gps/PositionTracking.h #1139954:1139955
@@ -7,6 +7,7 @@
 //
 // Copyright 2007   Andrew Manson   <g.real.ate at gmail.com>
 // Copyright 2009   Eckhart Wörner  <ewoerner at kde.org>
+// Copyright 2010   Thibaut Gridel  <tgridel at free.fr>
 //
 
 #ifndef MARBLE_POSITIONTRACKING_H
@@ -24,8 +25,6 @@
 {
 
 class GeoDataDocument;
-class ClipPainter;
-class ViewParams;
 class GeoDataCoordinates;
 class PluginManager;
 class MarbleGeometryModel;
@@ -41,32 +40,6 @@
     ~PositionTracking();
 
     /**
-     * @brief update the provider position
-     * 
-     * this function is designed to be polled at a regular interval so
-     * that the provider object can update its position and construct the 
-     * new polygon that needs to be painted to screen. 
-     * 
-     * @param canvasSize current size of view
-     * @param radius current radius of globe
-     * @param invRotAxis current Quaternion representation of globe.
-     * @param reg the region on screen that needs to be re-painted
-     *            following this update
-     * @return @c true the region of the screen needs to be repainted
-     *         @c false the gps object was not updated so no repaint
-     *                  necessary.
-     */
-    bool update(const QSize &canvasSize, ViewParams *viewParams,
-                QRegion &reg);
-
-    void construct ( const QSize &canvasSize,
-                     ViewParams *viewParams );
-
-    void draw( ClipPainter *painter,
-                const QSize &canvasSize, 
-                ViewParams *viewParams );
-
-    /**
       * Change the position provider to use. You can provide 0 to disable
       * position tracking. Ownership of the provided plugin is taken.
       */
@@ -87,12 +60,6 @@
     void updateSpeed( GeoDataCoordinates& previous, GeoDataCoordinates next );
 
     qreal               m_speed;
-    //used to draw the arrow in gps tracking
-    QPointF             m_relativeTip;
-    QPointF             m_relativeLeft;
-    QPointF             m_relativeRight;
-    QPolygonF           m_currentDraw;
-    QPolygonF           m_previousDraw;
 
     GeoDataDocument     *m_document;
     MarbleGeometryModel *m_geometryModel;
--- trunk/KDE/kdeedu/marble/src/plugins/render/CMakeLists.txt #1139954:1139955
@@ -10,6 +10,7 @@
 add_subdirectory( stars )
 # add_subdirectory( panoramio )
 add_subdirectory( photo )
+add_subdirectory( positionmarker )
 add_subdirectory( progress )
 # add_subdirectory ( twitter )
 add_subdirectory( wikipedia )


More information about the Marble-commits mailing list