[FEM] extend displacement constraint

- add fields to specify a formula for the displacement, this is necessary to make transient deformation analyses with Elmer
- add option to set displacement from result of flow equation
- this way also a major overhaul -> simpler dialog logic etc.
This commit is contained in:
Uwe
2023-03-22 06:56:02 +01:00
parent 971785a160
commit dba00d44d0
8 changed files with 837 additions and 609 deletions

View File

@@ -41,39 +41,55 @@ ConstraintDisplacement::ConstraintDisplacement()
// Displacement or Rotation not 0.0, prescribed displacement, Free and Fix should be False
// x displacement
ADD_PROPERTY(xFix,(0));
ADD_PROPERTY(xFree,(1));
ADD_PROPERTY(xDisplacement,(0.0));
ADD_PROPERTY(xFix, (false));
ADD_PROPERTY(xFree, (1));
ADD_PROPERTY(xDisplacement, (0.0));
ADD_PROPERTY(hasXFormula, (false));
ADD_PROPERTY(xDisplacementFormula, (""));
// y displacement
ADD_PROPERTY(yFix,(0));
ADD_PROPERTY(yFree,(1));
ADD_PROPERTY(yDisplacement,(0.0));
ADD_PROPERTY(yFix, (false));
ADD_PROPERTY(yFree, (true));
ADD_PROPERTY(yDisplacement, (0.0));
ADD_PROPERTY(hasYFormula, (false));
ADD_PROPERTY(yDisplacementFormula, (""));
// z displacement
ADD_PROPERTY(zFix,(0));
ADD_PROPERTY(zFree,(1));
ADD_PROPERTY(zDisplacement,(0.0));
ADD_PROPERTY(zFix, (false));
ADD_PROPERTY(zFree, (true));
ADD_PROPERTY(zDisplacement, (0.0));
ADD_PROPERTY(hasZFormula, (false));
ADD_PROPERTY(zDisplacementFormula, (""));
// flow surface force
ADD_PROPERTY(useFlowSurfaceForce, (false));
// x rotation
ADD_PROPERTY(rotxFix,(0));
ADD_PROPERTY(rotxFree,(1));
ADD_PROPERTY(xRotation,(0.0));
ADD_PROPERTY(rotxFix, (false));
ADD_PROPERTY(rotxFree, (true));
ADD_PROPERTY(xRotation, (0.0));
// y rotation
ADD_PROPERTY(rotyFix,(0));
ADD_PROPERTY(rotyFree,(1));
ADD_PROPERTY(yRotation,(0.0));
ADD_PROPERTY(rotyFix, (false));
ADD_PROPERTY(rotyFree, (true));
ADD_PROPERTY(yRotation, (0.0));
// z rotation
ADD_PROPERTY(rotzFix,(0));
ADD_PROPERTY(rotzFree,(1));
ADD_PROPERTY(zRotation,(0.0));
ADD_PROPERTY(rotzFix, (false));
ADD_PROPERTY(rotzFree, (true));
ADD_PROPERTY(zRotation, (0.0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,
(Base::Vector3d()),
"ConstraintFixed",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,
(Base::Vector3d()),
"ConstraintFixed",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
@@ -97,11 +113,11 @@ void ConstraintDisplacement::onChanged(const App::Property* prop)
if (prop == &References) {
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
int scale = 1; //OvG: Enforce use of scale
int scale = 1; // OvG: Enforce use of scale
if (getPoints(points, normals, &scale)) {
Points.setValues(points);
Normals.setValues(normals);
Scale.setValue(scale); //OvG: Scale
Scale.setValue(scale); // OvG: Scale
Points.touch(); // This triggers ViewProvider::updateData()
}
}

View File

@@ -51,6 +51,9 @@ public:
App::PropertyFloat xRotation;
App::PropertyFloat yRotation;
App::PropertyFloat zRotation;
App::PropertyString xDisplacementFormula;
App::PropertyString yDisplacementFormula;
App::PropertyString zDisplacementFormula;
App::PropertyBool xFree;
App::PropertyBool yFree;
App::PropertyBool zFree;
@@ -63,7 +66,10 @@ public:
App::PropertyBool rotxFix;
App::PropertyBool rotyFix;
App::PropertyBool rotzFix;
//App::PropertyBool element;
App::PropertyBool hasXFormula;
App::PropertyBool hasYFormula;
App::PropertyBool hasZFormula;
App::PropertyBool useFlowSurfaceForce;
/// recalculate the object
App::DocumentObjectExecReturn *execute() override;

View File

@@ -1,8 +1,9 @@
/***************************************************************************
* Copyright (c) 2015 FreeCAD Developers *
* Copyright (c) 2015, 2023 FreeCAD Developers *
* Authors: Michael Hindley <hindlemp@eskom.co.za> *
* Ruan Olwagen <olwager@eskom.co.za> *
* Oswald van Ginkel <vginkeo@eskom.co.za> *
* Uwe Stöhr <uwestoehr@lyx.org> *
* Based on Force constraint by Jan Rheinländer *
* This file is part of the FreeCAD CAx development system. *
* *
@@ -24,7 +25,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
# include <QAction>
@@ -44,7 +44,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintDisplacement */
TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent)
TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(
ViewProviderFemConstraintDisplacement* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintDisplacement")
{
proxy = new QWidget(this);
@@ -79,15 +80,20 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons
ui->spinzRotation->setMaximum(FLOAT_MAX);
// Get the feature data
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
double fStates[6];
bool bStates[12];
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
double fStates[6] {};
const char* sStates[3] {};
bool bStates[16] {};
fStates[0] = pcConstraint->xDisplacement.getValue();
fStates[1] = pcConstraint->yDisplacement.getValue();
fStates[2] = pcConstraint->zDisplacement.getValue();
fStates[3] = pcConstraint->xRotation.getValue();
fStates[4] = pcConstraint->yRotation.getValue();
fStates[5] = pcConstraint->zRotation.getValue();
sStates[0] = pcConstraint->xDisplacementFormula.getValue();
sStates[1] = pcConstraint->yDisplacementFormula.getValue();
sStates[2] = pcConstraint->zDisplacementFormula.getValue();
bStates[0] = pcConstraint->xFix.getValue();
bStates[1] = pcConstraint->xFree.getValue();
bStates[2] = pcConstraint->yFix.getValue();
@@ -100,30 +106,14 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons
bStates[9] = pcConstraint->rotyFree.getValue();
bStates[10] = pcConstraint->rotzFix.getValue();
bStates[11] = pcConstraint->rotzFree.getValue();
bStates[12] = pcConstraint->hasXFormula.getValue();
bStates[13] = pcConstraint->hasYFormula.getValue();
bStates[14] = pcConstraint->hasZFormula.getValue();
bStates[15] = pcConstraint->useFlowSurfaceForce.getValue();
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
// Fill data into dialog elements
ui->spinxDisplacement->setValue(fStates[0]);
ui->spinyDisplacement->setValue(fStates[1]);
ui->spinzDisplacement->setValue(fStates[2]);
ui->spinxRotation->setValue(fStates[3]);
ui->spinyRotation->setValue(fStates[4]);
ui->spinzRotation->setValue(fStates[5]);
ui->dispxfix->setChecked(bStates[0]);
ui->dispxfree->setChecked(bStates[1]);
ui->dispyfix->setChecked(bStates[2]);
ui->dispyfree->setChecked(bStates[3]);
ui->dispzfix->setChecked(bStates[4]);
ui->dispzfree->setChecked(bStates[5]);
ui->rotxfix->setChecked(bStates[6]);
ui->rotxfree->setChecked(bStates[7]);
ui->rotyfix->setChecked(bStates[8]);
ui->rotyfree->setChecked(bStates[9]);
ui->rotzfix->setChecked(bStates[10]);
ui->rotzfree->setChecked(bStates[11]);
ui->lw_references->clear();
for (std::size_t i = 0; i < Objects.size(); i++) {
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
@@ -132,35 +122,51 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(ViewProviderFemCons
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
}
// Connect decimal value inputs
connect(ui->spinxDisplacement, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::x_changed);
connect(ui->spinyDisplacement, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::y_changed);
connect(ui->spinzDisplacement, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::z_changed);
connect(ui->spinxRotation, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::x_rot);
connect(ui->spinyRotation, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::y_rot);
connect(ui->spinzRotation, qOverload<double>(&QDoubleSpinBox::valueChanged),
this, &TaskFemConstraintDisplacement::z_rot);
// Connect check box values displacements
connect(ui->dispxfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixx);
connect(ui->dispxfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freex);
connect(ui->dispyfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixy);
connect(ui->dispyfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freey);
connect(ui->dispzfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::fixz);
connect(ui->dispzfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::freez);
connect(ui->dispxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixx);
connect(ui->DisplacementXFormulaCB, &QCheckBox::toggled,
this, &TaskFemConstraintDisplacement::formulaX);
connect(ui->dispyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixy);
connect(ui->DisplacementYFormulaCB, &QCheckBox::toggled,
this, &TaskFemConstraintDisplacement::formulaY);
connect(ui->dispzfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::fixz);
connect(ui->DisplacementZFormulaCB, &QCheckBox::toggled,
this, &TaskFemConstraintDisplacement::formulaZ);
connect(ui->FlowForceCB, &QCheckBox::toggled,
this, &TaskFemConstraintDisplacement::flowForce);
// Connect to check box values for rotations
connect(ui->rotxfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixx);
connect(ui->rotxfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreex);
connect(ui->rotyfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixy);
connect(ui->rotyfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreey);
connect(ui->rotzfix, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfixz);
connect(ui->rotzfree, &QCheckBox::stateChanged, this, &TaskFemConstraintDisplacement::rotfreez);
connect(ui->rotxfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixx);
connect(ui->rotyfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixy);
connect(ui->rotzfix, &QCheckBox::toggled, this, &TaskFemConstraintDisplacement::rotfixz);
//Selection buttons
// Fill data into dialog elements
ui->spinxDisplacement->setValue(fStates[0]);
ui->spinyDisplacement->setValue(fStates[1]);
ui->spinzDisplacement->setValue(fStates[2]);
ui->spinxRotation->setValue(fStates[3]);
ui->spinyRotation->setValue(fStates[4]);
ui->spinzRotation->setValue(fStates[5]);
ui->DisplacementXFormulaLE->setText(QString::fromUtf8(sStates[0]));
ui->DisplacementYFormulaLE->setText(QString::fromUtf8(sStates[1]));
ui->DisplacementZFormulaLE->setText(QString::fromUtf8(sStates[2]));
ui->dispxfix->setChecked(bStates[0]);
ui->DisplacementXGB->setChecked(!bStates[1]);
ui->dispyfix->setChecked(bStates[2]);
ui->DisplacementYGB->setChecked(!bStates[3]);
ui->dispzfix->setChecked(bStates[4]);
ui->DisplacementZGB->setChecked(!bStates[5]);
ui->rotxfix->setChecked(bStates[6]);
ui->RotationXGB->setChecked(!bStates[7]);
ui->rotyfix->setChecked(bStates[8]);
ui->RotationYGB->setChecked(!bStates[9]);
ui->rotzfix->setChecked(bStates[10]);
ui->RotationZGB->setChecked(!bStates[11]);
ui->DisplacementXFormulaCB->setChecked(bStates[12]);
ui->DisplacementYFormulaCB->setChecked(bStates[13]);
ui->DisplacementZFormulaCB->setChecked(bStates[14]);
ui->FlowForceCB->setChecked(bStates[15]);
// Selection buttons
buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd);
buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove);
@@ -181,227 +187,149 @@ void TaskFemConstraintDisplacement::updateUI()
}
}
void TaskFemConstraintDisplacement::x_changed(double val) {
if (val != 0)
{
ui->dispxfree->setChecked(false);
ui->dispxfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::y_changed(double val) {
if (val != 0)
{
ui->dispyfree->setChecked(false);
ui->dispyfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::z_changed(double val) {
if (val != 0)
{
ui->dispzfree->setChecked(false);
ui->dispzfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::x_rot(double val) {
if (val != 0)
{
ui->rotxfree->setChecked(false);
ui->rotxfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::y_rot(double val) {
if (val != 0)
{
ui->rotyfree->setChecked(false);
ui->rotyfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::z_rot(double val) {
if (val != 0)
{
ui->rotzfree->setChecked(false);
ui->rotzfix->setChecked(false);
}
}
void TaskFemConstraintDisplacement::fixx(int val) {
if (val == 2)
{
ui->dispxfree->setChecked(false);
void TaskFemConstraintDisplacement::fixx(bool state)
{
if (state) {
ui->spinxDisplacement->setValue(0);
ui->DisplacementXFormulaCB->setChecked(!state);
}
else if (ui->spinxDisplacement->value() == 0)
{
ui->dispxfree->setChecked(true);
}
ui->spinxDisplacement->setEnabled(!state);
ui->DisplacementXFormulaCB->setEnabled(!state);
}
void TaskFemConstraintDisplacement::freex(int val) {
if (val == 2)
{
ui->dispxfix->setChecked(false);
ui->spinxDisplacement->setValue(0);
}
else if (ui->spinxDisplacement->value() == 0)
{
ui->dispxfix->setChecked(true);
}
void TaskFemConstraintDisplacement::formulaX(bool state)
{
ui->spinxDisplacement->setEnabled(!state);
ui->dispxfix->setEnabled(!state);
ui->DisplacementXFormulaLE->setEnabled(state);
}
void TaskFemConstraintDisplacement::fixy(int val) {
if (val == 2)
{
ui->dispyfree->setChecked(false);
void TaskFemConstraintDisplacement::fixy(bool state)
{
if (state) {
ui->spinyDisplacement->setValue(0);
ui->DisplacementYFormulaCB->setChecked(!state);
}
else if (ui->spinyDisplacement->value() == 0)
{
ui->dispyfree->setChecked(true);
}
ui->spinyDisplacement->setEnabled(!state);
ui->DisplacementYFormulaCB->setEnabled(!state);
}
void TaskFemConstraintDisplacement::freey(int val) {
if (val == 2)
{
ui->dispyfix->setChecked(false);
ui->spinyDisplacement->setValue(0);
}
else if (ui->spinyDisplacement->value() == 0)
{
ui->dispyfix->setChecked(true);
}
void TaskFemConstraintDisplacement::formulaY(bool state)
{
ui->spinyDisplacement->setEnabled(!state);
ui->dispyfix->setEnabled(!state);
ui->DisplacementYFormulaLE->setEnabled(state);
}
void TaskFemConstraintDisplacement::fixz(int val) {
if (val == 2)
{
ui->dispzfree->setChecked(false);
void TaskFemConstraintDisplacement::fixz(bool state)
{
if (state) {
ui->spinzDisplacement->setValue(0);
ui->DisplacementZFormulaCB->setChecked(!state);
}
else if (ui->spinzDisplacement->value() == 0)
{
ui->dispzfree->setChecked(true);
ui->spinzDisplacement->setEnabled(!state);
ui->DisplacementZFormulaCB->setEnabled(!state);
}
void TaskFemConstraintDisplacement::formulaZ(bool state)
{
ui->spinzDisplacement->setEnabled(!state);
ui->dispzfix->setEnabled(!state);
ui->DisplacementZFormulaLE->setEnabled(state);
}
void TaskFemConstraintDisplacement::flowForce(bool state)
{
if (state) {
ui->DisplacementXGB->setChecked(!state);
ui->DisplacementYGB->setChecked(!state);
ui->DisplacementZGB->setChecked(!state);
ui->RotationXGB->setChecked(!state);
ui->RotationYGB->setChecked(!state);
ui->RotationZGB->setChecked(!state);
}
}
void TaskFemConstraintDisplacement::freez(int val) {
if (val == 2)
{
ui->dispzfix->setChecked(false);
ui->spinzDisplacement->setValue(0);
}
else if (ui->spinzDisplacement->value() == 0)
{
ui->dispzfix->setChecked(true);
}
}
void TaskFemConstraintDisplacement::rotfixx(int val) {
if (val == 2)
{
ui->rotxfree->setChecked(false);
void TaskFemConstraintDisplacement::rotfixx(bool state)
{
if (state)
ui->spinxRotation->setValue(0);
}
else if (ui->spinxRotation->value() == 0)
{
ui->rotxfree->setChecked(true);
}
ui->spinxRotation->setEnabled(!state);
}
void TaskFemConstraintDisplacement::rotfreex(int val) {
if (val == 2)
{
ui->rotxfix->setChecked(false);
ui->spinxRotation->setValue(0);
}
else if (ui->spinxRotation->value() == 0)
{
ui->rotxfix->setChecked(true);
}
void TaskFemConstraintDisplacement::formulaRotx(bool state)
{
ui->spinxRotation->setEnabled(!state);
ui->rotxfix->setEnabled(!state);
}
void TaskFemConstraintDisplacement::rotfixy(int val) {
if (val == 2)
{
ui->rotyfree->setChecked(false);
void TaskFemConstraintDisplacement::rotfixy(bool state)
{
if (state)
ui->spinyRotation->setValue(0);
}
else if (ui->spinyRotation->value() == 0)
{
ui->rotyfree->setChecked(true);
}
ui->spinyRotation->setEnabled(!state);
}
void TaskFemConstraintDisplacement::rotfreey(int val) {
if (val == 2)
{
ui->rotyfix->setChecked(false);
ui->spinyRotation->setValue(0);
}
else if (ui->spinyRotation->value() == 0)
{
ui->rotyfix->setChecked(true);
}
void TaskFemConstraintDisplacement::formulaRoty(bool state)
{
ui->spinyRotation->setEnabled(!state);
ui->rotyfix->setEnabled(!state);
}
void TaskFemConstraintDisplacement::rotfixz(int val) {
if (val == 2)
{
ui->rotzfree->setChecked(false);
void TaskFemConstraintDisplacement::rotfixz(bool state)
{
if (state)
ui->spinzRotation->setValue(0);
}
else if (ui->spinzRotation->value() == 0)
{
ui->rotzfree->setChecked(true);
}
ui->spinzRotation->setEnabled(!state);
}
void TaskFemConstraintDisplacement::rotfreez(int val) {
if (val == 2)
{
ui->rotzfix->setChecked(false);
ui->spinzRotation->setValue(0);
}
else if (ui->spinzRotation->value() == 0)
{
ui->rotzfix->setChecked(true);
}
void TaskFemConstraintDisplacement::formulaRotz(bool state)
{
ui->spinzRotation->setEnabled(!state);
ui->rotzfix->setEnabled(!state);
}
void TaskFemConstraintDisplacement::addToSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
std::vector<Gui::SelectionObject> selection =
Gui::Selection().getSelectionEx();// gets vector of selected objects of active document
if (selection.empty()) {
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end();
++it) {// for every selected object
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
for (size_t subIt = 0; subIt < (subNames.size());
++subIt) {// for every selected sub element
bool addMe = true;
for (std::vector<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so don't add
for (std::vector<std::string>::iterator itr =
std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr,
SubElements.end(),
subNames[subIt])) {// for every sub element in selection that
// matches one in old list
if (obj
== Objects[std::distance(
SubElements.begin(),
itr)]) {// if selected sub element's object equals the one in old list then
// it was added before so don't add
addMe = false;
}
}
// limit constraint such that only vertexes or faces or edges can be used depending on what was selected first
// limit constraint such that only vertexes or faces or edges can be used depending on
// what was selected first
std::string searchStr;
if (subNames[subIt].find("Vertex") != std::string::npos)
searchStr = "Vertex";
@@ -411,7 +339,8 @@ void TaskFemConstraintDisplacement::addToSelection()
searchStr = "Face";
for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) {
if (SubElements[iStr].find(searchStr) == std::string::npos) {
QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!");
QString msg = tr(
"Only one type of selection (vertex,face or edge) per constraint allowed!");
QMessageBox::warning(this, tr("Selection error"), msg);
addMe = false;
break;
@@ -425,23 +354,26 @@ void TaskFemConstraintDisplacement::addToSelection()
}
}
}
//Update UI
// Update UI
pcConstraint->References.setValues(Objects, SubElements);
updateUI();
}
void TaskFemConstraintDisplacement::removeFromSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
std::vector<Gui::SelectionObject> selection =
Gui::Selection().getSelectionEx();// gets vector of selected objects of active document
if (selection.empty()) {
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
Fem::ConstraintDisplacement* pcConstraint =
static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end();
++it) {// for every selected object
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
@@ -449,12 +381,20 @@ void TaskFemConstraintDisplacement::removeFromSelection()
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
for (std::vector<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so mark for deletion
for (size_t subIt = 0; subIt < (subNames.size());
++subIt) {// for every selected sub element
for (std::vector<std::string>::iterator itr =
std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr,
SubElements.end(),
subNames[subIt])) {// for every sub element in selection that
// matches one in old list
if (obj
== Objects[std::distance(
SubElements.begin(),
itr)]) {// if selected sub element's object equals the one in old list then
// it was added before so mark for deletion
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
}
}
@@ -466,7 +406,7 @@ void TaskFemConstraintDisplacement::removeFromSelection()
SubElements.erase(SubElements.begin() + itemsToDel.back());
itemsToDel.pop_back();
}
//Update UI
// Update UI
{
QSignalBlocker block(ui->lw_references);
ui->lw_references->clear();
@@ -478,8 +418,10 @@ void TaskFemConstraintDisplacement::removeFromSelection()
updateUI();
}
void TaskFemConstraintDisplacement::onReferenceDeleted() {
TaskFemConstraintDisplacement::removeFromSelection(); //OvG: On right-click face is automatically selected, so just remove
void TaskFemConstraintDisplacement::onReferenceDeleted()
{
TaskFemConstraintDisplacement::removeFromSelection();// OvG: On right-click face is
// automatically selected, so just remove
}
const std::string TaskFemConstraintDisplacement::getReferences() const
@@ -492,25 +434,137 @@ const std::string TaskFemConstraintDisplacement::getReferences() const
return TaskFemConstraint::getReferences(items);
}
double TaskFemConstraintDisplacement::get_spinxDisplacement() const { return ui->spinxDisplacement->value(); }
double TaskFemConstraintDisplacement::get_spinyDisplacement() const { return ui->spinyDisplacement->value(); }
double TaskFemConstraintDisplacement::get_spinzDisplacement() const { return ui->spinzDisplacement->value(); }
double TaskFemConstraintDisplacement::get_spinxRotation() const { return ui->spinxRotation->value(); }
double TaskFemConstraintDisplacement::get_spinyRotation() const { return ui->spinyRotation->value(); }
double TaskFemConstraintDisplacement::get_spinzRotation() const { return ui->spinzRotation->value(); }
double TaskFemConstraintDisplacement::get_spinxDisplacement() const
{
return ui->spinxDisplacement->value();
}
bool TaskFemConstraintDisplacement::get_dispxfix() const { return ui->dispxfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_dispxfree() const { return ui->dispxfree->isChecked(); }
bool TaskFemConstraintDisplacement::get_dispyfix() const { return ui->dispyfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_dispyfree() const { return ui->dispyfree->isChecked(); }
bool TaskFemConstraintDisplacement::get_dispzfix() const { return ui->dispzfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_dispzfree() const { return ui->dispzfree->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotxfix() const { return ui->rotxfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotxfree() const { return ui->rotxfree->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotyfix() const { return ui->rotyfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotyfree() const { return ui->rotyfree->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotzfix() const { return ui->rotzfix->isChecked(); }
bool TaskFemConstraintDisplacement::get_rotzfree() const { return ui->rotzfree->isChecked(); }
double TaskFemConstraintDisplacement::get_spinyDisplacement() const
{
return ui->spinyDisplacement->value();
}
double TaskFemConstraintDisplacement::get_spinzDisplacement() const
{
return ui->spinzDisplacement->value();
}
double TaskFemConstraintDisplacement::get_spinxRotation() const
{
return ui->spinxRotation->value();
}
double TaskFemConstraintDisplacement::get_spinyRotation() const
{
return ui->spinyRotation->value();
}
double TaskFemConstraintDisplacement::get_spinzRotation() const
{
return ui->spinzRotation->value();
}
std::string TaskFemConstraintDisplacement::get_xFormula() const
{
QString xFormula = ui->DisplacementXFormulaLE->text();
xFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
return xFormula.toStdString();
}
std::string TaskFemConstraintDisplacement::get_yFormula() const
{
QString yFormula = ui->DisplacementYFormulaLE->text();
yFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
return yFormula.toStdString();
}
std::string TaskFemConstraintDisplacement::get_zFormula() const
{
QString zFormula = ui->DisplacementZFormulaLE->text();
zFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
return zFormula.toStdString();
;
}
bool TaskFemConstraintDisplacement::get_dispxfix() const
{
return ui->dispxfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_dispxfree() const
{
return !ui->DisplacementXGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_hasDispXFormula() const
{
return ui->DisplacementXFormulaCB->isChecked();
}
bool TaskFemConstraintDisplacement::get_dispyfix() const
{
return ui->dispyfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_dispyfree() const
{
return !ui->DisplacementYGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_hasDispYFormula() const
{
return ui->DisplacementYFormulaCB->isChecked();
}
bool TaskFemConstraintDisplacement::get_dispzfix() const
{
return ui->dispzfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_dispzfree() const
{
return !ui->DisplacementZGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_hasDispZFormula() const
{
return ui->DisplacementZFormulaCB->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotxfix() const
{
return ui->rotxfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotxfree() const
{
return !ui->RotationXGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotyfix() const
{
return ui->rotyfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotyfree() const
{
return !ui->RotationYGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotzfix() const
{
return ui->rotzfix->isChecked();
}
bool TaskFemConstraintDisplacement::get_rotzfree() const
{
return !ui->RotationZGB->isChecked();
}
bool TaskFemConstraintDisplacement::get_useFlowSurfaceForce() const
{
return ui->FlowForceCB->isChecked();
}
bool TaskFemConstraintDisplacement::event(QEvent* e)
{
@@ -539,7 +593,8 @@ void TaskFemConstraintDisplacement::clearButtons(const SelectionChangeModes notT
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderFemConstraintDisplacement* ConstraintView)
TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(
ViewProviderFemConstraintDisplacement* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -557,55 +612,98 @@ void TaskDlgFemConstraintDisplacement::open()
QString msg = QObject::tr("Constraint displacement");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(
Gui::Command::Doc,
ViewProviderFemConstraint::gethideMeshShowPartStr(
(static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument())
.c_str());// OvG: Hide meshes and show parts
}
}
bool TaskDlgFemConstraintDisplacement::accept()
{
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintDisplacement* parameterDisplacement = static_cast<const TaskFemConstraintDisplacement*>(parameter);
const TaskFemConstraintDisplacement* parameterDisplacement =
static_cast<const TaskFemConstraintDisplacement*>(parameter);
try {
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xDisplacement = %f",
name.c_str(), parameterDisplacement->get_spinxDisplacement());
name.c_str(), parameterDisplacement->get_spinxDisplacement());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.xDisplacementFormula = \"%s\"",
name.c_str(), parameterDisplacement->get_xFormula().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yDisplacement = %f",
name.c_str(), parameterDisplacement->get_spinyDisplacement());
name.c_str(), parameterDisplacement->get_spinyDisplacement());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.yDisplacementFormula = \"%s\"",
name.c_str(), parameterDisplacement->get_yFormula().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zDisplacement = %f",
name.c_str(), parameterDisplacement->get_spinzDisplacement());
name.c_str(), parameterDisplacement->get_spinzDisplacement());
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.zDisplacementFormula = \"%s\"",
name.c_str(), parameterDisplacement->get_zFormula().c_str());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xRotation = %f",
name.c_str(), parameterDisplacement->get_spinxRotation());
name.c_str(), parameterDisplacement->get_spinxRotation());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yRotation = %f",
name.c_str(), parameterDisplacement->get_spinyRotation());
name.c_str(), parameterDisplacement->get_spinyRotation());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zRotation = %f",
name.c_str(), parameterDisplacement->get_spinzRotation());
name.c_str(), parameterDisplacement->get_spinzRotation());
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFree = %s",
name.c_str(), parameterDisplacement->get_dispxfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispxfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.xFix = %s",
name.c_str(), parameterDisplacement->get_dispxfix() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispxfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasXFormula = %s",
name.c_str(),
parameterDisplacement->get_hasDispXFormula() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFree = %s",
name.c_str(), parameterDisplacement->get_dispyfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispyfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.yFix = %s",
name.c_str(), parameterDisplacement->get_dispyfix() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispyfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasYFormula = %s",
name.c_str(),
parameterDisplacement->get_hasDispYFormula() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFree = %s",
name.c_str(), parameterDisplacement->get_dispzfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispzfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.zFix = %s",
name.c_str(), parameterDisplacement->get_dispzfix() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_dispzfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.hasZFormula = %s",
name.c_str(),
parameterDisplacement->get_hasDispZFormula() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFree = %s",
name.c_str(), parameterDisplacement->get_rotxfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_rotxfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotxFix = %s",
name.c_str(), parameterDisplacement->get_rotxfix() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_rotxfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFree = %s",
name.c_str(), parameterDisplacement->get_rotyfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_rotyfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotyFix = %s",
name.c_str(), parameterDisplacement->get_rotyfix() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_rotyfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFree = %s",
name.c_str(), parameterDisplacement->get_rotzfree() ? "True" : "False");
name.c_str(),
parameterDisplacement->get_rotzfree() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.rotzFix = %s",
name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False");
std::string scale = parameterDisplacement->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale
name.c_str(),
parameterDisplacement->get_rotzfix() ? "True" : "False");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.useFlowSurfaceForce = %s",
name.c_str(),
parameterDisplacement->get_useFlowSurfaceForce() ? "True"
: "False");
std::string scale = parameterDisplacement->getScale();// OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.Scale = %s",
name.c_str(),
scale.c_str());// OvG: implement modified scale
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what()));

View File

@@ -53,39 +53,41 @@ public:
double get_spinxRotation()const;
double get_spinyRotation()const;
double get_spinzRotation()const;
std::string get_xFormula() const;
std::string get_yFormula() const;
std::string get_zFormula() const;
bool get_dispxfix()const;
bool get_dispxfree()const;
bool get_hasDispXFormula() const;
bool get_dispyfix()const;
bool get_dispyfree()const;
bool get_hasDispYFormula() const;
bool get_dispzfix()const;
bool get_dispzfree()const;
bool get_hasDispZFormula() const;
bool get_rotxfix()const;
bool get_rotxfree()const;
bool get_rotyfix()const;
bool get_rotyfree()const;
bool get_rotzfix()const;
bool get_rotzfree()const;
bool get_useFlowSurfaceForce() const;
private Q_SLOTS:
void onReferenceDeleted();
void x_changed(double);
void y_changed(double);
void z_changed(double);
void x_rot(double);
void y_rot(double);
void z_rot(double);
void fixx(int);
void freex(int);
void fixy(int);
void freey(int);
void fixz(int);
void freez(int);
void rotfixx(int);
void rotfreex(int);
void rotfixy(int);
void rotfreey(int);
void rotfixz(int);
void rotfreez(int);
void fixx(bool);
void formulaX(bool);
void fixy(bool);
void formulaY(bool);
void fixz(bool);
void formulaZ(bool);
void flowForce(bool);
void rotfixx(bool);
void formulaRotx(bool);
void rotfixy(bool);
void formulaRoty(bool);
void rotfixz(bool);
void formulaRotz(bool);
void addToSelection() override;
void removeFromSelection() override;

View File

@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>300</width>
<height>641</height>
<height>617</height>
</rect>
</property>
<property name="sizePolicy">
@@ -43,287 +43,376 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QToolButton" name="btnAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QHBoxLayout" name="hLayout1">
<item>
<widget class="QToolButton" name="btnAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QToolButton" name="btnRemove">
<item row="1" column="0">
<widget class="QListWidget" name="lw_references">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lw_references">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QGroupBox" name="DisplacementXGB">
<property name="title">
<string>Displacement x</string>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
<property name="checkable">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinxDisplacement"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="dispxfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="DisplacementXFormulaLE"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="DisplacementXFormulaCB">
<property name="toolTip">
<string>Formulas are only valid
for the Emer solver</string>
</property>
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="DisplacementYGB">
<property name="title">
<string>Displacement y</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinyDisplacement"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="dispyfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="DisplacementYFormulaLE"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="DisplacementYFormulaCB">
<property name="toolTip">
<string>Formulas are only valid
for the Emer solver</string>
</property>
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="DisplacementZGB">
<property name="title">
<string>Displacement z</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinzDisplacement"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="dispzfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="DisplacementZFormulaLE"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="DisplacementZFormulaCB">
<property name="toolTip">
<string>Formulas are only valid
for the Emer solver</string>
</property>
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="FlowForceCB">
<property name="toolTip">
<string>Flow solution is used to determine
surface force (and thus displacement)
generated by the flow
(Option only applies for Elmer solver)</string>
</property>
<property name="text">
<string>Surface force by flow</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="dispx">
<property name="text">
<string>Displacement x</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="dispxfree">
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dispxfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinxDisplacement"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="dispy">
<property name="text">
<string>Displacement y</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="dispyfree">
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dispyfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinyDisplacement"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="dispz">
<property name="text">
<string>Displacement z</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="dispzfree">
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dispzfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinzDisplacement"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Rotations are only valid for Beam and Shell elements.</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="rotx">
<property name="text">
<string>Rotation x</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="rotxfree">
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="rotxfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinxRotation"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="roty">
<property name="text">
<string>Rotation y</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="rotyfree">
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="rotyfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinyRotation"/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="rotz">
<property name="text">
<string>Rotation z</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="rotzfree">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Free</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="rotzfix">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinzRotation">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Rotations are only valid for Beam and Shell elements.</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RotationXGB">
<property name="title">
<string>Rotation x</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="QCheckBox" name="rotxfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinxRotation"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RotationYGB">
<property name="title">
<string>Rotation y</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinyRotation"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="rotyfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RotationZGB">
<property name="title">
<string>Rotation z</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinzRotation"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="rotzfix">
<property name="text">
<string>Fixed</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>RotationXGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>463</y>
</hint>
</hints>
</connection>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>DisplacementXGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>170</y>
</hint>
</hints>
</connection>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>DisplacementYGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>255</y>
</hint>
</hints>
</connection>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>DisplacementZGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>340</y>
</hint>
</hints>
</connection>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>RotationYGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>522</y>
</hint>
</hints>
</connection>
<connection>
<sender>FlowForceCB</sender>
<signal>toggled(bool)</signal>
<receiver>RotationZGB</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>149</x>
<y>394</y>
</hint>
<hint type="destinationlabel">
<x>149</x>
<y>581</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -40,7 +40,8 @@
using namespace FemGui;
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement, FemGui::ViewProviderFemConstraintOnBoundary)
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintDisplacement,
FemGui::ViewProviderFemConstraintOnBoundary)
ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement()
{
@@ -52,7 +53,7 @@ ViewProviderFemConstraintDisplacement::~ViewProviderFemConstraintDisplacement()
{
}
//FIXME setEdit needs a careful review
// FIXME setEdit needs a careful review
bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
@@ -91,14 +92,16 @@ bool ViewProviderFemConstraintDisplacement::setEdit(int ModNum)
#define HEIGHT (4)
#define WIDTH (0.3)
//#define USE_MULTIPLE_COPY //OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
//#define USE_MULTIPLE_COPY
//OvG: MULTICOPY fails to update scaled display on initial drawing - so disable
void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop)
{
// Gets called whenever a property of the attached object changes
Fem::ConstraintDisplacement *pcConstraint =
static_cast<Fem::ConstraintDisplacement *>(this->getObject());
float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
// OvG: Calculate scaled values once only
float scaledwidth = WIDTH * pcConstraint->Scale.getValue();
float scaledheight = HEIGHT * pcConstraint->Scale.getValue();
bool xFree = pcConstraint->xFree.getValue();
bool yFree = pcConstraint->yFree.getValue();

View File

@@ -107,21 +107,28 @@ class DeformationWriter:
for obj in self.write.getMember("Fem::ConstraintDisplacement"):
if obj.References:
for name in obj.References[0][1]:
if obj.useFlowSurfaceForce:
self.write.boundary(name, "FSI BC", obj.useFlowSurfaceForce)
# if useFlowSurfaceForce no displacements must be output
continue
if not obj.xFree:
self.write.boundary(
name, "Displacement 1", obj.xDisplacement * 0.001)
elif obj.xFix:
self.write.boundary(name, "Displacement 1", 0.0)
if not obj.hasXFormula:
displacement = obj.xDisplacement * 0.001
else:
displacement = obj.xDisplacementFormula
self.write.boundary(name, "Displacement 1", displacement)
if not obj.yFree:
self.write.boundary(
name, "Displacement 2", obj.yDisplacement * 0.001)
elif obj.yFix:
self.write.boundary(name, "Displacement 2", 0.0)
if not obj.hasYFormula:
displacement = obj.yDisplacement * 0.001
else:
displacement = obj.yDisplacementFormula
self.write.boundary(name, "Displacement 2", displacement)
if not obj.zFree:
self.write.boundary(
name, "Displacement 3", obj.zDisplacement * 0.001)
elif obj.zFix:
self.write.boundary(name, "Displacement 3", 0.0)
if not obj.hasZFormula:
displacement = obj.zDisplacement * 0.001
else:
displacement = obj.zDisplacementFormula
self.write.boundary(name, "Displacement 3", displacement)
self.write.handled(obj)
def handleDeformationInitial(self, bodies):

View File

@@ -323,21 +323,28 @@ class ElasticityWriter:
for obj in self.write.getMember("Fem::ConstraintDisplacement"):
if obj.References:
for name in obj.References[0][1]:
if obj.useFlowSurfaceForce:
self.write.boundary(name, "FSI BC", obj.useFlowSurfaceForce)
# if useFlowSurfaceForce no displacements must be output
continue
if not obj.xFree:
self.write.boundary(
name, "Displacement 1", obj.xDisplacement * 0.001)
elif obj.xFix:
self.write.boundary(name, "Displacement 1", 0.0)
if not obj.hasXFormula:
displacement = obj.xDisplacement * 0.001
else:
displacement = obj.xDisplacementFormula
self.write.boundary(name, "Displacement 1", displacement)
if not obj.yFree:
self.write.boundary(
name, "Displacement 2", obj.yDisplacement * 0.001)
elif obj.yFix:
self.write.boundary(name, "Displacement 2", 0.0)
if not obj.hasYFormula:
displacement = obj.yDisplacement * 0.001
else:
displacement = obj.yDisplacementFormula
self.write.boundary(name, "Displacement 2", displacement)
if not obj.zFree:
self.write.boundary(
name, "Displacement 3", obj.zDisplacement * 0.001)
elif obj.zFix:
self.write.boundary(name, "Displacement 3", 0.0)
if not obj.hasZFormula:
displacement = obj.zDisplacement * 0.001
else:
displacement = obj.zDisplacementFormula
self.write.boundary(name, "Displacement 3", displacement)
self.write.handled(obj)
def handleElasticityInitial(self, bodies):