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

Andrew Manson g.real.ate at gmail.com
Mon Jul 13 16:32:14 CEST 2009


SVN commit 995942 by mansona:

fixing 3 bugs: GeoClue position should not be enabled by default, 
marblewidget input reenabled after using sun locator and gps 
position marker nolonger floats 

BUG:199858 fixed


 M  +2 -2      lib/MarbleWidget.cpp  
 M  +39 -45    lib/gps/PositionTracking.cpp  
 M  +3 -0      lib/gps/PositionTracking.h  
 M  +2 -1      plugins/positionprovider/CMakeLists.txt  


--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #995941:995942
@@ -206,7 +206,7 @@
 
     m_logZoom  = 0;
 
-    m_widget->connect( m_model->sunLocator(), SIGNAL( reenableWidgetInput() ),
+    m_widget->connect( m_model->sunLocator(), SIGNAL( enableWidgetInput(bool) ),
                        m_widget, SLOT( setInputEnabled( bool ) ) );
 
     m_widget->connect( m_model->sunLocator(), SIGNAL( updateStars() ),
@@ -1037,7 +1037,7 @@
                                                          d->m_map->viewParams(),
                                                          temp );
     if ( draw ) {
-        qDebug() << "Updating viewport for GPS";
+//        qDebug() << "Updating viewport for GPS";
         update( temp );
     }
 }
--- trunk/KDE/kdeedu/marble/src/lib/gps/PositionTracking.cpp #995941:995942
@@ -76,51 +76,7 @@
 void PositionTracking::construct( const QSize &canvasSize,
                              ViewParams *viewParams )
 {
-    //qreal const radius = viewParams->m_radius;
 
-    // FIXME: Review
-//#ifdef HAVE_LIBGPS
-//    if( !m_gpsd ) {
-//        m_currentDraw.clear();
-//        return;
-//    }
-//#endif
-    QPointF  position;
-    QPointF  previousPosition;
-
-    bool draw = false;
-
-    draw = m_gpsCurrentPosition->getPixelPos( canvasSize, viewParams,
-                                              &position );
-
-    draw = m_gpsPreviousPosition->getPixelPos( canvasSize, viewParams,
-                                               &previousPosition );
-
-    if ( !draw ) {
-        m_currentDraw.clear();
-        return;
-    }
-
-    qreal distance = std::sqrt( AbstractLayer::distance( position,
-                                                     previousPosition) );
-    if (distance == 0) {
-        return;
-    }
-
-    QPointF unitVector = ( ( position - previousPosition )
-                           / distance );
-    // The normal of the unit vector between first and second
-    QPointF unitVector2 = QPointF ( -unitVector.y(), unitVector.x() );
-
-    m_previousDraw = m_currentDraw;
-
-    m_currentDraw.clear();
-    m_currentDraw << position
-                  << ( position - ( unitVector * 9 ) 
-                                + ( unitVector2 * 9 ) )
-                  << ( position + ( unitVector * 19.0 ) )
-                  << ( position - ( unitVector * 9 ) 
-                                - ( unitVector2 * 9 ) );
 }
 
 
@@ -161,7 +117,10 @@
         PositionProviderStatusAvailable )
     {
         m_gpsTracking->setPosition( m_positionProvider->position() );
+        m_gpsTracking->setPosition( m_gpsTracking->position().latitude(GeoDataCoordinates::Degree),
+                                       m_gpsTracking->position().longitude( GeoDataCoordinates::Degree ) );
 
+
         if (m_gpsTrackSeg == 0 ) {
             m_gpsTrackSeg = new TrackSegment();
             m_gpsTrack->append( m_gpsTrackSeg );
@@ -202,10 +161,45 @@
     Q_UNUSED( canvasSize )
     Q_UNUSED( viewParams )
 
+    QPointF position;
+    QPointF previousPosition;
+
+    //FIXME: this is a workaround for dealing with NAN values. we need to protect against that in the future
+    m_gpsCurrentPosition->setPosition( m_gpsCurrentPosition->position().latitude(GeoDataCoordinates::Degree),
+                                       m_gpsCurrentPosition->position().longitude( GeoDataCoordinates::Degree ) );
+    m_gpsPreviousPosition->setPosition( m_gpsPreviousPosition->position().latitude(GeoDataCoordinates::Degree),
+                                       m_gpsPreviousPosition->position().longitude( GeoDataCoordinates::Degree ) );
+
+
+    m_gpsCurrentPosition->getPixelPos( canvasSize, viewParams, &position );
+    m_gpsPreviousPosition->getPixelPos( canvasSize, viewParams, &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;
+    }
+
+    QPolygonF arrow;
+
+    arrow   << position
+            << position + m_relativeLeft
+            << position + m_relativeTip
+            << position + m_relativeRight;
+
     QPoint temp;
+    painter->save();
     painter->setPen( Qt::black );
     painter->setBrush( Qt::white );
-    painter->drawPolygon( m_currentDraw, Qt::OddEvenFill );
+    painter->drawPolygon( arrow );
+    painter->restore();
 }
 
 
--- trunk/KDE/kdeedu/marble/src/lib/gps/PositionTracking.h #995941:995942
@@ -95,6 +95,9 @@
     qreal               m_speed;
     //used to draw the arrow in gps tracking
     GpxFile             *m_currentGpx;
+    QPointF             m_relativeTip;
+    QPointF             m_relativeLeft;
+    QPointF             m_relativeRight;
     QPolygonF           m_currentDraw;
     QPolygonF           m_previousDraw;
     QPointF             m_previousDistancePosition;
--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/CMakeLists.txt #995941:995942
@@ -11,4 +11,5 @@
 
 endif(libgps_FOUND)
 
-add_subdirectory( geoclue )
+# experimental implementation
+# add_subdirectory( geoclue )


More information about the Marble-commits mailing list