Merge pull request #5163 from donovaly/PD-sweep-section-visibility2

[PD] fix sweep visibility bug
This commit is contained in:
Chris Hennes
2021-11-10 22:43:49 -06:00
committed by GitHub
2 changed files with 36 additions and 21 deletions

View File

@@ -108,20 +108,23 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
Gui::Document* doc = PipeView->getDocument();
//make sure the user sees all important things: the
//spine/auxiliary spine he already selected
// make sure the user sees all important things and load the values
// also save visibility state to reset it later when pipe is closes
// first the spine
if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
spineShow = svp->isShow();
svp->setVisible(true);
}
//add initial values
if (pipe->Profile.getValue())
ui->profileBaseEdit->setText(make2DLabel(pipe->Profile.getValue(), pipe->Profile.getSubValues()));
if (pipe->Spine.getValue())
auto* spineVP = doc->getViewProvider(pipe->Spine.getValue());
spineShow = spineVP->isShow();
spineVP->setVisible(true);
ui->spineBaseEdit->setText(QString::fromUtf8(pipe->Spine.getValue()->Label.getValue()));
}
// the profile
if (pipe->Profile.getValue()) {
auto* profileVP = doc->getViewProvider(pipe->Profile.getValue());
profileShow = profileVP->isShow();
profileVP->setVisible(true);
ui->profileBaseEdit->setText(make2DLabel(pipe->Profile.getValue(), pipe->Profile.getSubValues()));
}
// the spine edges
std::vector<std::string> strings = pipe->Spine.getSubValues();
for (std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it) {
QString label = QString::fromStdString(*it);
@@ -147,15 +150,19 @@ TaskPipeParameters::~TaskPipeParameters()
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
//make sure the user sees all important things: the
//spine/auxiliary spine he already selected
// set visibility to the state when the pipe was opened
if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
svp->setVisible(spineShow);
auto* spineVP = doc->getViewProvider(pipe->Spine.getValue());
spineVP->setVisible(spineShow);
spineShow = false;
}
if (pipe->Profile.getValue()) {
auto* profileVP = doc->getViewProvider(pipe->Profile.getValue());
profileVP->setVisible(profileShow);
profileShow = false;
}
//setting visibility to true is needed when preselecting profile and path prior to invoking sweep
// setting visibility to true is needed when preselecting profile and path prior to invoking sweep
Gui::cmdGuiObject(pipe, "Visibility = True");
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
}
@@ -387,7 +394,8 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const
// hide the old or new profile again
auto* pvp = doc->getViewProvider(pipe->Profile.getValue());
if (pvp) pvp->setVisible(false);
if (pvp)
pvp->setVisible(false);
}
return success;
}
@@ -944,6 +952,12 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW
TaskPipeScaling::~TaskPipeScaling()
{
if (vp) {
// hide all sections on closing to be consistent with the spine and profile
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
for (auto obj : pipe->Sections.getValues())
Gui::Application::Instance->hideViewProvider(obj);
}
}
void TaskPipeScaling::clearButtons(const selectionModes notThis)

View File

@@ -53,7 +53,7 @@ class TaskPipeParameters : public TaskSketchBasedParameters
Q_OBJECT
public:
TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0);
TaskPipeParameters(ViewProviderPipe *PipeView, bool newObj=false, QWidget *parent = 0);
~TaskPipeParameters();
bool accept();
@@ -84,7 +84,8 @@ private:
{ return static_cast<ViewProviderPipe*>(vp); }
bool spineShow = false;
bool profileShow = false;
private:
QWidget* proxy;
std::unique_ptr<Ui_TaskPipeParameters> ui;
@@ -95,7 +96,7 @@ class TaskPipeOrientation : public TaskSketchBasedParameters
Q_OBJECT
public:
TaskPipeOrientation(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0);
TaskPipeOrientation(ViewProviderPipe *PipeView, bool newObj=false, QWidget *parent = 0);
virtual ~TaskPipeOrientation();