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

Bastian Holst bastianholst at gmx.de
Thu Aug 6 13:54:40 CEST 2009


SVN commit 1007878 by bholst:

First support for "Level of Detail" of GeoItems in MarbleGraphicsView.


 M  +40 -1     lib/graphicsview/GeoGraphicsItem_p.h  
 M  +1 -1      lib/graphicsview/MarbleGraphicsItem.cpp  
 M  +4 -1      lib/graphicsview/MarbleGraphicsItem_p.h  
 M  +4 -1      lib/graphicsview/ScreenGraphicsItem_p.h  
 M  +3 -3      plugins/render/weather/bbc-xml-generator.rb  


--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/GeoGraphicsItem_p.h #1007877:1007878
@@ -40,10 +40,16 @@
         return m_positions;
     }
 
-    void setProjection( AbstractProjection *projection, ViewportParams *viewport )
+    void setProjection( AbstractProjection *projection,
+                        ViewportParams *viewport,
+                        GeoPainter *painter )
     {
         m_positions.clear();
 
+        if ( !isActive( painter ) ) {
+            return;
+        }
+
         qreal x[100], y;
         int pointRepeatNumber;
         bool globeHidesPoint;
@@ -64,6 +70,39 @@
         }
     }
 
+    /**
+     * Returns true if the item is active and should be shown.
+     * This depends on the LOD settings.
+     */
+    virtual bool isActive( GeoPainter *painter )
+    {
+        if ( m_latLonAltBox.isNull()
+             || ( m_minLodPixels == 0 && m_maxLodPixels == -1 ) )
+        {
+            return true;
+        }
+
+        QRegion region = painter->regionFromRect( m_latLonAltBox.center(),
+                                                  m_latLonAltBox.width(),
+                                                  m_latLonAltBox.height(),
+                                                  true );
+
+        int pixels = 0;
+
+        foreach( QRect rect, region.rects() ) {
+            pixels += rect.width() * rect.height();
+        }
+
+        if ( pixels >= m_minLodPixels
+             && pixels <= m_maxLodPixels )
+        {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
     GeoDataCoordinates m_coordinate;
     QString m_target;
     QList<QPointF> m_positions;
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem.cpp #1007877:1007878
@@ -47,7 +47,7 @@
 
     p()->updateLabelPositions();
 
-    p()->setProjection( viewport->currentProjection(), viewport );
+    p()->setProjection( viewport->currentProjection(), viewport, painter );
     
     // Remove the pixmap if it has been requested. This prevents QPixmapCache from being used
     // outside the ui thread.
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem_p.h #1007877:1007878
@@ -114,10 +114,13 @@
         return list;
     }
 
-    virtual void setProjection( AbstractProjection *projection, ViewportParams *viewport )
+    virtual void setProjection( AbstractProjection *projection,
+                                ViewportParams *viewport,
+                                GeoPainter *painter )
     {
         Q_UNUSED( projection );
         Q_UNUSED( viewport );
+        Q_UNUSED( painter );
     }
 
     virtual void setParentSize( QSizeF size )
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/ScreenGraphicsItem_p.h #1007877:1007878
@@ -63,9 +63,12 @@
         return position;
     }
 
-    void setProjection( AbstractProjection *projection, ViewportParams *viewport )
+    void setProjection( AbstractProjection *projection,
+                        ViewportParams *viewport,
+                        GeoPainter *painter )
     {
         Q_UNUSED( projection );
+        Q_UNUSED( painter );
 
         // If we have no parent
         if( m_parent == 0 ) {
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/bbc-xml-generator.rb #1007877:1007878
@@ -71,9 +71,9 @@
         return string
     end
     
-    def priority=(newPriority)
-        @priority = newPriority
-    end
+#    def priority=(newPriority)
+#        @priority = newPriority
+#    end
     
     def angelDistance(other)
         begin


More information about the Marble-commits mailing list