diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index 76c6cc73b2..4ebb8bdc97 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -679,6 +679,14 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView) : ui->extendedInformation, SIGNAL(stateChanged(int)), this , SLOT (on_extendedInformation_stateChanged(int)) ); + QObject::connect( + ui->showAllButton, SIGNAL(clicked(bool)), + this , SLOT (on_showAllButton_clicked(bool)) + ); + QObject::connect( + ui->hideAllButton, SIGNAL(clicked(bool)), + this , SLOT (on_hideAllButton_clicked(bool)) + ); connectionConstraintsChanged = sketchView->signalConstraintsChanged.connect( boost::bind(&SketcherGui::TaskSketcherConstrains::slotConstraintsChanged, this)); @@ -698,6 +706,62 @@ TaskSketcherConstrains::~TaskSketcherConstrains() connectionConstraintsChanged.disconnect(); } +void TaskSketcherConstrains::changeFilteredVisibility(bool show) +{ + assert(sketchView); + const Sketcher::SketchObject * sketch = sketchView->getSketchObject(); + + bool doCommit = false; + + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update constraint's virtual space")); + + for(int i = 0; i < ui->listWidgetConstraints->count(); ++i) + { + QListWidgetItem* item = ui->listWidgetConstraints->item(i); + + if(!item->isHidden()) { // The item is shown in the filtered list + const ConstraintItem *it = dynamic_cast(item); + + if (!it) + continue; + + // must change state is shown and is to be hidden or hidden and must change state is shown + if((it->isInVirtualSpace() == sketchView->getIsShownVirtualSpace() && !show) || + (it->isInVirtualSpace() != sketchView->getIsShownVirtualSpace() && show)) { + + + try { + Gui::cmdAppObjectArgs(sketch, "setVirtualSpace(%d, %s)", + it->ConstraintNbr, + show?"False":"True"); + + doCommit = true; + } + catch (const Base::Exception & e) { + Gui::Command::abortCommand(); + + QMessageBox::critical(Gui::MainWindow::getInstance(), tr("Error"), + QString::fromLatin1("Impossible to update visibility tracking"), QMessageBox::Ok, QMessageBox::Ok); + + return; + } + } + } + } + + if(doCommit) + Gui::Command::commitCommand(); +} + +void TaskSketcherConstrains::on_showAllButton_clicked(bool) +{ + changeFilteredVisibility(true); +} +void TaskSketcherConstrains::on_hideAllButton_clicked(bool) +{ + changeFilteredVisibility(false); +} + void TaskSketcherConstrains::onSelectionChanged(const Gui::SelectionChanges& msg) { std::string temp; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h index efcafbc9fc..e0f2fd6d5c 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h @@ -109,6 +109,7 @@ private: void slotConstraintsChanged(void); bool isConstraintFiltered(QListWidgetItem * item); void change3DViewVisibilityToTrackFilter(); + void changeFilteredVisibility(bool show); public Q_SLOTS: void on_comboBoxFilter_currentIndexChanged(int); @@ -120,6 +121,8 @@ public Q_SLOTS: void on_listWidgetConstraints_emitCenterSelectedItems(void); void on_filterInternalAlignment_stateChanged(int state); void on_extendedInformation_stateChanged(int state); + void on_showAllButton_clicked(bool); + void on_hideAllButton_clicked(bool); protected: void changeEvent(QEvent *e); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui index 72111ff806..11bfdaf064 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui @@ -6,7 +6,7 @@ 0 0 - 234 + 299 388 @@ -167,7 +167,7 @@ - + 0 0 @@ -182,8 +182,102 @@ - 1 + 0 + + + + 0 + 0 + + + + View + + + + + 10 + 10 + 125 + 27 + + + + + 0 + 0 + + + + Shows all the constraints in the list + + + Show All + + + + + + 140 + 10 + 125 + 27 + + + + + 0 + 0 + + + + Hides all the constraints in the list + + + Hide All + + + + + + Controls visualisation in the 3D view + + + Automation + + + + + 0 + 0 + 189 + 36 + + + + + 0 + 0 + + + + Constraint visualisation tracks filter selection so that filtered out constraints are hidden + + + Track filter selection + + + false + + + VisualisationTrackingFilter + + + Mod/Sketcher + + + @@ -201,7 +295,7 @@ Controls widget list behaviour - List control + List @@ -266,45 +360,6 @@ - - - Controls visualisation in the 3D view - - - Visualisation - - - - - 0 - 0 - 189 - 36 - - - - - 0 - 0 - - - - Constraint visualisation tracks filter selection so that filtered out constraints are hidden - - - Track filter selection - - - false - - - VisualisationTrackingFilter - - - Mod/Sketcher - - -