diff --git a/src/Mod/Fem/Gui/Resources/ui/CurrentDensity.ui b/src/Mod/Fem/Gui/Resources/ui/CurrentDensity.ui index c2d528a4b9..f7b8ee65f6 100644 --- a/src/Mod/Fem/Gui/Resources/ui/CurrentDensity.ui +++ b/src/Mod/Fem/Gui/Resources/ui/CurrentDensity.ui @@ -6,36 +6,53 @@ 0 0 - 350 - 40 + 300 + 128 Constraint Properties - - - + + + Current density: - - - - Qt::Horizontal + + + + true - - - 130 - 19 - + + Real - + - - + + + + true + + + Imaginary + + + + + + + true + + + x + + + + + true @@ -45,12 +62,15 @@ 20 - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Real part of potential x-component true + + + -1000000000000000000000.000000000000000 @@ -58,10 +78,260 @@ 1000000000000000000000.000000000000000 - 100.000000000000000 + 1.000000000000000 - 0.000000000000000 + 1.000000000000000 + + + + + + + unspecified + + + + + + + + + + true + + + + 100 + 20 + + + + Imaginary part of potential x-component + + + true + + + + + + -1000000000000000000000.000000000000000 + + + 1000000000000000000000.000000000000000 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + unspecified + + + + + + + + + + true + + + y + + + + + + + true + + + + 100 + 20 + + + + Real part of potential y-component + + + true + + + + + + -1000000000000000000000.000000000000000 + + + 1000000000000000000000.000000000000000 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + unspecified + + + + + + + + + + true + + + + 100 + 20 + + + + Imaginary part of potential y-component + + + true + + + + + + -1000000000000000000000.000000000000000 + + + 1000000000000000000000.000000000000000 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + unspecified + + + + + + + + + + true + + + z + + + + + + + true + + + + 100 + 20 + + + + Real part of potential z-component + + + true + + + + + + -1000000000000000000000.000000000000000 + + + 1000000000000000000000.000000000000000 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + unspecified + + + + + + + + + + true + + + + 100 + 20 + + + + Imaginary part of potential z-component + + + true + + + + + + -1000000000000000000000.000000000000000 + + + 1000000000000000000000.000000000000000 + + + 1.000000000000000 + + + 1.000000000000000 + + + + + + + unspecified + + + @@ -75,5 +345,102 @@ - + + + reXunspecBox + toggled(bool) + realXQSB + setDisabled(bool) + + + 152 + 61 + + + 80 + 61 + + + + + reYunspecBox + toggled(bool) + realYQSB + setDisabled(bool) + + + 152 + 87 + + + 80 + 87 + + + + + imZunspecBox + toggled(bool) + imagZQSB + setDisabled(bool) + + + 297 + 113 + + + 224 + 113 + + + + + imYunspecBox + toggled(bool) + imagYQSB + setDisabled(bool) + + + 297 + 87 + + + 224 + 87 + + + + + imXunspecBox + toggled(bool) + imagXQSB + setDisabled(bool) + + + 297 + 61 + + + 224 + 61 + + + + + reZunspecBox + toggled(bool) + realZQSB + setDisabled(bool) + + + 152 + 113 + + + 80 + 113 + + + + diff --git a/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui b/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui index 48451e6b1f..d2296c4524 100644 --- a/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui +++ b/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui @@ -6,7 +6,7 @@ 0 0 - 313 + 300 133 @@ -15,7 +15,7 @@ - + Magnetization diff --git a/src/Mod/Fem/femobjects/constraint_currentdensity.py b/src/Mod/Fem/femobjects/constraint_currentdensity.py index 8efa92faf1..13c2e38c3c 100644 --- a/src/Mod/Fem/femobjects/constraint_currentdensity.py +++ b/src/Mod/Fem/femobjects/constraint_currentdensity.py @@ -44,11 +44,101 @@ class ConstraintCurrentDensity(base_fempythonobject.BaseFemPythonObject): self.add_properties(obj) def add_properties(self, obj): - if not hasattr(obj, "CurrentDensity"): + if not hasattr(obj, "CurrentDensity_re_1"): obj.addProperty( "App::PropertyCurrentDensity", - "CurrentDensity", - "Parameter", - "Current Density" + "CurrentDensity_re_1", + "Vector Potential", + "Real part of current density x-component" ) - obj.CurrentDensity = 0.0 + obj.CurrentDensity_re_1 = "0 A/m^2" + if not hasattr(obj, "CurrentDensity_re_2"): + obj.addProperty( + "App::PropertyCurrentDensity", + "CurrentDensity_re_2", + "Vector Potential", + "Real part of current density y-component" + ) + obj.CurrentDensity_re_2 = "0 A/m^2" + if not hasattr(obj, "CurrentDensity_re_3"): + obj.addProperty( + "App::PropertyCurrentDensity", + "CurrentDensity_re_3", + "Vector Potential", + "Real part of current density z-component" + ) + obj.CurrentDensity_re_3 = "0 A/m^2" + if not hasattr(obj, "CurrentDensity_im_1"): + obj.addProperty( + "App::PropertyCurrentDensity", + "CurrentDensity_im_1", + "Vector Potential", + "Imaginary part of current density x-component" + ) + obj.CurrentDensity_im_1 = "0 A/m^2" + if not hasattr(obj, "CurrentDensity_im_2"): + obj.addProperty( + "App::PropertyCurrentDensity", + "CurrentDensity_im_2", + "Vector Potential", + "Imaginary part of current density y-component" + ) + obj.CurrentDensity_im_2 = "0 A/m^2" + if not hasattr(obj, "CurrentDensity_im_3"): + obj.addProperty( + "App::PropertyCurrentDensity", + "CurrentDensity_im_3", + "Vector Potential", + "Imaginary part of current density z-component" + ) + obj.CurrentDensity_im_3 = "0 A/m^2" + + # now the enable bools + if not hasattr(obj, "CurrentDensity_re_1_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_re_1_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_re_1_Disabled = True + if not hasattr(obj, "CurrentDensity_re_2_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_re_2_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_re_2_Disabled = True + if not hasattr(obj, "CurrentDensity_re_3_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_re_3_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_re_3_Disabled = True + if not hasattr(obj, "CurrentDensity_im_1_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_im_1_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_im_1_Disabled = True + if not hasattr(obj, "CurrentDensity_im_2_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_im_2_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_im_2_Disabled = True + if not hasattr(obj, "CurrentDensity_im_3_Disabled"): + obj.addProperty( + "App::PropertyBool", + "CurrentDensity_im_3_Disabled", + "Vector Potential", + "" + ) + obj.CurrentDensity_im_3_Disabled = True diff --git a/src/Mod/Fem/femtaskpanels/task_constraint_currentdensity.py b/src/Mod/Fem/femtaskpanels/task_constraint_currentdensity.py index 437e689a22..35b151696a 100644 --- a/src/Mod/Fem/femtaskpanels/task_constraint_currentdensity.py +++ b/src/Mod/Fem/femtaskpanels/task_constraint_currentdensity.py @@ -102,22 +102,86 @@ class _TaskPanel(object): self._part.ViewObject.hide() def _initParamWidget(self): - self._paramWidget.currentDensityQSB.setProperty( - 'value', self._obj.CurrentDensity) + self._paramWidget.realXQSB.setProperty( + 'value', self._obj.CurrentDensity_re_1) FreeCADGui.ExpressionBinding( - self._paramWidget.currentDensityQSB).bind(self._obj, "CurrentDensity") - self._paramWidget.currentDensityQSB.setProperty( - 'value', self._obj.CurrentDensity) + self._paramWidget.realXQSB).bind(self._obj, "CurrentDensity_re_1") + self._paramWidget.realYQSB.setProperty( + 'value', self._obj.CurrentDensity_re_2) + FreeCADGui.ExpressionBinding( + self._paramWidget.realYQSB).bind(self._obj, "CurrentDensity_re_2") + self._paramWidget.realZQSB.setProperty( + 'value', self._obj.CurrentDensity_re_3) + FreeCADGui.ExpressionBinding( + self._paramWidget.realZQSB).bind(self._obj, "CurrentDensity_re_3") + self._paramWidget.imagXQSB.setProperty( + 'value', self._obj.CurrentDensity_im_1) + FreeCADGui.ExpressionBinding( + self._paramWidget.imagXQSB).bind(self._obj, "CurrentDensity_im_1") + self._paramWidget.imagYQSB.setProperty( + 'value', self._obj.CurrentDensity_im_2) + FreeCADGui.ExpressionBinding( + self._paramWidget.imagYQSB).bind(self._obj, "CurrentDensity_im_2") + self._paramWidget.imagZQSB.setProperty( + 'value', self._obj.CurrentDensity_im_3) + FreeCADGui.ExpressionBinding( + self._paramWidget.imagZQSB).bind(self._obj, "CurrentDensity_im_3") - def _applyWidgetChanges(self): + self._paramWidget.reXunspecBox.setChecked( + self._obj.CurrentDensity_re_1_Disabled) + self._paramWidget.reYunspecBox.setChecked( + self._obj.CurrentDensity_re_2_Disabled) + self._paramWidget.reZunspecBox.setChecked( + self._obj.CurrentDensity_re_3_Disabled) + self._paramWidget.imXunspecBox.setChecked( + self._obj.CurrentDensity_im_1_Disabled) + self._paramWidget.imYunspecBox.setChecked( + self._obj.CurrentDensity_im_2_Disabled) + self._paramWidget.imZunspecBox.setChecked( + self._obj.CurrentDensity_im_3_Disabled) + + def _applyCurrentDensityChanges(self, enabledBox, currentDensityQSB): + enabled = enabledBox.isChecked() currentdensity = None try: - currentdensity = self._paramWidget.currentDensityQSB.property('value') + currentdensity = currentDensityQSB.property('value') except ValueError: FreeCAD.Console.PrintMessage( "Wrong input. Not recognised input: '{}' " - "Current density has not been set.\n" - .format(self._paramWidget.currentDensityQSB.text()) + "Current density has not been set.\n".format(currentDensityQSB.text()) + ) + currentdensity = '0.0 A/m^2' + return enabled, currentdensity + + def _applyWidgetChanges(self): + # apply the current densities and their enabled state + self._obj.CurrentDensity_re_1_Disabled, self._obj.CurrentDensity_re_1 = \ + self._applyCurrentDensityChanges( + self._paramWidget.reXunspecBox, + self._paramWidget.realXQSB + ) + self._obj.CurrentDensity_re_2_Disabled, self._obj.CurrentDensity_re_2 = \ + self._applyCurrentDensityChanges( + self._paramWidget.reYunspecBox, + self._paramWidget.realYQSB + ) + self._obj.CurrentDensity_re_3_Disabled, self._obj.CurrentDensity_re_3 = \ + self._applyCurrentDensityChanges( + self._paramWidget.reZunspecBox, + self._paramWidget.realZQSB + ) + self._obj.CurrentDensity_im_1_Disabled, self._obj.CurrentDensity_im_1 = \ + self._applyCurrentDensityChanges( + self._paramWidget.imXunspecBox, + self._paramWidget.imagXQSB + ) + self._obj.CurrentDensity_im_2_Disabled, self._obj.CurrentDensity_im_2 = \ + self._applyCurrentDensityChanges( + self._paramWidget.imYunspecBox, + self._paramWidget.imagYQSB + ) + self._obj.CurrentDensity_im_3_Disabled, self._obj.CurrentDensity_im_3 = \ + self._applyCurrentDensityChanges( + self._paramWidget.imZunspecBox, + self._paramWidget.imagZQSB ) - if currentdensity is not None: - self._obj.CurrentDensity = currentdensity