From d94c65ba3f3a1a1df26a8d8a677cb302eb09bbdb Mon Sep 17 00:00:00 2001 From: marioalexis Date: Tue, 8 Oct 2024 15:29:03 -0300 Subject: [PATCH] Fem: Enable expression for the spring constraint task panel --- src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp | 43 ++++++++---------- src/Mod/Fem/Gui/TaskFemConstraintSpring.h | 4 +- src/Mod/Fem/Gui/TaskFemConstraintSpring.ui | 50 ++++++++++++--------- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp index cdc53f827a..34b2531c97 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.cpp @@ -77,30 +77,22 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring std::vector SubElements = pcConstraint->References.getSubValues(); // Fill data into dialog elements - ui->if_norm->setUnit(pcConstraint->NormalStiffness.getUnit()); - ui->if_norm->setMinimum( - 0); // TODO fix this ------------------------------------------------------------------- - ui->if_norm->setMaximum(FLOAT_MAX); - Base::Quantity ns = - Base::Quantity((pcConstraint->NormalStiffness.getValue()), Base::Unit::Stiffness); - ui->if_norm->setValue(ns); + ui->qsb_norm->setUnit(pcConstraint->NormalStiffness.getUnit()); + ui->qsb_norm->setMaximum(FLOAT_MAX); + ui->qsb_norm->setValue(pcConstraint->NormalStiffness.getQuantityValue()); - ui->if_tan->setUnit(pcConstraint->TangentialStiffness.getUnit()); - ui->if_tan->setMinimum( - 0); // TODO fix this ------------------------------------------------------------------- - ui->if_tan->setMaximum(FLOAT_MAX); - Base::Quantity ts = - Base::Quantity((pcConstraint->TangentialStiffness.getValue()), Base::Unit::Stiffness); - ui->if_tan->setValue(ts); + ui->qsb_tan->setUnit(pcConstraint->TangentialStiffness.getUnit()); + ui->qsb_tan->setMaximum(FLOAT_MAX); + ui->qsb_tan->setValue(pcConstraint->TangentialStiffness.getQuantityValue()); - ui->ElmerStiffnessCB->clear(); + ui->cb_elmer_stiffness->clear(); auto stiffnesses = pcConstraint->ElmerStiffness.getEnumVector(); QStringList stiffnessesList; for (auto item : stiffnesses) { stiffnessesList << QLatin1String(item.c_str()); } - ui->ElmerStiffnessCB->addItems(stiffnessesList); - ui->ElmerStiffnessCB->setCurrentIndex(pcConstraint->ElmerStiffness.getValue()); + ui->cb_elmer_stiffness->addItems(stiffnessesList); + ui->cb_elmer_stiffness->setCurrentIndex(pcConstraint->ElmerStiffness.getValue()); ui->lw_references->clear(); for (std::size_t i = 0; i < Objects.size(); i++) { @@ -114,6 +106,9 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring buttonGroup->addButton(ui->btnAdd, (int)SelectionChangeModes::refAdd); buttonGroup->addButton(ui->btnRemove, (int)SelectionChangeModes::refRemove); + ui->qsb_norm->bind(pcConstraint->NormalStiffness); + ui->qsb_tan->bind(pcConstraint->TangentialStiffness); + updateUI(); } @@ -255,19 +250,19 @@ const std::string TaskFemConstraintSpring::getReferences() const return TaskFemConstraint::getReferences(items); } -std::string TaskFemConstraintSpring::get_normalStiffness() const +std::string TaskFemConstraintSpring::getNormalStiffness() const { - return ui->if_norm->value().getSafeUserString().toStdString(); + return ui->qsb_norm->value().getSafeUserString().toStdString(); } -std::string TaskFemConstraintSpring::get_tangentialStiffness() const +std::string TaskFemConstraintSpring::getTangentialStiffness() const { - return ui->if_tan->value().getSafeUserString().toStdString(); + return ui->qsb_tan->value().getSafeUserString().toStdString(); } std::string TaskFemConstraintSpring::getElmerStiffness() const { - return Base::Tools::toStdString(ui->ElmerStiffnessCB->currentText()); + return Base::Tools::toStdString(ui->cb_elmer_stiffness->currentText()); } void TaskFemConstraintSpring::changeEvent(QEvent*) @@ -312,11 +307,11 @@ bool TaskDlgFemConstraintSpring::accept() Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.NormalStiffness = \"%s\"", name.c_str(), - parameterStiffness->get_normalStiffness().c_str()); + parameterStiffness->getNormalStiffness().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.TangentialStiffness = \"%s\"", name.c_str(), - parameterStiffness->get_tangentialStiffness().c_str()); + parameterStiffness->getTangentialStiffness().c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.ElmerStiffness = '%s'", name.c_str(), diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.h b/src/Mod/Fem/Gui/TaskFemConstraintSpring.h index 589deb7af8..b6d5de7f8b 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.h @@ -44,8 +44,8 @@ public: QWidget* parent = nullptr); ~TaskFemConstraintSpring() override; const std::string getReferences() const override; - std::string get_normalStiffness() const; - std::string get_tangentialStiffness() const; + std::string getNormalStiffness() const; + std::string getTangentialStiffness() const; std::string getElmerStiffness() const; private Q_SLOTS: diff --git a/src/Mod/Fem/Gui/TaskFemConstraintSpring.ui b/src/Mod/Fem/Gui/TaskFemConstraintSpring.ui index d8cf1933ff..5161d3912e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintSpring.ui +++ b/src/Mod/Fem/Gui/TaskFemConstraintSpring.ui @@ -69,8 +69,25 @@ - - + + + + Normal Stiffness + + + + + + + N/m + + + 0.000000000000000 + + + + + 0 @@ -82,36 +99,25 @@ - - + + - + N/m + + + 0.000000000000000 - - - - Normal Stiffness - - - - - - - - - - - + Stiffness for Elmer - - + + What stiffness should be used for the Elmer solver