PartDesign: Added support for expressions.
This commit is contained in:
@@ -82,6 +82,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
||||
bool reversed = pcGroove->Reversed.getValue();
|
||||
|
||||
ui->grooveAngle->setValue(l);
|
||||
ui->grooveAngle->bind(pcGroove->Angle);
|
||||
|
||||
int count=pcGroove->getSketchAxisCount();
|
||||
|
||||
@@ -250,6 +251,38 @@ void TaskGrooveParameters::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::apply()
|
||||
{
|
||||
App::DocumentObject* groove = GrooveView->getObject();
|
||||
std::string name = groove->getNameInDocument();
|
||||
|
||||
// retrieve sketch and its support object
|
||||
App::DocumentObject* sketch = 0;
|
||||
App::DocumentObject* support = 0;
|
||||
if (groove->getTypeId().isDerivedFrom(PartDesign::Groove::getClassTypeId())) {
|
||||
sketch = static_cast<PartDesign::Groove*>(groove)->Sketch.getValue<Sketcher::SketchObject*>();
|
||||
if (sketch) {
|
||||
support = static_cast<Sketcher::SketchObject*>(sketch)->Support.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
//Gui::Command::openCommand("Groove changed");
|
||||
ui->grooveAngle->apply();
|
||||
std::string axis = getReferenceAxis().toStdString();
|
||||
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 (groove->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();
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
@@ -288,35 +321,7 @@ void TaskDlgGrooveParameters::clicked(int)
|
||||
|
||||
bool TaskDlgGrooveParameters::accept()
|
||||
{
|
||||
App::DocumentObject* groove = GrooveView->getObject();
|
||||
std::string name = groove->getNameInDocument();
|
||||
|
||||
// retrieve sketch and its support object
|
||||
App::DocumentObject* sketch = 0;
|
||||
App::DocumentObject* support = 0;
|
||||
if (groove->getTypeId().isDerivedFrom(PartDesign::Groove::getClassTypeId())) {
|
||||
sketch = static_cast<PartDesign::Groove*>(groove)->Sketch.getValue<Sketcher::SketchObject*>();
|
||||
if (sketch) {
|
||||
support = static_cast<Sketcher::SketchObject*>(sketch)->Support.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
//Gui::Command::openCommand("Groove changed");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle());
|
||||
std::string axis = parameter->getReferenceAxis().toStdString();
|
||||
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(),parameter->getMidplane()?1:0);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),parameter->getReversed()?1:0);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
if (groove->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();
|
||||
|
||||
parameter->apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user