Skip to content

Commit

Permalink
fixes #1333: Extruding a shape 'MyShape' should call solid 'Extruded …
Browse files Browse the repository at this point in the history
…from MyShape'
  • Loading branch information
wwmayer committed Jan 2, 2014
1 parent 18c62a5 commit e5965a4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/Mod/Part/Gui/DlgExtrusion.cpp
Expand Up @@ -153,12 +153,25 @@ void DlgExtrusion::apply()
}
activeDoc->openTransaction("Extrude");

QString shape, type, name;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
bool addBaseName = hGrp->GetBool("AddBaseObjectName", false);

QString shape, type, name, label;
QList<QTreeWidgetItem *> items = ui->treeWidget->selectedItems();
for (QList<QTreeWidgetItem *>::iterator it = items.begin(); it != items.end(); ++it) {
shape = (*it)->data(0, Qt::UserRole).toString();
type = QString::fromAscii("Part::Extrusion");
name = QString::fromAscii(activeDoc->getUniqueObjectName("Extrude").c_str());
if (addBaseName) {
QString baseName = QString::fromLatin1("Extrude_%1").arg(shape);
label = QString::fromLatin1("%1_Extrude").arg((*it)->text(0));
name = QString::fromAscii(activeDoc->getUniqueObjectName((const char*)baseName.toLatin1()).c_str());
}
else {
name = QString::fromAscii(activeDoc->getUniqueObjectName("Extrude").c_str());
label = name;
}

double len = ui->dirLen->value();
double dirX = ui->dirX->value();
double dirY = ui->dirY->value();
Expand Down Expand Up @@ -197,14 +210,16 @@ void DlgExtrusion::apply()
"FreeCAD.getDocument(\"%1\").%3.Dir = (%5,%6,%7)\n"
"FreeCAD.getDocument(\"%1\").%3.Solid = (%8)\n"
"FreeCAD.getDocument(\"%1\").%3.TaperAngle = (%9)\n"
"FreeCADGui.getDocument(\"%1\").%4.Visibility = False\n")
"FreeCADGui.getDocument(\"%1\").%4.Visibility = False\n"
"FreeCAD.getDocument(\"%1\").%3.Label = '%10'\n")
.arg(QString::fromAscii(this->document.c_str()))
.arg(type).arg(name).arg(shape)
.arg(dirX*len)
.arg(dirY*len)
.arg(dirZ*len)
.arg(makeSolid ? QLatin1String("True") : QLatin1String("False"))
.arg(angle);
.arg(angle)
.arg(label);
Gui::Application::Instance->runPythonCode((const char*)code.toAscii());
QByteArray to = name.toAscii();
QByteArray from = shape.toAscii();
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/Gui/DlgSettingsGeneral.cpp
Expand Up @@ -72,6 +72,7 @@ void DlgSettingsGeneral::saveSettings()
ui->checkBooleanCheck->onSave();
ui->checkBooleanRefine->onSave();
ui->checkSketchBaseRefine->onSave();
ui->checkObjectNaming->onSave();
}

void DlgSettingsGeneral::loadSettings()
Expand All @@ -83,6 +84,7 @@ void DlgSettingsGeneral::loadSettings()
ui->checkBooleanCheck->onRestore();
ui->checkBooleanRefine->onRestore();
ui->checkSketchBaseRefine->onRestore();
ui->checkObjectNaming->onRestore();
}

/**
Expand Down
24 changes: 23 additions & 1 deletion src/Mod/Part/Gui/DlgSettingsGeneral.ui
Expand Up @@ -13,7 +13,7 @@
<property name="windowTitle">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand Down Expand Up @@ -117,6 +117,28 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Object naming</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="checkObjectNaming">
<property name="text">
<string>Add name of base object</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>AddBaseObjectName</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Part</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down

0 comments on commit e5965a4

Please sign in to comment.