X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.cpp;fp=src%2Fdrawingview.cpp;h=dc6853203769404357e2ac7ca05c5e57f9c7329f;hb=e34f829de8f46c03e74f75e46438433153f6b96d;hp=d35bd14f5a308dbc1f947950043d0c462e01a5a9;hpb=60565e2216e2d6d8d3634d0614823a117770e47f;p=architektonas diff --git a/src/drawingview.cpp b/src/drawingview.cpp index d35bd14..dc68532 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -145,7 +145,8 @@ void DrawingView::SetGridSize(uint32_t size) 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(); } @@ -1783,6 +1784,13 @@ void DrawingView::mousePressEvent(QMouseEvent * event) 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 @@ -1989,32 +1997,31 @@ void DrawingView::mouseReleaseEvent(QMouseEvent * event) 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));