Fem: Add suppressible extension to objects - fixes #12115
This commit is contained in:
committed by
Yorik van Havre
parent
f7a39fc313
commit
4d5424e422
@@ -41,6 +41,8 @@ FemMeshObject::FemMeshObject()
|
||||
ADD_PROPERTY_TYPE(FemMesh, (), "FEM Mesh", Prop_NoRecompute, "FEM Mesh object");
|
||||
// in the regard of recomputes see:
|
||||
// https://forum.freecad.org/viewtopic.php?f=18&t=33329#p279203
|
||||
|
||||
suppressibleExt.initExtension(this);
|
||||
}
|
||||
|
||||
FemMeshObject::~FemMeshObject() = default;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/GeoFeature.h>
|
||||
#include <App/SuppressibleExtension.h>
|
||||
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshProperty.h"
|
||||
@@ -63,6 +64,9 @@ public:
|
||||
protected:
|
||||
/// get called by the container when a property has changed
|
||||
void onChanged(const App::Property* prop) override;
|
||||
|
||||
private:
|
||||
App::SuppressibleExtension suppressibleExt;
|
||||
};
|
||||
|
||||
using FemMeshObjectPython = App::FeaturePythonT<FemMeshObject>;
|
||||
|
||||
@@ -220,6 +220,8 @@ ViewProviderFemMesh::ViewProviderFemMesh()
|
||||
App::Prop_Hidden,
|
||||
"Node diffuse color array");
|
||||
|
||||
suppressibleExt.initExtension(this);
|
||||
|
||||
ColorMode.setEnums(colorModeEnum);
|
||||
onlyEdges = false;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <Gui/ViewProviderBuilder.h>
|
||||
#include <Gui/ViewProviderGeometryObject.h>
|
||||
#include <Gui/ViewProviderFeaturePython.h>
|
||||
#include <Gui/ViewProviderSuppressibleExtension.h>
|
||||
#include <Mod/Fem/FemGlobal.h>
|
||||
|
||||
class SoCoordinate3;
|
||||
@@ -144,6 +145,7 @@ public:
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints floatRange;
|
||||
static const char* colorModeEnum[];
|
||||
Gui::ViewProviderSuppressibleExtension suppressibleExt;
|
||||
|
||||
protected:
|
||||
/// get called by the container whenever a property has been changed
|
||||
|
||||
@@ -45,6 +45,8 @@ class BaseFemElement(base_fempythonobject.BaseFemPythonObject):
|
||||
for prop in self._get_properties():
|
||||
prop.add_to_object(obj)
|
||||
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
def _get_properties(self):
|
||||
prop = []
|
||||
|
||||
@@ -71,3 +73,6 @@ class BaseFemElement(base_fempythonobject.BaseFemPythonObject):
|
||||
if prop.name == "References":
|
||||
# change References to App::PropertyLinkSubListGlobal
|
||||
prop.handle_change_type(obj, old_type="App::PropertyLinkSubList")
|
||||
|
||||
if not obj.hasExtension("App::SuppressibleExtensionPython"):
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
@@ -49,6 +49,8 @@ class MaterialCommon(base_fempythonobject.BaseFemPythonObject):
|
||||
for prop in self._get_properties():
|
||||
prop.add_to_object(obj)
|
||||
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
def _get_properties(self):
|
||||
prop = []
|
||||
|
||||
@@ -95,6 +97,9 @@ class MaterialCommon(base_fempythonobject.BaseFemPythonObject):
|
||||
# change References to App::PropertyLinkSubListGlobal
|
||||
prop.handle_change_type(obj, old_type="App::PropertyLinkSubList")
|
||||
|
||||
if not obj.hasExtension("App::SuppressibleExtensionPython"):
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
"""
|
||||
Some remarks to the category. Not finished, thus to be continued.
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ class MaterialMechanicalNonlinear(base_fempythonobject.BaseFemPythonObject):
|
||||
super().__init__(obj)
|
||||
self.add_properties(obj)
|
||||
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
|
||||
# YieldPoints was (until 0.19) stored as 3 separate variables. Consolidate them if present.
|
||||
@@ -64,6 +66,8 @@ class MaterialMechanicalNonlinear(base_fempythonobject.BaseFemPythonObject):
|
||||
if yield_points:
|
||||
obj.YieldPoints = yield_points
|
||||
|
||||
if not obj.hasExtension("App::SuppressibleExtensionPython"):
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
# TODO: If in the future more nonlinear options are added, update choices here.
|
||||
|
||||
def add_properties(self, obj):
|
||||
|
||||
@@ -60,7 +60,7 @@ def check_member_for_solver_calculix(analysis, solver, mesh, member):
|
||||
|
||||
# mesh
|
||||
if not mesh:
|
||||
message += "No mesh object defined in the analysis.\n"
|
||||
message += "A single mesh object must be defined in the analysis.\n"
|
||||
if mesh:
|
||||
if (
|
||||
mesh.FemMesh.VolumeCount == 0
|
||||
|
||||
@@ -141,11 +141,7 @@ def get_mesh_to_solve(analysis):
|
||||
"""
|
||||
mesh_to_solve = None
|
||||
for m in analysis.Group:
|
||||
if (
|
||||
m.isDerivedFrom("Fem::FemMeshObject")
|
||||
# the next line should not be needed as the result mesh is not a analysis member
|
||||
and not femutils.is_of_type(m, "Fem::MeshResult")
|
||||
):
|
||||
if m.isDerivedFrom("Fem::FemMeshObject") and not m.Suppressed:
|
||||
if not mesh_to_solve:
|
||||
mesh_to_solve = m
|
||||
else:
|
||||
|
||||
@@ -35,5 +35,9 @@ from femviewprovider import view_base_femobject
|
||||
class VPBaseFemElement(view_base_femobject.VPBaseFemObject):
|
||||
"""Proxy View Provider for Python base element."""
|
||||
|
||||
def __init__(self, vobj):
|
||||
super().__init__(vobj)
|
||||
vobj.addExtension("Gui::ViewProviderSuppressibleExtensionPython")
|
||||
|
||||
def isShow(self):
|
||||
return self.ViewObject.Visibility
|
||||
|
||||
@@ -35,5 +35,9 @@ from femviewprovider import view_base_femobject
|
||||
class VPBaseFemMaterial(view_base_femobject.VPBaseFemObject):
|
||||
"""Proxy View Provider for Python base material."""
|
||||
|
||||
def __init__(self, vobj):
|
||||
super().__init__(vobj)
|
||||
vobj.addExtension("Gui::ViewProviderSuppressibleExtensionPython")
|
||||
|
||||
def isShow(self):
|
||||
return self.ViewObject.Visibility
|
||||
|
||||
Reference in New Issue
Block a user