[PD] allow to change feature order in patterns

As discussed here: https://forum.freecadweb.org/viewtopic.php?f=27&t=48998#p420352
The pattern dialogs need a feature to change the order of the features to be patterned
This commit is contained in:
donovaly
2020-07-31 03:02:42 +02:00
committed by wwmayer
parent 3600ccae8d
commit d5787f9bda
11 changed files with 92 additions and 3 deletions

View File

@@ -118,6 +118,8 @@ void TaskMirroredParameters::setupUI()
ui->listWidgetFeatures->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onFeatureDeleted()));
ui->listWidgetFeatures->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listWidgetFeatures->model(),
SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), this, SLOT(indexesMoved()));
connect(ui->comboPlane, SIGNAL(activated(int)),
this, SLOT(onPlaneChanged(int)));
@@ -184,6 +186,22 @@ void TaskMirroredParameters::updateUI()
blockUpdate = false;
}
void TaskMirroredParameters::indexesMoved()
{
PartDesign::Transformed* pcTransformed = getObject();
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
// the number of items has not been changed, they have just been reordered
// so we read every list item to recreate the originals vector
std::string name;
for (unsigned i = 0; i < ui->listWidgetFeatures->count(); i++) {
name = ui->listWidgetFeatures->item(i)->data(Qt::UserRole).toByteArray().constData();
originals[i] = pcTransformed->getDocument()->getObject(name.c_str());
}
setupTransaction();
pcTransformed->Originals.setValues(originals);
recomputeFeature();
}
void TaskMirroredParameters::addObject(App::DocumentObject* obj)
{
QString label = QString::fromUtf8(obj->Label.getValue());