diff --git a/src/Gui/DlgUnitsCalculatorImp.cpp b/src/Gui/DlgUnitsCalculatorImp.cpp
index ce0cab5848..b5162bd8c2 100644
--- a/src/Gui/DlgUnitsCalculatorImp.cpp
+++ b/src/Gui/DlgUnitsCalculatorImp.cpp
@@ -96,6 +96,7 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
<< Base::Unit::MagneticFieldStrength
<< Base::Unit::MagneticFlux
<< Base::Unit::MagneticFluxDensity
+ << Base::Unit::Magnetization
<< Base::Unit::Pressure
<< Base::Unit::Power
<< Base::Unit::SpecificHeat
diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt
index f2f4f454c6..65ce6b8095 100755
--- a/src/Mod/Fem/CMakeLists.txt
+++ b/src/Mod/Fem/CMakeLists.txt
@@ -174,6 +174,7 @@ SET(FemObjects_SRCS
femobjects/constraint_flowvelocity.py
femobjects/constraint_initialflowvelocity.py
femobjects/constraint_initialpressure.py
+ femobjects/constraint_magnetization.py
femobjects/constraint_sectionprint.py
femobjects/constraint_selfweight.py
femobjects/constraint_tie.py
@@ -579,6 +580,7 @@ SET(FemGuiTaskPanels_SRCS
femtaskpanels/task_constraint_flowvelocity.py
femtaskpanels/task_constraint_initialflowvelocity.py
femtaskpanels/task_constraint_initialpressure.py
+ femtaskpanels/task_constraint_magnetization.py
femtaskpanels/task_constraint_sectionprint.py
femtaskpanels/task_constraint_tie.py
femtaskpanels/task_element_fluid1D.py
@@ -618,6 +620,7 @@ SET(FemGuiViewProvider_SRCS
femviewprovider/view_constraint_flowvelocity.py
femviewprovider/view_constraint_initialflowvelocity.py
femviewprovider/view_constraint_initialpressure.py
+ femviewprovider/view_constraint_magnetization.py
femviewprovider/view_constraint_sectionprint.py
femviewprovider/view_constraint_selfweight.py
femviewprovider/view_constraint_tie.py
diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt
index 6b6b4768ab..61783817c3 100755
--- a/src/Mod/Fem/Gui/CMakeLists.txt
+++ b/src/Mod/Fem/Gui/CMakeLists.txt
@@ -384,6 +384,7 @@ SET(FemGuiPythonUI_SRCS
Resources/ui/FlowVelocity.ui
Resources/ui/InitialFlowVelocity.ui
Resources/ui/InitialPressure.ui
+ Resources/ui/Magnetization.ui
Resources/ui/Material.ui
Resources/ui/MaterialReinforcement.ui
Resources/ui/MeshBoundaryLayer.ui
diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp
index 6c1ca3ff3d..2ff8be389e 100644
--- a/src/Mod/Fem/Gui/Command.cpp
+++ b/src/Mod/Fem/Gui/Command.cpp
@@ -1261,6 +1261,8 @@ void CmdFemCompEmConstraints::activated(int iMsg)
rcCmdMgr.runCommandByName("FEM_ConstraintElectrostaticPotential");
else if (iMsg == 1)
rcCmdMgr.runCommandByName("FEM_ConstraintCurrentDensity");
+ else if (iMsg == 2)
+ rcCmdMgr.runCommandByName("FEM_ConstraintMagnetization");
else
return;
@@ -1283,6 +1285,8 @@ Gui::Action* CmdFemCompEmConstraints::createAction()
cmd0->setIcon(Gui::BitmapFactory().iconFromTheme("FEM_ConstraintElectrostaticPotential"));
QAction* cmd1 = pcAction->addAction(QString());
cmd1->setIcon(Gui::BitmapFactory().iconFromTheme("FEM_ConstraintCurrentDensity"));
+ QAction* cmd2 = pcAction->addAction(QString());
+ cmd2->setIcon(Gui::BitmapFactory().iconFromTheme("FEM_ConstraintMagnetization"));
_pcAction = pcAction;
languageChange();
@@ -1329,6 +1333,18 @@ void CmdFemCompEmConstraints::languageChange()
cmd1->setStatusTip(QApplication::translate("FEM_ConstraintCurrentDensity",
ConstraintCurrentDensity->getStatusTip()));
}
+
+ Gui::Command* ConstraintMagnetization =
+ rcCmdMgr.getCommandByName("FEM_ConstraintMagnetization");
+ if (ConstraintMagnetization) {
+ QAction* cmd2 = a[2];
+ cmd2->setText(QApplication::translate("FEM_ConstraintMagnetization",
+ ConstraintMagnetization->getMenuText()));
+ cmd2->setToolTip(QApplication::translate("FEM_ConstraintMagnetization",
+ ConstraintMagnetization->getToolTipText()));
+ cmd2->setStatusTip(QApplication::translate("FEM_ConstraintMagnetization",
+ ConstraintMagnetization->getStatusTip()));
+ }
}
bool CmdFemCompEmConstraints::isActive()
diff --git a/src/Mod/Fem/Gui/Resources/Fem.qrc b/src/Mod/Fem/Gui/Resources/Fem.qrc
index 9cc6c1a307..3636ce6723 100755
--- a/src/Mod/Fem/Gui/Resources/Fem.qrc
+++ b/src/Mod/Fem/Gui/Resources/Fem.qrc
@@ -25,6 +25,7 @@
icons/FEM_ConstraintInitialFlowVelocity.svg
icons/FEM_ConstraintInitialPressure.svg
icons/FEM_ConstraintInitialTemperature.svg
+ icons/FEM_ConstraintMagnetization.svg
icons/FEM_ConstraintPlaneRotation.svg
icons/FEM_ConstraintPressure.svg
icons/FEM_ConstraintPulley.svg
@@ -169,6 +170,7 @@
ui/FlowVelocity.ui
ui/InitialFlowVelocity.ui
ui/InitialPressure.ui
+ ui/Magnetization.ui
ui/Material.ui
ui/MaterialReinforcement.ui
ui/MeshBoundaryLayer.ui
diff --git a/src/Mod/Fem/Gui/Resources/icons/FEM_ConstraintMagnetization.svg b/src/Mod/Fem/Gui/Resources/icons/FEM_ConstraintMagnetization.svg
new file mode 100644
index 0000000000..07d95cc365
--- /dev/null
+++ b/src/Mod/Fem/Gui/Resources/icons/FEM_ConstraintMagnetization.svg
@@ -0,0 +1,103 @@
+
+
+
+
diff --git a/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui b/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui
new file mode 100644
index 0000000000..48451e6b1f
--- /dev/null
+++ b/src/Mod/Fem/Gui/Resources/ui/Magnetization.ui
@@ -0,0 +1,446 @@
+
+
+ Form
+
+
+
+ 0
+ 0
+ 313
+ 133
+
+
+
+ Constraint Properties
+
+
+ -
+
+
+ Magnetization
+
+
+
+ -
+
+
+ true
+
+
+ Real
+
+
+
+ -
+
+
+ true
+
+
+ Imaginary
+
+
+
+ -
+
+
+ true
+
+
+ x
+
+
+
+ -
+
+
+ true
+
+
+
+ 100
+ 20
+
+
+
+ Real part of potential x-component
+
+
+ true
+
+
+
+
+
+ -1000000000000000000000.000000000000000
+
+
+ 1000000000000000000000.000000000000000
+
+
+ 1.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
+
+
+
+
+
+
+
+
+
+
+ Gui::QuantitySpinBox
+ QWidget
+
+
+
+
+
+
+ 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/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp
index ffd6f6aef3..9be3e2e32f 100755
--- a/src/Mod/Fem/Gui/Workbench.cpp
+++ b/src/Mod/Fem/Gui/Workbench.cpp
@@ -246,7 +246,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
elec->setCommand("&Electromagnetic Constraints");
*elec
<< "FEM_ConstraintElectrostaticPotential"
- << "FEM_ConstraintCurrentDensity";
+ << "FEM_ConstraintCurrentDensity"
+ << "FEM_ConstraintMagnetization";
Gui::MenuItem* fluid = new Gui::MenuItem;
fluid->setCommand("&Fluid Constraints");
diff --git a/src/Mod/Fem/ObjectsFem.py b/src/Mod/Fem/ObjectsFem.py
index 503d3e3f4d..e6d00b2c31 100644
--- a/src/Mod/Fem/ObjectsFem.py
+++ b/src/Mod/Fem/ObjectsFem.py
@@ -268,6 +268,21 @@ def makeConstraintInitialTemperature(
return obj
+def makeConstraintMagnetization(
+ doc,
+ name="ConstraintMagnetization"
+):
+ """makeConstraintMagnetization(document, [name]):
+ makes a Fem Magnetization object"""
+ obj = doc.addObject("Fem::ConstraintPython", name)
+ from femobjects import constraint_magnetization
+ constraint_magnetization.ConstraintMagnetization(obj)
+ if FreeCAD.GuiUp:
+ from femviewprovider import view_constraint_magnetization
+ view_constraint_magnetization.VPConstraintMagnetization(obj.ViewObject)
+ return obj
+
+
def makeConstraintPlaneRotation(
doc,
name="ConstraintPlaneRotation"
diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py
index 39271fc6b5..4e625983db 100644
--- a/src/Mod/Fem/femcommands/commands.py
+++ b/src/Mod/Fem/femcommands/commands.py
@@ -295,6 +295,23 @@ class _ConstraintInitialPressure(CommandManager):
self.do_activated = "add_obj_on_gui_set_edit"
+class _ConstraintMagnetization(CommandManager):
+ "The FEM_ConstraintMagnetization command definition"
+
+ def __init__(self):
+ super(_ConstraintMagnetization, self).__init__()
+ self.menutext = Qt.QT_TRANSLATE_NOOP(
+ "FEM_ConstraintMagnetization",
+ "Constraint magnetization"
+ )
+ self.tooltip = Qt.QT_TRANSLATE_NOOP(
+ "FEM_ConstraintMagnetization",
+ "Creates a FEM constraint magnetization"
+ )
+ self.is_active = "with_analysis"
+ self.do_activated = "add_obj_on_gui_set_edit"
+
+
class _ConstraintSectionPrint(CommandManager):
"The FEM_ConstraintSectionPrint command definition"
@@ -1166,6 +1183,10 @@ FreeCADGui.addCommand(
"FEM_ConstraintInitialPressure",
_ConstraintInitialPressure()
)
+FreeCADGui.addCommand(
+ "FEM_ConstraintMagnetization",
+ _ConstraintMagnetization()
+)
FreeCADGui.addCommand(
"FEM_ConstraintSectionPrint",
_ConstraintSectionPrint()
diff --git a/src/Mod/Fem/femobjects/constraint_magnetization.py b/src/Mod/Fem/femobjects/constraint_magnetization.py
new file mode 100644
index 0000000000..2e10e49394
--- /dev/null
+++ b/src/Mod/Fem/femobjects/constraint_magnetization.py
@@ -0,0 +1,144 @@
+# ***************************************************************************
+# * Copyright (c) 2023 Uwe Stöhr *
+# * *
+# * This file is part of the FreeCAD CAx development system. *
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU Lesser General Public License (LGPL) *
+# * as published by the Free Software Foundation; either version 2 of *
+# * the License, or (at your option) any later version. *
+# * for detail see the LICENCE text file. *
+# * *
+# * This program is distributed in the hope that it will be useful, *
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# * GNU Library General Public License for more details. *
+# * *
+# * You should have received a copy of the GNU Library General Public *
+# * License along with this program; if not, write to the Free Software *
+# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
+# * USA *
+# * *
+# ***************************************************************************
+
+__title__ = "FreeCAD FEM constraint magnetization document object"
+__author__ = "Uwe Stöhr"
+__url__ = "https://www.freecadweb.org"
+
+## @package constraint_magnetization
+# \ingroup FEM
+# \brief constraint magnetization source object
+
+from . import base_fempythonobject
+
+
+class ConstraintMagnetization(base_fempythonobject.BaseFemPythonObject):
+
+ Type = "Fem::ConstraintMagnetization"
+
+ def __init__(self, obj):
+ super(ConstraintMagnetization, self).__init__(obj)
+ self.add_properties(obj)
+
+ def onDocumentRestored(self, obj):
+ self.add_properties(obj)
+
+ def add_properties(self, obj):
+ if not hasattr(obj, "Magnetization_re_1"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_re_1",
+ "Vector Potential",
+ "Real part of magnetization x-component"
+ )
+ obj.Magnetization_re_1 = "0 A/m"
+ if not hasattr(obj, "Magnetization_re_2"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_re_2",
+ "Vector Potential",
+ "Real part of magnetization y-component"
+ )
+ obj.Magnetization_re_2 = "0 A/m"
+ if not hasattr(obj, "Magnetization_re_3"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_re_3",
+ "Vector Potential",
+ "Real part of magnetization z-component"
+ )
+ obj.Magnetization_re_3 = "0 A/m"
+ if not hasattr(obj, "Magnetization_im_1"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_im_1",
+ "Vector Potential",
+ "Imaginary part of magnetization x-component"
+ )
+ obj.Magnetization_im_1 = "0 A/m"
+ if not hasattr(obj, "Magnetization_im_2"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_im_2",
+ "Vector Potential",
+ "Imaginary part of magnetization y-component"
+ )
+ obj.Magnetization_im_2 = "0 A/m"
+ if not hasattr(obj, "Magnetization_im_3"):
+ obj.addProperty(
+ "App::PropertyMagnetization",
+ "Magnetization_im_3",
+ "Vector Potential",
+ "Imaginary part of magnetization z-component"
+ )
+ obj.Magnetization_im_3 = "0 A/m"
+
+ # now the enable bools
+ if not hasattr(obj, "Magnetization_re_1_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_re_1_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_re_1_Disabled = True
+ if not hasattr(obj, "Magnetization_re_2_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_re_2_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_re_2_Disabled = True
+ if not hasattr(obj, "Magnetization_re_3_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_re_3_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_re_3_Disabled = True
+ if not hasattr(obj, "Magnetization_im_1_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_im_1_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_im_1_Disabled = True
+ if not hasattr(obj, "Magnetization_im_2_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_im_2_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_im_2_Disabled = True
+ if not hasattr(obj, "Magnetization_im_3_Disabled"):
+ obj.addProperty(
+ "App::PropertyBool",
+ "Magnetization_im_3_Disabled",
+ "Vector Potential",
+ ""
+ )
+ obj.Magnetization_im_3_Disabled = True
diff --git a/src/Mod/Fem/femtaskpanels/task_constraint_magnetization.py b/src/Mod/Fem/femtaskpanels/task_constraint_magnetization.py
new file mode 100644
index 0000000000..a403622569
--- /dev/null
+++ b/src/Mod/Fem/femtaskpanels/task_constraint_magnetization.py
@@ -0,0 +1,187 @@
+# ***************************************************************************
+# * Copyright (c) 2023 Uwe Stöhr *
+# * *
+# * This file is part of the FreeCAD CAx development system. *
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU Lesser General Public License (LGPL) *
+# * as published by the Free Software Foundation; either version 2 of *
+# * the License, or (at your option) any later version. *
+# * for detail see the LICENCE text file. *
+# * *
+# * This program is distributed in the hope that it will be useful, *
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# * GNU Library General Public License for more details. *
+# * *
+# * You should have received a copy of the GNU Library General Public *
+# * License along with this program; if not, write to the Free Software *
+# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
+# * USA *
+# * *
+# ***************************************************************************
+
+__title__ = "FreeCAD FEM constraint magnetization task panel for the document object"
+__author__ = "Uwe Stöhr"
+__url__ = "https://www.freecadweb.org"
+
+## @package task_constraint_magnetization
+# \ingroup FEM
+# \brief task panel for constraint magnetization object
+
+import FreeCAD
+import FreeCADGui
+
+from femguiutils import selection_widgets
+
+from femtools import femutils
+from femtools import membertools
+
+
+class _TaskPanel(object):
+
+ def __init__(self, obj):
+ self._obj = obj
+
+ self._paramWidget = FreeCADGui.PySideUic.loadUi(
+ FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/Magnetization.ui")
+ self._initParamWidget()
+
+ # geometry selection widget
+ # magnetization is always a body force for 3D, therefore only allow solid
+ self._selectionWidget = selection_widgets.GeometryElementsSelection(
+ obj.References,
+ ["Solid"],
+ True,
+ False
+ )
+
+ # form made from param and selection widget
+ self.form = [self._paramWidget, self._selectionWidget]
+
+ analysis = obj.getParentGroup()
+ self._mesh = None
+ self._part = None
+ if analysis is not None:
+ self._mesh = membertools.get_single_member(analysis, "Fem::FemMeshObject")
+ if self._mesh is not None:
+ self._part = femutils.get_part_to_mesh(self._mesh)
+ self._partVisible = None
+ self._meshVisible = None
+
+ def open(self):
+ if self._mesh is not None and self._part is not None:
+ self._meshVisible = self._mesh.ViewObject.isVisible()
+ self._partVisible = self._part.ViewObject.isVisible()
+ self._mesh.ViewObject.hide()
+ self._part.ViewObject.show()
+
+ def reject(self):
+ self._restoreVisibility()
+ FreeCADGui.ActiveDocument.resetEdit()
+ return True
+
+ def accept(self):
+ if self._obj.References != self._selectionWidget.references:
+ self._obj.References = self._selectionWidget.references
+ self._applyWidgetChanges()
+ self._obj.Document.recompute()
+ FreeCADGui.ActiveDocument.resetEdit()
+ self._restoreVisibility()
+ return True
+
+ def _restoreVisibility(self):
+ if self._mesh is not None and self._part is not None:
+ if self._meshVisible:
+ self._mesh.ViewObject.show()
+ else:
+ self._mesh.ViewObject.hide()
+ if self._partVisible:
+ self._part.ViewObject.show()
+ else:
+ self._part.ViewObject.hide()
+
+ def _initParamWidget(self):
+ self._paramWidget.realXQSB.setProperty(
+ 'value', self._obj.Magnetization_re_1)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.realXQSB).bind(self._obj, "Magnetization_re_1")
+ self._paramWidget.realYQSB.setProperty(
+ 'value', self._obj.Magnetization_re_2)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.realYQSB).bind(self._obj, "Magnetization_re_2")
+ self._paramWidget.realZQSB.setProperty(
+ 'value', self._obj.Magnetization_re_3)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.realZQSB).bind(self._obj, "Magnetization_re_3")
+ self._paramWidget.imagXQSB.setProperty(
+ 'value', self._obj.Magnetization_im_1)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.imagXQSB).bind(self._obj, "Magnetization_im_1")
+ self._paramWidget.imagYQSB.setProperty(
+ 'value', self._obj.Magnetization_im_2)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.imagYQSB).bind(self._obj, "Magnetization_im_2")
+ self._paramWidget.imagZQSB.setProperty(
+ 'value', self._obj.Magnetization_im_3)
+ FreeCADGui.ExpressionBinding(
+ self._paramWidget.imagZQSB).bind(self._obj, "Magnetization_im_3")
+
+ self._paramWidget.reXunspecBox.setChecked(
+ self._obj.Magnetization_re_1)
+ self._paramWidget.reYunspecBox.setChecked(
+ self._obj.Magnetization_re_2)
+ self._paramWidget.reZunspecBox.setChecked(
+ self._obj.Magnetization_re_3)
+ self._paramWidget.imXunspecBox.setChecked(
+ self._obj.Magnetization_im_1)
+ self._paramWidget.imYunspecBox.setChecked(
+ self._obj.Magnetization_im_2)
+ self._paramWidget.imZunspecBox.setChecked(
+ self._obj.Magnetization_im_3)
+
+ def _applyMagnetizationChanges(self, enabledBox, magnetizationQSB):
+ enabled = enabledBox.isChecked()
+ magnetization = None
+ try:
+ magnetization = magnetizationQSB.property('value')
+ except ValueError:
+ FreeCAD.Console.PrintMessage(
+ "Wrong input. Not recognised input: '{}' "
+ "Magnetization has not been set.\n".format(magnetizationQSB.text())
+ )
+ magnetization = '0.0 A/m'
+ return enabled, magnetization
+
+ def _applyWidgetChanges(self):
+ # apply the magnetizations and their enabled state
+ self._obj.Magnetization_re_1_Disabled, self._obj.Magnetization_re_1 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.reXunspecBox,
+ self._paramWidget.realXQSB
+ )
+ self._obj.Magnetization_re_2_Disabled, self._obj.Magnetization_re_2 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.reYunspecBox,
+ self._paramWidget.realYQSB
+ )
+ self._obj.Magnetization_re_3_Disabled, self._obj.Magnetization_re_3 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.reZunspecBox,
+ self._paramWidget.realZQSB
+ )
+ self._obj.Magnetization_im_1_Disabled, self._obj.Magnetization_im_1 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.imXunspecBox,
+ self._paramWidget.imagXQSB
+ )
+ self._obj.Magnetization_im_2_Disabled, self._obj.Magnetization_im_2 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.imYunspecBox,
+ self._paramWidget.imagYQSB
+ )
+ self._obj.Magnetization_im_3_Disabled, self._obj.Magnetization_im_3 = \
+ self._applyMagnetizationChanges(
+ self._paramWidget.imZunspecBox,
+ self._paramWidget.imagZQSB
+ )
diff --git a/src/Mod/Fem/femtest/app/test_object.py b/src/Mod/Fem/femtest/app/test_object.py
index f341c0ab8c..a5a5d012c6 100644
--- a/src/Mod/Fem/femtest/app/test_object.py
+++ b/src/Mod/Fem/femtest/app/test_object.py
@@ -225,6 +225,10 @@ class TestObjectType(unittest.TestCase):
"Fem::ConstraintInitialTemperature",
type_of_obj(ObjectsFem.makeConstraintInitialTemperature(doc))
)
+ self.assertEqual(
+ "Fem::ConstraintMagnetization",
+ type_of_obj(ObjectsFem.makeConstraintMagnetization(doc))
+ )
self.assertEqual(
"Fem::ConstraintPlaneRotation",
type_of_obj(ObjectsFem.makeConstraintPlaneRotation(doc))
@@ -430,6 +434,10 @@ class TestObjectType(unittest.TestCase):
ObjectsFem.makeConstraintFluidBoundary(doc),
"Fem::ConstraintFluidBoundary"
))
+ self.assertTrue(is_of_type(
+ ObjectsFem.makeConstraintMagnetization(doc),
+ "Fem::ConstraintMagnetization"
+ ))
self.assertTrue(is_of_type(
ObjectsFem.makeConstraintSpring(doc),
"Fem::ConstraintSpring"
@@ -784,6 +792,21 @@ class TestObjectType(unittest.TestCase):
"Fem::ConstraintFluidBoundary"
))
+ # ConstraintMagnetization
+ constraint_magnetization = ObjectsFem.makeConstraintMagnetization(doc)
+ self.assertTrue(is_derived_from(
+ constraint_magnetization,
+ "App::DocumentObject"
+ ))
+ self.assertTrue(is_derived_from(
+ constraint_magnetization,
+ "Fem::ConstraintPython"
+ ))
+ self.assertTrue(is_derived_from(
+ constraint_magnetization,
+ "Fem::ConstraintMagnetization"
+ ))
+
# ConstraintSpring
constraint_spring = ObjectsFem.makeConstraintSpring(doc)
self.assertTrue(is_derived_from(
@@ -1513,6 +1536,11 @@ class TestObjectType(unittest.TestCase):
doc
).isDerivedFrom("Fem::ConstraintFluidBoundary")
)
+ self.assertTrue(
+ ObjectsFem.makeConstraintMagnetization(
+ doc
+ ).isDerivedFrom("Fem::ConstraintPython")
+ )
self.assertTrue(
ObjectsFem.makeConstraintSpring(
doc
@@ -1767,6 +1795,7 @@ def create_all_fem_objects_doc(
analysis.addObject(ObjectsFem.makeConstraintInitialFlowVelocity(doc))
analysis.addObject(ObjectsFem.makeConstraintInitialPressure(doc))
analysis.addObject(ObjectsFem.makeConstraintInitialTemperature(doc))
+ analysis.addObject(ObjectsFem.makeConstraintMagnetization(doc))
analysis.addObject(ObjectsFem.makeConstraintPlaneRotation(doc))
analysis.addObject(ObjectsFem.makeConstraintPressure(doc))
analysis.addObject(ObjectsFem.makeConstraintPulley(doc))
diff --git a/src/Mod/Fem/femtest/app/test_open.py b/src/Mod/Fem/femtest/app/test_open.py
index 17e213eda8..a12b13c98b 100644
--- a/src/Mod/Fem/femtest/app/test_open.py
+++ b/src/Mod/Fem/femtest/app/test_open.py
@@ -209,6 +209,11 @@ class TestObjectOpen(unittest.TestCase):
doc.ConstraintInitialFlowVelocity.Proxy.__class__
)
+ self.assertEqual(
+ "Fem::ConstraintMagnetization",
+ type_of_obj(ObjectsFem.makeConstraintMagnetization(doc))
+ )
+
from femobjects.constraint_selfweight import ConstraintSelfWeight
self.assertEqual(
ConstraintSelfWeight,
diff --git a/src/Mod/Fem/femtest/gui/test_open.py b/src/Mod/Fem/femtest/gui/test_open.py
index 94e513437a..2ea21655c2 100644
--- a/src/Mod/Fem/femtest/gui/test_open.py
+++ b/src/Mod/Fem/femtest/gui/test_open.py
@@ -184,6 +184,11 @@ class TestObjectOpen(unittest.TestCase):
doc.ConstraintInitialFlowVelocity.ViewObject.Proxy.__class__
)
+ self.assertEqual(
+ "Fem::ConstraintMagnetization",
+ type_of_obj(ObjectsFem.makeConstraintMagnetization(doc))
+ )
+
from femviewprovider.view_constraint_selfweight import VPConstraintSelfWeight
self.assertEqual(
VPConstraintSelfWeight,
diff --git a/src/Mod/Fem/femviewprovider/view_constraint_magnetization.py b/src/Mod/Fem/femviewprovider/view_constraint_magnetization.py
new file mode 100644
index 0000000000..3bd813a697
--- /dev/null
+++ b/src/Mod/Fem/femviewprovider/view_constraint_magnetization.py
@@ -0,0 +1,44 @@
+# ***************************************************************************
+# * Copyright (c) 2023 Uwe Stöhr *
+# * *
+# * This file is part of the FreeCAD CAx development system. *
+# * *
+# * This program is free software; you can redistribute it and/or modify *
+# * it under the terms of the GNU Lesser General Public License (LGPL) *
+# * as published by the Free Software Foundation; either version 2 of *
+# * the License, or (at your option) any later version. *
+# * for detail see the LICENCE text file. *
+# * *
+# * This program is distributed in the hope that it will be useful, *
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# * GNU Library General Public License for more details. *
+# * *
+# * You should have received a copy of the GNU Library General Public *
+# * License along with this program; if not, write to the Free Software *
+# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
+# * USA *
+# * *
+# ***************************************************************************
+
+__title__ = "FreeCAD FEM constraint magnetization ViewProvider for the document object"
+__author__ = "Uwe Stöhr"
+__url__ = "https://www.freecadweb.org"
+
+## @package view_constraint_magnetization
+# \ingroup FEM
+# \brief view provider for constraint magnetization object
+
+from femtaskpanels import task_constraint_magnetization
+from . import view_base_femconstraint
+
+
+class VPConstraintMagnetization(view_base_femconstraint.VPBaseFemConstraint):
+
+ def setEdit(self, vobj, mode=0):
+ view_base_femconstraint.VPBaseFemConstraint.setEdit(
+ self,
+ vobj,
+ mode,
+ task_constraint_magnetization._TaskPanel
+ )