pmp.end();
// Set up new BG brush & zoom level (pixels per base unit)
- Global::zoom = gridPixels / Global::gridSpacing;
+// This shouldn't be done here, because it fucks up the scrollwheel zooming...
+// Global::zoom = gridPixels / Global::gridSpacing;
UpdateGridBackground();
}
void DrawingView::mouseMoveEvent(QMouseEvent * event)
{
+ // It seems that wheelEvent() triggers this for some reason...
+ if (scrollWheelSeen)
+ {
+ scrollWheelSeen = false;
+ return;
+ }
+
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
Global::selection.setBottomRight(QPointF(point.x, point.y));
// Only needs to be done here, as mouse down is always preceded by movement
void DrawingView::wheelEvent(QWheelEvent * event)
{
double zoomFactor = 1.25;
- QSize sizeWin = size();
- Vector center(sizeWin.width() / 2.0, sizeWin.height() / 2.0);
- center = Painter::QtToCartesianCoords(center);
+ scrollWheelSeen = true;
- // This is not centering for some reason. Need to figure out why. :-/
- if (event->delta() > 0)
+ if (event->delta() < 0)
{
if (Global::zoom > 20.0)
return;
- Vector newOrigin = center - ((center - Global::origin) / zoomFactor);
- Global::origin = newOrigin;
Global::zoom *= zoomFactor;
+// Point np = Painter::QtToCartesianCoords(oldScrollPoint);
+// Global::origin += (oldPoint - np);
}
else
{
if (Global::zoom < 0.25)
return;
- Vector newOrigin = center + ((-center + Global::origin) * zoomFactor);
- Global::origin = newOrigin;
Global::zoom /= zoomFactor;
+// Point np = Painter::QtToCartesianCoords(oldScrollPoint);
+// Global::origin += (oldPoint - np);
}
+ Point np = Painter::QtToCartesianCoords(oldScrollPoint);
+ Global::origin += (oldPoint - np);
+
// Global::gridSpacing = gridPixels / Painter::zoom;
-// UpdateGridBackground();
SetGridSize(Global::gridSpacing * Global::zoom);
update();
// zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Global::gridSpacing));