From e2f829d3ce082a35b27d3fdae9ce340be804a25a Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sun, 10 Mar 2019 07:40:39 +0930 Subject: [PATCH] Make chamfer tool as a separate tool Remove cut template customiziation. --- src/document.cpp | 17 +++ src/document.h | 2 + src/documentwindow.cpp | 3 +- src/meshgenerator.cpp | 3 + src/parttreewidget.cpp | 31 +++-- src/parttreewidget.h | 3 +- src/partwidget.cpp | 299 ++++++++++++++++++++++------------------- src/partwidget.h | 7 +- src/skeletondocument.h | 3 + 9 files changed, 212 insertions(+), 156 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index 6dc21076..f22061cb 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -859,6 +859,7 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set &limitNodeId part["xMirrored"] = partIt.second.xMirrored ? "true" : "false"; part["zMirrored"] = partIt.second.zMirrored ? "true" : "false"; part["rounded"] = partIt.second.rounded ? "true" : "false"; + part["chamfered"] = partIt.second.chamfered ? "true" : "false"; if (partIt.second.cutRotationAdjusted()) part["cutRotation"] = QString::number(partIt.second.cutRotation); if (partIt.second.cutTemplateAdjusted()) @@ -1117,6 +1118,7 @@ void Document::addFromSnapshot(const Snapshot &snapshot, bool fromPaste) part.xMirrored = isTrueValueString(valueOfKeyInMapOrEmpty(partKv.second, "xMirrored")); part.zMirrored = isTrueValueString(valueOfKeyInMapOrEmpty(partKv.second, "zMirrored")); part.rounded = isTrueValueString(valueOfKeyInMapOrEmpty(partKv.second, "rounded")); + part.chamfered = isTrueValueString(valueOfKeyInMapOrEmpty(partKv.second, "chamfered")); const auto &cutRotationIt = partKv.second.find("cutRotation"); if (cutRotationIt != partKv.second.end()) part.setCutRotation(cutRotationIt->second.toFloat()); @@ -2198,6 +2200,21 @@ void Document::setPartRoundState(QUuid partId, bool rounded) emit skeletonChanged(); } +void Document::setPartChamferState(QUuid partId, bool chamfered) +{ + auto part = partMap.find(partId); + if (part == partMap.end()) { + qDebug() << "Part not found:" << partId; + return; + } + if (part->second.chamfered == chamfered) + return; + part->second.chamfered = chamfered; + part->second.dirty = true; + emit partChamferStateChanged(partId); + emit skeletonChanged(); +} + void Document::setPartCutRotation(QUuid partId, float cutRotation) { auto part = partMap.find(partId); diff --git a/src/document.h b/src/document.h index 99d98ac9..9280b0c8 100644 --- a/src/document.h +++ b/src/document.h @@ -403,6 +403,7 @@ signals: void partCutRotationChanged(QUuid partId); void partCutTemplateChanged(QUuid partId); void partMaterialIdChanged(QUuid partId); + void partChamferStateChanged(QUuid partId); void componentCombineModeChanged(QUuid componentId); void cleanup(); void originChanged(); @@ -557,6 +558,7 @@ public slots: void setPartCutRotation(QUuid partId, float cutRotation); void setPartCutTemplate(QUuid partId, std::vector cutTemplate); void setPartMaterialId(QUuid partId, QUuid materialId); + void setPartChamferState(QUuid partId, bool chamfered); void setComponentCombineMode(QUuid componentId, CombineMode combineMode); void moveComponentUp(QUuid componentId); void moveComponentDown(QUuid componentId); diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index ea0c3e0e..c647dfa1 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -839,9 +839,10 @@ DocumentWindow::DocumentWindow() : connect(m_document, &Document::partDeformThicknessChanged, partTreeWidget, &PartTreeWidget::partDeformChanged); connect(m_document, &Document::partDeformWidthChanged, partTreeWidget, &PartTreeWidget::partDeformChanged); connect(m_document, &Document::partRoundStateChanged, partTreeWidget, &PartTreeWidget::partRoundStateChanged); + connect(m_document, &Document::partChamferStateChanged, partTreeWidget, &PartTreeWidget::partChamferStateChanged); connect(m_document, &Document::partColorStateChanged, partTreeWidget, &PartTreeWidget::partColorStateChanged); connect(m_document, &Document::partCutRotationChanged, partTreeWidget, &PartTreeWidget::partCutRotationChanged); - connect(m_document, &Document::partCutTemplateChanged, partTreeWidget, &PartTreeWidget::partCutTemplateChanged); + //connect(m_document, &Document::partCutTemplateChanged, partTreeWidget, &PartTreeWidget::partCutTemplateChanged); connect(m_document, &Document::partMaterialIdChanged, partTreeWidget, &PartTreeWidget::partMaterialIdChanged); connect(m_document, &Document::partRemoved, partTreeWidget, &PartTreeWidget::partRemoved); connect(m_document, &Document::cleanup, partTreeWidget, &PartTreeWidget::removeAllContent); diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 18a87847..700cd04f 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -143,6 +143,7 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt bool xMirrored = isTrueValueString(valueOfKeyInMapOrEmpty(part, "xMirrored")); bool subdived = isTrueValueString(valueOfKeyInMapOrEmpty(part, "subdived")); bool rounded = isTrueValueString(valueOfKeyInMapOrEmpty(part, "rounded")); + bool chamfered = isTrueValueString(valueOfKeyInMapOrEmpty(part, "chamfered")); QString colorString = valueOfKeyInMapOrEmpty(part, "color"); QColor partColor = colorString.isEmpty() ? m_defaultPartColor : QColor(colorString); float deformThickness = 1.0; @@ -150,6 +151,8 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt float cutRotation = 0.0; std::vector cutTemplate = cutTemplatePointsFromString(valueOfKeyInMapOrEmpty(part, "cutTemplate")); + if (chamfered) + nodemesh::chamferFace2D(&cutTemplate); normalizeCutTemplatePoints(&cutTemplate); QString cutRotationString = valueOfKeyInMapOrEmpty(part, "cutRotation"); if (!cutRotationString.isEmpty()) { diff --git a/src/parttreewidget.cpp b/src/parttreewidget.cpp index b31cff59..3b392366 100644 --- a/src/parttreewidget.cpp +++ b/src/parttreewidget.cpp @@ -910,6 +910,17 @@ void PartTreeWidget::partRoundStateChanged(QUuid partId) widget->updateRoundButton(); } +void PartTreeWidget::partChamferStateChanged(QUuid partId) +{ + auto item = m_partItemMap.find(partId); + if (item == m_partItemMap.end()) { + qDebug() << "Part item not found:" << partId; + return; + } + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); + widget->updateChamferButton(); +} + void PartTreeWidget::partColorStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); @@ -932,16 +943,16 @@ void PartTreeWidget::partCutRotationChanged(QUuid partId) widget->updateCutRotationButton(); } -void PartTreeWidget::partCutTemplateChanged(QUuid partId) -{ - auto item = m_partItemMap.find(partId); - if (item == m_partItemMap.end()) { - qDebug() << "Part item not found:" << partId; - return; - } - PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); - widget->updateCutTemplateButton(); -} +//void PartTreeWidget::partCutTemplateChanged(QUuid partId) +//{ +// auto item = m_partItemMap.find(partId); +// if (item == m_partItemMap.end()) { +// qDebug() << "Part item not found:" << partId; +// return; +// } +// PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); +// widget->updateCutTemplateButton(); +//} void PartTreeWidget::partMaterialIdChanged(QUuid partId) { diff --git a/src/parttreewidget.h b/src/parttreewidget.h index c5068167..0fb90d7f 100644 --- a/src/parttreewidget.h +++ b/src/parttreewidget.h @@ -59,9 +59,10 @@ public slots: void partXmirrorStateChanged(QUuid partId); void partDeformChanged(QUuid partId); void partRoundStateChanged(QUuid partId); + void partChamferStateChanged(QUuid partId); void partColorStateChanged(QUuid partId); void partCutRotationChanged(QUuid partId); - void partCutTemplateChanged(QUuid partId); + //void partCutTemplateChanged(QUuid partId); void partMaterialIdChanged(QUuid partId); void partChecked(QUuid partId); void partUnchecked(QUuid partId); diff --git a/src/partwidget.cpp b/src/partwidget.cpp index fd973493..a79c29e3 100644 --- a/src/partwidget.cpp +++ b/src/partwidget.cpp @@ -62,6 +62,11 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : m_roundButton->setSizePolicy(retainSizePolicy); initButton(m_roundButton); + m_chamferButton = new QPushButton; + m_chamferButton->setToolTip(tr("Chamfer")); + m_chamferButton->setSizePolicy(retainSizePolicy); + initButton(m_chamferButton); + m_colorButton = new QPushButton; m_colorButton->setToolTip(tr("Color and material picker")); m_colorButton->setSizePolicy(retainSizePolicy); @@ -72,10 +77,10 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : m_cutRotationButton->setSizePolicy(retainSizePolicy); initButton(m_cutRotationButton); - m_cutTemplateButton = new QPushButton; - m_cutTemplateButton->setToolTip(tr("Cut template")); - m_cutTemplateButton->setSizePolicy(retainSizePolicy); - initButton(m_cutTemplateButton); + //m_cutTemplateButton = new QPushButton; + //m_cutTemplateButton->setToolTip(tr("Cut template")); + //m_cutTemplateButton->setSizePolicy(retainSizePolicy); + //initButton(m_cutTemplateButton); m_previewWidget = new ModelWidget; m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); @@ -109,7 +114,8 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : col = 0; toolsLayout->addWidget(m_subdivButton, row, col++, Qt::AlignTop); toolsLayout->addWidget(m_roundButton, row, col++, Qt::AlignTop); - toolsLayout->addWidget(m_cutTemplateButton, row, col++, Qt::AlignTop); + //toolsLayout->addWidget(m_cutTemplateButton, row, col++, Qt::AlignTop); + toolsLayout->addWidget(m_chamferButton, row, col++, Qt::AlignTop); toolsLayout->addWidget(m_cutRotationButton, row, col++, Qt::AlignTop); toolsLayout->addWidget(m_deformButton, row, col++, Qt::AlignTop); @@ -157,6 +163,7 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : connect(this, &PartWidget::setPartDeformThickness, m_document, &Document::setPartDeformThickness); connect(this, &PartWidget::setPartDeformWidth, m_document, &Document::setPartDeformWidth); connect(this, &PartWidget::setPartRoundState, m_document, &Document::setPartRoundState); + connect(this, &PartWidget::setPartChamferState, m_document, &Document::setPartChamferState); connect(this, &PartWidget::setPartCutRotation, m_document, &Document::setPartCutRotation); connect(this, &PartWidget::setPartCutTemplate, m_document, &Document::setPartCutTemplate); connect(this, &PartWidget::setPartColorState, m_document, &Document::setPartColorState); @@ -236,6 +243,16 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : emit groupOperationAdded(); }); + connect(m_chamferButton, &QPushButton::clicked, [=]() { + const SkeletonPart *part = m_document->findPart(m_partId); + if (!part) { + qDebug() << "Part not found:" << m_partId; + return; + } + emit setPartChamferState(m_partId, !part->chamfered); + emit groupOperationAdded(); + }); + connect(m_colorButton, &QPushButton::clicked, [=]() { const SkeletonPart *part = m_document->findPart(m_partId); if (!part) { @@ -254,14 +271,14 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : showCutRotationSettingPopup(mapFromGlobal(QCursor::pos())); }); - connect(m_cutTemplateButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); - if (!part) { - qDebug() << "Part not found:" << m_partId; - return; - } - showCutTemplateSettingPopup(mapFromGlobal(QCursor::pos())); - }); + //connect(m_cutTemplateButton, &QPushButton::clicked, [=]() { + // const SkeletonPart *part = m_document->findPart(m_partId); + // if (!part) { + // qDebug() << "Part not found:" << m_partId; + // return; + // } + // showCutTemplateSettingPopup(mapFromGlobal(QCursor::pos())); + //}); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setFixedSize(preferredSize()); @@ -288,9 +305,10 @@ void PartWidget::updateAllButtons() updateXmirrorButton(); updateDeformButton(); updateRoundButton(); + updateChamferButton(); updateColorButton(); updateCutRotationButton(); - updateCutTemplateButton(); + //updateCutTemplateButton(); } void PartWidget::updateCheckedState(bool checked) @@ -443,122 +461,106 @@ void PartWidget::showCutRotationSettingPopup(const QPoint &pos) popupMenu.exec(mapToGlobal(pos)); } -void PartWidget::showCutTemplateSettingPopup(const QPoint &pos) -{ - QMenu popupMenu; - - const SkeletonPart *part = m_document->findPart(m_partId); - if (!part) { - qDebug() << "Find part failed:" << m_partId; - return; - } - - CutDocument cutDocument; - SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(&cutDocument); - graphicsWidget->setNodePositionModifyOnly(true); - graphicsWidget->setMainProfileOnly(true); - - GraphicsContainerWidget *containerWidget = new GraphicsContainerWidget; - containerWidget->setGraphicsWidget(graphicsWidget); - QGridLayout *containerLayout = new QGridLayout; - containerLayout->setSpacing(0); - containerLayout->setContentsMargins(1, 0, 0, 0); - containerLayout->addWidget(graphicsWidget); - containerWidget->setLayout(containerLayout); - containerWidget->setFixedSize(160, 100); - - connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged, - graphicsWidget, &SkeletonGraphicsWidget::canvasResized); - - connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, &cutDocument, &CutDocument::moveNodeBy); - connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, &cutDocument, &CutDocument::setNodeOrigin); - connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, &cutDocument, &CutDocument::saveHistoryItem); - connect(graphicsWidget, &SkeletonGraphicsWidget::undo, &cutDocument, &CutDocument::undo); - connect(graphicsWidget, &SkeletonGraphicsWidget::redo, &cutDocument, &CutDocument::redo); - connect(graphicsWidget, &SkeletonGraphicsWidget::paste, &cutDocument, &CutDocument::paste); - - connect(&cutDocument, &CutDocument::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent); - - connect(&cutDocument, &CutDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded); - connect(&cutDocument, &CutDocument::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded); - connect(&cutDocument, &CutDocument::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); - - cutDocument.fromCutTemplate(part->cutTemplate); - - connect(&cutDocument, &CutDocument::cutTemplateChanged, this, [&]() { - std::vector cutTemplate; - cutDocument.toCutTemplate(cutTemplate); - emit setPartCutTemplate(m_partId, cutTemplate); - }); - - QWidget *popup = new QWidget; - - initShortCuts(popup, graphicsWidget); - - std::vector presetButtons; - - { - CutTemplate cutTemplate = CutTemplate::Quad; - QPushButton *button = new QPushButton(tr("Reset")); - connect(button, &QPushButton::clicked, [cutTemplate, &cutDocument, this]() { - auto points = CutTemplateToPoints(cutTemplate); - cutDocument.fromCutTemplate(points); - emit setPartCutTemplate(m_partId, points); - emit groupOperationAdded(); - }); - Theme::initToolButton(button); - presetButtons.push_back(button); - } - - /* - { - QPushButton *button = new QPushButton(tr("Subdivide")); - connect(button, &QPushButton::clicked, [&cutDocument, this]() { - std::vector cutTemplate; - cutDocument.toCutTemplate(cutTemplate); - nodemesh::subdivideFace2D(&cutTemplate); - cutDocument.fromCutTemplate(cutTemplate); - emit setPartCutTemplate(m_partId, cutTemplate); - emit groupOperationAdded(); - }); - Theme::initToolButton(button); - presetButtons.push_back(button); - } - */ - - { - QPushButton *button = new QPushButton(tr("Chamfer")); - connect(button, &QPushButton::clicked, [&cutDocument, this]() { - std::vector cutTemplate; - cutDocument.toCutTemplate(cutTemplate); - nodemesh::chamferFace2D(&cutTemplate); - cutDocument.fromCutTemplate(cutTemplate); - emit setPartCutTemplate(m_partId, cutTemplate); - emit groupOperationAdded(); - }); - Theme::initToolButton(button); - presetButtons.push_back(button); - } - - QVBoxLayout *layout = new QVBoxLayout; - QHBoxLayout *presetButtonsLayout = new QHBoxLayout; - for (const auto &it: presetButtons) - presetButtonsLayout->addWidget(it); - presetButtonsLayout->addStretch(); - layout->addLayout(presetButtonsLayout); - layout->addWidget(containerWidget); - - popup->setLayout(layout); - - popup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - - QWidgetAction action(this); - action.setDefaultWidget(popup); - - popupMenu.addAction(&action); - - popupMenu.exec(mapToGlobal(pos)); -} +//void PartWidget::showCutTemplateSettingPopup(const QPoint &pos) +//{ +// QMenu popupMenu; +// +// const SkeletonPart *part = m_document->findPart(m_partId); +// if (!part) { +// qDebug() << "Find part failed:" << m_partId; +// return; +// } +// +// CutDocument cutDocument; +// SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(&cutDocument); +// graphicsWidget->setNodePositionModifyOnly(true); +// graphicsWidget->setMainProfileOnly(true); +// +// GraphicsContainerWidget *containerWidget = new GraphicsContainerWidget; +// containerWidget->setGraphicsWidget(graphicsWidget); +// QGridLayout *containerLayout = new QGridLayout; +// containerLayout->setSpacing(0); +// containerLayout->setContentsMargins(1, 0, 0, 0); +// containerLayout->addWidget(graphicsWidget); +// containerWidget->setLayout(containerLayout); +// containerWidget->setFixedSize(160, 100); +// +// connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged, +// graphicsWidget, &SkeletonGraphicsWidget::canvasResized); +// +// connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, &cutDocument, &CutDocument::moveNodeBy); +// connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, &cutDocument, &CutDocument::setNodeOrigin); +// connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, &cutDocument, &CutDocument::saveHistoryItem); +// connect(graphicsWidget, &SkeletonGraphicsWidget::undo, &cutDocument, &CutDocument::undo); +// connect(graphicsWidget, &SkeletonGraphicsWidget::redo, &cutDocument, &CutDocument::redo); +// connect(graphicsWidget, &SkeletonGraphicsWidget::paste, &cutDocument, &CutDocument::paste); +// +// connect(&cutDocument, &CutDocument::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent); +// +// connect(&cutDocument, &CutDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded); +// connect(&cutDocument, &CutDocument::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded); +// connect(&cutDocument, &CutDocument::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); +// +// cutDocument.fromCutTemplate(part->cutTemplate); +// +// connect(&cutDocument, &CutDocument::cutTemplateChanged, this, [&]() { +// std::vector cutTemplate; +// cutDocument.toCutTemplate(cutTemplate); +// emit setPartCutTemplate(m_partId, cutTemplate); +// }); +// +// QWidget *popup = new QWidget; +// +// initShortCuts(popup, graphicsWidget); +// +// std::vector presetButtons; +// +// { +// CutTemplate cutTemplate = CutTemplate::Quad; +// QPushButton *button = new QPushButton(tr("Reset")); +// connect(button, &QPushButton::clicked, [cutTemplate, &cutDocument, this]() { +// auto points = CutTemplateToPoints(cutTemplate); +// cutDocument.fromCutTemplate(points); +// emit setPartCutTemplate(m_partId, points); +// emit groupOperationAdded(); +// }); +// Theme::initToolButton(button); +// presetButtons.push_back(button); +// } +// +// { +// QPushButton *button = new QPushButton(tr("Chamfer")); +// connect(button, &QPushButton::clicked, [&cutDocument, this]() { +// std::vector cutTemplate; +// cutDocument.toCutTemplate(cutTemplate); +// nodemesh::chamferFace2D(&cutTemplate); +// cutDocument.fromCutTemplate(cutTemplate); +// emit setPartCutTemplate(m_partId, cutTemplate); +// emit groupOperationAdded(); +// }); +// Theme::initToolButton(button); +// presetButtons.push_back(button); +// } +// +// QVBoxLayout *layout = new QVBoxLayout; +// QHBoxLayout *presetButtonsLayout = new QHBoxLayout; +// for (const auto &it: presetButtons) +// presetButtonsLayout->addWidget(it); +// presetButtonsLayout->addStretch(); +// layout->addLayout(presetButtonsLayout); +// layout->addWidget(containerWidget); +// +// popup->setLayout(layout); +// +// popup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); +// +// QWidgetAction action(this); +// action.setDefaultWidget(popup); +// +// popupMenu.addAction(&action); +// +// popupMenu.exec(mapToGlobal(pos)); +//} void PartWidget::showDeformSettingPopup(const QPoint &pos) { @@ -741,6 +743,19 @@ void PartWidget::updateRoundButton() updateButton(m_roundButton, QChar(fa::magnet), false); } +void PartWidget::updateChamferButton() +{ + const SkeletonPart *part = m_document->findPart(m_partId); + if (!part) { + qDebug() << "Part not found:" << m_partId; + return; + } + if (part->chamfered) + updateButton(m_chamferButton, QChar(fa::scissors), true); + else + updateButton(m_chamferButton, QChar(fa::scissors), false); +} + void PartWidget::updateColorButton() { const SkeletonPart *part = m_document->findPart(m_partId); @@ -767,18 +782,18 @@ void PartWidget::updateCutRotationButton() updateButton(m_cutRotationButton, QChar(fa::spinner), false); } -void PartWidget::updateCutTemplateButton() -{ - const SkeletonPart *part = m_document->findPart(m_partId); - if (!part) { - qDebug() << "Part not found:" << m_partId; - return; - } - if (part->cutTemplateAdjusted()) - updateButton(m_cutTemplateButton, QChar(fa::objectungroup), true); - else - updateButton(m_cutTemplateButton, QChar(fa::objectungroup), false); -} +//void PartWidget::updateCutTemplateButton() +//{ +// const SkeletonPart *part = m_document->findPart(m_partId); +// if (!part) { +// qDebug() << "Part not found:" << m_partId; +// return; +// } +// if (part->cutTemplateAdjusted()) +// updateButton(m_cutTemplateButton, QChar(fa::objectungroup), true); +// else +// updateButton(m_cutTemplateButton, QChar(fa::objectungroup), false); +//} void PartWidget::reload() { diff --git a/src/partwidget.h b/src/partwidget.h index 955dcb55..e47bcd56 100644 --- a/src/partwidget.h +++ b/src/partwidget.h @@ -19,6 +19,7 @@ signals: void setPartDeformThickness(QUuid partId, float thickness); void setPartDeformWidth(QUuid partId, float width); void setPartRoundState(QUuid partId, bool rounded); + void setPartChamferState(QUuid partId, bool chamfered); void setPartColorState(QUuid partId, bool hasColor, QColor color); void setPartCutRotation(QUuid partId, float cutRotation); void setPartCutTemplate(QUuid partId, std::vector cutTemplate); @@ -43,6 +44,7 @@ public: void updateZmirrorButton(); void updateDeformButton(); void updateRoundButton(); + void updateChamferButton(); void updateColorButton(); void updateCutRotationButton(); void updateCutTemplateButton(); @@ -55,7 +57,7 @@ protected: public slots: void showDeformSettingPopup(const QPoint &pos); void showCutRotationSettingPopup(const QPoint &pos); - void showCutTemplateSettingPopup(const QPoint &pos); + //void showCutTemplateSettingPopup(const QPoint &pos); void showColorSettingPopup(const QPoint &pos); private: // need initialize const Document *m_document; @@ -71,9 +73,10 @@ private: QPushButton *m_zMirrorButton; QPushButton *m_deformButton; QPushButton *m_roundButton; + QPushButton *m_chamferButton; QPushButton *m_colorButton; QPushButton *m_cutRotationButton; - QPushButton *m_cutTemplateButton; + //QPushButton *m_cutTemplateButton; QWidget *m_backgroundWidget; private: void initToolButton(QPushButton *button); diff --git a/src/skeletondocument.h b/src/skeletondocument.h index 34dadb7f..9c2a6798 100644 --- a/src/skeletondocument.h +++ b/src/skeletondocument.h @@ -79,6 +79,7 @@ public: float deformThickness; float deformWidth; bool rounded; + bool chamfered; QColor color; bool hasColor; QUuid componentId; @@ -98,6 +99,7 @@ public: deformThickness(1.0), deformWidth(1.0), rounded(false), + chamfered(false), color(Theme::white), hasColor(false), dirty(true), @@ -175,6 +177,7 @@ public: deformThickness = other.deformThickness; deformWidth = other.deformWidth; rounded = other.rounded; + chamfered = other.chamfered; color = other.color; hasColor = other.hasColor; cutRotation = other.cutRotation;