Commit 94a28944 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Avoid flickering: Use a floating point position for collision detection

parent 934dfd76
......@@ -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.
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment