diff --git a/src/cutfacewidget.cpp b/src/cutfacewidget.cpp index 90614677..b2ff2449 100644 --- a/src/cutfacewidget.cpp +++ b/src/cutfacewidget.cpp @@ -11,6 +11,9 @@ CutFaceWidget::CutFaceWidget(const Document *document, QUuid partId) : m_previewWidget->setFixedSize(Theme::cutFacePreviewImageSize, Theme::cutFacePreviewImageSize); m_previewWidget->enableMove(false); m_previewWidget->enableZoom(false); + m_previewWidget->setXRotation(0); + m_previewWidget->setYRotation(0); + m_previewWidget->setZRotation(0); setFixedSize(Theme::cutFacePreviewImageSize, CutFaceWidget::preferredHeight()); diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 07660d39..afe4df33 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -15,11 +15,15 @@ const QVector3D ModelWidget::m_cameraPosition = QVector3D(0, 0, -4.0); float ModelWidget::m_minZoomRatio = 5.0; float ModelWidget::m_maxZoomRatio = 80.0; +int ModelWidget::m_defaultXRotation = 30 * 16; +int ModelWidget::m_defaultYRotation = -45 * 16; +int ModelWidget::m_defaultZRotation = 0; + ModelWidget::ModelWidget(QWidget *parent) : QOpenGLWidget(parent), - m_xRot(30 * 16), - m_yRot(-45 * 16), - m_zRot(0), + m_xRot(m_defaultXRotation), + m_yRot(m_defaultYRotation), + m_zRot(m_defaultZRotation), m_program(nullptr), m_moveStarted(false), m_moveEnabled(true), diff --git a/src/modelwidget.h b/src/modelwidget.h index 87e32649..4f156447 100644 --- a/src/modelwidget.h +++ b/src/modelwidget.h @@ -98,6 +98,10 @@ private: int m_modelInitialHeight = 0; QTimer *m_rotationTimer = nullptr; std::pair screenPositionToMouseRay(const QPoint &screenPosition); +public: + static int m_defaultXRotation; + static int m_defaultYRotation; + static int m_defaultZRotation; }; #endif diff --git a/src/partwidget.cpp b/src/partwidget.cpp index ff79a5e8..13df4637 100644 --- a/src/partwidget.cpp +++ b/src/partwidget.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "partwidget.h" #include "theme.h" #include "floatnumberwidget.h" @@ -795,6 +796,19 @@ void PartWidget::updatePreview() //m_previewLabel->setPixmap(QPixmap::fromImage(part->preview)); MeshLoader *previewMesh = part->takePreviewMesh(); m_previewWidget->updateMesh(previewMesh); + if (PartTarget::CutFace == part->target) { + if (0 != m_previewWidget->xRot()) { + m_previewWidget->setXRotation(0); + m_previewWidget->setYRotation(0); + m_previewWidget->setZRotation(0); + } + } else { + if (0 == m_previewWidget->xRot()) { + m_previewWidget->setXRotation(ModelWidget::m_defaultXRotation); + m_previewWidget->setYRotation(ModelWidget::m_defaultYRotation); + m_previewWidget->setZRotation(ModelWidget::m_defaultZRotation); + } + } } void PartWidget::updateLockButton()