diff --git a/src/scalepicker.cpp b/src/scalepicker.cpp --- a/src/scalepicker.cpp +++ b/src/scalepicker.cpp @@ -100,12 +100,12 @@ bool ScalePicker::eventFilter(QObject* o updateSnapPoints(); QMouseEvent* mouseEvent = (QMouseEvent*) event; - double posPx = this->positionPx(mouseEvent); + int posPx = this->positionPx(mouseEvent); // do snapping unless Shift is pressed if (! (mouseEvent->modifiers() & Qt::ShiftModifier)) { - for (double sp : snapPoints) + for (auto sp : snapPoints) { if (fabs(posPx-sp) <= SNAP_DISTANCE) { @@ -227,7 +227,7 @@ double ScalePicker::position(double posP return _scaleWidget->scaleDraw()->scaleMap().invTransform(posPx); } -double ScalePicker::positionPx(QMouseEvent* mouseEvent) +int ScalePicker::positionPx(QMouseEvent* mouseEvent) { double pos; if (_scaleWidget->alignment() == QwtScaleDraw::BottomScale || @@ -272,6 +272,7 @@ void ScalePicker::updateSnapPoints() snapPoints.clear(); for(auto t : allTicks) { - snapPoints << _scaleWidget->scaleDraw()->scaleMap().transform(t); + // `round` is used because `allTicks` is double but `snapPoints` is int + snapPoints << round(_scaleWidget->scaleDraw()->scaleMap().transform(t)); } } diff --git a/src/scalepicker.h b/src/scalepicker.h --- a/src/scalepicker.h +++ b/src/scalepicker.h @@ -57,10 +57,10 @@ private: double firstPos; // converted to plot coordinates double firstPosPx; // pixel coordinates double currentPosPx; // current position in pixel coordinates - QList snapPoints; + QList snapPoints; double position(double); // returns the axis mouse position relative to plot coordinates - double positionPx(QMouseEvent*); // returns the axis mouse position in pixels + int positionPx(QMouseEvent*); // returns the axis mouse position in pixels double posCanvasPx(double pos); // returns the given position in canvas coordinates private slots: