Skip to content

Commit

Permalink
FEM: code improvement in command manager
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Feb 20, 2020
1 parent 3940295 commit edc134c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 72 deletions.
96 changes: 24 additions & 72 deletions src/Mod/Fem/femcommands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


class _ConstraintElectrostaticPotential(CommandManager):
Expand All @@ -185,9 +183,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ConstraintFlowVelocity(CommandManager):
Expand All @@ -207,9 +203,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ConstraintInitialFlowVelocity(CommandManager):
Expand All @@ -229,9 +223,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ConstraintSelfWeight(CommandManager):
Expand All @@ -252,9 +244,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


class _ConstraintTie(CommandManager):
Expand All @@ -275,9 +265,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ElementFluid1D(CommandManager):
Expand All @@ -298,9 +286,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ElementGeometry1D(CommandManager):
Expand All @@ -321,9 +307,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ElementGeometry2D(CommandManager):
Expand All @@ -344,9 +328,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _ElementRotation1D(CommandManager):
Expand All @@ -367,9 +349,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


class _EquationElectrostatic(CommandManager):
Expand All @@ -389,9 +369,7 @@ def __init__(self):
)
}
self.is_active = "with_solver_elmer"

def Activated(self):
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_noset_edit"


class _EquationElasticity(CommandManager):
Expand All @@ -411,9 +389,7 @@ def __init__(self):
)
}
self.is_active = "with_solver_elmer"

def Activated(self):
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_noset_edit"


class _EquationFlow(CommandManager):
Expand All @@ -433,9 +409,7 @@ def __init__(self):
)
}
self.is_active = "with_solver_elmer"

def Activated(self):
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_noset_edit"


class _EquationFluxsolver(CommandManager):
Expand All @@ -455,9 +429,7 @@ def __init__(self):
)
}
self.is_active = "with_solver_elmer"

def Activated(self):
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_noset_edit"


class _EquationHeat(CommandManager):
Expand All @@ -477,9 +449,7 @@ def __init__(self):
)
}
self.is_active = "with_solver_elmer"

def Activated(self):
self.add_obj_on_gui_selobj_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_noset_edit"


class _MaterialEditor(CommandManager):
Expand Down Expand Up @@ -524,9 +494,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _MaterialMechanicalNonlinear(CommandManager):
Expand Down Expand Up @@ -626,9 +594,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _MaterialSolid(CommandManager):
Expand All @@ -649,9 +615,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_set_edit"


class _Mesh2Mesh(CommandManager):
Expand Down Expand Up @@ -722,9 +686,7 @@ def __init__(self):
)
}
self.is_active = "with_gmsh_femmesh"

def Activated(self):
self.add_obj_on_gui_selobj_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_set_edit"


class _MeshClear(CommandManager):
Expand Down Expand Up @@ -855,9 +817,7 @@ def __init__(self):
)
}
self.is_active = "with_gmsh_femmesh"

def Activated(self):
self.add_obj_on_gui_selobj_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_set_edit"


class _MeshNetgenFromShape(CommandManager):
Expand Down Expand Up @@ -926,9 +886,7 @@ def __init__(self):
)
}
self.is_active = "with_gmsh_femmesh"

def Activated(self):
self.add_obj_on_gui_selobj_set_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_selobj_set_edit"


class _ResultShow(CommandManager):
Expand Down Expand Up @@ -1038,9 +996,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


class _SolverControl(CommandManager):
Expand Down Expand Up @@ -1084,9 +1040,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


class _SolverRun(CommandManager):
Expand Down Expand Up @@ -1133,9 +1087,7 @@ def __init__(self):
)
}
self.is_active = "with_analysis"

def Activated(self):
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
self.do_activated = "add_obj_on_gui_noset_edit"


# the string in add command will be the page name on FreeCAD wiki
Expand Down
12 changes: 12 additions & 0 deletions src/Mod/Fem/femcommands/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self):
}
# FIXME add option description
self.is_active = None
self.do_activated = None
self.selobj = None
self.selobj2 = None
self.active_analysis = None
Expand Down Expand Up @@ -130,6 +131,17 @@ def IsActive(self):
)
return active

def Activated(self):
if self.do_activated == "add_obj_on_gui_noset_edit":
self.add_obj_on_gui_noset_edit(self.__class__.__name__.lstrip("_"))
elif self.do_activated == "add_obj_on_gui_set_edit":
self.add_obj_on_gui_set_edit(self.__class__.__name__.lstrip("_"))
elif self.do_activated == "add_obj_on_gui_selobj_noset_edit":
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("_"))
# in all other cases Activated is implemented it the command class

def results_present(self):
results = False
analysis_members = FemGui.getActiveAnalysis().Group
Expand Down

0 comments on commit edc134c

Please sign in to comment.