From 2f789e6ce79e3bcf5921f509083dc0589b575d50 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 2 Oct 2021 17:43:05 +0200 Subject: [PATCH] Sketcher: Constraint widget Multi Filter feature ================================================ This feature adds a new filter entry "Multiple Filters" in the combobox of the filter. This enables to define a "Multiple Filter" based on the aggregation of individual filters. So it basically provides for a user defined filter based on constraint types. This "Multiple Filter" defaults to "All Constraints", and can be defined using the button "..." next to the filter combobox. The "Multiple Filter" works on the list of constraints, as any other filter, limiting the elements shown in the list to match the multi filter definition. The "Multiple Filter" interacts with the visibility options as any other filter. This is, in visibility non-tracking mode, it does not change the visibility. The Buttons "Hide Listed" and "Show Listed" can be operated in this mode as any other filter. In visibility tracking-mode, it will adapt the visibility of the constraints in the 3D view to the "Multi Filter" definition (exactly as it would to any other filter with its own definition). --- src/Mod/Sketcher/Gui/CMakeLists.txt | 4 + src/Mod/Sketcher/Gui/ConstraintFilters.h | 104 +++++++ .../Gui/ConstraintMultiFilterDialog.cpp | 127 ++++++++ .../Gui/ConstraintMultiFilterDialog.h | 59 ++++ .../Gui/ConstraintMultiFilterDialog.ui | 277 ++++++++++++++++++ .../Sketcher/Gui/TaskSketcherConstrains.cpp | 115 ++++++-- src/Mod/Sketcher/Gui/TaskSketcherConstrains.h | 33 +-- .../Sketcher/Gui/TaskSketcherConstrains.ui | 26 +- 8 files changed, 691 insertions(+), 54 deletions(-) create mode 100644 src/Mod/Sketcher/Gui/ConstraintFilters.h create mode 100644 src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.cpp create mode 100644 src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.h create mode 100644 src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.ui diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index 0f9dafb6f5..2be18fd827 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -46,6 +46,7 @@ set(SketcherGui_UIC_SRCS SketcherSettingsDisplay.ui SketchRectangularArrayDialog.ui SketcherRegularPolygonDialog.ui + ConstraintMultiFilterDialog.ui ) if(BUILD_QT5) @@ -78,6 +79,7 @@ SET(SketcherGui_SRCS PropertyConstraintListItem.cpp TaskSketcherConstrains.ui TaskSketcherConstrains.cpp + ConstraintFilters.h TaskSketcherConstrains.h TaskSketcherElements.ui TaskSketcherElements.cpp @@ -116,6 +118,8 @@ SET(SketcherGui_SRCS SketchRectangularArrayDialog.cpp SketcherRegularPolygonDialog.h SketcherRegularPolygonDialog.cpp + ConstraintMultiFilterDialog.h + ConstraintMultiFilterDialog.cpp TaskDlgEditSketch.cpp TaskDlgEditSketch.h ViewProviderPython.cpp diff --git a/src/Mod/Sketcher/Gui/ConstraintFilters.h b/src/Mod/Sketcher/Gui/ConstraintFilters.h new file mode 100644 index 0000000000..5517592305 --- /dev/null +++ b/src/Mod/Sketcher/Gui/ConstraintFilters.h @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright (c) 2021 Abdullah Tahiri * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef SKETCHERGUI_ConstraintFilters_H +#define SKETCHERGUI_ConstraintFilters_H + +#include +#include + +namespace SketcherGui { + +namespace ConstraintFilter { + + enum FilterValue { + All = 0, + Geometric = 1, + Datums = 2, + Named = 3, + NonDriving = 4, + Horizontal = 5, + Vertical = 6, + Coincident = 7, + PointOnObject = 8, + Parallel = 9, + Perpendicular = 10, + Tangent = 11, + Equality = 12, + Symmetric = 13, + Block = 14, + Distance = 15, + HorizontalDistance = 16, + VerticalDistance = 17, + Radius = 18, + Weight = 19, + Diameter = 20, + Angle = 21, + SnellsLaw = 22, + InternalAlignment = 23, + NumFilterValue + }; + + enum SpecialFilterValue { + Multiple = 24, + NumSpecialFilterValue + }; + + constexpr std::array< std::bitset, FilterValue::NumFilterValue> filterAggregates { + 1 << FilterValue::All | 1 << FilterValue::Geometric | 1 << FilterValue::Datums | 1 << FilterValue::Named | 1 << FilterValue::NonDriving | + 1 << FilterValue::Horizontal | 1 << FilterValue::Vertical | 1 << FilterValue::Coincident | 1 << FilterValue::PointOnObject | + 1 << FilterValue::Parallel | 1 << FilterValue::Perpendicular | 1 << FilterValue::Tangent | 1 << FilterValue::Equality | + 1 << FilterValue::Symmetric | 1 << FilterValue::Block | 1 << FilterValue::Distance | 1 << FilterValue::HorizontalDistance | + 1 << FilterValue::VerticalDistance | 1 << FilterValue::Radius | 1 << FilterValue::Weight | 1 << FilterValue::Diameter | + 1 << FilterValue::Angle | 1 << FilterValue::SnellsLaw | 1 << FilterValue::InternalAlignment, // All = All other groups are covered (0) + 1 << FilterValue::Geometric | 1 << FilterValue::Horizontal | 1 << FilterValue::Vertical | 1 << FilterValue::Coincident | + 1 << FilterValue::PointOnObject | 1 << FilterValue::Parallel | 1 << FilterValue::Perpendicular | 1 << FilterValue::Tangent | + 1 << FilterValue::Equality | 1 << FilterValue::Symmetric | 1 << FilterValue::Block | 1 << FilterValue::InternalAlignment, // Geometric = All others not being datums (1) + 1 << FilterValue::Datums | 1 << FilterValue::NonDriving | 1 << FilterValue::Distance | 1 << FilterValue::HorizontalDistance | 1 << FilterValue::VerticalDistance | 1 << FilterValue::Radius | 1 << FilterValue::Weight | 1 << FilterValue::Diameter | 1 << FilterValue::Angle | 1 << FilterValue::SnellsLaw, // Datum = all others not being geometric (2) + 1 << FilterValue::Named, // Named = Just this (3) + 1 << FilterValue::NonDriving, // NonDriving = Just this (4) + 1 << FilterValue::Horizontal, // Horizontal = Just this (5) + 1 << FilterValue::Vertical, // Vertical = Just this (6) + 1 << FilterValue::Coincident, // Coincident = Just this (7) + 1 << FilterValue::PointOnObject, // PointOnObject = Just this (8) + 1 << FilterValue::Parallel, // Parallel = Just this (9) + 1 << FilterValue::Perpendicular, // Perpendicular = Just this (10) + 1 << FilterValue::Tangent, // Tangent = Just this (11) + 1 << FilterValue::Equality, // Equality = Just this (12) + 1 << FilterValue::Symmetric, // Symmetric = Just this (13) + 1 << FilterValue::Block, // Block = Just this (14) + 1 << FilterValue::Distance, // Distance = Just this (15) + 1 << FilterValue::HorizontalDistance, // HorizontalDistance = Just this (16) + 1 << FilterValue::VerticalDistance, // VerticalDistance = Just this (17) + 1 << FilterValue::Radius, // Radius = Just this (18) + 1 << FilterValue::Weight, // Weight = Just this (19) + 1 << FilterValue::Diameter, // Diameter = Just this (20) + 1 << FilterValue::Angle, // Angle = Just this (21) + 1 << FilterValue::SnellsLaw, // SnellsLaw = Just this (22) + 1 << FilterValue::InternalAlignment, // InternalAlignment = Just this (23) + }; + +} + +} + +#endif // SKETCHERGUI_ConstraintFilters_H diff --git a/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.cpp b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.cpp new file mode 100644 index 0000000000..22e74bc5b8 --- /dev/null +++ b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.cpp @@ -0,0 +1,127 @@ +/*************************************************************************** + * Copyright (c) 2021 Abdullah Tahiri * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" + +#ifndef _PreComp_ +# include +# include +#endif + +#include +#include +#include +#include + +#include "ui_ConstraintMultiFilterDialog.h" +#include "ConstraintMultiFilterDialog.h" + +using namespace SketcherGui; + +ConstraintMultiFilterDialog::ConstraintMultiFilterDialog(void) + : QDialog(Gui::getMainWindow()), ui(new Ui_ConstraintMultiFilterDialog) +{ + ui->setupUi(this); + + // make filter items checkable + ui->listMultiFilter->blockSignals(true); + for(int i = 0; i < ui->listMultiFilter->count(); i++) { + QListWidgetItem* item = ui->listMultiFilter->item(i); + + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + + item->setCheckState(Qt::Unchecked); + } + ui->listMultiFilter->blockSignals(false); + + QMetaObject::connectSlotsByName(this); +} + +ConstraintMultiFilterDialog::~ConstraintMultiFilterDialog() +{ +} + +void ConstraintMultiFilterDialog::setMultiFilter(const std::bitset & bitset) +{ + ui->listMultiFilter->blockSignals(true); + for(int i = 0; i < ui->listMultiFilter->count(); i++) { + QListWidgetItem* item = ui->listMultiFilter->item(i); + + if(bitset[i]) + item->setCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); + } + ui->listMultiFilter->blockSignals(false); +} + +std::bitset ConstraintMultiFilterDialog::getMultiFilter() +{ + std::bitset tmpBitset; + + for(int i = 0; i < ui->listMultiFilter->count(); i++) { + QListWidgetItem* item = ui->listMultiFilter->item(i); + + if(item->checkState() == Qt::Checked) + tmpBitset.set(i); + } + + return tmpBitset; + +} + +void ConstraintMultiFilterDialog::on_listMultiFilter_itemChanged(QListWidgetItem * item) +{ + int filterindex = ui->listMultiFilter->row(item); + + auto aggregate = filterAggregates[filterindex]; + + ui->listMultiFilter->blockSignals(true); + if(item->checkState() == Qt::Checked) { + for(int i = 0; i < ui->listMultiFilter->count(); i++) { + if(aggregate[i]) + ui->listMultiFilter->item(i)->setCheckState(Qt::Checked); + } + } + ui->listMultiFilter->blockSignals(false); +} + +void ConstraintMultiFilterDialog::setCheckStateAll(Qt::CheckState state) +{ + ui->listMultiFilter->blockSignals(true); + for(int i = 0; i < ui->listMultiFilter->count(); i++) { + ui->listMultiFilter->item(i)->setCheckState(state); + } + ui->listMultiFilter->blockSignals(false); +} + +void ConstraintMultiFilterDialog::on_checkAllButton_clicked(bool) +{ + setCheckStateAll(Qt::Checked); +} + +void ConstraintMultiFilterDialog::on_uncheckAllButton_clicked(bool) +{ + setCheckStateAll(Qt::Unchecked); +} + +#include "moc_ConstraintMultiFilterDialog.cpp" diff --git a/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.h b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.h new file mode 100644 index 0000000000..20e8a31212 --- /dev/null +++ b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (c) 2021 Abdullah Tahiri * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef SKETCHERGUI_ConstraintMultiFilter_H +#define SKETCHERGUI_ConstraintMultiFilter_H + +#include + +#include "ConstraintFilters.h" + +namespace SketcherGui { + +using namespace ConstraintFilter; + +class Ui_ConstraintMultiFilterDialog; +class ConstraintMultiFilterDialog : public QDialog +{ + Q_OBJECT + +public: + ConstraintMultiFilterDialog(void); + ~ConstraintMultiFilterDialog(); + + void setMultiFilter(const std::bitset & bitset); + std::bitset getMultiFilter(); + +public Q_SLOTS: + void on_listMultiFilter_itemChanged(QListWidgetItem * item); + void on_checkAllButton_clicked(bool); + void on_uncheckAllButton_clicked(bool); + +protected: + void setCheckStateAll(Qt::CheckState); +private: + std::unique_ptr ui; +}; + +} + +#endif // SKETCHERGUI_ConstraintMultiFilter_H diff --git a/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.ui b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.ui new file mode 100644 index 0000000000..62a7396c33 --- /dev/null +++ b/src/Mod/Sketcher/Gui/ConstraintMultiFilterDialog.ui @@ -0,0 +1,277 @@ + + + SketcherGui::ConstraintMultiFilterDialog + + + Qt::WindowModal + + + + 0 + 0 + 325 + 600 + + + + + 0 + 0 + + + + + 16777215 + 700 + + + + Multiple filter selection + + + + + + Check the filters to aggregate: + + + + + + + + 0 + 0 + + + + + 0 + 500 + + + + QAbstractItemView::NoSelection + + + 0 + + + + All + + + + + Geometric + + + + + Datums + + + + + Named + + + + + Non-Driving + + + + + Horizontal + + + + + Vertical + + + + + Coincident + + + + + Point on Object + + + + + Parallel + + + + + Perpendicular + + + + + Tangent + + + + + Equality + + + + + Symmetric + + + + + Block + + + + + Distance + + + + + Horizontal Distance + + + + + Vertical Distance + + + + + Radius + + + + + Weight + + + + + Diameter + + + + + Angle + + + + + Snell's Law + + + + + Internal Alignment + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + Shows all the constraints in the list + + + Check All + + + + + + + + 0 + 0 + + + + Hides all the constraints in the list + + + Uncheck All + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SketcherGui::ConstraintMultiFilterDialog + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + SketcherGui::ConstraintMultiFilterDialog + reject() + + + 20 + 20 + + + 20 + 20 + + + + + diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index b9234cc4a7..6848c25815 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -33,6 +33,7 @@ # include # include # include +# include # include #endif @@ -56,6 +57,8 @@ #include #include +#include "ConstraintMultiFilterDialog.h" + using namespace SketcherGui; using namespace Gui::TaskView; @@ -691,6 +694,10 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView) : ui->visualisationTrackingFilter, SIGNAL(stateChanged(int)), this , SLOT (on_visualisationTrackingFilter_stateChanged(int)) ); + QObject::connect( + ui->multipleFilterButton, SIGNAL(clicked(bool)), + this , SLOT (on_multipleFilterButton_clicked(bool)) + ); connectionConstraintsChanged = sketchView->signalConstraintsChanged.connect( boost::bind(&SketcherGui::TaskSketcherConstrains::slotConstraintsChanged, this)); @@ -700,6 +707,8 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView) : this->ui->filterInternalAlignment->onRestore(); this->ui->extendedInformation->onRestore(); + multiFilterStatus.set(); // Match 'All' selection, all bits set. + slotConstraintsChanged(); } @@ -710,6 +719,46 @@ TaskSketcherConstrains::~TaskSketcherConstrains() connectionConstraintsChanged.disconnect(); } +void TaskSketcherConstrains::updateMultiFilter() +{ + int filterindex = ui->comboBoxFilter->currentIndex(); + + multiFilterStatus.reset(); + + multiFilterStatus.set(filterindex); +} + +void TaskSketcherConstrains::updateList() +{ + // enforce constraint visibility + bool visibilityTracksFilter = ui->visualisationTrackingFilter->isChecked(); + + if(visibilityTracksFilter) + change3DViewVisibilityToTrackFilter(); // it will call slotConstraintChanged via update mechanism + else + slotConstraintsChanged(); +} + +void TaskSketcherConstrains::on_multipleFilterButton_clicked(bool) +{ + ConstraintMultiFilterDialog mf; + + int filterindex = ui->comboBoxFilter->currentIndex(); + + if(filterindex != ConstraintFilter::SpecialFilterValue::Multiple) { + ui->comboBoxFilter->setCurrentIndex(ConstraintFilter::SpecialFilterValue::Multiple); // Change filter to multi filter selection + } + + mf.setMultiFilter(multiFilterStatus); + + if (mf.exec() == QDialog::Accepted) { + multiFilterStatus = mf.getMultiFilter(); + + // if tracking, it will call slotConstraintChanged via update mechanism as Multi Filter affects not only visibility, but also filtered list content, if not tracking will still update the list to match the multi-filter. + updateList(); + } +} + void TaskSketcherConstrains::changeFilteredVisibility(bool show, ActionTarget target) { assert(sketchView); @@ -846,15 +895,10 @@ void TaskSketcherConstrains::onSelectionChanged(const Gui::SelectionChanges& msg } } + void TaskSketcherConstrains::on_comboBoxFilter_currentIndexChanged(int) { - // enforce constraint visibility - bool visibilityTracksFilter = ui->visualisationTrackingFilter->isChecked(); - - if(visibilityTracksFilter) - change3DViewVisibilityToTrackFilter(); // it will call slotConstraintChanged via update mechanism - else - slotConstraintsChanged(); + updateList(); } void TaskSketcherConstrains::on_filterInternalAlignment_stateChanged(int state) @@ -1087,61 +1131,80 @@ bool TaskSketcherConstrains::isConstraintFiltered(QListWidgetItem * item) switch(constraint->Type) { case Sketcher::Horizontal: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Horizontal); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Horizontal) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Horizontal]); break; case Sketcher::Vertical: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Vertical); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Vertical) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Vertical]); break; case Sketcher::Coincident: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Coincident); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Coincident) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Coincident]); break; case Sketcher::PointOnObject: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::PointOnObject); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::PointOnObject) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::PointOnObject]); break; case Sketcher::Parallel: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Parallel); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Parallel) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Parallel]); break; case Sketcher::Perpendicular: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Perpendicular); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Perpendicular) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Perpendicular]); break; case Sketcher::Tangent: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Tangent); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Tangent) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Tangent]); break; case Sketcher::Equal: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Equality); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Equality) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Equality]); break; case Sketcher::Symmetric: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Symmetric); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Symmetric) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Symmetric]); break; case Sketcher::Block: - visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Block); + visible = showAll || showGeometric || showNamed || (Filter == FilterValue::Block) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Block]); break; case Sketcher::Distance: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Distance); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Distance) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Distance]); break; case Sketcher::DistanceX: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::HorizontalDistance); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::HorizontalDistance) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::HorizontalDistance]); break; case Sketcher::DistanceY: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::VerticalDistance); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::VerticalDistance) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::VerticalDistance]); break; case Sketcher::Radius: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Radius); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Radius) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Radius]); break; case Sketcher::Weight: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Weight); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Weight) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Weight]); break; case Sketcher::Diameter: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Diameter); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Diameter) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Diameter]); break; case Sketcher::Angle: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Angle); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::Angle) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::Angle]); break; case Sketcher::SnellsLaw: - visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::SnellsLaw); + visible = ( showAll || showDatums || showNamed || showNonDriving) || (Filter == FilterValue::SnellsLaw) || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::SnellsLaw]); break; case Sketcher::InternalAlignment: - visible = (( showAll || showGeometric || showNamed || Filter == FilterValue::InternalAlignment) && + visible = (( showAll || showGeometric || showNamed || Filter == FilterValue::InternalAlignment || + (Filter == SpecialFilterValue::Multiple && multiFilterStatus[FilterValue::InternalAlignment])) && (!hideInternalAlignment || (Filter == FilterValue::InternalAlignment))); default: break; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h index 9fccb2f2ef..e4bbebf5bf 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.h @@ -29,6 +29,8 @@ #include #include +#include "ConstraintFilters.h" + namespace App { class Property; } @@ -73,33 +75,6 @@ class TaskSketcherConstrains : public Gui::TaskView::TaskBox, public Gui::Select { Q_OBJECT - enum FilterValue { - All = 0, - Geometric = 1, - Datums = 2, - Named = 3, - NonDriving = 4, - Horizontal = 5, - Vertical = 6, - Coincident = 7, - PointOnObject = 8, - Parallel = 9, - Perpendicular = 10, - Tangent = 11, - Equality = 12, - Symmetric = 13, - Block = 14, - Distance = 15, - HorizontalDistance = 16, - VerticalDistance = 17, - Radius = 18, - Weight = 19, - Diameter = 20, - Angle = 21, - SnellsLaw = 22, - InternalAlignment = 23 - }; - enum class ActionTarget { All, Selected @@ -117,6 +92,8 @@ private: bool isConstraintFiltered(QListWidgetItem * item); void change3DViewVisibilityToTrackFilter(); void changeFilteredVisibility(bool show, ActionTarget target = ActionTarget::All); + void updateMultiFilter(); + void updateList(); public Q_SLOTS: void on_comboBoxFilter_currentIndexChanged(int); @@ -133,6 +110,7 @@ public Q_SLOTS: void on_hideAllButton_clicked(bool); void on_listWidgetConstraints_emitShowSelection3DVisibility(); void on_listWidgetConstraints_emitHideSelection3DVisibility(); + void on_multipleFilterButton_clicked(bool); protected: void changeEvent(QEvent *e); @@ -144,6 +122,7 @@ private: QWidget* proxy; bool inEditMode; std::unique_ptr ui; + std::bitset multiFilterStatus; }; } //namespace SketcherGui diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui index 7232823005..e7a3d82462 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.ui @@ -6,7 +6,7 @@ 0 0 - 319 + 325 388 @@ -160,6 +160,30 @@ Internal Alignment + + + Multiple Filters + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + ... +