FEM: Move _CommandMechanicalShowResult class to separate file
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
d6392b751a
commit
dec1563c95
|
@ -86,7 +86,7 @@ SET(FemScripts_SRCS
|
|||
_JobControlTaskPanel.py
|
||||
_ViewProviderFemAnalysis.py
|
||||
_FemAnalysis.py
|
||||
|
||||
_CommandMechanicalShowResult.py
|
||||
)
|
||||
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ INSTALL(
|
|||
_JobControlTaskPanel.py
|
||||
_ViewProviderFemAnalysis.py
|
||||
_FemAnalysis.py
|
||||
_CommandMechanicalShowResult.py
|
||||
DESTINATION
|
||||
Mod/Fem
|
||||
)
|
||||
|
|
|
@ -102,6 +102,7 @@ void FemGuiExport initFemGui()
|
|||
FemGui::ViewProviderResult ::init();
|
||||
FemGui::ViewProviderResultPython ::init();
|
||||
|
||||
Base::Interpreter().loadModule("_CommandMechanicalShowResult");
|
||||
Base::Interpreter().loadModule("MechanicalAnalysis");
|
||||
Base::Interpreter().loadModule("MechanicalMaterial");
|
||||
Base::Interpreter().loadModule("FemBeamSection");
|
||||
|
|
|
@ -202,29 +202,6 @@ class _CommandFrequencyAnalysis:
|
|||
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
||||
|
||||
|
||||
class _CommandMechanicalShowResult:
|
||||
"the Fem JobControl command definition"
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'fem-result',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result"),
|
||||
'Accel': "S, R",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result information of an analysis")}
|
||||
|
||||
def Activated(self):
|
||||
self.result_object = get_results_object(FreeCADGui.Selection.getSelection())
|
||||
|
||||
if not self.result_object:
|
||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No result found in active Analysis")
|
||||
return
|
||||
|
||||
import _ResultControlTaskPanel
|
||||
taskd = _ResultControlTaskPanel._ResultControlTaskPanel()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCADGui.ActiveDocument is not None and results_present()
|
||||
|
||||
|
||||
# Helpers
|
||||
|
||||
|
||||
|
@ -254,4 +231,3 @@ if FreeCAD.GuiUp:
|
|||
FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis())
|
||||
FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis())
|
||||
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
|
||||
FreeCADGui.addCommand('Fem_ShowResult', _CommandMechanicalShowResult())
|
||||
|
|
55
src/Mod/Fem/_CommandMechanicalShowResult.py
Normal file
55
src/Mod/Fem/_CommandMechanicalShowResult.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
import FreeCAD
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
|
||||
class _CommandMechanicalShowResult:
|
||||
"the Fem JobControl command definition"
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'fem-result',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result"),
|
||||
'Accel': "S, R",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Result", "Show result information of an analysis")}
|
||||
|
||||
def Activated(self):
|
||||
self.result_object = get_results_object(FreeCADGui.Selection.getSelection())
|
||||
|
||||
if not self.result_object:
|
||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No result found in active Analysis")
|
||||
return
|
||||
|
||||
import _ResultControlTaskPanel
|
||||
taskd = _ResultControlTaskPanel._ResultControlTaskPanel()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCADGui.ActiveDocument is not None and results_present()
|
||||
|
||||
|
||||
#Code duplidation - 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
|
||||
|
||||
|
||||
#Code duplidation - to be removed after migration to FemTools
|
||||
def get_results_object(sel):
|
||||
import FemGui
|
||||
if (len(sel) == 1):
|
||||
if sel[0].isDerivedFrom("Fem::FemResultObject"):
|
||||
return sel[0]
|
||||
|
||||
for i in FemGui.getActiveAnalysis().Member:
|
||||
if(i.isDerivedFrom("Fem::FemResultObject")):
|
||||
return i
|
||||
return None
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Fem_ShowResult', _CommandMechanicalShowResult())
|
Loading…
Reference in New Issue
Block a user