parent
69b371adb9
commit
e2f829d3ce
|
@ -859,6 +859,7 @@ void Document::toSnapshot(Snapshot *snapshot, const std::set<QUuid> &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);
|
||||
|
|
|
@ -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<QVector2D> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<QVector2D> cutTemplate = cutTemplatePointsFromString(valueOfKeyInMapOrEmpty(part, "cutTemplate"));
|
||||
if (chamfered)
|
||||
nodemesh::chamferFace2D(&cutTemplate);
|
||||
normalizeCutTemplatePoints(&cutTemplate);
|
||||
QString cutRotationString = valueOfKeyInMapOrEmpty(part, "cutRotation");
|
||||
if (!cutRotationString.isEmpty()) {
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<QVector2D> cutTemplate;
|
||||
cutDocument.toCutTemplate(cutTemplate);
|
||||
emit setPartCutTemplate(m_partId, cutTemplate);
|
||||
});
|
||||
|
||||
QWidget *popup = new QWidget;
|
||||
|
||||
initShortCuts(popup, graphicsWidget);
|
||||
|
||||
std::vector<QPushButton *> 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<QVector2D> 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<QVector2D> 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<QVector2D> cutTemplate;
|
||||
// cutDocument.toCutTemplate(cutTemplate);
|
||||
// emit setPartCutTemplate(m_partId, cutTemplate);
|
||||
// });
|
||||
//
|
||||
// QWidget *popup = new QWidget;
|
||||
//
|
||||
// initShortCuts(popup, graphicsWidget);
|
||||
//
|
||||
// std::vector<QPushButton *> 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<QVector2D> 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()
|
||||
{
|
||||
|
|
|
@ -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<QVector2D> 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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue