PartDesignGui: Make DressUp and SketchSupport propertie dialogs use common accept() structure

This commit is contained in:
Alexander Golubev
2015-07-23 01:32:19 +03:00
committed by Stefan Tröger
parent d03c6c82a4
commit 180985cec0
12 changed files with 1071 additions and 104 deletions

View File

@@ -382,20 +382,7 @@ void TaskRevolutionParameters::changeEvent(QEvent *e)
void TaskRevolutionParameters::apply()
{
App::DocumentObject* revolve = vp->getObject();
std::string name = revolve->getNameInDocument();
// retrieve sketch and its support object
App::DocumentObject* sketch = 0;
App::DocumentObject* support = 0;
if (revolve->getTypeId().isDerivedFrom(PartDesign::Revolution::getClassTypeId())) {
sketch = static_cast<PartDesign::Revolution*>(revolve)->Sketch.getValue();
try{//throws if no base
support = static_cast<PartDesign::Revolution*>(revolve)->getBaseObject();
} catch (Base::Exception) {
support = NULL;
}
}
std::string name = vp->getObject()->getNameInDocument();
//Gui::Command::openCommand("Revolution changed");
ui->revolveAngle->apply();
@@ -406,15 +393,6 @@ void TaskRevolutionParameters::apply()
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.ReferenceAxis = %s",name.c_str(),axis.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(), getMidplane() ? 1 : 0);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(), getReversed() ? 1 : 0);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (revolve->isValid()) {
if (sketch)
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
if (support)
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
}
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
//**************************************************************************
@@ -440,7 +418,7 @@ TaskDlgRevolutionParameters::~TaskDlgRevolutionParameters()
bool TaskDlgRevolutionParameters::accept()
{
parameter->apply();
return true;
return TaskDlgSketchBasedParameters::accept();
}