FEM: Move _CommandQuickAnalysis class to separate file
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
@@ -88,6 +88,7 @@ SET(FemScripts_SRCS
|
||||
_FemAnalysis.py
|
||||
_CommandMechanicalShowResult.py
|
||||
_CommandFrequencyAnalysis.py
|
||||
_CommandQuickAnalysis.py
|
||||
)
|
||||
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ INSTALL(
|
||||
_FemAnalysis.py
|
||||
_CommandMechanicalShowResult.py
|
||||
_CommandFrequencyAnalysis.py
|
||||
_CommandQuickAnalysis.py
|
||||
DESTINATION
|
||||
Mod/Fem
|
||||
)
|
||||
|
||||
@@ -104,6 +104,7 @@ void FemGuiExport initFemGui()
|
||||
|
||||
Base::Interpreter().loadModule("_CommandMechanicalShowResult");
|
||||
Base::Interpreter().loadModule("_CommandFrequencyAnalysis");
|
||||
Base::Interpreter().loadModule("_CommandQuickAnalysis");
|
||||
Base::Interpreter().loadModule("MechanicalAnalysis");
|
||||
Base::Interpreter().loadModule("MechanicalMaterial");
|
||||
Base::Interpreter().loadModule("FemBeamSection");
|
||||
|
||||
@@ -26,7 +26,7 @@ from FemTools import FemTools
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide import QtCore
|
||||
|
||||
__title__ = "Mechanical Analysis managment"
|
||||
__author__ = "Juergen Riegel"
|
||||
@@ -138,42 +138,6 @@ class _CommandPurgeFemResults:
|
||||
def IsActive(self):
|
||||
return FreeCADGui.ActiveDocument is not None and results_present()
|
||||
|
||||
|
||||
class _CommandQuickAnalysis:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'fem-quick-analysis',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Run CalculiX ccx"),
|
||||
'Accel': "R, C",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Write .inp file and run CalculiX ccx")}
|
||||
|
||||
def Activated(self):
|
||||
def load_results(ret_code):
|
||||
if ret_code == 0:
|
||||
self.fea.load_results()
|
||||
self.show_results_on_mesh()
|
||||
else:
|
||||
print "CalculiX failed ccx finished with error {}".format(ret_code)
|
||||
|
||||
self.fea = FemTools()
|
||||
self.fea.reset_all()
|
||||
message = self.fea.check_prerequisites()
|
||||
if message:
|
||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", message)
|
||||
return
|
||||
self.fea.finished.connect(load_results)
|
||||
QtCore.QThreadPool.globalInstance().start(self.fea)
|
||||
|
||||
def show_results_on_mesh(self):
|
||||
#FIXME proprer mesh refreshing as per FreeCAD.FEM_dialog settings required
|
||||
# or confirmation that it's safe to call restore_result_dialog
|
||||
import _ResultControlTaskPanel
|
||||
tp = _ResultControlTaskPanel._ResultControlTaskPanel()
|
||||
tp.restore_result_dialog()
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
||||
|
||||
|
||||
# Helpers
|
||||
|
||||
|
||||
@@ -190,5 +154,4 @@ if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())
|
||||
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
|
||||
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())
|
||||
FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis())
|
||||
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
|
||||
|
||||
46
src/Mod/Fem/_CommandQuickAnalysis.py
Normal file
46
src/Mod/Fem/_CommandQuickAnalysis.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import FreeCAD
|
||||
from FemTools import FemTools
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
|
||||
class _CommandQuickAnalysis:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'fem-quick-analysis',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Run CalculiX ccx"),
|
||||
'Accel': "R, C",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Quick_Analysis", "Write .inp file and run CalculiX ccx")}
|
||||
|
||||
def Activated(self):
|
||||
def load_results(ret_code):
|
||||
if ret_code == 0:
|
||||
self.fea.load_results()
|
||||
self.show_results_on_mesh()
|
||||
else:
|
||||
print "CalculiX failed ccx finished with error {}".format(ret_code)
|
||||
|
||||
self.fea = FemTools()
|
||||
self.fea.reset_all()
|
||||
message = self.fea.check_prerequisites()
|
||||
if message:
|
||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", message)
|
||||
return
|
||||
self.fea.finished.connect(load_results)
|
||||
QtCore.QThreadPool.globalInstance().start(self.fea)
|
||||
|
||||
def show_results_on_mesh(self):
|
||||
#FIXME proprer mesh refreshing as per FreeCAD.FEM_dialog settings required
|
||||
# or confirmation that it's safe to call restore_result_dialog
|
||||
import _ResultControlTaskPanel
|
||||
tp = _ResultControlTaskPanel._ResultControlTaskPanel()
|
||||
tp.restore_result_dialog()
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis())
|
||||
Reference in New Issue
Block a user