[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble
From:       Dennis Nienhüser <earthwings () gentoo ! org>
Date:       2011-02-03 20:05:41
Message-ID: 20110203200541.90B093E1F8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1218690 by nienhueser:

Merge screenX(), screenY() into pixel().

 M  +6 -8      examples/qml/google-search/google-search.qml  
 M  +3 -2      examples/qml/where-is-that/where-is-that.qml  
 M  +5 -17     src/plugins/declarative/MarbleDeclarativeWidget.cpp  
 M  +4 -9      src/plugins/declarative/MarbleDeclarativeWidget.h  


--- trunk/KDE/kdeedu/marble/examples/qml/google-search/google-search.qml \
#1218689:1218690 @@ -83,10 +83,9 @@
         itemdetails.visible = false
         var result = search.searchResult()
         for( var i=0; i<result.length; ++i ) {
-          var x = map.screenX( result[i].coordinate.longitude, \
                result[i].coordinate.latitude ) - 10
-          var y = map.screenY( result[i].coordinate.longitude, \
                result[i].coordinate.latitude ) - 30
-          if ( x > 0 && y > 0 ) {
-            Search.updateResult( i, result[i].name, x, y )
+          var pixel = map.pixel( result[i].coordinate.longitude, \
result[i].coordinate.latitude ) +          if ( pixel.x > 10 && pixel.y > 30 ) {
+            Search.updateResult( i, result[i].name, pixel.x-10, pixel.y-30 )
           } else {
             Search.invalidate( i )
           }
@@ -101,10 +100,9 @@
         var result = search.searchResult()
         Search.prepareResults(result.length)
         for( var i=0; i<result.length; ++i ) {
-          var x = map.screenX( result[i].coordinate.longitude, \
                result[i].coordinate.latitude ) - 10
-          var y = map.screenY( result[i].coordinate.longitude, \
                result[i].coordinate.latitude ) - 30
-          if ( x > 0 && y > 0 ) {
-            Search.createResult( i, result[i].name, x, y, mapcontainer )
+          var pixel = map.pixel( result[i].coordinate.longitude, \
result[i].coordinate.latitude ) +          if ( pixel.x > 10 && pixel.y > 30 ) {
+            Search.createResult( i, result[i].name, pixel.x-10, pixel.y-30, \
mapcontainer )  }
         }
     }
--- trunk/KDE/kdeedu/marble/examples/qml/where-is-that/where-is-that.qml \
#1218689:1218690 @@ -222,8 +222,9 @@
   {
     var lon = questionModel.get(questionView.currentIndex).lon
     var lat = questionModel.get(questionView.currentIndex).lat
-    solution.x = map.screenX( lon, lat )
-    solution.y = map.screenY( lon, lat ) - solution.height
+    var pixel = map.pixel( lon, lat )
+    solution.x = pixel.x
+    solution.y = pixel.y  - solution.height
   }
 
   function solve()
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/MarbleDeclarativeWidget.cpp \
#1218689:1218690 @@ -114,32 +114,20 @@
     m_marbleWidget->zoomOut();
 }
 
-qreal MarbleWidget::screenX( qreal lon, qreal lat ) const
+QPoint MarbleWidget::pixel( qreal lon, qreal lat ) const
 {
     GeoDataCoordinates position( lon, lat, 0, GeoDataCoordinates::Degree );
-    qreal result( 0.0 );
+    qreal x( 0.0 );
     qreal y( 0.0 );
     ViewportParams *viewport = m_marbleWidget->viewport();
     bool hidden = false;
-    if ( !viewport->currentProjection()->screenCoordinates( position, viewport, \
                result, y, hidden ) || hidden ) {
-        result = 0.0;
+    QPoint result;
+    if ( viewport->currentProjection()->screenCoordinates( position, viewport, x, y, \
hidden ) && !hidden ) { +        result = QPoint( x, y );
     }
     return result;
 }
 
-qreal MarbleWidget::screenY( qreal lon, qreal lat ) const
-{
-    GeoDataCoordinates position( lon, lat, 0, GeoDataCoordinates::Degree );
-    qreal x( 0.0 );
-    qreal result( 0.0 );
-    ViewportParams *viewport = m_marbleWidget->viewport();
-    bool hidden = false;
-    if ( !viewport->currentProjection()->screenCoordinates( position, viewport, x, \
                result, hidden ) || hidden ) {
-        result = 0.0;
-    }
-    return result;
-}
-
 Coordinate *MarbleWidget::coordinate( int x, int y )
 {
     qreal lat( 0.0 ), lon( 0.0 );
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/MarbleDeclarativeWidget.h \
#1218689:1218690 @@ -12,6 +12,7 @@
 #define DECLARATIVE_MARBLE_WIDGET_H
 
 #include <QtGui/QGraphicsProxyWidget>
+#include <QtCore/QPoint>
 
 namespace Marble
 {
@@ -92,18 +93,12 @@
     void zoomOut();
 
     /**
-      * Screen position of the given position, x coordinate
-      * @todo FIXME: Introduce GeoDataCoordinates and use QPoint
+      * Returns the screen position of the given coordinate,
+      * an invalid point if the coordinate is not visible
       */
-    qreal screenX( qreal lon, qreal lat ) const;
+    QPoint pixel( qreal longitude, qreal latitude ) const;
 
     /**
-      * Screen position of the given position, y coordinate
-      * @todo FIXME: Introduce GeoDataCoordinates and use QPoint
-      */
-    qreal screenY( qreal lon, qreal lat ) const;
-
-    /**
       * Returns the coordinate at the given screen position
       */
     Marble::Declarative::Coordinate *coordinate( int x, int y );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic