Skip to content

Commit

Permalink
fixes 0003823: FEM, unusable material property changing when using ta…
Browse files Browse the repository at this point in the history
…sk panel
  • Loading branch information
wwmayer committed Feb 18, 2019
1 parent 68e7975 commit a12f4f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions src/Gui/InputField.cpp
Expand Up @@ -431,6 +431,11 @@ void InputField::setValue(const double& value)
setValue(Base::Quantity(value, actUnit));
}

double InputField::rawValue() const
{
return this->actQuantity.getValue();
}

void InputField::setUnit(const Base::Unit& unit)
{
actUnit = unit;
Expand Down
3 changes: 3 additions & 0 deletions src/Gui/InputField.h
Expand Up @@ -66,6 +66,7 @@ class GuiExport InputField : public ExpressionLineEdit, public ExpressionBinding
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep )
Q_PROPERTY(double maximum READ maximum WRITE setMaximum )
Q_PROPERTY(double minimum READ minimum WRITE setMinimum )
Q_PROPERTY(double rawValue READ rawValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(int historySize READ historySize WRITE setHistorySize )
Q_PROPERTY(QString unit READ getUnitText WRITE setUnitText )
Q_PROPERTY(int precision READ getPrecision WRITE setPrecision )
Expand All @@ -86,6 +87,8 @@ class GuiExport InputField : public ExpressionLineEdit, public ExpressionBinding

/// get the current value
Base::Quantity getQuantity(void)const{return this->actQuantity;}
/// Get the current quantity without unit
double rawValue() const;

/// get stored, valid quantity as a string (user string - avoid storing)
QString getQuantityString(void) const;
Expand Down
40 changes: 24 additions & 16 deletions src/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py
Expand Up @@ -120,17 +120,17 @@ def __init__(self, obj):
QtCore.QObject.connect(self.parameterWidget.chbu_allow_edit, QtCore.SIGNAL("clicked()"), self.toggleInputFieldsReadOnly)
QtCore.QObject.connect(self.parameterWidget.pushButton_editMat, QtCore.SIGNAL("clicked()"), self.edit_material)
# basic properties must be provided
QtCore.QObject.connect(self.parameterWidget.input_fd_density, QtCore.SIGNAL("valueChanged(double)"), self.density_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_density, QtCore.SIGNAL("editingFinished()"), self.density_changed)
# mechanical properties
QtCore.QObject.connect(self.parameterWidget.input_fd_young_modulus, QtCore.SIGNAL("valueChanged(double)"), self.ym_changed)
QtCore.QObject.connect(self.parameterWidget.spinBox_poisson_ratio, QtCore.SIGNAL("valueChanged(double)"), self.pr_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_young_modulus, QtCore.SIGNAL("editingFinished()"), self.ym_changed)
QtCore.QObject.connect(self.parameterWidget.spinBox_poisson_ratio, QtCore.SIGNAL("editingFinished()"), self.pr_changed)
# thermal properties
QtCore.QObject.connect(self.parameterWidget.input_fd_thermal_conductivity, QtCore.SIGNAL("valueChanged(double)"), self.tc_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_expansion_coefficient, QtCore.SIGNAL("valueChanged(double)"), self.tec_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_specific_heat, QtCore.SIGNAL("valueChanged(double)"), self.sh_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_thermal_conductivity, QtCore.SIGNAL("editingFinished()"), self.tc_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_expansion_coefficient, QtCore.SIGNAL("editingFinished()"), self.tec_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_specific_heat, QtCore.SIGNAL("editingFinished()"), self.sh_changed)
# fluidic properties, only volumetric thermal expansion coeff makes sense
QtCore.QObject.connect(self.parameterWidget.input_fd_kinematic_viscosity, QtCore.SIGNAL("valueChanged(double)"), self.kinematic_viscosity_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_vol_expansion_coefficient, QtCore.SIGNAL("valueChanged(double)"), self.vtec_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_kinematic_viscosity, QtCore.SIGNAL("editingFinished()"), self.kinematic_viscosity_changed)
QtCore.QObject.connect(self.parameterWidget.input_fd_vol_expansion_coefficient, QtCore.SIGNAL("editingFinished()"), self.vtec_changed)

# init all parameter input files with read only
self.parameterWidget.chbu_allow_edit.setCheckState(QtCore.Qt.CheckState.Unchecked)
Expand Down Expand Up @@ -359,8 +359,9 @@ def check_material_keys(self):
self.material['SpecificHeat'] = '0 J/kg/K'

# mechanical input fields
def ym_changed(self, value):
def ym_changed(self):
# FreeCADs standard unit for stress is kPa
value = self.parameterWidget.input_fd_young_modulus.property("rawValue")
old_ym = Units.Quantity(self.material['YoungsModulus']).getValueAs("kPa")
variation = 0.001
if value:
Expand All @@ -374,8 +375,9 @@ def ym_changed(self, value):
else:
self.set_transient_material()

def density_changed(self, value):
def density_changed(self):
# FreeCADs standard unit for density is kg/mm^3
value = self.parameterWidget.input_fd_density.property("rawValue")
old_density = Units.Quantity(self.material['Density']).getValueAs("kg/m^3")
variation = 0.001
if value:
Expand All @@ -390,7 +392,8 @@ def density_changed(self, value):
else:
self.set_transient_material()

def pr_changed(self, value):
def pr_changed(self):
value = self.parameterWidget.spinBox_poisson_ratio.value()
old_pr = Units.Quantity(self.material['PoissonRatio'])
variation = 0.001
if value:
Expand All @@ -414,7 +417,8 @@ def pr_changed(self, value):
self.set_transient_material()

# thermal input fields
def tc_changed(self, value):
def tc_changed(self):
value = self.parameterWidget.input_fd_thermal_conductivity.property("rawValue")
old_tc = Units.Quantity(self.material['ThermalConductivity']).getValueAs("W/m/K")
variation = 0.001
if value:
Expand All @@ -429,7 +433,8 @@ def tc_changed(self, value):
else:
self.set_transient_material()

def tec_changed(self, value):
def tec_changed(self):
value = self.parameterWidget.input_fd_expansion_coefficient.property("rawValue")
old_tec = Units.Quantity(self.material['ThermalExpansionCoefficient']).getValueAs("um/m/K")
variation = 0.001
if value:
Expand All @@ -444,7 +449,8 @@ def tec_changed(self, value):
else:
self.set_transient_material()

def sh_changed(self, value):
def sh_changed(self):
value = self.parameterWidget.input_fd_specific_heat.property("rawValue")
old_sh = Units.Quantity(self.material['SpecificHeat']).getValueAs("J/kg/K")
variation = 0.001
if value:
Expand All @@ -460,7 +466,8 @@ def sh_changed(self, value):
self.set_transient_material()

# fluidic input fields
def vtec_changed(self, value):
def vtec_changed(self):
value = self.parameterWidget.input_fd_vol_expansion_coefficient.property("rawValue")
old_vtec = Units.Quantity(self.material['VolumetricThermalExpansionCoefficient']).getValueAs("m/m/K")
variation = 0.001
if value:
Expand All @@ -475,7 +482,8 @@ def vtec_changed(self, value):
else:
self.set_transient_material()

def kinematic_viscosity_changed(self, value):
def kinematic_viscosity_changed(self):
value = self.parameterWidget.input_fd_kinematic_viscosity.property("rawValue")
old_nu = Units.Quantity(self.material['KinematicViscosity']).getValueAs("m^2/s")
variation = 0.000001
if value:
Expand Down

0 comments on commit a12f4f3

Please sign in to comment.