From b0a32940b0812361f81400039e2e7d679e67e999 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 9 Feb 2026 18:13:41 -0700 Subject: [PATCH] fix: Rename camera state members to avoid name conflicts Co-authored-by: aider (gemini/gemini-2.5-pro) --- src/ViewportWidget.cpp | 84 +++++++++++++++++++++--------------------- src/ViewportWidget.h | 10 ++--- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/ViewportWidget.cpp b/src/ViewportWidget.cpp index 8ee885f..2234d3a 100644 --- a/src/ViewportWidget.cpp +++ b/src/ViewportWidget.cpp @@ -32,47 +32,47 @@ void ViewportWidget::setDocument(Document* document) m_featureBrowser->setDocument(document); } -float ViewportWidget::xRotation() const { return xRot; } +float ViewportWidget::xRotation() const { return m_xRot; } void ViewportWidget::setXRotation(float angle) { - if (angle != xRot) { - xRot = angle; + if (angle != m_xRot) { + m_xRot = angle; update(); } } -float ViewportWidget::yRotation() const { return yRot; } +float ViewportWidget::yRotation() const { return m_yRot; } void ViewportWidget::setYRotation(float angle) { - if (angle != yRot) { - yRot = angle; + if (angle != m_yRot) { + m_yRot = angle; update(); } } -float ViewportWidget::zoom() const { return zoom; } +float ViewportWidget::zoom() const { return m_zoom; } void ViewportWidget::setZoom(float value) { - if (value != zoom) { - zoom = value; + if (value != m_zoom) { + m_zoom = value; update(); } } -float ViewportWidget::panX() const { return panX; } +float ViewportWidget::panX() const { return m_panX; } void ViewportWidget::setPanX(float value) { - if (value != panX) { - panX = value; + if (value != m_panX) { + m_panX = value; update(); } } -float ViewportWidget::panY() const { return panY; } +float ViewportWidget::panY() const { return m_panY; } void ViewportWidget::setPanY(float value) { - if (value != panY) { - panY = value; + if (value != m_panY) { + m_panY = value; update(); } } @@ -96,9 +96,9 @@ void ViewportWidget::paintGL() glEnable(GL_CULL_FACE); QMatrix4x4 model; - model.translate(panX, panY, zoom); - model.rotate(xRot / 16.0f, 1, 0, 0); - model.rotate(yRot / 16.0f, 0, 1, 0); + model.translate(m_panX, m_panY, m_zoom); + model.rotate(m_xRot / 16.0f, 1, 0, 0); + model.rotate(m_yRot / 16.0f, 0, 1, 0); // For simplicity, we'll use a fixed-function pipeline style for drawing. // In a real app, this would use shaders. @@ -114,8 +114,8 @@ void ViewportWidget::paintGL() // View cube rendering QMatrix4x4 viewCubeModel; - viewCubeModel.rotate(xRot / 16.0f, 1, 0, 0); - viewCubeModel.rotate(yRot / 16.0f, 0, 1, 0); + viewCubeModel.rotate(m_xRot / 16.0f, 1, 0, 0); + viewCubeModel.rotate(m_yRot / 16.0f, 0, 1, 0); m_viewCube->paintGL(viewCubeModel, width(), height()); glViewport(0, 0, width(), height()); @@ -147,12 +147,12 @@ void ViewportWidget::mouseMoveEvent(QMouseEvent *event) if (event->buttons() & Qt::MiddleButton) { if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { // Pan - panX += dx / 100.0f; - panY -= dy / 100.0f; + m_panX += dx / 100.0f; + m_panY -= dy / 100.0f; } else { // Rotate - xRot += 8 * dy; - yRot += 8 * dx; + m_xRot += 8 * dy; + m_yRot += 8 * dx; } } lastPos = event->pos(); @@ -163,7 +163,7 @@ void ViewportWidget::wheelEvent(QWheelEvent *event) { QPoint numDegrees = event->angleDelta() / 8; if (!numDegrees.isNull()) { - zoom += numDegrees.y() / 5.0f; + m_zoom += numDegrees.y() / 5.0f; } update(); } @@ -172,14 +172,14 @@ void ViewportWidget::startSketch(SketchPlane plane) { m_currentPlane = plane; - m_savedXRot = xRot; - m_savedYRot = yRot; - m_savedPanX = panX; - m_savedPanY = panY; - m_savedZoom = zoom; + m_savedXRot = m_xRot; + m_savedYRot = m_yRot; + m_savedPanX = m_panX; + m_savedPanY = m_panY; + m_savedZoom = m_zoom; - float targetXRot = xRot; - float targetYRot = yRot; + float targetXRot = m_xRot; + float targetYRot = m_yRot; switch (plane) { case SketchPlane::XY: // Front view targetXRot = 0; @@ -201,35 +201,35 @@ void ViewportWidget::startSketch(SketchPlane plane) auto* xRotAnim = new QPropertyAnimation(this, "xRotation"); xRotAnim->setDuration(300); - xRotAnim->setStartValue(xRot); + xRotAnim->setStartValue(m_xRot); xRotAnim->setEndValue(targetXRot); xRotAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(xRotAnim); auto* yRotAnim = new QPropertyAnimation(this, "yRotation"); yRotAnim->setDuration(300); - yRotAnim->setStartValue(yRot); + yRotAnim->setStartValue(m_yRot); yRotAnim->setEndValue(targetYRot); yRotAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(yRotAnim); auto* panXAnim = new QPropertyAnimation(this, "panX"); panXAnim->setDuration(300); - panXAnim->setStartValue(panX); + panXAnim->setStartValue(m_panX); panXAnim->setEndValue(0.0f); panXAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(panXAnim); auto* panYAnim = new QPropertyAnimation(this, "panY"); panYAnim->setDuration(300); - panYAnim->setStartValue(panY); + panYAnim->setStartValue(m_panY); panYAnim->setEndValue(0.0f); panYAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(panYAnim); auto* zoomAnim = new QPropertyAnimation(this, "zoom"); zoomAnim->setDuration(300); - zoomAnim->setStartValue(zoom); + zoomAnim->setStartValue(m_zoom); zoomAnim->setEndValue(-20.0f); zoomAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(zoomAnim); @@ -243,35 +243,35 @@ void ViewportWidget::saveSketch() auto* xRotAnim = new QPropertyAnimation(this, "xRotation"); xRotAnim->setDuration(300); - xRotAnim->setStartValue(xRot); + xRotAnim->setStartValue(m_xRot); xRotAnim->setEndValue(m_savedXRot); xRotAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(xRotAnim); auto* yRotAnim = new QPropertyAnimation(this, "yRotation"); yRotAnim->setDuration(300); - yRotAnim->setStartValue(yRot); + yRotAnim->setStartValue(m_yRot); yRotAnim->setEndValue(m_savedYRot); yRotAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(yRotAnim); auto* panXAnim = new QPropertyAnimation(this, "panX"); panXAnim->setDuration(300); - panXAnim->setStartValue(panX); + panXAnim->setStartValue(m_panX); panXAnim->setEndValue(m_savedPanX); panXAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(panXAnim); auto* panYAnim = new QPropertyAnimation(this, "panY"); panYAnim->setDuration(300); - panYAnim->setStartValue(panY); + panYAnim->setStartValue(m_panY); panYAnim->setEndValue(m_savedPanY); panYAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(panYAnim); auto* zoomAnim = new QPropertyAnimation(this, "zoom"); zoomAnim->setDuration(300); - zoomAnim->setStartValue(zoom); + zoomAnim->setStartValue(m_zoom); zoomAnim->setEndValue(m_savedZoom); zoomAnim->setEasingCurve(QEasingCurve::InOutQuad); animGroup->addAnimation(zoomAnim); diff --git a/src/ViewportWidget.h b/src/ViewportWidget.h index 41fc0af..e8bd64f 100644 --- a/src/ViewportWidget.h +++ b/src/ViewportWidget.h @@ -72,11 +72,11 @@ private: FeatureBrowser* m_featureBrowser = nullptr; SketchPlane m_currentPlane = SketchPlane::NONE; - float xRot = 0; - float yRot = 0; - float zoom = -5.0f; - float panX = 0; - float panY = 0; + float m_xRot = 0; + float m_yRot = 0; + float m_zoom = -5.0f; + float m_panX = 0; + float m_panY = 0; QPoint lastPos; float m_savedXRot = 0;