changed order of scale and translate, makes it zoom at center

This commit is contained in:
Miodrag Milanovic 2018-07-12 17:38:58 +02:00
parent 8fde7935e7
commit 8a226626be

View File

@ -342,8 +342,8 @@ void FPGAViewWidget::paintGL()
QMatrix4x4 matrix; QMatrix4x4 matrix;
matrix.ortho(QRectF(-aspect / 2.0, -0.5, aspect, 1.0f)); matrix.ortho(QRectF(-aspect / 2.0, -0.5, aspect, 1.0f));
matrix.translate(moveX_, moveY_, -0.5);
matrix.scale(zoom_ * 0.01f, -zoom_ * 0.01f, 0); matrix.scale(zoom_ * 0.01f, -zoom_ * 0.01f, 0);
matrix.translate(moveX_, -moveY_, 0);
// Draw grid. // Draw grid.
auto grid = LineShaderData(0.001f, QColor("#DDD")); auto grid = LineShaderData(0.001f, QColor("#DDD"));
@ -434,7 +434,7 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event)
QPoint degree = event->angleDelta() / 8; QPoint degree = event->angleDelta() / 8;
if (!degree.isNull()) { if (!degree.isNull()) {
float steps = degree.y() / 15.0; float steps = degree.y() / 3.0;
setZoom(zoom_ + steps); setZoom(zoom_ + steps);
} }
} }