FEM: Migrate _CommandFemFromShape to FemCommands and add new is_active type
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
217103affb
commit
1ad481b435
|
@ -54,6 +54,8 @@ class FemCommands(object):
|
||||||
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
||||||
elif self.is_active == 'with_results':
|
elif self.is_active == 'with_results':
|
||||||
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
|
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
|
||||||
|
elif self.is_active == 'with_part_feature':
|
||||||
|
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.part_feature_selected()
|
||||||
return active
|
return active
|
||||||
|
|
||||||
def results_present(self):
|
def results_present(self):
|
||||||
|
@ -63,3 +65,10 @@ class FemCommands(object):
|
||||||
if o.isDerivedFrom('Fem::FemResultObject'):
|
if o.isDerivedFrom('Fem::FemResultObject'):
|
||||||
results = True
|
results = True
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def part_feature_selected(self):
|
||||||
|
sel = FreeCADGui.Selection.getSelection()
|
||||||
|
if len(sel) == 1 and sel[0].isDerivedFrom("Part::Feature"):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
|
@ -25,17 +25,20 @@ __author__ = "Juergen Riegel"
|
||||||
__url__ = "http://www.freecadweb.org"
|
__url__ = "http://www.freecadweb.org"
|
||||||
|
|
||||||
import FreeCAD
|
import FreeCAD
|
||||||
|
from FemCommands import FemCommands
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
import FreeCADGui
|
import FreeCADGui
|
||||||
from PySide import QtCore
|
from PySide import QtCore
|
||||||
|
|
||||||
|
|
||||||
class _CommandFemFromShape:
|
class _CommandFemFromShape(FemCommands):
|
||||||
def GetResources(self):
|
def __init__(self):
|
||||||
return {'Pixmap': 'fem-fem-mesh-from-shape',
|
super(_CommandFemFromShape, self).__init__()
|
||||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh"),
|
self.resources = {'Pixmap': 'fem-fem-mesh-from-shape',
|
||||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh from shape")}
|
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh"),
|
||||||
|
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh from shape")}
|
||||||
|
self.is_active = 'with_part_feature'
|
||||||
|
|
||||||
def Activated(self):
|
def Activated(self):
|
||||||
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
|
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
|
||||||
|
@ -50,11 +53,6 @@ class _CommandFemFromShape:
|
||||||
|
|
||||||
FreeCADGui.Selection.clearSelection()
|
FreeCADGui.Selection.clearSelection()
|
||||||
|
|
||||||
def IsActive(self):
|
|
||||||
sel = FreeCADGui.Selection.getSelection()
|
|
||||||
if len(sel) == 1:
|
|
||||||
return sel[0].isDerivedFrom("Part::Feature")
|
|
||||||
return False
|
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
|
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user