Sketcher: Show All and Hide All buttons on Constraint Widget

This commit is contained in:
Abdullah Tahiri
2021-09-21 16:51:56 +02:00
parent 3e644ed2af
commit 6343836689
3 changed files with 165 additions and 43 deletions

View File

@@ -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<const ConstraintItem*>(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;

View File

@@ -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);

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>234</width>
<width>299</width>
<height>388</height>
</rect>
</property>
@@ -167,7 +167,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -182,8 +182,102 @@
<string/>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="visualisationTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>View</string>
</attribute>
<widget class="QPushButton" name="showAllButton">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>125</width>
<height>27</height>
</rect>
</property>
<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>Show All</string>
</property>
</widget>
<widget class="QPushButton" name="hideAllButton">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>125</width>
<height>27</height>
</rect>
</property>
<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>Hide All</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="automationTab">
<property name="toolTip">
<string>Controls visualisation in the 3D view</string>
</property>
<attribute name="title">
<string>Automation</string>
</attribute>
<widget class="Gui::PrefCheckBox" name="visualisationTrackingFilter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>189</width>
<height>36</height>
</rect>
</property>
<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>Track filter selection</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>
</widget>
<widget class="QWidget" name="controlTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
@@ -201,7 +295,7 @@
<string>Controls widget list behaviour</string>
</property>
<attribute name="title">
<string>List control</string>
<string>List</string>
</attribute>
<widget class="Gui::PrefCheckBox" name="extendedInformation">
<property name="geometry">
@@ -266,45 +360,6 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="visualisationTab">
<property name="toolTip">
<string>Controls visualisation in the 3D view</string>
</property>
<attribute name="title">
<string>Visualisation</string>
</attribute>
<widget class="Gui::PrefCheckBox" name="visualisationTrackingFilter">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>189</width>
<height>36</height>
</rect>
</property>
<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>Track filter selection</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>
</widget>
</widget>
</item>
<item>