summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-06 11:20:00 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-06 11:20:00 (GMT)
commit94a289443f792285cf5f8448d7bb19ce047b976d (patch)
treecd80239857c43097b43e06a3342f56a9d69e48fe
parent934dfd760ce613d3cdabe78b944f70982f1c98a9 (diff)
Avoid flickering: Use a floating point position for collision detection
-rw-r--r--src/lib/marble/PlacemarkLayout.cpp5
-rw-r--r--src/lib/marble/VisiblePlacemark.cpp4
-rw-r--r--src/lib/marble/VisiblePlacemark.h6
-rw-r--r--src/lib/marble/layers/PlacemarkLayer.cpp2
4 files changed, 8 insertions, 9 deletions
diff --git a/src/lib/marble/PlacemarkLayout.cpp b/src/lib/marble/PlacemarkLayout.cpp
index 2e7a53b..436155f 100644
--- a/src/lib/marble/PlacemarkLayout.cpp
+++ b/src/lib/marble/PlacemarkLayout.cpp
@@ -203,8 +203,7 @@ QVector<const GeoDataFeature*> PlacemarkLayout::whichPlacemarkAt( const QPoint&
QVector<const GeoDataFeature*> ret;
foreach( VisiblePlacemark* mark, m_paintOrder ) {
- if ( mark->labelRect().contains( curpos )
- || QRect( mark->symbolPosition(), mark->symbolPixmap().size() ).contains( curpos ) ) {
+ if ( mark->labelRect().contains( curpos ) || mark->symbolRect().contains( curpos ) ) {
ret.append( mark->placemark() );
}
}
@@ -524,7 +523,7 @@ bool PlacemarkLayout::layoutPlacemark( const GeoDataPlacemark *placemark, qreal
QPointF hotSpot = mark->hotSpot();
mark->setSelected(selected);
- mark->setSymbolPosition(QPoint(qRound(x - hotSpot.x()), qRound(y - hotSpot.y())));
+ mark->setSymbolPosition(QPointF(x - hotSpot.x(), y - hotSpot.y()));
// Find out whether the area around the placemark is covered already.
// If there's not enough space free don't add a VisiblePlacemark here.
diff --git a/src/lib/marble/VisiblePlacemark.cpp b/src/lib/marble/VisiblePlacemark.cpp
index 9ad5cd7..bde76a0 100644
--- a/src/lib/marble/VisiblePlacemark.cpp
+++ b/src/lib/marble/VisiblePlacemark.cpp
@@ -62,7 +62,7 @@ void VisiblePlacemark::setSelected( bool selected )
}
}
-const QPoint& VisiblePlacemark::symbolPosition() const
+const QPointF& VisiblePlacemark::symbolPosition() const
{
return m_symbolPosition;
}
@@ -102,7 +102,7 @@ const QPointF VisiblePlacemark::hotSpot() const
return pixelHotSpot;
}
-void VisiblePlacemark::setSymbolPosition( const QPoint& position )
+void VisiblePlacemark::setSymbolPosition( const QPointF& position )
{
m_symbolPosition = position;
}
diff --git a/src/lib/marble/VisiblePlacemark.h b/src/lib/marble/VisiblePlacemark.h
index 1c8b4cd..25a39a2 100644
--- a/src/lib/marble/VisiblePlacemark.h
+++ b/src/lib/marble/VisiblePlacemark.h
@@ -67,7 +67,7 @@ class VisiblePlacemark : public QObject
/**
* Returns the position of the place mark symbol on the map.
*/
- const QPoint& symbolPosition() const;
+ const QPointF& symbolPosition() const;
/**
* Returns the top left corner of the place mark symbol's hot spot
@@ -77,7 +77,7 @@ class VisiblePlacemark : public QObject
/**
* Sets the @p position of the place mark symbol on the map.
*/
- void setSymbolPosition( const QPoint& position );
+ void setSymbolPosition(const QPointF &position );
/**
* Returns the pixmap of the place mark name label.
@@ -121,7 +121,7 @@ private Q_SLOTS:
const GeoDataPlacemark *m_placemark;
// View stuff
- QPoint m_symbolPosition; // position of the placemark's symbol
+ QPointF m_symbolPosition; // position of the placemark's symbol
bool m_selected; // state of the placemark
QPixmap m_labelPixmap; // the text label (most often name)
QRectF m_labelRect; // bounding box of label
diff --git a/src/lib/marble/layers/PlacemarkLayer.cpp b/src/lib/marble/layers/PlacemarkLayer.cpp
index a06890a..c52d331 100644
--- a/src/lib/marble/layers/PlacemarkLayer.cpp
+++ b/src/lib/marble/layers/PlacemarkLayer.cpp
@@ -76,7 +76,7 @@ bool PlacemarkLayer::render( GeoPainter *geoPainter, ViewportParams *viewport,
VisiblePlacemark *const mark = *visit;
QRect labelRect( mark->labelRect().toRect() );
- QPoint symbolPos( mark->symbolPosition() );
+ QPoint symbolPos(mark->symbolPosition().toPoint());
// when the map is such zoomed out that a given place
// appears many times, we draw one placemark at each