From 525a44905a280bb781e35e2d8e0410a30db89ab1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 20 Sep 2018 15:14:33 +0200 Subject: [PATCH] issue #0003599: PartDesign Additive and Subtractive Pipe features don't allow changing sections after creation --- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 2fe83ad9da..058a9de7a6 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -28,6 +28,8 @@ # include # include # include +# include +# include # include #endif @@ -533,9 +535,9 @@ void TaskPipeOrientation::updateUI(int idx) { // Task Scaling //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QWidget* parent) - : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Additive_Pipe", tr("Section transformation")) { - - // we need a separate container widget to add all controls to + : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Additive_Pipe", tr("Section transformation")) +{ + // we need a separate container widget to add all controls to proxy = new QWidget(this); ui = new Ui_TaskPipeScaling(); ui->setupUi(proxy); @@ -549,13 +551,21 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW this, SLOT(onButtonRefRemove(bool))); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(updateUI(int))); - + this->groupLayout()->addWidget(proxy); - + PartDesign::Pipe* pipe = static_cast(PipeView->getObject()); + const std::vector& sections = pipe->Sections.getValues(); + for (auto it : sections) { + QString label = QString::fromUtf8(it->Label.getValue()); + ui->listWidgetReferences->addItem(label); + } + ui->comboBoxScaling->setCurrentIndex(pipe->Transformation.getValue()); - - updateUI(pipe->Mode.getValue()); + + // should be called after panel has become visible + QMetaObject::invokeMethod(this, "updateUI", Qt::QueuedConnection, + QGenericReturnArgument(), Q_ARG(int,pipe->Transformation.getValue())); } TaskPipeScaling::~TaskPipeScaling() { @@ -577,7 +587,7 @@ void TaskPipeScaling::exitSelectionMode() { void TaskPipeScaling::onButtonRefAdd(bool checked) { if (checked) { - Gui::Selection().clearSelection(); + Gui::Selection().clearSelection(); selectionMode = refAdd; //static_cast(vp)->highlightReferences(true, true); } @@ -586,7 +596,7 @@ void TaskPipeScaling::onButtonRefAdd(bool checked) { void TaskPipeScaling::onButtonRefRemove(bool checked) { if (checked) { - Gui::Selection().clearSelection(); + Gui::Selection().clearSelection(); selectionMode = refRemove; //static_cast(vp)->highlightReferences(true, true); } @@ -605,20 +615,22 @@ void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) { if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { - if (selectionMode == refAdd) { - QString objn = QString::fromStdString(msg.pObjectName); - if(!objn.isEmpty()) - ui->listWidgetReferences->addItem(objn); - } - else if (selectionMode == refRemove) { - QString objn = QString::fromStdString(msg.pObjectName); - if(!objn.isEmpty()) - removeFromListWidget(ui->listWidgetReferences, objn); + 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()); + if (selectionMode == refAdd) { + ui->listWidgetReferences->addItem(label); + } + else if (selectionMode == refRemove) { + removeFromListWidget(ui->listWidgetReferences, label); + } } + clearButtons(); //static_cast(vp)->highlightReferences(false, true); recomputeFeature(); - } + } clearButtons(); exitSelectionMode(); } @@ -626,7 +638,6 @@ void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) { bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const { - if ((msg.Type == Gui::SelectionChanges::AddSelection) && ( (selectionMode == refAdd) || (selectionMode == refRemove))) { @@ -637,10 +648,10 @@ bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const { const char* fname = vp->getObject()->getNameInDocument(); if (strcmp(msg.pObjectName, fname) == 0) return false; - + //every selection needs to be a profile in itself, hence currently only full objects are //supported, not individual edges of a part - + //change the references std::vector refs = static_cast(vp->getObject())->Sections.getValues(); App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(msg.pObjectName);