[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [marble] src/lib: PlacemarkLayout: optimise for label-less placemarks
From: Thibaut Gridel <tgridel () free ! fr>
Date: 2013-07-31 22:34:24
Message-ID: E1V4eyO-0007xw-72 () scm ! kde ! org
[Download RAW message or body]
Git commit b532c4bbb057d9120f94205bff5605c6535230c5 by Thibaut Gridel.
Committed on 31/07/2013 at 22:33.
Pushed by tgridel into branch 'master'.
PlacemarkLayout: optimise for label-less placemarks
roomForLabel is indeed the culprit:
- it didn't scale as it wrongly iterated all placemarks
- it isn't needed once we know a placemark doesn't have text
BUG: 322783
M +19 -14 src/lib/PlacemarkLayout.cpp
http://commits.kde.org/marble/b532c4bbb057d9120f94205bff5605c6535230c5
diff --git a/src/lib/PlacemarkLayout.cpp b/src/lib/PlacemarkLayout.cpp
index 491aeb6..4c322d9 100644
--- a/src/lib/PlacemarkLayout.cpp
+++ b/src/lib/PlacemarkLayout.cpp
@@ -542,10 +542,13 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
// If there's not enough space free don't add a VisiblePlacemark here.
const GeoDataStyle* style = placemark->style();
- QRectF labelRect = roomForLabel( style, x, y, placemark->name() );
-
- if ( labelRect.isNull() )
- return false;
+ QRectF labelRect;
+ if( !placemark->name().isEmpty() ) {
+ labelRect = roomForLabel( style, x, y, placemark->name() );
+ if ( labelRect.isNull() ) {
+ return false;
+ }
+ }
// Find the corresponding visible placemark
VisiblePlacemark *mark = m_visiblePlacemarks.value( placemark );
@@ -566,14 +569,16 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
y - qRound( hotSpot.y() ) ) );
mark->setLabelRect( labelRect );
- // Add the current placemark to the matching row and its
- // direct neighbors.
- int idx = y / m_maxLabelHeight;
- if ( idx - 1 >= 0 )
- m_rowsection[ idx - 1 ].append( mark );
- m_rowsection[ idx ].append( mark );
- if ( idx + 1 < m_rowsection.size() )
- m_rowsection[ idx + 1 ].append( mark );
+ if ( !labelRect.isEmpty() ) {
+ // Add the current placemark to the matching row and its
+ // direct neighbors.
+ int idx = y / m_maxLabelHeight;
+ if ( idx - 1 >= 0 )
+ m_rowsection[ idx - 1 ].append( mark );
+ m_rowsection[ idx ].append( mark );
+ if ( idx + 1 < m_rowsection.size() )
+ m_rowsection[ idx + 1 ].append( mark );
+ }
m_paintOrder.append( mark );
m_labelArea += labelRect.width() * labelRect.height();
@@ -640,8 +645,8 @@ QRectF PlacemarkLayout::roomForLabel( const GeoDataStyle * style,
labelRect.moveTo( xpos, ypos );
// Check if there is another label or symbol that overlaps.
- QVector<VisiblePlacemark*>::const_iterator beforeItEnd = m_paintOrder.constEnd();
- for ( QVector<VisiblePlacemark*>::ConstIterator beforeIt = m_paintOrder.constBegin();
+ QVector<VisiblePlacemark*>::const_iterator beforeItEnd = currentsec.constEnd();
+ for ( QVector<VisiblePlacemark*>::ConstIterator beforeIt = currentsec.constBegin();
beforeIt != beforeItEnd;
++beforeIt ) {
if ( labelRect.intersects( (*beforeIt)->labelRect()) ) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic