From 86978d0ac32009e6a6f71c29f26e8afee972afe4 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Wed, 27 Feb 2019 08:25:29 +0930 Subject: [PATCH] Add new cut face type: triangle --- src/cuttemplate.h | 10 +++++++++- src/partwidget.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cuttemplate.h b/src/cuttemplate.h index 2fbfabf1..af370eb4 100644 --- a/src/cuttemplate.h +++ b/src/cuttemplate.h @@ -8,7 +8,7 @@ enum class CutTemplate { Quad = 0, - //Octagon, + Triangle, Count }; @@ -19,6 +19,8 @@ QString CutTemplateToDispName(CutTemplate cutTemplate) \ switch (cutTemplate) { \ case CutTemplate::Quad: \ return QObject::tr("Quad"); \ + case CutTemplate::Triangle: \ + return QObject::tr("Triangle"); \ default: \ return ""; \ } \ @@ -35,6 +37,12 @@ std::vector CutTemplateToPoints(CutTemplate cutTemplate) \ { 1.0, 1.0}, \ {-1.0, 1.0}, \ }; \ + case CutTemplate::Triangle: \ + return { \ + {0, -1.0}, \ + {1.732, 0}, \ + {0, 1.0}, \ + }; \ default: \ return { \ {-1.0, -1.0}, \ diff --git a/src/partwidget.cpp b/src/partwidget.cpp index 1eddaf2e..7a7f740f 100644 --- a/src/partwidget.cpp +++ b/src/partwidget.cpp @@ -498,7 +498,7 @@ void PartWidget::showCutTemplateSettingPopup(const QPoint &pos) for (size_t i = 0; i < (size_t)CutTemplate::Count; ++i) { CutTemplate cutTemplate = (CutTemplate)i; QPushButton *button = new QPushButton(CutTemplateToDispName(cutTemplate)); - connect(button, &QPushButton::clicked, [&]() { + connect(button, &QPushButton::clicked, [cutTemplate, &cutDocument, this]() { auto points = CutTemplateToPoints(cutTemplate); cutDocument.fromCutTemplate(points); emit setPartCutTemplate(m_partId, points);