Sketcher: redefine filters and groups of filters

================================================

Filters redefined to match:
https://forum.freecadweb.org/viewtopic.php?p=537777#p537777

Group "Datum" stops comprising group "Reference"

Datums+References are now selectable as a multi-filter.

Fixes the akward behaviour of multiselection:
https://forum.freecadweb.org/viewtopic.php?p=537722#p537722

Now when a selection of a filter causes a group of filters comprising the selection to be fulfiled, this is also checked.
This commit is contained in:
Abdullah Tahiri
2021-10-04 16:25:55 +02:00
parent 5715ceb728
commit a4192448a9
3 changed files with 35 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ namespace ConstraintFilter {
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::Datums | 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::Coincident, // Coincident = Just this (5)

View File

@@ -93,15 +93,43 @@ void ConstraintMultiFilterDialog::on_listMultiFilter_itemChanged(QListWidgetItem
{
int filterindex = ui->listMultiFilter->row(item);
auto aggregate = filterAggregates[filterindex];
auto itemAggregate = 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);
for(int i = 0; i < ui->listMultiFilter->count(); i++) {
// any filter comprised on the filter of the activated item, gets the same check state
if(itemAggregate[i])
ui->listMultiFilter->item(i)->setCheckState(item->checkState());
// if unchecking, in addition uncheck any group comprising the unchecked item
if(item->checkState() == Qt::Unchecked) {
if(filterAggregates[i][filterindex])
ui->listMultiFilter->item(i)->setCheckState(Qt::Unchecked);
}
}
// Now that all filters are correctly updated to match dependencies,
// if checking, in addition check any group comprising all items that are checked, and check it if all checked.
if(item->checkState() == Qt::Checked) {
for(int i = 0; i < ui->listMultiFilter->count(); i++) {
if(filterAggregates[i][filterindex]) { // only for groups comprising the changed filter
bool mustBeChecked = true;
for(int j = 0; j < FilterValue::NumFilterValue; j++) {
if (i == j)
continue;
if (filterAggregates[i][j]) // if it is in group
mustBeChecked = mustBeChecked && ui->listMultiFilter->item(j)->checkState() == Qt::Checked;
}
if(mustBeChecked)
ui->listMultiFilter->item(i)->setCheckState(Qt::Checked);
}
}
}
ui->listMultiFilter->blockSignals(false);
}

View File

@@ -1125,7 +1125,7 @@ bool TaskSketcherConstrains::isConstraintFiltered(QListWidgetItem * item)
bool visible = true;
bool showAll = (Filter == FilterValue::All);
bool showGeometric = (Filter == FilterValue::Geometric);
bool showDatums = (Filter == FilterValue::Datums);
bool showDatums = (Filter == FilterValue::Datums && constraint->isDriving);
bool showNamed = (Filter == FilterValue::Named && !(constraint->Name.empty()));
bool showNonDriving = (Filter == FilterValue::NonDriving && !constraint->isDriving);