FEM: constraint dialogs: sort out commonly used function
additionally remove double code from TaskFemConstraintForce.cpp
This commit is contained in:
committed by
Bernd Hahnebach
parent
f13db9f63a
commit
d19d5b5fce
@@ -135,6 +135,24 @@ const std::string TaskFemConstraint::getScale() const //OvG: Return pre-calculat
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskFemConstraint::setSelection(QListWidgetItem* item) {
|
||||
std::string s = item->text().toStdString();
|
||||
std::string docName = ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName = s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
|
||||
}
|
||||
|
||||
void TaskFemConstraint::onReferenceDeleted(const int row) {
|
||||
Fem::Constraint* pcConstraint = static_cast<Fem::Constraint*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
class QAction;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
|
||||
namespace FemGui {
|
||||
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
protected Q_SLOTS:
|
||||
void onReferenceDeleted(const int row);
|
||||
void onButtonReference(const bool pressed = true);
|
||||
void setSelection(QListWidgetItem* item);
|
||||
// Shaft Wizard integration
|
||||
void onButtonWizOk();
|
||||
void onButtonWizCancel();
|
||||
|
||||
@@ -524,24 +524,6 @@ void TaskFemConstraintDisplacement::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintDisplacement::setSelection(QListWidgetItem* item){
|
||||
std::string s = item->text().toStdString();
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintDisplacement::onReferenceDeleted() {
|
||||
TaskFemConstraintDisplacement::removeFromSelection(); //OvG: On right-click face is automatically selected, so just remove
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintDisplacement;
|
||||
|
||||
@@ -94,7 +93,6 @@ private Q_SLOTS:
|
||||
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -230,24 +230,6 @@ void TaskFemConstraintFixed::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintFixed::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintFixed::onReferenceDeleted() {
|
||||
TaskFemConstraintFixed::removeFromSelection();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <QObject>
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintFixed;
|
||||
|
||||
@@ -52,10 +51,8 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onReferenceDeleted(void);
|
||||
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -845,24 +845,6 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintFluidBoundary::setSelection(QListWidgetItem* item) {
|
||||
std::string s = item->text().toStdString();
|
||||
std::string docName = ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName = s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintFluidBoundary::updateUI()
|
||||
{
|
||||
if (ui->listReferences->model()->rowCount() == 0) {
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "ViewProviderFemConstraintFluidBoundary.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintFluidBoundary;
|
||||
|
||||
@@ -89,7 +88,6 @@ private Q_SLOTS:
|
||||
void onCheckReverse(bool); // consider removing this slot as the UI is hidden
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -257,25 +257,6 @@ void TaskFemConstraintForce::removeFromSelection()
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintForce::setSelection(QListWidgetItem* item) {
|
||||
std::string s = item->text().toStdString();
|
||||
std::string docName = ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName = s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintForce::onForceChanged(double f)
|
||||
{
|
||||
Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
|
||||
@@ -324,10 +305,6 @@ void TaskFemConstraintForce::onButtonDirection(const bool pressed)
|
||||
Part::Feature* feat = static_cast<Part::Feature*>(obj);
|
||||
TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNamesElement.c_str());
|
||||
|
||||
if (TypeName.substr(0, 4).compare(std::string("Part")) != 0) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
if (subNamesElement.substr(0, 4) == "Face") {
|
||||
if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only planar faces can be picked for 3D"));
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "ViewProviderFemConstraintForce.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintForce;
|
||||
|
||||
@@ -67,7 +66,6 @@ private Q_SLOTS:
|
||||
void onCheckReverse(bool);
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -331,25 +331,6 @@ void TaskFemConstraintHeatflux::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
void TaskFemConstraintHeatflux::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintHeatflux::onReferenceDeleted() {
|
||||
TaskFemConstraintHeatflux::removeFromSelection();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintHeatflux;
|
||||
|
||||
@@ -67,7 +66,6 @@ private Q_SLOTS:
|
||||
void Flux();
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -253,24 +253,6 @@ void TaskFemConstraintPlaneRotation::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintPlaneRotation::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintPlaneRotation::onReferenceDeleted() {
|
||||
TaskFemConstraintPlaneRotation::removeFromSelection();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintPlaneRotation;
|
||||
|
||||
@@ -55,10 +54,8 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onReferenceDeleted(void);
|
||||
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#include "ui_TaskFemConstraintPressure.h"
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
|
||||
@@ -238,24 +235,6 @@ void TaskFemConstraintPressure::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintPressure::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintPressure::onReferenceDeleted() {
|
||||
TaskFemConstraintPressure::removeFromSelection();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintPressure;
|
||||
|
||||
@@ -57,11 +56,9 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onReferenceDeleted(void);
|
||||
|
||||
void onCheckReverse(bool);
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -274,24 +274,6 @@ void TaskFemConstraintTemperature::removeFromSelection()
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::onReferenceDeleted() {
|
||||
TaskFemConstraintTemperature::removeFromSelection();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintTemperature;
|
||||
|
||||
@@ -63,7 +62,6 @@ private Q_SLOTS:
|
||||
void Flux();
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
@@ -49,13 +49,12 @@
|
||||
#include "TaskFemConstraintTransform.h"
|
||||
#include "ui_TaskFemConstraintTransform.h"
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
|
||||
#include <math.h>
|
||||
#define PI (3.141592653589793238462643383279502884L)
|
||||
@@ -408,24 +407,6 @@ void TaskFemConstraintTransform::removeFromSelection()
|
||||
ui->sp_Z->setValue(0);
|
||||
}
|
||||
|
||||
void TaskFemConstraintTransform::setSelection(QListWidgetItem* item){
|
||||
std::string docName=ConstraintView->getObject()->getDocument()->getName();
|
||||
|
||||
std::string s = item->text().toStdString();
|
||||
std::string delimiter = ":";
|
||||
|
||||
size_t pos = 0;
|
||||
std::string objName;
|
||||
std::string subName;
|
||||
pos = s.find(delimiter);
|
||||
objName = s.substr(0, pos);
|
||||
s.erase(0, pos + delimiter.length());
|
||||
subName=s;
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0);
|
||||
}
|
||||
|
||||
const std::string TaskFemConstraintTransform::getReferences() const
|
||||
{
|
||||
std::vector<std::string> items;
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
class Ui_TaskFemConstraintTransform;
|
||||
|
||||
@@ -64,7 +63,6 @@ private Q_SLOTS:
|
||||
void Cyl();
|
||||
void addToSelection();
|
||||
void removeFromSelection();
|
||||
void setSelection(QListWidgetItem* item);
|
||||
void x_Changed(int x);
|
||||
void y_Changed(int y);
|
||||
void z_Changed(int z);
|
||||
|
||||
Reference in New Issue
Block a user