+ add refine option to shape builder

This commit is contained in:
wmayer 2016-03-05 16:13:15 +01:00
parent 948ccac021
commit 781f91e6af
2 changed files with 61 additions and 26 deletions

View File

@ -349,12 +349,22 @@ void ShapeBuilderWidget::createShellFromFace()
}
QString cmd;
cmd = QString::fromLatin1(
"_=Part.Shell(%1)\n"
"if _.isNull(): raise RuntimeError('Failed to create shell')\n"
"App.ActiveDocument.addObject('Part::Feature','Shell').Shape=_.removeSplitter()\n"
"del _\n"
).arg(list);
if (d->ui.checkRefine->isEnabled() && d->ui.checkRefine->isChecked()) {
cmd = QString::fromLatin1(
"_=Part.Shell(%1)\n"
"if _.isNull(): raise RuntimeError('Failed to create shell')\n"
"App.ActiveDocument.addObject('Part::Feature','Shell').Shape=_.removeSplitter()\n"
"del _\n"
).arg(list);
}
else {
cmd = QString::fromLatin1(
"_=Part.Shell(%1)\n"
"if _.isNull(): raise RuntimeError('Failed to create shell')\n"
"App.ActiveDocument.addObject('Part::Feature','Shell').Shape=_\n"
"del _\n"
).arg(list);
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Shell");
@ -387,14 +397,26 @@ void ShapeBuilderWidget::createSolidFromShell()
}
QString cmd;
cmd = QString::fromLatin1(
"shell=%1\n"
"if shell.ShapeType != 'Shell': raise RuntimeError('Part object is not a shell')\n"
"_=Part.Solid(shell)\n"
"if _.isNull(): raise RuntimeError('Failed to create solid')\n"
"App.ActiveDocument.addObject('Part::Feature','Solid').Shape=_.removeSplitter()\n"
"del _\n"
).arg(line);
if (d->ui.checkRefine->isEnabled() && d->ui.checkRefine->isChecked()) {
cmd = QString::fromLatin1(
"shell=%1\n"
"if shell.ShapeType != 'Shell': raise RuntimeError('Part object is not a shell')\n"
"_=Part.Solid(shell)\n"
"if _.isNull(): raise RuntimeError('Failed to create solid')\n"
"App.ActiveDocument.addObject('Part::Feature','Solid').Shape=_.removeSplitter()\n"
"del _\n"
).arg(line);
}
else {
cmd = QString::fromLatin1(
"shell=%1\n"
"if shell.ShapeType != 'Shell': raise RuntimeError('Part object is not a shell')\n"
"_=Part.Solid(shell)\n"
"if _.isNull(): raise RuntimeError('Failed to create solid')\n"
"App.ActiveDocument.addObject('Part::Feature','Solid').Shape=_\n"
"del _\n"
).arg(line);
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Solid");
@ -415,30 +437,35 @@ void ShapeBuilderWidget::switchMode(int mode)
d->ui.label->setText(tr("Select two vertices to create an edge"));
d->ui.checkPlanar->setEnabled(false);
d->ui.checkFaces->setEnabled(false);
d->ui.checkRefine->setEnabled(false);
}
else if (mode == 1) {
d->gate->setMode(ShapeSelection::VERTEX);
d->ui.label->setText(tr("Select a list of vertices"));
d->ui.checkPlanar->setEnabled(true);
d->ui.checkFaces->setEnabled(false);
d->ui.checkRefine->setEnabled(false);
}
else if (mode == 2) {
d->gate->setMode(ShapeSelection::EDGE);
d->ui.label->setText(tr("Select a closed set of edges"));
d->ui.checkPlanar->setEnabled(true);
d->ui.checkFaces->setEnabled(false);
d->ui.checkRefine->setEnabled(false);
}
else if (mode == 3) {
d->gate->setMode(ShapeSelection::FACE);
d->ui.label->setText(tr("Select adjacent faces"));
d->ui.checkPlanar->setEnabled(false);
d->ui.checkFaces->setEnabled(true);
d->ui.checkRefine->setEnabled(true);
}
else {
d->gate->setMode(ShapeSelection::ALL);
d->ui.label->setText(tr("All shape types can be selected"));
d->ui.checkPlanar->setEnabled(false);
d->ui.checkFaces->setEnabled(false);
d->ui.checkRefine->setEnabled(true);
}
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>182</width>
<height>263</height>
<width>200</width>
<height>336</height>
</rect>
</property>
<property name="windowTitle">
@ -20,42 +20,42 @@
<string>Create shape</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonEdgeFromVertex">
<property name="text">
<string>Edge from vertices</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0">
<widget class="QRadioButton" name="radioButtonFaceFromVertex">
<property name="text">
<string>Face from vertices</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0">
<widget class="QRadioButton" name="radioButtonFaceFromEdge">
<property name="text">
<string>Face from edges</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0">
<widget class="QRadioButton" name="radioButtonShellFromFace">
<property name="text">
<string>Shell from faces</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QRadioButton" name="radioButtonSolidFromShell">
<property name="text">
<string>Solid from shell</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="5" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -69,14 +69,21 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="0">
<widget class="QCheckBox" name="checkRefine">
<property name="text">
<string>Refine shape</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkFaces">
<property name="text">
<string>All faces</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="9" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
@ -128,11 +135,12 @@
<tabstops>
<tabstop>radioButtonEdgeFromVertex</tabstop>
<tabstop>radioButtonFaceFromVertex</tabstop>
<tabstop>checkPlanar</tabstop>
<tabstop>radioButtonFaceFromEdge</tabstop>
<tabstop>radioButtonShellFromFace</tabstop>
<tabstop>checkFaces</tabstop>
<tabstop>radioButtonSolidFromShell</tabstop>
<tabstop>checkPlanar</tabstop>
<tabstop>checkRefine</tabstop>
<tabstop>checkFaces</tabstop>
<tabstop>createButton</tabstop>
</tabstops>
<resources/>