Add new cut face type: triangle

master
Jeremy Hu 2019-02-27 08:25:29 +09:30
parent 2b44576f22
commit 86978d0ac3
2 changed files with 10 additions and 2 deletions

View File

@ -8,7 +8,7 @@
enum class CutTemplate enum class CutTemplate
{ {
Quad = 0, Quad = 0,
//Octagon, Triangle,
Count Count
}; };
@ -19,6 +19,8 @@ QString CutTemplateToDispName(CutTemplate cutTemplate) \
switch (cutTemplate) { \ switch (cutTemplate) { \
case CutTemplate::Quad: \ case CutTemplate::Quad: \
return QObject::tr("Quad"); \ return QObject::tr("Quad"); \
case CutTemplate::Triangle: \
return QObject::tr("Triangle"); \
default: \ default: \
return ""; \ return ""; \
} \ } \
@ -35,6 +37,12 @@ std::vector<QVector2D> CutTemplateToPoints(CutTemplate cutTemplate) \
{ 1.0, 1.0}, \ { 1.0, 1.0}, \
{-1.0, 1.0}, \ {-1.0, 1.0}, \
}; \ }; \
case CutTemplate::Triangle: \
return { \
{0, -1.0}, \
{1.732, 0}, \
{0, 1.0}, \
}; \
default: \ default: \
return { \ return { \
{-1.0, -1.0}, \ {-1.0, -1.0}, \

View File

@ -498,7 +498,7 @@ void PartWidget::showCutTemplateSettingPopup(const QPoint &pos)
for (size_t i = 0; i < (size_t)CutTemplate::Count; ++i) { for (size_t i = 0; i < (size_t)CutTemplate::Count; ++i) {
CutTemplate cutTemplate = (CutTemplate)i; CutTemplate cutTemplate = (CutTemplate)i;
QPushButton *button = new QPushButton(CutTemplateToDispName(cutTemplate)); QPushButton *button = new QPushButton(CutTemplateToDispName(cutTemplate));
connect(button, &QPushButton::clicked, [&]() { connect(button, &QPushButton::clicked, [cutTemplate, &cutDocument, this]() {
auto points = CutTemplateToPoints(cutTemplate); auto points = CutTemplateToPoints(cutTemplate);
cutDocument.fromCutTemplate(points); cutDocument.fromCutTemplate(points);
emit setPartCutTemplate(m_partId, points); emit setPartCutTemplate(m_partId, points);