Update cut face model preview

Cut face will show as flat front view
master
huxingyi 2020-03-25 21:10:44 +09:30
parent bfcf9af037
commit 2800bf7c46
4 changed files with 28 additions and 3 deletions

View File

@ -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());

View File

@ -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),

View File

@ -98,6 +98,10 @@ private:
int m_modelInitialHeight = 0;
QTimer *m_rotationTimer = nullptr;
std::pair<QVector3D, QVector3D> screenPositionToMouseRay(const QPoint &screenPosition);
public:
static int m_defaultXRotation;
static int m_defaultYRotation;
static int m_defaultZRotation;
};
#endif

View File

@ -9,6 +9,7 @@
#include <QSizePolicy>
#include <QCheckBox>
#include <QLabel>
#include <QRadioButton>
#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()