Fem: Create own base class for Python Element objects

This commit is contained in:
marioalexis
2024-06-18 14:04:33 -03:00
committed by Chris Hennes
parent b485c3fcd6
commit 2bb2160fa2
11 changed files with 120 additions and 53 deletions

View File

@@ -169,6 +169,7 @@ SET(FemMesh_SRCS
SET(FemObjects_SRCS
femobjects/__init__.py
femobjects/base_femelement.py
femobjects/base_fempythonobject.py
femobjects/constant_vacuumpermittivity.py
femobjects/constraint_bodyheatsource.py
@@ -606,6 +607,7 @@ SET(FemGuiUtils_SRCS
SET(FemGuiViewProvider_SRCS
femviewprovider/__init__.py
femviewprovider/view_base_femconstraint.py
femviewprovider/view_base_femelement.py
femviewprovider/view_base_femobject.py
femviewprovider/view_constant_vacuumpermittivity.py
femviewprovider/view_constraint_bodyheatsource.py

View File

@@ -0,0 +1,60 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#/***************************************************************************
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD 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 *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# **************************************************************************
__title__ = "FreeCAD FEM base element object"
__author__ = "Mario Passaglia"
__url__ = "https://www.freecad.org"
## @package base_femelement
# \ingroup FEM
# \brief base object for FEM Element Features
from . import base_fempythonobject
_PropHelper = base_fempythonobject._PropHelper
class BaseFemElement(base_fempythonobject.BaseFemPythonObject):
BaseType = "Fem::BaseFemElement"
def __init__(self, obj):
super().__init__(obj)
for prop in self._get_properties():
prop.add_to_object(obj)
def _get_properties(self):
prop = []
prop.append(_PropHelper(
type = "App::PropertyLinkSubList",
name = "References",
group = "Element",
doc = "List of element shapes",
value = []
)
)
return prop

View File

@@ -31,10 +31,10 @@ __url__ = "https://www.freecad.org"
# \ingroup FEM
# \brief element fluid 1D object
from . import base_fempythonobject
from . import base_femelement
class ElementFluid1D(base_fempythonobject.BaseFemPythonObject):
class ElementFluid1D(base_femelement.BaseFemElement):
"""
The element_fluid1D object
"""
@@ -63,14 +63,6 @@ class ElementFluid1D(base_fempythonobject.BaseFemPythonObject):
def __init__(self, obj):
super(ElementFluid1D, self).__init__(obj)
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"FluidSection",
"List of fluid section shapes"
)
obj.setPropertyStatus("References", "LockDynamic")
obj.addProperty(
"App::PropertyEnumeration",
"SectionType",

View File

@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
# \ingroup FEM
# \brief element geometry 1D object
from . import base_fempythonobject
from . import base_femelement
class ElementGeometry1D(base_fempythonobject.BaseFemPythonObject):
class ElementGeometry1D(base_femelement.BaseFemElement):
"""
The ElementGeometry1D object
"""
@@ -91,12 +91,5 @@ class ElementGeometry1D(base_fempythonobject.BaseFemPythonObject):
)
obj.setPropertyStatus("SectionType", "LockDynamic")
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"BeamSection",
"List of beam section shapes"
)
obj.setPropertyStatus("References", "LockDynamic")
obj.SectionType = ElementGeometry1D.known_beam_types
obj.SectionType = "Rectangular"

View File

@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
# \ingroup FEM
# \brief element geometry 2D object
from . import base_fempythonobject
from . import base_femelement
class ElementGeometry2D(base_fempythonobject.BaseFemPythonObject):
class ElementGeometry2D(base_femelement.BaseFemElement):
"""
The ElementGeometry2D object
"""
@@ -49,11 +49,3 @@ class ElementGeometry2D(base_fempythonobject.BaseFemPythonObject):
"set thickness of the shell elements"
)
obj.setPropertyStatus("Thickness", "LockDynamic")
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"ShellThickness",
"List of shell thickness shapes"
)
obj.setPropertyStatus("References", "LockDynamic")

