Skip to content

Commit

Permalink
FEM: Move _CommandFrequencyAnalysis class to separate file
Browse files Browse the repository at this point in the history
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Oct 11, 2015
1 parent dec1563 commit ad68cad
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/Mod/Fem/App/CMakeLists.txt
Expand Up @@ -87,6 +87,7 @@ SET(FemScripts_SRCS
_ViewProviderFemAnalysis.py
_FemAnalysis.py
_CommandMechanicalShowResult.py
_CommandFrequencyAnalysis.py
)
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})

Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/CMakeLists.txt
Expand Up @@ -29,6 +29,7 @@ INSTALL(
_ViewProviderFemAnalysis.py
_FemAnalysis.py
_CommandMechanicalShowResult.py
_CommandFrequencyAnalysis.py
DESTINATION
Mod/Fem
)
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/Gui/AppFemGui.cpp
Expand Up @@ -103,6 +103,7 @@ void FemGuiExport initFemGui()
FemGui::ViewProviderResultPython ::init();

Base::Interpreter().loadModule("_CommandMechanicalShowResult");
Base::Interpreter().loadModule("_CommandFrequencyAnalysis");
Base::Interpreter().loadModule("MechanicalAnalysis");
Base::Interpreter().loadModule("MechanicalMaterial");
Base::Interpreter().loadModule("FemBeamSection");
Expand Down
29 changes: 0 additions & 29 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -174,34 +174,6 @@ def IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None


class _CommandFrequencyAnalysis:
def GetResources(self):
return {'Pixmap': 'fem-frequency-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Run frequency analysis with CalculiX ccx"),
'Accel': "R, F",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Write .inp file and run frequency analysis with CalculiX ccx")}

def Activated(self):
def load_results(ret_code):
if ret_code == 0:
self.fea.load_results()
else:
print "CalculiX failed ccx finished with error {}".format(ret_code)

self.fea = FemTools()
self.fea.reset_all()
self.fea.set_analysis_type('frequency')
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 IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None


# Helpers


Expand Down Expand Up @@ -229,5 +201,4 @@ def get_results_object(sel):
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())
FreeCADGui.addCommand('Fem_Quick_Analysis', _CommandQuickAnalysis())
FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis())
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
39 changes: 39 additions & 0 deletions src/Mod/Fem/_CommandFrequencyAnalysis.py
@@ -0,0 +1,39 @@
import FreeCAD
from FemTools import FemTools

if FreeCAD.GuiUp:
import FreeCADGui
import FemGui
from PySide import QtCore, QtGui


class _CommandFrequencyAnalysis:
def GetResources(self):
return {'Pixmap': 'fem-frequency-analysis',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Run frequency analysis with CalculiX ccx"),
'Accel': "R, F",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_Frequency_Analysis", "Write .inp file and run frequency analysis with CalculiX ccx")}

def Activated(self):
def load_results(ret_code):
if ret_code == 0:
self.fea.load_results()
else:
print "CalculiX failed ccx finished with error {}".format(ret_code)

self.fea = FemTools()
self.fea.reset_all()
self.fea.set_analysis_type('frequency')
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 IsActive(self):
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None


if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_Frequency_Analysis', _CommandFrequencyAnalysis())

0 comments on commit ad68cad

Please sign in to comment.