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

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


SVN commit 995968 by mansona:

Backporting r995942 which fixes BUG:199858
Also committing a fix to the QtOnly version which caused a failed build an 
is currently [ POSSIBLY UNSAFE ] due to a conversion from an int to an 
enum 


 M  +11 -11    QtMarbleConfigDialog.cpp  
 M  +1 -1      QtMarbleConfigDialog.h  
 M  +1 -1      lib/MarbleWidget.cpp  
 M  +2 -2      lib/global.h  
 M  +39 -45    lib/gps/PositionTracking.cpp  
 M  +3 -0      lib/gps/PositionTracking.h  


--- branches/KDE/4.3/kdeedu/marble/src/QtMarbleConfigDialog.cpp #995967:995968
@@ -178,8 +178,14 @@
     w_cacheSettings->kcfg_proxyPort->setValue( proxyPort() );
     w_cacheSettings->kcfg_proxyUser->setText( proxyUser() );
     w_cacheSettings->kcfg_proxyPass->setText( proxyPass() );
-    w_cacheSettings->kcfg_proxyHttp->setChecked( proxyHttp() );
-    w_cacheSettings->kcfg_proxySocks5->setChecked( proxySocks5() );
+
+    //FIXME: are we guarenteed that the indexes will stay the same?
+    if( proxyType() == Marble::HttpProxy ){
+        w_cacheSettings->kcfg_proxyType->setCurrentIndex( 0 );
+    } else if ( proxyType() == Marble::Socks5Proxy ) {
+        w_cacheSettings->kcfg_proxyType->setCurrentIndex( 1 );
+    }
+
     if ( proxyAuth() ) {
         w_cacheSettings->kcfg_proxyAuth->setCheckState( Qt::Checked );
     } else {
@@ -264,8 +270,7 @@
     settings->setValue( "persistentTileCacheLimit", w_cacheSettings->kcfg_persistentTileCacheLimit->value() );
     settings->setValue( "proxyUrl", w_cacheSettings->kcfg_proxyUrl->text() );
     settings->setValue( "proxyPort", w_cacheSettings->kcfg_proxyPort->value() );
-    settings->setValue( "proxyHttp", w_cacheSettings->kcfg_proxyHttp->isChecked() );
-    settings->setValue( "proxySocks5", w_cacheSettings->kcfg_proxySocks5->isChecked() );
+    settings->setValue( "proxyType", w_cacheSettings->kcfg_proxyType->currentIndex() );
     if ( w_cacheSettings->kcfg_proxyAuth->isChecked() ) {
         settings->setValue( "proxyAuth", true );
         settings->setValue( "proxyUser", w_cacheSettings->kcfg_proxyUser->text() );
@@ -390,16 +395,11 @@
     return settings->value( "Cache/proxyPass", "" ).toString();
 }
 
-bool QtMarbleConfigDialog::proxyHttp() const
+Marble::ProxyType QtMarbleConfigDialog::proxyType() const
 {
-    return settings->value( "Cache/proxyHttp", "" ).toBool();
+    return (Marble::ProxyType)settings->value( "Cache/proxyType", "" ).toInt();
 }
 
-bool QtMarbleConfigDialog::proxySocks5() const
-{
-    return settings->value( "Cache/proxySocks5", "" ).toBool();
-}
-
 bool QtMarbleConfigDialog::proxyAuth() const
 {
     return settings->value( "Cache/proxyAuth", false ).toBool();
--- branches/KDE/4.3/kdeedu/marble/src/QtMarbleConfigDialog.h #995967:995968
@@ -60,7 +60,7 @@
 
     QString proxyUser() const;
     QString proxyPass() const;
-    bool proxyType() const;
+    ProxyType proxyType() const;
     bool proxyAuth() const;
 
     Q_SIGNALS:
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleWidget.cpp #995967:995968
@@ -1005,7 +1005,7 @@
                                                          d->m_map->viewParams(),
                                                          temp );
     if ( draw ) {
-        qDebug() << "Updating viewport for GPS";
+//        qDebug() << "Updating viewport for GPS";
         update( temp );
     }
 }
--- branches/KDE/4.3/kdeedu/marble/src/lib/global.h #995967:995968
@@ -104,8 +104,8 @@
  * @brief This enum is used to specify the proxy that is used.
  */
 enum ProxyType {
-    HttpProxy,          ///< Uses an Http proxy
-    Socks5Proxy         ///< Uses a Socks5Proxy
+    HttpProxy = 0x0 ,          ///< Uses an Http proxy
+    Socks5Proxy = 0x1         ///< Uses a Socks5Proxy
 };
 
 /**
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/PositionTracking.cpp #995967:995968
@@ -74,51 +74,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 ) );
 }
 
 
@@ -159,7 +115,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 );
@@ -200,10 +159,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();
 }
 
 
--- branches/KDE/4.3/kdeedu/marble/src/lib/gps/PositionTracking.h #995967:995968
@@ -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;


More information about the Marble-commits mailing list