[FEM] Use modal add/remove for more constraints (8/??)

Use the previously added superclass `TaskConstraintOnBoundary` for more
constraints where it's usable.

Currently done:
TaskFemConstraintDisplacement
TaskFemConstraintForce
TaskFemConstraintSpring
TaskFemConstraintFluidBoundary
TaskFemConstraintHeatflux
TaskFemConstraintFixed
TaskFemConstraintTemperature
TaskFemConstraintPressure

Too different:
TaskFemConstraintTransform (single selection)
TaskFemConstraintContact (single selection, two fields)
TaskFemConstraintPlaneRotation (single selection)
(Other constraint tasks, which do not use `addToSelection`)
This commit is contained in:
Ajinkya Dahale
2021-10-22 20:51:39 -04:00
committed by Uwe
parent 0aeed0e53b
commit c558fc7195
21 changed files with 162 additions and 45 deletions

View File

@@ -60,7 +60,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintFixed */
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintFixed")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed")
{ //Note change "Fixed" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintFixed();
@@ -96,8 +96,10 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *C
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
updateUI();
}
@@ -244,6 +246,12 @@ void TaskFemConstraintFixed::changeEvent(QEvent *)
{
}
void TaskFemConstraintFixed::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -31,6 +31,7 @@
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintFixed.h"
#include <QObject>
@@ -40,7 +41,7 @@
class Ui_TaskFemConstraintFixed;
namespace FemGui {
class TaskFemConstraintFixed : public TaskFemConstraint
class TaskFemConstraintFixed : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -57,6 +58,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateUI();

View File

@@ -24,17 +24,23 @@
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -132,7 +132,7 @@ void initComboBox(QComboBox* combo, const std::vector<std::string>& textItems, c
/* TRANSLATOR FemGui::TaskFemConstraintFluidBoundary */
TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintFluidBoundary")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFluidBoundary")
, dimension(-1)
{
// we need a separate container widget to add all controls to
@@ -175,8 +175,10 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemCo
ui->checkReverse->blockSignals(true);
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
// Get the feature data
Fem::ConstraintFluidBoundary* pcConstraint = static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
@@ -557,6 +559,9 @@ void TaskFemConstraintFluidBoundary::onButtonDirection(const bool pressed)
// sets the normal vector of the currently selecteed planar face as direction
Q_UNUSED(pressed)
clearButtons(none);
//get vector of selected objects of active document
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
if (selection.size() == 0) {
@@ -863,6 +868,12 @@ void TaskFemConstraintFluidBoundary::changeEvent(QEvent *e)
}
}
void TaskFemConstraintFluidBoundary::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
//**************************************************************************
// TaskDialog

View File

@@ -31,6 +31,7 @@
#include <Mod/Fem/App/FemSolverObject.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintFluidBoundary.h"
#include <QKeyEvent>
@@ -47,7 +48,7 @@ class ViewProvider;
namespace FemGui {
class TaskFemConstraintFluidBoundary : public TaskFemConstraint
class TaskFemConstraintFluidBoundary : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -92,6 +93,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
virtual void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateBoundaryTypeUI();

View File

@@ -88,17 +88,23 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -70,7 +70,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintForce */
TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintForce")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintForce")
{
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
@@ -128,8 +128,10 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce *C
ui->checkReverse->blockSignals(false);
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
updateUI();
}
@@ -315,6 +317,8 @@ void TaskFemConstraintForce::onButtonDirection(const bool pressed)
// sets the normal vector of the currently selecteed planar face as direction
Q_UNUSED(pressed)
clearButtons(none);
auto link = getDirection(Gui::Selection().getSelectionEx());
if (!link.first) {
QMessageBox::warning(this, tr("Wrong selection"), tr("Select an edge or a face, please."));
@@ -402,6 +406,12 @@ void TaskFemConstraintForce::changeEvent(QEvent *e)
}
}
void TaskFemConstraintForce::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
//**************************************************************************
// TaskDialog

View File

