From 7d392d120906111247ecb3ab406f6aa91c658d59 Mon Sep 17 00:00:00 2001 From: mwganson Date: Wed, 29 Jul 2020 22:38:23 -0500 Subject: [PATCH] [Part Design] allow for preselecting loft sections and pipe spines prior to invoking command --- src/Mod/PartDesign/Gui/Command.cpp | 34 ++++++++++++++++++- src/Mod/PartDesign/Gui/TaskLoftParameters.cpp | 3 ++ src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 8 +++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 79d7b8969f..2ca71fec62 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -1004,7 +1004,39 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons for (auto &s : subs) ss << "'" << s << "',"; FCMD_OBJ_CMD(Feat,"Profile = (" << objCmd << ", [" << ss.str() << "])"); - } + } + + //for additive and subtractive lofts allow the user to preselect the sections + if (which.compare("AdditiveLoft") == 0 || which.compare("SubtractiveLoft") == 0){ + std::vector selection = cmd->getSelection().getSelectionEx(); + if (selection.size()>1){ //treat additional selected objects as sections + for (std::vector::size_type ii = 1; ii != selection.size(); ii++){ + if (selection[ii].getObject()->isDerivedFrom(Part::Part2DObject::getClassTypeId())){ + auto objCmdSection = Gui::Command::getObjectCmd(selection[ii].getObject()); + FCMD_OBJ_CMD(Feat,"Sections += [" << objCmdSection << "]"); + } + } + } + } + + // for additive and subtractive pipes allow the user to preselect the spines + if (which.compare("AdditivePipe") == 0 || which.compare("SubtractivePipe") == 0){ + std::vector selection = cmd->getSelection().getSelectionEx(); + if (selection.size()==2){ //treat additional selected object as spine + std::vector subnames = selection[1].getSubNames(); + auto objCmdSpine = Gui::Command::getObjectCmd(selection[1].getObject()); + if(selection[1].getObject()->isDerivedFrom(Part::Part2DObject::getClassTypeId()) && subnames.empty()){ + FCMD_OBJ_CMD(Feat,"Spine = " << objCmdSpine); + } else { + std::ostringstream ss; + for(auto &s : subnames){ + if(s.find("Edge") != std::string::npos) + ss << "'" << s << "',"; + } + FCMD_OBJ_CMD(Feat,"Spine = (" << objCmdSpine << ", [" << ss.str() << "])"); + } + } + } func(static_cast(feature), Feat); }; diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 21cfccd6a8..5dd3637c84 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -108,6 +108,9 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool /*newObj* item->setData(Qt::UserRole, QByteArray(obj->getNameInDocument())); ui->listWidgetReferences->addItem(item); } + if (loft->Sections.getValues().size()>0){ + static_cast(vp)->makeTemporaryVisible(true); + } // activate and de-activate dialog elements as appropriate for (QWidget* child : proxy->findChildren()) diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 1f939ca24a..0a6da45849 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -112,7 +112,9 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj std::vector strings = pipe->Spine.getSubValues(); for (std::vector::const_iterator it = strings.begin(); it != strings.end(); ++it) ui->listWidgetReferences->addItem(QString::fromStdString(*it)); - + if(strings.size()>0){ + static_cast(vp)->makeTemporaryVisible(true); + } ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue()); updateUI(); @@ -132,7 +134,9 @@ TaskPipeParameters::~TaskPipeParameters() svp->setVisible(spineShow); spineShow = false; } - + //setting visibility to true is needed when preselecting profile and path prior to invoking sweep + std::string pipeName = pipe->getNameInDocument(); + Gui::Command::doCommand(Gui::Command::Gui,"App.ActiveDocument.%s.ViewObject.Visibility=True",pipeName.c_str()); static_cast(vp)->highlightReferences(false, false); } }