[FEM] implement new object addition mode
- for e.g. the Elmer equations it is important that one can add several equations subsequently and that the added equations are visible in the TreeView
This commit is contained in:
@@ -445,7 +445,7 @@ class _EquationDeformation(CommandManager):
|
||||
"Creates a FEM equation for\n deformation (nonlinear elasticity)"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationElasticity(CommandManager):
|
||||
@@ -462,7 +462,7 @@ class _EquationElasticity(CommandManager):
|
||||
"Creates a FEM equation for\n elasticity (stress)"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationElectricforce(CommandManager):
|
||||
@@ -479,7 +479,7 @@ class _EquationElectricforce(CommandManager):
|
||||
"Creates a FEM equation for electric forces"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationElectrostatic(CommandManager):
|
||||
@@ -496,7 +496,7 @@ class _EquationElectrostatic(CommandManager):
|
||||
"Creates a FEM equation for electrostatic"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationFlow(CommandManager):
|
||||
@@ -513,7 +513,7 @@ class _EquationFlow(CommandManager):
|
||||
"Creates a FEM equation for flow"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationFlux(CommandManager):
|
||||
@@ -530,7 +530,7 @@ class _EquationFlux(CommandManager):
|
||||
"Creates a FEM equation for flux"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationHeat(CommandManager):
|
||||
@@ -547,7 +547,7 @@ class _EquationHeat(CommandManager):
|
||||
"Creates a FEM equation for heat"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationMagnetodynamic(CommandManager):
|
||||
@@ -564,7 +564,7 @@ class _EquationMagnetodynamic(CommandManager):
|
||||
"Creates a FEM equation for\n magnetodynamic forces"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _EquationMagnetodynamic2D(CommandManager):
|
||||
@@ -581,7 +581,7 @@ class _EquationMagnetodynamic2D(CommandManager):
|
||||
"Creates a FEM equation for\n 2D magnetodynamic forces"
|
||||
)
|
||||
self.is_active = "with_solver_elmer"
|
||||
self.do_activated = "add_obj_on_gui_selobj_noset_edit"
|
||||
self.do_activated = "add_obj_on_gui_selobj_expand_noset_edit"
|
||||
|
||||
|
||||
class _Examples(CommandManager):
|
||||
|
||||
@@ -36,6 +36,7 @@ from femtools.femutils import is_of_type
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
|
||||
@@ -152,6 +153,8 @@ class CommandManager(object):
|
||||
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
|
||||
elif self.do_activated == "add_obj_on_gui_selobj_set_edit":
|
||||
self.add_obj_on_gui_selobj_set_edit(self.__class__.__name__.lstrip("_"))
|
||||
elif self.do_activated == "add_obj_on_gui_selobj_expand_noset_edit":
|
||||
self.add_obj_on_gui_selobj_expand_noset_edit(self.__class__.__name__.lstrip("_"))
|
||||
# in all other cases Activated is implemented it the command class
|
||||
|
||||
def results_present(self):
|
||||
@@ -372,3 +375,28 @@ class CommandManager(object):
|
||||
)
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def add_obj_on_gui_selobj_expand_noset_edit(self, objtype):
|
||||
# like add_obj_on_gui_selobj_noset_edit but the selection is kept
|
||||
# and the selobj view is expanded in the tree to see the added obj
|
||||
FreeCAD.ActiveDocument.openTransaction(
|
||||
"Create Fem{}"
|
||||
.format(objtype)
|
||||
)
|
||||
FreeCADGui.addModule(
|
||||
"ObjectsFem"
|
||||
)
|
||||
FreeCADGui.doCommand(
|
||||
"ObjectsFem.make{}("
|
||||
"FreeCAD.ActiveDocument, FreeCAD.ActiveDocument.{})"
|
||||
.format(objtype, self.selobj.Name)
|
||||
)
|
||||
# expand selobj in tree view
|
||||
trees = FreeCADGui.getMainWindow().findChildren(QtGui.QTreeWidget)
|
||||
for tree in trees:
|
||||
items = tree.selectedItems()
|
||||
if items == []:
|
||||
continue
|
||||
for item in items:
|
||||
tree.expandItem(item)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
Reference in New Issue
Block a user