From 1145a9a06e827bcad56514b2e87c7c4928d7349a Mon Sep 17 00:00:00 2001 From: Uwe Date: Fri, 10 Jun 2022 04:20:25 +0200 Subject: [PATCH] [FEM] fix unit handling of point result filter - the App part used already units but the dialog worked unitless. This is error-prone and confusing. Therefore use unit widgets in the dialog. - also fix issue that unit was not reset (after e.g. a temperature maybe a unitless strain should be shown) --- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 20 ++- src/Mod/Fem/Gui/TaskPostDataAtPoint.ui | 208 +++++++++++++------------ 2 files changed, 127 insertions(+), 101 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 287b0b6fd1..48632aa0da 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -767,6 +768,17 @@ TaskPostDataAtPoint::TaskPostDataAtPoint(ViewProviderDocumentObject* view, QWidg QMetaObject::connectSlotsByName(this); this->groupLayout()->addWidget(proxy); + // set decimals before the edits are filled to avoid rounding mistakes + int UserDecimals = Base::UnitsApi::getDecimals(); + ui->centerX->setDecimals(UserDecimals); + ui->centerY->setDecimals(UserDecimals); + ui->centerZ->setDecimals(UserDecimals); + + const Base::Unit lengthUnit = static_cast(getObject())->Center.getUnit(); + ui->centerX->setUnit(lengthUnit); + ui->centerY->setUnit(lengthUnit); + ui->centerZ->setUnit(lengthUnit); + const Base::Vector3d& vec = static_cast(getObject())->Center.getValue(); ui->centerX->setValue(vec.x); ui->centerY->setValue(vec.y); @@ -852,9 +864,10 @@ void TaskPostDataAtPoint::onChange(double x, double y, double z) { void TaskPostDataAtPoint::centerChanged(double) { - Base::Vector3d vec(ui->centerX->value(), ui->centerY->value(), ui->centerZ->value()); + Base::Vector3d vec(ui->centerX->value().getValue(), ui->centerY->value().getValue(), ui->centerZ->value().getValue()); std::string ObjName = static_cast(getObject())->Label.getValue(); - Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", ObjName.c_str(), ui->centerX->value(), ui->centerY->value(), ui->centerZ->value()); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", ObjName.c_str(), + ui->centerX->value().getValue(), ui->centerY->value().getValue(), ui->centerZ->value().getValue()); } void TaskPostDataAtPoint::pointCallback(void* ud, SoEventCallback* n) @@ -923,6 +936,9 @@ void TaskPostDataAtPoint::on_Field_activated(int i) { else if (FieldName == "potential loads") { static_cast(getObject())->Unit.setValue(""); } + else { + static_cast(getObject())->Unit.setValue(""); + } std::string PointData = " The value at that location is " + std::to_string(static_cast(getObject())->PointData[0]) diff --git a/src/Mod/Fem/Gui/TaskPostDataAtPoint.ui b/src/Mod/Fem/Gui/TaskPostDataAtPoint.ui index 4fe21d4ff6..7a00503e3c 100644 --- a/src/Mod/Fem/Gui/TaskPostDataAtPoint.ui +++ b/src/Mod/Fem/Gui/TaskPostDataAtPoint.ui @@ -6,101 +6,110 @@ 0 0 - 482 - 363 + 300 + 156 - - Form - - - - Qt::Horizontal + + + Center + + + + + x + + + Qt::AlignCenter + + + + + + + y + + + Qt::AlignCenter + + + + + + + z + + + Qt::AlignCenter + + + + + + + + 100 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + mm + + + + + + + + 100 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + mm + + + + + + + + 100 + 16777215 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + mm + + + 1.000000000000000 + + + + - - - - - - Center - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - -999999999.000000000000000 - - - 999999999.000000000000000 - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - -999999999.000000000000000 - - - 999999999.000000000000000 - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - -999999999.000000000000000 - - - 999999999.000000000000000 - - - - - @@ -132,19 +141,20 @@ - - - - Qt::Horizontal - - - - SelectPoint - line - line_2 - line_3 + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+ + Gui::PrefQuantitySpinBox + Gui::QuantitySpinBox +
Gui/PrefWidgets.h
+
+