@@ -30,6 +30,7 @@
#include <Gui/TaskView/TaskDialog.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintForce.h"
#include <QKeyEvent>
@@ -47,7 +48,7 @@ class ViewProvider;
namespace FemGui {
class TaskFemConstraintForce : public TaskFemConstraint
class TaskFemConstraintForce : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -71,6 +72,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
virtual void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
std::pair<App::DocumentObject*, std::string> getDirection(const std::vector<Gui::SelectionObject>&) const;

View File

@@ -42,17 +42,23 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@@ -94,7 +100,7 @@
<item>
<layout class="QHBoxLayout" name="layoutDirection">
<item>
<widget class="QPushButton" name="buttonDirection">
<widget class="QToolButton" name="buttonDirection">
<property name="toolTip">
<string>Select a planar edge or face, then press this button</string>
</property>

View File

@@ -59,7 +59,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintHeatflux */
TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHeatflux *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintHeatflux")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintHeatflux")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintHeatflux();
@@ -130,8 +130,10 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(ViewProviderFemConstraintHe
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
ui->if_ambienttemp->blockSignals(false);
//ui->if_facetemp->blockSignals(false);
@@ -375,6 +377,12 @@ void TaskFemConstraintHeatflux::changeEvent(QEvent *e)
}
}
void TaskFemConstraintHeatflux::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -33,6 +33,7 @@
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintHeatflux.h"
#include <QObject>
@@ -43,7 +44,7 @@
class Ui_TaskFemConstraintHeatflux;
namespace FemGui {
class TaskFemConstraintHeatflux : public TaskFemConstraint
class TaskFemConstraintHeatflux : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -70,6 +71,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
virtual void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateUI();

View File

@@ -24,17 +24,23 @@
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -59,7 +59,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintPressure */
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintPressure")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintPressure")
{ //Note change "pressure" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintPressure();
@@ -105,8 +105,10 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPr
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
updateUI();
}
@@ -261,6 +263,12 @@ void TaskFemConstraintPressure::changeEvent(QEvent *)
{
}
void TaskFemConstraintPressure::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -33,6 +33,7 @@
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintPressure.h"
#include <QObject>
@@ -43,7 +44,7 @@
class Ui_TaskFemConstraintPressure;
namespace FemGui {
class TaskFemConstraintPressure : public TaskFemConstraint
class TaskFemConstraintPressure : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -63,6 +64,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateUI();

View File

@@ -24,17 +24,23 @@
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -59,8 +59,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintSpring */
TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring *ConstraintView, QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintSpring")
{
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintSpring")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintSpring();
ui->setupUi(proxy);
@@ -95,7 +95,7 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
ui->if_tan->setMaximum(FLOAT_MAX);
Base::Quantity ts = Base::Quantity((pcConstraint->tangentialStiffness.getValue()), Base::Unit::Stiffness);
ui->if_tan->setValue(ts);
/* */
ui->lw_references->clear();
@@ -107,8 +107,10 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
updateUI();
}
@@ -261,6 +263,12 @@ void TaskFemConstraintSpring::changeEvent(QEvent *)
{
}
void TaskFemConstraintSpring::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -31,6 +31,7 @@
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintSpring.h"
#include <QObject>
@@ -41,7 +42,7 @@
class Ui_TaskFemConstraintSpring;
namespace FemGui {
class TaskFemConstraintSpring : public TaskFemConstraint
class TaskFemConstraintSpring : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -60,6 +61,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateUI();

View File

@@ -24,17 +24,23 @@
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@@ -61,7 +61,7 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintTemperature */
TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstraintTemperature *ConstraintView,QWidget *parent)
: TaskFemConstraint(ConstraintView, parent, "FEM_ConstraintTemperature")
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintTemperature")
{
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintTemperature();
@@ -120,8 +120,10 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(ViewProviderFemConstr
}
//Selection buttons
connect(ui->btnAdd, SIGNAL(clicked()), this, SLOT(addToSelection()));
connect(ui->btnRemove, SIGNAL(clicked()), this, SLOT(removeFromSelection()));
connect(ui->btnAdd, SIGNAL(toggled(bool)),
this, SLOT(_addToSelection(bool)));
connect(ui->btnRemove, SIGNAL(toggled(bool)),
this, SLOT(_removeFromSelection(bool)));
updateUI();
}
@@ -316,6 +318,12 @@ void TaskFemConstraintTemperature::changeEvent(QEvent *)
// }
}
void TaskFemConstraintTemperature::clearButtons(const SelectionChangeModes notThis)
{
if (notThis != refAdd) ui->btnAdd->setChecked(false);
if (notThis != refRemove) ui->btnRemove->setChecked(false);
}
//**************************************************************************
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@@ -33,6 +33,7 @@
#include <Base/Quantity.h>
#include "TaskFemConstraint.h"
#include "TaskFemConstraintOnBoundary.h"
#include "ViewProviderFemConstraintTemperature.h"
#include <QObject>
@@ -43,7 +44,7 @@
class Ui_TaskFemConstraintTemperature;
namespace FemGui {
class TaskFemConstraintTemperature : public TaskFemConstraint
class TaskFemConstraintTemperature : public TaskFemConstraintOnBoundary
{
Q_OBJECT
@@ -66,6 +67,7 @@ private Q_SLOTS:
protected:
bool event(QEvent *e);
void changeEvent(QEvent *e);
void clearButtons(const SelectionChangeModes notThis) override;
private:
void updateUI();

View File

@@ -24,17 +24,23 @@
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QPushButton" name="btnAdd">
<widget class="QToolButton" name="btnAdd">
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<widget class="QToolButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>