Add radius lock

master
Jeremy Hu 2018-09-08 12:20:31 +08:00
parent 1988118179
commit a9b379a77a
4 changed files with 35 additions and 2 deletions

View File

@ -21,6 +21,7 @@ SkeletonDocument::SkeletonDocument() :
xlocked(false),
ylocked(false),
zlocked(false),
radiusLocked(false),
textureGuideImage(nullptr),
textureImage(nullptr),
textureBorderImage(nullptr),
@ -443,7 +444,8 @@ void SkeletonDocument::scaleNodeByAddRadius(QUuid nodeId, float amount)
}
if (isPartReadonly(it->second.partId))
return;
it->second.setRadius(it->second.radius + amount);
if (!radiusLocked)
it->second.setRadius(it->second.radius + amount);
auto part = partMap.find(it->second.partId);
if (part != partMap.end())
part->second.dirty = true;
@ -527,7 +529,8 @@ void SkeletonDocument::setNodeRadius(QUuid nodeId, float radius)
}
if (isPartReadonly(it->second.partId))
return;
it->second.setRadius(radius);
if (!radiusLocked)
it->second.setRadius(radius);
auto part = partMap.find(it->second.partId);
if (part != partMap.end())
part->second.dirty = true;
@ -1964,6 +1967,14 @@ void SkeletonDocument::setZlockState(bool locked)
emit zlockStateChanged();
}
void SkeletonDocument::setRadiusLockState(bool locked)
{
if (radiusLocked == locked)
return;
radiusLocked = locked;
emit radiusLockStateChanged();
}
bool SkeletonDocument::isExportReady() const
{
if (m_isResultMeshObsolete ||

View File

@ -370,6 +370,7 @@ signals:
void xlockStateChanged();
void ylockStateChanged();
void zlockStateChanged();
void radiusLockStateChanged();
void checkPart(QUuid partId);
void partChecked(QUuid partId);
void partUnchecked(QUuid partId);
@ -388,6 +389,7 @@ public: // need initialize
bool xlocked;
bool ylocked;
bool zlocked;
bool radiusLocked;
QImage *textureGuideImage;
QImage *textureImage;
QImage *textureBorderImage;
@ -501,6 +503,7 @@ public slots:
void setXlockState(bool locked);
void setYlockState(bool locked);
void setZlockState(bool locked);
void setRadiusLockState(bool locked);
void enableAllPositionRelatedLocks();
void disableAllPositionRelatedLocks();
void toggleSmoothNormal();

View File

@ -137,6 +137,10 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
initLockButton(m_zlockButton);
updateZlockButtonState();
m_radiusLockButton = new QPushButton(QChar(fa::bullseye));
Theme::initAwesomeButton(m_radiusLockButton);
updateRadiusLockButtonState();
QPushButton *rotateCounterclockwiseButton = new QPushButton(QChar(fa::rotateleft));
Theme::initAwesomeButton(rotateCounterclockwiseButton);
@ -152,6 +156,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
toolButtonLayout->addWidget(m_xlockButton);
toolButtonLayout->addWidget(m_ylockButton);
toolButtonLayout->addWidget(m_zlockButton);
toolButtonLayout->addWidget(m_radiusLockButton);
toolButtonLayout->addSpacing(10);
toolButtonLayout->addWidget(rotateCounterclockwiseButton);
toolButtonLayout->addWidget(rotateClockwiseButton);
@ -524,6 +529,9 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(m_zlockButton, &QPushButton::clicked, [=]() {
m_document->setZlockState(!m_document->zlocked);
});
connect(m_radiusLockButton, &QPushButton::clicked, [=]() {
m_document->setRadiusLockState(!m_document->radiusLocked);
});
m_partListDockerVisibleSwitchConnection = connect(m_document, &SkeletonDocument::skeletonChanged, [=]() {
if (m_graphicsWidget->hasItems()) {
@ -678,6 +686,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(m_document, &SkeletonDocument::xlockStateChanged, this, &SkeletonDocumentWindow::updateXlockButtonState);
connect(m_document, &SkeletonDocument::ylockStateChanged, this, &SkeletonDocumentWindow::updateYlockButtonState);
connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState);
connect(m_document, &SkeletonDocument::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState);
connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady);
@ -1035,3 +1044,11 @@ void SkeletonDocumentWindow::updateZlockButtonState()
else
m_zlockButton->setStyleSheet("QPushButton {color: #aaebc4}");
}
void SkeletonDocumentWindow::updateRadiusLockButtonState()
{
if (m_document->radiusLocked)
m_radiusLockButton->setStyleSheet("QPushButton {color: #252525}");
else
m_radiusLockButton->setStyleSheet("QPushButton {color: " + Theme::white.name() + "}");
}

View File

@ -52,6 +52,7 @@ public slots:
void updateXlockButtonState();
void updateYlockButtonState();
void updateZlockButtonState();
void updateRadiusLockButtonState();
private:
void initLockButton(QPushButton *button);
void setCurrentFilename(const QString &filename);
@ -128,6 +129,7 @@ private:
QPushButton *m_xlockButton;
QPushButton *m_ylockButton;
QPushButton *m_zlockButton;
QPushButton *m_radiusLockButton;
QMetaObject::Connection m_partListDockerVisibleSwitchConnection;
public: