[PD] Support adding solid faces for loft and pipe sections

With these changes, one face per solid can be added as either the first
"profile" or subsequent sections in loft and pipe.

This commit depends on `App::PropertyXLinkSubList` preserving the order in which
sections are added.

A minor change this also adds is that when a solid's face is selected that face
is mentioned in the fields instead of the solid (eg `Box:Face1` instead of
`Box`).
This commit is contained in:
Ajinkya Dahale
2021-11-07 03:39:56 -05:00
committed by Uwe
parent 5c77af421d
commit 03a8ff7841
8 changed files with 129 additions and 88 deletions

View File

@@ -103,14 +103,14 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView, bool /*newObj
if (profile) {
Gui::Application::Instance->showViewProvider(profile);
QString label = QString::fromUtf8(profile->Label.getValue());
QString label = make2DLabel(profile, loft->Profile.getSubValues());
ui->profileBaseEdit->setText(label);
}
for (auto obj : loft->Sections.getValues()) {
Gui::Application::Instance->showViewProvider(obj);
QString label = QString::fromUtf8(obj->Label.getValue());
QString label = make2DLabel(obj, loft->Sections.getSubValues(obj));
QListWidgetItem* item = new QListWidgetItem();
item->setText(label);
item->setData(Qt::UserRole, QByteArray(obj->getNameInDocument()));
@@ -150,7 +150,7 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
App::Document* document = App::GetApplication().getDocument(msg.pDocName);
App::DocumentObject* object = document ? document->getObject(msg.pObjectName) : nullptr;
if (object) {
QString label = QString::fromUtf8(object->Label.getValue());
QString label = make2DLabel(object, {msg.pSubName});
if (selectionMode == refProfile) {
ui->profileBaseEdit->setText(label);
}
@@ -196,7 +196,7 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con
App::DocumentObject* obj = loft->getDocument()->getObject(msg.pObjectName);
if (selectionMode == refProfile) {
loft->Profile.setValue(obj);
loft->Profile.setValue(obj, {msg.pSubName});
return true;
}
else if (selectionMode == refAdd || selectionMode == refRemove) {
@@ -206,18 +206,17 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con
if (selectionMode == refAdd) {
if (f == refs.end())
refs.push_back(obj);
loft->Sections.addValue(obj, {msg.pSubName});
else
return false; // duplicate selection
}
else if (selectionMode == refRemove) {
if (f != refs.end())
refs.erase(f);
loft->Sections.removeValue(obj);
else
return false;
}
static_cast<PartDesign::Loft*>(vp->getObject())->Sections.setValues(refs);
return true;
}
}