View File

@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
# \ingroup FEM
# \brief element rotation 1D object
from . import base_fempythonobject
from . import base_femelement
class ElementRotation1D(base_fempythonobject.BaseFemPythonObject):
class ElementRotation1D(base_femelement.BaseFemElement):
"""
The ElementRotation1D object
"""
@@ -49,11 +49,3 @@ class ElementRotation1D(base_fempythonobject.BaseFemPythonObject):
"Set the rotation of beam elements"
)
obj.setPropertyStatus("Rotation", "LockDynamic")
obj.addProperty(
"App::PropertyLinkSubList",
"References",
"BeamRotation",
"List of beam rotation shapes"
)
obj.setPropertyStatus("References", "LockDynamic")

View File

@@ -0,0 +1,39 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#/***************************************************************************
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD 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 *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# **************************************************************************
__title__ = "FreeCAD FEM base element ViewProvider"
__author__ = "Mario Passaglia"
__url__ = "https://www.freecad.org"
## @package view_base_femelement
# \ingroup FEM
# \brief view provider for Python base element object
from femviewprovider import view_base_femobject
class VPBaseFemElement(view_base_femobject.VPBaseFemObject):
"""Proxy View Provider for Python base element."""
def isShow(self):
return self.ViewObject.Visibility

View File

@@ -32,17 +32,16 @@ __url__ = "https://www.freecad.org"
# \brief view provider for element fluid 1D object
from femtaskpanels import task_element_fluid1D
from . import view_base_femconstraint
from . import view_base_femelement
class VPElementFluid1D(view_base_femconstraint.VPBaseFemConstraint):
class VPElementFluid1D(view_base_femelement.VPBaseFemElement):
"""
A View Provider for the ElementFluid1D object
"""
def setEdit(self, vobj, mode=0):
view_base_femconstraint.VPBaseFemConstraint.setEdit(
self,
super().setEdit(
vobj,
mode,
task_element_fluid1D._TaskPanel

View File

@@ -30,17 +30,16 @@ __url__ = "https://www.freecad.org"
# \brief view provider for element geometry 1D object
from femtaskpanels import task_element_geometry1D
from . import view_base_femconstraint
from . import view_base_femelement
class VPElementGeometry1D(view_base_femconstraint.VPBaseFemConstraint):
class VPElementGeometry1D(view_base_femelement.VPBaseFemElement):
"""
A View Provider for the ElementGeometry1D object
"""
def setEdit(self, vobj, mode=0):
view_base_femconstraint.VPBaseFemConstraint.setEdit(
self,
super().setEdit(
vobj,
mode,
task_element_geometry1D._TaskPanel

View File

@@ -30,17 +30,16 @@ __url__ = "https://www.freecad.org"
# \brief view provider for element geometry 2D object
from femtaskpanels import task_element_geometry2D
from . import view_base_femconstraint
from . import view_base_femelement
class VPElementGeometry2D(view_base_femconstraint.VPBaseFemConstraint):
class VPElementGeometry2D(view_base_femelement.VPBaseFemElement):
"""
A View Provider for the ElementGeometry2D object
"""
def setEdit(self, vobj, mode=0):
view_base_femconstraint.VPBaseFemConstraint.setEdit(
self,
super().setEdit(
vobj,
mode,
task_element_geometry2D._TaskPanel

View File

@@ -30,10 +30,10 @@ __url__ = "https://www.freecad.org"
# \brief view provider for element rotation 1D object
# from femtaskpanels import task_element_rotation1D
from . import view_base_femconstraint
from . import view_base_femelement
class VPElementRotation1D(view_base_femconstraint.VPBaseFemConstraint):
class VPElementRotation1D(view_base_femelement.VPBaseFemElement):
"""
A View Provider for the ElementRotation1D object
"""