[PD] Use PropertyLinkSubList for loft and sweep sections
This change is necessary since we restrict part-design features to only use other features from the same body.
This commit is contained in:
@@ -40,7 +40,7 @@ class PartDesignExport Loft : public ProfileBased
|
||||
public:
|
||||
Loft();
|
||||
|
||||
App::PropertyXLinkSubList Sections;
|
||||
App::PropertyLinkSubList Sections;
|
||||
App::PropertyBool Ruled;
|
||||
App::PropertyBool Closed;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
App::PropertyVector Binormal;
|
||||
App::PropertyEnumeration Transition;
|
||||
App::PropertyEnumeration Transformation;
|
||||
App::PropertyXLinkSubList Sections;
|
||||
App::PropertyLinkSubList Sections;
|
||||
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include "TaskSketchBasedParameters.h"
|
||||
#include "ReferenceSelection.h"
|
||||
|
||||
Q_DECLARE_METATYPE(App::PropertyLinkSubList::SubSet);
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
@@ -107,13 +109,13 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView, bool /*newObj
|
||||
ui->profileBaseEdit->setText(label);
|
||||
}
|
||||
|
||||
for (auto obj : loft->Sections.getValues()) {
|
||||
Gui::Application::Instance->showViewProvider(obj);
|
||||
for (auto &subSet : loft->Sections.getSubListValues()) {
|
||||
Gui::Application::Instance->showViewProvider(subSet.first);
|
||||
|
||||
QString label = make2DLabel(obj, loft->Sections.getSubValues(obj));
|
||||
QString label = make2DLabel(subSet.first, subSet.second);
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(obj->getNameInDocument()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(subSet));
|
||||
ui->listWidgetReferences->addItem(item);
|
||||
}
|
||||
|
||||
@@ -157,7 +159,8 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
else if (selectionMode == refAdd) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(msg.pObjectName));
|
||||
item->setData(Qt::UserRole,
|
||||
QVariant::fromValue(std::make_pair(object, std::vector<std::string>(1, msg.pSubName))));
|
||||
ui->listWidgetReferences->addItem(item);
|
||||
}
|
||||
else if (selectionMode == refRemove) {
|
||||
@@ -243,7 +246,7 @@ void TaskLoftParameters::onDeleteSection()
|
||||
int row = ui->listWidgetReferences->currentRow();
|
||||
QListWidgetItem* item = ui->listWidgetReferences->takeItem(row);
|
||||
if (item) {
|
||||
QByteArray data = item->data(Qt::UserRole).toByteArray();
|
||||
QByteArray data(item->data(Qt::UserRole).value<App::PropertyLinkSubList::SubSet>().first->getNameInDocument());
|
||||
delete item;
|
||||
|
||||
// search inside the list of sections
|
||||
@@ -270,17 +273,16 @@ void TaskLoftParameters::indexesMoved()
|
||||
return;
|
||||
|
||||
PartDesign::Loft* loft = static_cast<PartDesign::Loft*>(vp->getObject());
|
||||
std::vector<App::DocumentObject*> originals = loft->Sections.getValues();
|
||||
auto originals = loft->Sections.getSubListValues();
|
||||
|
||||
QByteArray name;
|
||||
int rows = model->rowCount();
|
||||
for (int i = 0; i < rows; i++) {
|
||||
QModelIndex index = model->index(i, 0);
|
||||
name = index.data(Qt::UserRole).toByteArray().constData();
|
||||
originals[i] = loft->getDocument()->getObject(name.constData());
|
||||
originals[i] = index.data(Qt::UserRole).value<App::PropertyLinkSubList::SubSet>();
|
||||
}
|
||||
|
||||
loft->Sections.setValues(originals);
|
||||
loft->Sections.setSubListValues(originals);
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#include "Utils.h"
|
||||
#include "TaskFeaturePick.h"
|
||||
|
||||
Q_DECLARE_METATYPE(App::PropertyLinkSubList::SubSet);
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
@@ -540,21 +542,26 @@ bool TaskPipeParameters::accept()
|
||||
copies.push_back(pcPipe->AuxillerySpine.getValue());
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
std::vector<App::PropertyLinkSubList::SubSet> subSets;
|
||||
int index = 0;
|
||||
for (App::DocumentObject* obj : pcPipe->Sections.getValues()) {
|
||||
if (!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
|
||||
objs.push_back(PartDesignGui::TaskFeaturePick::makeCopy(obj, "", dlg.radioIndependent->isChecked()));
|
||||
copies.push_back(objs.back());
|
||||
for (auto &subSet : pcPipe->Sections.getSubListValues()) {
|
||||
if (!pcActiveBody->hasObject(subSet.first) &&
|
||||
!pcActiveBody->getOrigin()->hasObject(subSet.first)) {
|
||||
subSets.push_back(
|
||||
std::make_pair(
|
||||
PartDesignGui::TaskFeaturePick::makeCopy(
|
||||
subSet.first, "", dlg.radioIndependent->isChecked()),
|
||||
subSet.second));
|
||||
copies.push_back(subSets.back().first);
|
||||
}
|
||||
else {
|
||||
objs.push_back(obj);
|
||||
subSets.push_back(subSet);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
pcPipe->Sections.setValues(objs);
|
||||
pcPipe->Sections.setSubListValues(subSets);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,12 +941,12 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
|
||||
for (auto obj : pipe->Sections.getValues()) {
|
||||
Gui::Application::Instance->showViewProvider(obj);
|
||||
QString label = make2DLabel(obj, pipe->Sections.getSubValues(obj));
|
||||
for (auto &subSet : pipe->Sections.getSubListValues()) {
|
||||
Gui::Application::Instance->showViewProvider(subSet.first);
|
||||
QString label = make2DLabel(subSet.first, subSet.second);
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(obj->getNameInDocument()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(subSet));
|
||||
ui->listWidgetReferences->addItem(item);
|
||||
}
|
||||
|
||||
@@ -1022,7 +1029,8 @@ void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg)
|
||||
if (selectionMode == refAdd) {
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(label);
|
||||
item->setData(Qt::UserRole, QByteArray(msg.pObjectName));
|
||||
item->setData(Qt::UserRole,
|
||||
QVariant::fromValue(std::make_pair(object, std::vector<std::string>(1, msg.pSubName))));
|
||||
ui->listWidgetReferences->addItem(item);
|
||||
}
|
||||
else if (selectionMode == refRemove) {
|
||||
@@ -1098,7 +1106,7 @@ void TaskPipeScaling::onDeleteSection()
|
||||
int row = ui->listWidgetReferences->currentRow();
|
||||
QListWidgetItem* item = ui->listWidgetReferences->takeItem(row);
|
||||
if (item) {
|
||||
QByteArray data = item->data(Qt::UserRole).toByteArray();
|
||||
QByteArray data(item->data(Qt::UserRole).value<App::PropertyLinkSubList::SubSet>().first->getNameInDocument());
|
||||
delete item;
|
||||
|
||||
// search inside the list of sections
|
||||
|
||||
Reference in New Issue
Block a user