PartDesign changes

* Mostly for supporting in-place editing

* Add new SubShapeBinder that support cross coordinate system,
  external, and sub-object binding
This commit is contained in:
Zheng, Lei
2019-07-13 18:13:21 +08:00
committed by wmayer
parent 11321bb996
commit cd2b7e297c
55 changed files with 1944 additions and 755 deletions

View File

@@ -132,6 +132,7 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
getReferencedSelection(pcDraft, msg, selObj, planes);
if(!selObj)
return;
setupTransaction();
pcDraft->NeutralPlane.setValue(selObj, planes);
ui->linePlane->setText(getRefStr(selObj, planes));
@@ -145,6 +146,7 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
getReferencedSelection(pcDraft, msg, selObj, edges);
if(!selObj)
return;
setupTransaction();
pcDraft->PullDirection.setValue(selObj, edges);
ui->lineLine->setText(getRefStr(selObj, edges));
@@ -192,6 +194,7 @@ void TaskDraftParameters::onRefDeleted(void)
App::DocumentObject* base = pcDraft->Base.getValue();
std::vector<std::string> faces = pcDraft->Base.getSubValues();
faces.erase(faces.begin() + ui->listWidgetReferences->currentRow());
setupTransaction();
pcDraft->Base.setValue(base, faces);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcDraft->getDocument()->recomputeFeature(pcDraft);
@@ -219,6 +222,7 @@ void TaskDraftParameters::onAngleChanged(double angle)
{
clearButtons(none);
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject());
setupTransaction();
pcDraft->Angle.setValue(angle);
pcDraft->getDocument()->recomputeFeature(pcDraft);
}
@@ -231,6 +235,7 @@ double TaskDraftParameters::getAngle(void) const
void TaskDraftParameters::onReversedChanged(const bool on) {
clearButtons(none);
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject());
setupTransaction();
pcDraft->Reversed.setValue(on);
pcDraft->getDocument()->recomputeFeature(pcDraft);
}
@@ -300,18 +305,21 @@ bool TaskDlgDraftParameters::accept()
std::string pullDirection = buildLinkSingleSubPythonStr(obj, strings);
// Force the user to select a neutral plane
if (neutralPlane.empty() || neutralPlane == "None") {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Missing neutral plane"),
QObject::tr("Please select a plane or an edge plus a pull direction"));
return false;
}
// if (neutralPlane.empty() || neutralPlane == "None") {
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Missing neutral plane"),
// QObject::tr("Please select a plane or an edge plus a pull direction"));
// return false;
// }
std::string name = vp->getObject()->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),draftparameter->getAngle());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),draftparameter->getReversed());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.NeutralPlane = %s", name.c_str(), neutralPlane.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.PullDirection = %s", name.c_str(), pullDirection.c_str());
auto tobj = vp->getObject();
FCMD_OBJ_CMD(tobj,"Angle = " << draftparameter->getAngle());
FCMD_OBJ_CMD(tobj,"Reversed = " << draftparameter->getReversed());
if(neutralPlane.empty())
neutralPlane = "None";
FCMD_OBJ_CMD(tobj,"NeutralPlane = " << neutralPlane);
if(pullDirection.empty())
pullDirection = "None";
FCMD_OBJ_CMD(tobj,"PullDirection = " << pullDirection);
return TaskDlgDressUpParameters::accept();
}