Fem: Create own base class for Python Mesh objects
This commit is contained in:
committed by
Chris Hennes
parent
2bb2160fa2
commit
449f9b9be8
@@ -170,6 +170,7 @@ SET(FemMesh_SRCS
|
||||
SET(FemObjects_SRCS
|
||||
femobjects/__init__.py
|
||||
femobjects/base_femelement.py
|
||||
femobjects/base_femmeshelement.py
|
||||
femobjects/base_fempythonobject.py
|
||||
femobjects/constant_vacuumpermittivity.py
|
||||
femobjects/constraint_bodyheatsource.py
|
||||
@@ -608,6 +609,7 @@ SET(FemGuiViewProvider_SRCS
|
||||
femviewprovider/__init__.py
|
||||
femviewprovider/view_base_femconstraint.py
|
||||
femviewprovider/view_base_femelement.py
|
||||
femviewprovider/view_base_femmeshelement.py
|
||||
femviewprovider/view_base_femobject.py
|
||||
femviewprovider/view_constant_vacuumpermittivity.py
|
||||
femviewprovider/view_constraint_bodyheatsource.py
|
||||
|
||||
60
src/Mod/Fem/femobjects/base_femmeshelement.py
Normal file
60
src/Mod/Fem/femobjects/base_femmeshelement.py
Normal 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_femmeshelement
|
||||
# \ingroup FEM
|
||||
# \brief base object for FEM Mesh Element Features
|
||||
|
||||
|
||||
from . import base_fempythonobject
|
||||
|
||||
_PropHelper = base_fempythonobject._PropHelper
|
||||
|
||||
class BaseFemMeshElement(base_fempythonobject.BaseFemPythonObject):
|
||||
|
||||
BaseType = "Fem::BaseFemMeshElement"
|
||||
|
||||
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 = "Mesh Element",
|
||||
doc = "List of reference shapes",
|
||||
value = []
|
||||
)
|
||||
)
|
||||
|
||||
return prop
|
||||
@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
|
||||
# \ingroup FEM
|
||||
# \brief mesh boundary layer object
|
||||
|
||||
from . import base_fempythonobject
|
||||
from . import base_femmeshelement
|
||||
|
||||
|
||||
class MeshBoundaryLayer(base_fempythonobject.BaseFemPythonObject):
|
||||
class MeshBoundaryLayer(base_femmeshelement.BaseFemMeshElement):
|
||||
"""
|
||||
The MeshBoundaryLayer object
|
||||
"""
|
||||
@@ -68,11 +68,3 @@ class MeshBoundaryLayer(base_fempythonobject.BaseFemPythonObject):
|
||||
)
|
||||
obj.setPropertyStatus("GrowthRate", "LockDynamic")
|
||||
obj.GrowthRate = 1.5
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLinkSubList",
|
||||
"References",
|
||||
"MeshBoundaryLayerShapes",
|
||||
"List of FEM mesh region shapes"
|
||||
)
|
||||
obj.setPropertyStatus("References", "LockDynamic")
|
||||
|
||||
@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
|
||||
# \ingroup FEM
|
||||
# \brief mesh group object
|
||||
|
||||
from . import base_fempythonobject
|
||||
from . import base_femmeshelement
|
||||
|
||||
|
||||
class MeshGroup(base_fempythonobject.BaseFemPythonObject):
|
||||
class MeshGroup(base_femmeshelement.BaseFemMeshElement):
|
||||
"""
|
||||
The MeshGroup object
|
||||
"""
|
||||
@@ -49,11 +49,3 @@ class MeshGroup(base_fempythonobject.BaseFemPythonObject):
|
||||
"The identifier used for export (True: Label, False: Name)"
|
||||
)
|
||||
obj.setPropertyStatus("UseLabel", "LockDynamic")
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLinkSubList",
|
||||
"References",
|
||||
"MeshGroupShapes",
|
||||
"List of FEM mesh group shapes"
|
||||
)
|
||||
obj.setPropertyStatus("References", "LockDynamic")
|
||||
|
||||
@@ -29,10 +29,10 @@ __url__ = "https://www.freecad.org"
|
||||
# \ingroup FEM
|
||||
# \brief mesh region object
|
||||
|
||||
from . import base_fempythonobject
|
||||
from . import base_femmeshelement
|
||||
|
||||
|
||||
class MeshRegion(base_fempythonobject.BaseFemPythonObject):
|
||||
class MeshRegion(base_femmeshelement.BaseFemMeshElement):
|
||||
"""
|
||||
The FemMeshRegion object
|
||||
"""
|
||||
@@ -49,11 +49,3 @@ class MeshRegion(base_fempythonobject.BaseFemPythonObject):
|
||||
"set characteristic length of FEM elements for this refinement"
|
||||
)
|
||||
obj.setPropertyStatus("CharacteristicLength", "LockDynamic")
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLinkSubList",
|
||||
"References",
|
||||
"MeshRegionShapes",
|
||||
"List of FEM mesh refinement shapes"
|
||||
)
|
||||
obj.setPropertyStatus("References", "LockDynamic")
|
||||
|
||||
39
src/Mod/Fem/femviewprovider/view_base_femmeshelement.py
Normal file
39
src/Mod/Fem/femviewprovider/view_base_femmeshelement.py
Normal 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 mesh element ViewProvider"
|
||||
__author__ = "Mario Passaglia"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package view_base_femmeshelement
|
||||
# \ingroup FEM
|
||||
# \brief view provider for Python base mesh element object
|
||||
|
||||
from femviewprovider import view_base_femobject
|
||||
|
||||
|
||||
class VPBaseFemMeshElement(view_base_femobject.VPBaseFemObject):
|
||||
"""Proxy View Provider for Python base mesh element."""
|
||||
|
||||
def isShow(self):
|
||||
return self.ViewObject.Visibility
|
||||
@@ -30,17 +30,16 @@ __url__ = "https://www.freecad.org"
|
||||
# \brief view provider for mesh boundary object
|
||||
|
||||
from femtaskpanels import task_mesh_boundarylayer
|
||||
from . import view_base_femconstraint
|
||||
from . import view_base_femmeshelement
|
||||
|
||||
|
||||
class VPMeshBoundaryLayer(view_base_femconstraint.VPBaseFemConstraint):
|
||||
class VPMeshBoundaryLayer(view_base_femmeshelement.VPBaseFemMeshElement):
|
||||
"""
|
||||
A View Provider for the MeshBoundaryLayer object
|
||||
"""
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
view_base_femconstraint.VPBaseFemConstraint.setEdit(
|
||||
self,
|
||||
super().setEdit(
|
||||
vobj,
|
||||
mode,
|
||||
task_mesh_boundarylayer._TaskPanel
|
||||
|
||||
@@ -30,17 +30,16 @@ __url__ = "https://www.freecad.org"
|
||||
# \brief view provider for mesh group object
|
||||
|
||||
from femtaskpanels import task_mesh_group
|
||||
from . import view_base_femconstraint
|
||||
from . import view_base_femmeshelement
|
||||
|
||||
|
||||
class VPMeshGroup(view_base_femconstraint.VPBaseFemConstraint):
|
||||
class VPMeshGroup(view_base_femmeshelement.VPBaseFemMeshElement):
|
||||
"""
|
||||
A View Provider for the MeshGroup object
|
||||
"""
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
view_base_femconstraint.VPBaseFemConstraint.setEdit(
|
||||
self,
|
||||
super().setEdit(
|
||||
vobj,
|
||||
mode,
|
||||
task_mesh_group._TaskPanel
|
||||
|
||||
@@ -30,17 +30,16 @@ __url__ = "https://www.freecad.org"
|
||||
# \brief view provider for mesh region object
|
||||
|
||||
from femtaskpanels import task_mesh_region
|
||||
from . import view_base_femconstraint
|
||||
from . import view_base_femmeshelement
|
||||
|
||||
|
||||
class VPMeshRegion(view_base_femconstraint.VPBaseFemConstraint):
|
||||
class VPMeshRegion(view_base_femmeshelement.VPBaseFemMeshElement):
|
||||
"""
|
||||
A View Provider for the FemMeshRegion object
|
||||
"""
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
view_base_femconstraint.VPBaseFemConstraint.setEdit(
|
||||
self,
|
||||
super().setEdit(
|
||||
vobj,
|
||||
mode,
|
||||
task_mesh_region._TaskPanel
|
||||
|
||||
Reference in New Issue
Block a user