Skip to content

Commit

Permalink
FEM: Migrate _CommandPurgeFemResults to FemCommands and add new is_ac…
Browse files Browse the repository at this point in the history
…tive type

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Oct 13, 2015
1 parent 044c16d commit 217103a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
10 changes: 10 additions & 0 deletions src/Mod/Fem/FemCommands.py
Expand Up @@ -52,4 +52,14 @@ def IsActive(self):
active = FreeCADGui.ActiveDocument is not None
elif self.is_active == 'with_analysis':
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
elif self.is_active == 'with_results':
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
return active

def results_present(self):
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultObject'):
results = True
return results
28 changes: 9 additions & 19 deletions src/Mod/Fem/_CommandPurgeFemResults.py
Expand Up @@ -25,37 +25,27 @@
__url__ = "http://www.freecadweb.org"

import FreeCAD
from FemCommands import FemCommands
from FemTools import FemTools

if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore


class _CommandPurgeFemResults:
def GetResources(self):
return {'Pixmap': 'fem-purge-results',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results"),
'Accel': "S, S",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results from an analysis")}
class _CommandPurgeFemResults(FemCommands):
def __init__(self):
super(_CommandPurgeFemResults, self).__init__()
self.resources = {'Pixmap': 'fem-purge-results',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results"),
'Accel': "S, S",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results from an analysis")}
self.is_active = 'with_results'

def Activated(self):
fea = FemTools()
fea.reset_all()

def IsActive(self):
return FreeCADGui.ActiveDocument is not None and results_present()


#Code duplication to be removed after migration to FemTools
def results_present():
import FemGui
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultObject'):
results = True
return results

if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())

0 comments on commit 217103a

Please sign in to comment.