diff --git a/languages/dust3d_zh_CN.ts b/languages/dust3d_zh_CN.ts index 3374a30b..b9aee422 100644 --- a/languages/dust3d_zh_CN.ts +++ b/languages/dust3d_zh_CN.ts @@ -390,6 +390,10 @@ Tips: &Help 帮助(&H) + + Toggle Rotation + 打开/关闭自动旋转 + ExportPreviewWidget @@ -736,10 +740,6 @@ Tips: Paste Color 粘贴颜色 - - Remeshed - 重新网格化 - Poly 面数 diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index 1e752c1c..53fbde30 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -727,6 +727,12 @@ DocumentWindow::DocumentWindow() : }); m_viewMenu->addAction(m_toggleWireframeAction); + m_toggleRotationAction = new QAction(tr("Toggle Rotation"), this); + connect(m_toggleRotationAction, &QAction::triggered, [=]() { + m_modelRenderWidget->toggleRotation(); + }); + m_viewMenu->addAction(m_toggleRotationAction); + m_toggleUvCheckAction = new QAction(tr("Toggle UV Check"), this); connect(m_toggleUvCheckAction, &QAction::triggered, [=]() { m_modelRenderWidget->toggleUvCheck(); diff --git a/src/documentwindow.h b/src/documentwindow.h index 0fa8af8c..0f98e5bf 100644 --- a/src/documentwindow.h +++ b/src/documentwindow.h @@ -168,7 +168,7 @@ private: QAction *m_resetModelWidgetPosAction; QAction *m_toggleWireframeAction; QAction *m_toggleUvCheckAction; - QAction *m_showMotionsListAction; + QAction *m_toggleRotationAction; QMenu *m_windowMenu; QAction *m_showPartsListAction; diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 145387e8..f9afaa72 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -211,6 +211,22 @@ void ModelWidget::toggleWireframe() update(); } +void ModelWidget::toggleRotation() +{ + if (nullptr != m_rotationTimer) { + delete m_rotationTimer; + m_rotationTimer = nullptr; + } else { + m_rotationTimer = new QTimer(this); + m_rotationTimer->setInterval(42); + m_rotationTimer->setSingleShot(false); + connect(m_rotationTimer, &QTimer::timeout, this, [&]() { + setYRotation(m_yRot - 8); + }); + m_rotationTimer->start(); + } +} + void ModelWidget::toggleUvCheck() { if (m_meshBinder.isCheckUvEnabled()) diff --git a/src/modelwidget.h b/src/modelwidget.h index 2e9d08a8..8dac79c8 100644 --- a/src/modelwidget.h +++ b/src/modelwidget.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "meshloader.h" #include "modelshaderprogram.h" #include "modelmeshbinder.h" @@ -36,6 +37,7 @@ public: void updateMesh(MeshLoader *mesh); void setGraphicsFunctions(SkeletonGraphicsFunctions *graphicsFunctions); void toggleWireframe(); + void toggleRotation(); void toggleUvCheck(); void enableMove(bool enabled); void enableZoom(bool enabled); @@ -93,6 +95,7 @@ private: QPoint m_moveStartPos; QRect m_moveStartGeometry; int m_modelInitialHeight = 0; + QTimer *m_rotationTimer = nullptr; std::pair screenPositionToMouseRay(const QPoint &screenPosition); };