SKETCHER: Constraint widget rework (issue 7518)

see https://forum.freecadweb.org/viewtopic.php?f=34&t=71595&start=20
This commit is contained in:
Paddle
2022-11-17 07:30:58 +01:00
committed by Uwe
parent 8ba310fd3a
commit 398deb2f5b
11 changed files with 640 additions and 1584 deletions

View File

@@ -42,8 +42,6 @@ set(SketcherGui_UIC_SRCS
SketcherSettingsDisplay.ui
SketchRectangularArrayDialog.ui
SketcherRegularPolygonDialog.ui
ConstraintMultiFilterDialog.ui
ConstraintSettingsDialog.ui
)
SET(SketcherGui_SRCS
@@ -145,10 +143,6 @@ SET(SketcherGui_SRCS
SketchRectangularArrayDialog.cpp
SketcherRegularPolygonDialog.h
SketcherRegularPolygonDialog.cpp
ConstraintMultiFilterDialog.h
ConstraintMultiFilterDialog.cpp
ConstraintSettingsDialog.h
ConstraintSettingsDialog.cpp
TaskDlgEditSketch.cpp
TaskDlgEditSketch.h
ViewProviderPython.cpp

View File

@@ -39,27 +39,27 @@ namespace ConstraintFilter {
enum class FilterValue {
All = 0,
Geometric = 1,
Datums = 2,
Named = 3,
NonDriving = 4,
Coincident = 5,
PointOnObject = 6,
Vertical = 7,
Horizontal = 8,
Parallel = 9,
Perpendicular = 10,
Tangent = 11,
Equality = 12,
Symmetric = 13,
Block = 14,
HorizontalDistance = 15,
VerticalDistance = 16,
Distance = 17,
Radius = 18,
Weight = 19,
Diameter = 20,
Angle = 21,
SnellsLaw = 22,
Coincident = 2,
PointOnObject = 3,
Vertical = 4,
Horizontal = 5,
Parallel = 6,
Perpendicular = 7,
Tangent = 8,
Equality = 9,
Symmetric = 10,
Block = 11,
Datums = 12,
HorizontalDistance = 13,
VerticalDistance = 14,
Distance = 15,
Radius = 16,
Weight = 17,
Diameter = 18,
Angle = 19,
SnellsLaw = 20,
Named = 21,
NonDriving = 22,
InternalAlignment = 23,
NumFilterValue // SpecialFilterValue shall start at the same index as this
};
@@ -67,9 +67,8 @@ namespace ConstraintFilter {
constexpr auto FilterValueLength = static_cast<std::underlying_type_t<FilterValue>>(FilterValue::NumFilterValue);
enum class SpecialFilterValue {
Multiple = FilterValueLength, // = 24
Selection, // = 25
AssociatedConstraints, // = 26
Selection = FilterValueLength, // = 24
AssociatedConstraints, // = 25
NumSpecialFilterValue
};
@@ -84,15 +83,6 @@ namespace ConstraintFilter {
return static_cast<std::underlying_type_t<T>>(filterValue);
}
/// Helper function to test whether a provided integral value corresponds to the provided filter value
template <typename T>
inline bool isFilterMatch(T filterValue, std::underlying_type_t<T> integralTypeValue) {
auto underlyingFilterValue = static_cast<std::underlying_type_t<T>>(filterValue);
return (underlyingFilterValue == integralTypeValue);
}
/// Helper function to test whether a FilterValue value is set in a FilterValueBitset
inline bool checkFilterBitset(FilterValueBitset set, FilterValue filter)
{
@@ -111,36 +101,42 @@ namespace ConstraintFilter {
/// Array of FilterValue bit sets of size of the number of FilterValues indicating for each FilterValue, which other
/// FilterValues are comprised therein. It defines the dependencies between filters.
constexpr std::array< FilterValueBitset, FilterValueLength> filterAggregates {
buildBitset(FilterValue::All, FilterValue::Geometric, FilterValue::Datums, FilterValue::Named, FilterValue::NonDriving, FilterValue::Horizontal,
buildBitset(FilterValue::All, FilterValue::Geometric, FilterValue::Horizontal,
FilterValue::Vertical, FilterValue::Coincident, FilterValue::PointOnObject, FilterValue::Parallel, FilterValue::Perpendicular,
FilterValue::Tangent, FilterValue::Equality, FilterValue::Symmetric, FilterValue::Block, FilterValue::Distance,
FilterValue::Tangent, FilterValue::Equality, FilterValue::Symmetric, FilterValue::Block, FilterValue::Datums, FilterValue::Distance,
FilterValue::HorizontalDistance, FilterValue::VerticalDistance, FilterValue::Radius, FilterValue::Weight, FilterValue::Diameter,
FilterValue::Angle, FilterValue::SnellsLaw, FilterValue::InternalAlignment), // All = All other groups are covered (0)
FilterValue::Angle, FilterValue::SnellsLaw, FilterValue::Named, FilterValue::NonDriving, FilterValue::InternalAlignment), // All = All other groups are covered (0)
buildBitset(FilterValue::Geometric, FilterValue::Horizontal, FilterValue::Vertical, FilterValue::Coincident, FilterValue::PointOnObject,
FilterValue::Parallel, FilterValue::Perpendicular, FilterValue::Tangent, FilterValue::Equality, FilterValue::Symmetric,
FilterValue::Block, FilterValue::InternalAlignment), // Geometric = All others not being datums (1)
buildBitset(FilterValue::Coincident), // Coincident = Just this (2)
buildBitset(FilterValue::PointOnObject), // PointOnObject = Just this (3)
buildBitset(FilterValue::Vertical), // Vertical = Just this (4)
buildBitset(FilterValue::Horizontal), // Horizontal = Just this (5)
buildBitset(FilterValue::Parallel), // Parallel = Just this (6)
buildBitset(FilterValue::Perpendicular), // Perpendicular = Just this (7)
buildBitset(FilterValue::Tangent), // Tangent = Just this (8)
buildBitset(FilterValue::Equality), // Equality = Just this (9)
buildBitset(FilterValue::Symmetric), // Symmetric = Just this (10)
buildBitset(FilterValue::Block), // Block = Just this (11)
buildBitset(FilterValue::Datums, FilterValue::Distance, FilterValue::HorizontalDistance, FilterValue::VerticalDistance, FilterValue::Radius,
FilterValue::Weight, FilterValue::Diameter, FilterValue::Angle, FilterValue::SnellsLaw), // Datum = all others not being geometric (2)
buildBitset(FilterValue::Named), // Named = Just this (3)
buildBitset(FilterValue::NonDriving), // NonDriving = Just this (4)
buildBitset(FilterValue::Coincident), // Coincident = Just this (5)
buildBitset(FilterValue::PointOnObject), // PointOnObject = Just this (6)
buildBitset(FilterValue::Vertical), // Vertical = Just this (7)
buildBitset(FilterValue::Horizontal), // Horizontal = Just this (8)
buildBitset(FilterValue::Parallel), // Parallel = Just this (9)
buildBitset(FilterValue::Perpendicular), // Perpendicular = Just this (10)
buildBitset(FilterValue::Tangent), // Tangent = Just this (11)
buildBitset(FilterValue::Equality), // Equality = Just this (12)
buildBitset(FilterValue::Symmetric), // Symmetric = Just this (13)
buildBitset(FilterValue::Block), // Block = Just this (14)
buildBitset(FilterValue::HorizontalDistance), // HorizontalDistance = Just this (15)
buildBitset(FilterValue::VerticalDistance), // VerticalDistance = Just this (16)
buildBitset(FilterValue::Distance), // Distance = Just this (17)
buildBitset(FilterValue::Radius), // Radius = Just this (18)
buildBitset(FilterValue::Weight), // Weight = Just this (19)
buildBitset(FilterValue::Diameter), // Diameter = Just this (20)
buildBitset(FilterValue::Angle), // Angle = Just this (21)
buildBitset(FilterValue::SnellsLaw), // SnellsLaw = Just this (22)
FilterValue::Weight, FilterValue::Diameter, FilterValue::Angle, FilterValue::SnellsLaw), // Datum = all others not being geometric (12)
buildBitset(FilterValue::HorizontalDistance), // HorizontalDistance = Just this (13)
buildBitset(FilterValue::VerticalDistance), // VerticalDistance = Just this (14)
buildBitset(FilterValue::Distance), // Distance = Just this (15)
buildBitset(FilterValue::Radius), // Radius = Just this (16)
buildBitset(FilterValue::Weight), // Weight = Just this (17)
buildBitset(FilterValue::Diameter), // Diameter = Just this (18)
buildBitset(FilterValue::Angle), // Angle = Just this (19)
buildBitset(FilterValue::SnellsLaw), // SnellsLaw = Just this (20)
buildBitset(FilterValue::Named), // Named = Just this (21)
buildBitset(FilterValue::NonDriving), // NonDriving = Just this (22)
buildBitset(FilterValue::InternalAlignment) // InternalAlignment = Just this (23)
};

View File

@@ -1,155 +0,0 @@
/***************************************************************************
* Copyright (c) 2021 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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 <QPixmap>
# include <QDialog>
#endif
#include <Gui/BitmapFactory.h>
#include <Gui/MainWindow.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include "ui_ConstraintMultiFilterDialog.h"
#include "ConstraintMultiFilterDialog.h"
using namespace SketcherGui;
ConstraintMultiFilterDialog::ConstraintMultiFilterDialog()
: 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 FilterValueBitset & 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);
}
FilterValueBitset ConstraintMultiFilterDialog::getMultiFilter()
{
FilterValueBitset 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 itemAggregate = filterAggregates[filterindex];
ui->listMultiFilter->blockSignals(true);
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 < FilterValueLength; 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);
}
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"

View File

@@ -1,59 +0,0 @@
/***************************************************************************
* Copyright (c) 2021 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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 <QDialog>
#include "ConstraintFilters.h"
namespace SketcherGui {
using namespace ConstraintFilter;
class Ui_ConstraintMultiFilterDialog;
class ConstraintMultiFilterDialog : public QDialog
{
Q_OBJECT
public:
ConstraintMultiFilterDialog();
~ConstraintMultiFilterDialog() override;
void setMultiFilter(const FilterValueBitset & bitset);
FilterValueBitset 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_ConstraintMultiFilterDialog> ui;
};
}
#endif // SKETCHERGUI_ConstraintMultiFilter_H

View File

@@ -1,255 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SketcherGui::ConstraintMultiFilterDialog</class>
<widget class="QDialog" name="SketcherGui::ConstraintMultiFilterDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Multiple filter selection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Check the filters to aggregate:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listMultiFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="modelColumn">
<number>0</number>
</property>
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Geometric</string>
</property>
</item>
<item>
<property name="text">
<string>Datums</string>
</property>
</item>
<item>
<property name="text">
<string>Named</string>
</property>
</item>
<item>
<property name="text">
<string>Reference</string>
</property>
</item>
<item>
<property name="text">
<string>Coincident</string>
</property>
</item>
<item>
<property name="text">
<string>Point on Object</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Parallel</string>
</property>
</item>
<item>
<property name="text">
<string>Perpendicular</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Equality</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetric</string>
</property>
</item>
<item>
<property name="text">
<string>Block</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Radius</string>
</property>
</item>
<item>
<property name="text">
<string>Weight</string>
</property>
</item>
<item>
<property name="text">
<string>Diameter</string>
</property>
</item>
<item>
<property name="text">
<string>Angle</string>
</property>
</item>
<item>
<property name="text">
<string>Snell's Law</string>
</property>
</item>
<item>
<property name="text">
<string>Internal Alignment</string>
</property>
</item>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QPushButton" name="checkAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Shows all the constraints in the list</string>
</property>
<property name="text">
<string>Check All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="uncheckAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Hides all the constraints in the list</string>
</property>
<property name="text">
<string>Uncheck All</string>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SketcherGui::ConstraintMultiFilterDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SketcherGui::ConstraintMultiFilterDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -1,136 +0,0 @@
/***************************************************************************
* Copyright (c) 2021 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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 <QPixmap>
# include <QDialog>
#endif
#include <Gui/BitmapFactory.h>
#include <Gui/MainWindow.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include <Gui/PrefWidgets.h>
#include "ui_ConstraintSettingsDialog.h"
#include "ConstraintSettingsDialog.h"
using namespace SketcherGui;
ConstraintSettingsDialog::ConstraintSettingsDialog()
: QDialog(Gui::getMainWindow()), ui(new Ui_ConstraintSettingsDialog)
{
ui->setupUi(this);
{ // in case any signal is connected before this
QSignalBlocker block(this);
loadSettings();
snapshotInitialSettings();
}
QObject::connect(
ui->filterInternalAlignment, SIGNAL(stateChanged(int)),
this , SLOT (on_filterInternalAlignment_stateChanged(int))
);
QObject::connect(
ui->extendedInformation, SIGNAL(stateChanged(int)),
this , SLOT (on_extendedInformation_stateChanged(int))
);
QObject::connect(
ui->visualisationTrackingFilter, SIGNAL(stateChanged(int)),
this , SLOT (on_visualisationTrackingFilter_stateChanged(int))
);
}
void ConstraintSettingsDialog::saveSettings()
{
ui->extendedInformation->onSave();
ui->filterInternalAlignment->onSave();
ui->visualisationTrackingFilter->onSave();
}
void ConstraintSettingsDialog::loadSettings()
{
ui->extendedInformation->onRestore();
ui->filterInternalAlignment->onRestore();
ui->visualisationTrackingFilter->onRestore();
}
void ConstraintSettingsDialog::snapshotInitialSettings()
{
auto isChecked = [] (auto prefwidget) {return prefwidget->checkState() == Qt::Checked;};
extendedInformation = isChecked(ui->extendedInformation);
filterInternalAlignment = isChecked(ui->filterInternalAlignment);
visualisationTrackingFilter = isChecked(ui->visualisationTrackingFilter);
}
void ConstraintSettingsDialog::restoreInitialSettings()
{
auto restoreCheck = [] (auto prefwidget, bool initialvalue) {
if( initialvalue != (prefwidget->checkState() == Qt::Checked)) // if the state really changed
initialvalue ? prefwidget->setCheckState(Qt::Checked) : prefwidget->setCheckState(Qt::Unchecked);
};
restoreCheck(ui->extendedInformation, extendedInformation);
restoreCheck(ui->filterInternalAlignment, filterInternalAlignment);
restoreCheck(ui->visualisationTrackingFilter, visualisationTrackingFilter);
}
void ConstraintSettingsDialog::accept()
{
saveSettings();
QDialog::accept();
}
void ConstraintSettingsDialog::reject()
{
restoreInitialSettings();
saveSettings();
QDialog::reject();
}
void ConstraintSettingsDialog::on_filterInternalAlignment_stateChanged(int state)
{
ui->filterInternalAlignment->onSave();
Q_EMIT emit_filterInternalAlignment_stateChanged(state);
}
void ConstraintSettingsDialog::on_visualisationTrackingFilter_stateChanged(int state)
{
ui->visualisationTrackingFilter->onSave();
Q_EMIT emit_visualisationTrackingFilter_stateChanged(state);
}
void ConstraintSettingsDialog::on_extendedInformation_stateChanged(int state)
{
ui->extendedInformation->onSave();
Q_EMIT emit_extendedInformation_stateChanged(state);
}
ConstraintSettingsDialog::~ConstraintSettingsDialog()
{
}
#include "moc_ConstraintSettingsDialog.cpp"

View File

@@ -1,70 +0,0 @@
/***************************************************************************
* Copyright (c) 2021 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
* *
* 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_ConstraintSettingsDialog_H
#define SKETCHERGUI_ConstraintSettingsDialog_H
#include <QDialog>
#include "ConstraintFilters.h"
namespace SketcherGui {
using namespace ConstraintFilter;
class Ui_ConstraintSettingsDialog;
class ConstraintSettingsDialog : public QDialog
{
Q_OBJECT
public:
ConstraintSettingsDialog();
~ConstraintSettingsDialog() override;
Q_SIGNALS:
void emit_filterInternalAlignment_stateChanged(int);
void emit_extendedInformation_stateChanged(int);
void emit_visualisationTrackingFilter_stateChanged(int);
public Q_SLOTS:
void accept() override;
void reject() override;
void on_filterInternalAlignment_stateChanged(int state);
void on_extendedInformation_stateChanged(int state);
void on_visualisationTrackingFilter_stateChanged(int state);
private:
void saveSettings();
void loadSettings();
void snapshotInitialSettings();
void restoreInitialSettings();
private:
std::unique_ptr<Ui_ConstraintSettingsDialog> ui;
bool extendedInformation;
bool filterInternalAlignment;
bool visualisationTrackingFilter;
};
}
#endif // SKETCHERGUI_ConstraintSettingsDialog_H

View File

@@ -1,195 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SketcherGui::ConstraintSettingsDialog</class>
<widget class="QDialog" name="SketcherGui::ConstraintSettingsDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>215</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Constraint widget settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>List control</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="extendedInformation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Extended information will be added to the list</string>
</property>
<property name="text">
<string>Extended information</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ExtendedConstraintInformation</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="filterInternalAlignment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Internal alignments will be hidden</string>
</property>
<property name="text">
<string>Hide internal alignment</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HideInternalAlignment</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>3D view control</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="visualisationTrackingFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Constraint visualisation tracks filter selection so that filtered out constraints are hidden</string>
</property>
<property name="text">
<string>Show only filtered constraints</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>VisualisationTrackingFilter</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SketcherGui::ConstraintSettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SketcherGui::ConstraintSettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,8 @@ class Property;
namespace SketcherGui {
using namespace ConstraintFilter;
class ViewProviderSketch;
class Ui_TaskSketcherConstraints;
@@ -73,6 +75,21 @@ protected Q_SLOTS:
void hideConstraints();
};
class ConstraintFilterList : public QListWidget
{
Q_OBJECT
public:
explicit ConstraintFilterList(QWidget* parent = nullptr);
~ConstraintFilterList() override;
FilterValueBitset getMultiFilter();
int normalFilterCount; //All filters but selected and associated
int selectedFilterIndex;
int associatedFilterIndex;
};
class TaskSketcherConstraints : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
{
Q_OBJECT
@@ -82,6 +99,12 @@ class TaskSketcherConstraints : public Gui::TaskView::TaskBox, public Gui::Selec
Selected
};
enum class SpecialFilterType {
None,
Associated,
Selected
};
public:
explicit TaskSketcherConstraints(ViewProviderSketch *sketchView);
~TaskSketcherConstraints() override;
@@ -89,6 +112,8 @@ public:
/// Observer message from the Selection
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
SpecialFilterType specialFilterMode;
private:
void slotConstraintsChanged();
bool isConstraintFiltered(QListWidgetItem * item);
@@ -97,32 +122,27 @@ private:
void updateSelectionFilter();
void updateAssociatedConstraintsFilter();
void updateList();
void createVisibilityButtonActions();
template <class T>
bool isFilter(T filterValue);
void createFilterButtonActions();
void createSettingButtonActions();
void connectSignals();
void getSelectionGeoId(QString expr, int & geoid, Sketcher::PointPos & pos);
public Q_SLOTS:
void on_comboBoxFilter_currentIndexChanged(int);
void on_listWidgetConstraints_itemSelectionChanged();
void on_listWidgetConstraints_itemActivated(QListWidgetItem *item);
void on_listWidgetConstraints_itemChanged(QListWidgetItem * item);
void on_listWidgetConstraints_updateDrivingStatus(QListWidgetItem *item, bool status);
void on_listWidgetConstraints_updateActiveStatus(QListWidgetItem *item, bool status);
void on_listWidgetConstraints_emitCenterSelectedItems();
void on_filterInternalAlignment_stateChanged(int state);
void on_extendedInformation_stateChanged(int state);
void on_visualisationTrackingFilter_stateChanged(int state);
void on_visibilityButton_trackingaction_changed();
void on_visibilityButton_clicked(bool);
void on_showAllButton_clicked(bool);
void on_hideAllButton_clicked(bool);
void on_listWidgetConstraints_emitShowSelection3DVisibility();
void on_listWidgetConstraints_emitHideSelection3DVisibility();
void on_multipleFilterButton_clicked(bool);
void on_settingsDialogButton_clicked(bool);
void on_filterBox_stateChanged(int val);
void on_showHideButton_clicked(bool);
void on_settings_restrictVisibility_changed();
void on_settings_extendedInformation_changed();
void on_settings_hideInternalAligment_changed();
void on_filterList_itemChanged(QListWidgetItem* item);
protected:
void changeEvent(QEvent *e) override;
@@ -137,6 +157,7 @@ private:
ConstraintFilter::FilterValueBitset multiFilterStatus; // Stores the filters to be aggregated to form the multifilter.
std::vector<unsigned int> selectionFilter; // holds the constraint ids of the selected constraints
std::vector<unsigned int> associatedConstraintsFilter; // holds the constraint ids of the constraints associated with the selected geometry
ConstraintFilterList* filterList;
};
} //namespace SketcherGui

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<height>388</height>
<width>299</width>
<height>350</height>
</rect>
</property>
<property name="sizePolicy">
@@ -19,7 +19,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>388</height>
<height>350</height>
</size>
</property>
<property name="windowTitle">
@@ -27,172 +27,58 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout1">
<item>
<widget class="QLabel" name="label">
<widget class="QCheckBox" name="filterBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Check to toggle filters</string>
</property>
<property name="styleSheet">
<string notr="true">padding-right: 0px; margin-right: 0px</string>
</property>
<property name="text">
<string>Filter:</string>
<string></string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFilter">
<item>
<widget class="QToolButton" name="filterButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<property name="toolTip">
<string>Click to show filters</string>
</property>
<property name="styleSheet">
<string notr="true">padding-left: 0px; margin-left: 0px</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Filters</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Geometric</string>
</property>
</item>
<item>
<property name="text">
<string>Datums</string>
</property>
</item>
<item>
<property name="text">
<string>Named</string>
</property>
</item>
<item>
<property name="text">
<string>Reference</string>
</property>
</item>
<item>
<property name="text">
<string>Coincident</string>
</property>
</item>
<item>
<property name="text">
<string>Point on Object</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Parallel</string>
</property>
</item>
<item>
<property name="text">
<string>Perpendicular</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Equality</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetric</string>
</property>
</item>
<item>
<property name="text">
<string>Block</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Radius</string>
</property>
</item>
<item>
<property name="text">
<string>Weight</string>
</property>
</item>
<item>
<property name="text">
<string>Diameter</string>
</property>
</item>
<item>
<property name="text">
<string>Angle</string>
</property>
</item>
<item>
<property name="text">
<string>Snell's Law</string>
</property>
</item>
<item>
<property name="text">
<string>Internal Alignment</string>
</property>
</item>
<item>
<property name="text">
<string>Multiple Filters</string>
</property>
</item>
<item>
<property name="text">
<string>Selection Filter</string>
</property>
</item>
<item>
<property name="text">
<string>Associated Constraint Filter</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="multipleFilterButton">
<widget class="QPushButton" name="showHideButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -204,17 +90,21 @@
</size>
</property>
<property name="toolTip">
<string>Click to select multiple filters</string>
<string>Show/hide all listed constraints from 3D view. (same as ticking/unticking all listed constraints in list below)</string>
</property>
<property name="text">
<string>Select Multiple</string>
<string/>
</property>
<property name="icon">
<iconset resource="Resources/Sketcher.qrc">
<normaloff>:/icons/Std_ToggleVisibility.svg</normaloff>:/icons/Std_ToggleVisibility.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="settingsDialogButton">
<widget class="QToolButton" name="settingsButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -229,64 +119,9 @@
<iconset resource="Resources/Sketcher.qrc">
<normaloff>:/icons/dialogs/Sketcher_Settings.svg</normaloff>:/icons/dialogs/Sketcher_Settings.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="showAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Shows all the constraints in the list</string>
</property>
<property name="text">
<string>Show Listed</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hideAllButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Hides all the constraints in the list</string>
</property>
<property name="text">
<string>Hide Listed</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="visibilityButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Restricts 3D visibility to the listed elements</string>
</property>
<property name="text">
<string>Restrict Visibility</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
</layout>