[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

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