From 11b31eba09c056ba8cd62e1e03d99fa9b913264c Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Sat, 14 May 2016 19:47:28 +0100 Subject: [PATCH] FEM: Z88: add preference to set z88r binary path --- src/Mod/Fem/FemToolsZ88.py | 21 +++- src/Mod/Fem/Gui/DlgSettingsFem.ui | 174 +++++++++++++++++++++----- src/Mod/Fem/Gui/DlgSettingsFemImp.cpp | 6 +- 3 files changed, 164 insertions(+), 37 deletions(-) diff --git a/src/Mod/Fem/FemToolsZ88.py b/src/Mod/Fem/FemToolsZ88.py index 4d8500dbc..6f5a67cff 100644 --- a/src/Mod/Fem/FemToolsZ88.py +++ b/src/Mod/Fem/FemToolsZ88.py @@ -26,6 +26,7 @@ __author__ = "Bernd Hahnebach" __url__ = "http://www.freecadweb.org" +import FreeCAD import FemTools from PySide import QtCore from PySide.QtGui import QApplication @@ -37,7 +38,6 @@ class FemToolsZ88(FemTools.FemTools): ## The constructor # @param analysis - analysis object to be used as the core object. - # @param test_mode - True indicates that no real calculations will take place, so ccx bianry is not required. Used by test module. # "__init__" tries to use current active analysis in analysis is left empty. # Rises exception if analysis is not set and there is no active analysis def __init__(self, analysis=None, test_mode=False): @@ -55,12 +55,12 @@ class FemToolsZ88(FemTools.FemTools): if self.solver: self.set_analysis_type() self.setup_working_dir() + self.setup_z88() else: raise Exception('FEM: No solver found!') else: raise Exception('FEM: No active analysis found!') - self.z88_binary = "/home/hugo/z88progr/z88v14os/bin/unix64/z88r" self.z88_is_running = False self.z88_testrun = QtCore.QProcess() self.z88_solverun = QtCore.QProcess() @@ -86,6 +86,23 @@ class FemToolsZ88(FemTools.FemTools): print("Unexpected error when writing Z88 input files:", sys.exc_info()[0]) raise + ## Sets Z88 solver z88r binary path + # @param self The python object self + # @z88_binary path to z88r binary, default is guessed: "bin/z88r" windows, "z88r" for other systems + def setup_z88(self, z88_binary=None): + from platform import system + if not z88_binary: + self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem") + z88_binary = self.fem_prefs.GetString("z88BinaryPath", "") + if not z88_binary: + if system() == "Linux": + z88_binary = "z88r" + elif system() == "Windows": + z88_binary = FreeCAD.getHomePath() + "bin/z88r.exe" + else: + z88_binary = "z88r" + self.z88_binary = z88_binary + def run(self): # TODO: reimplement the process handling for z88 binary message = self.check_prerequisites() diff --git a/src/Mod/Fem/Gui/DlgSettingsFem.ui b/src/Mod/Fem/Gui/DlgSettingsFem.ui index 198eb274e..eaa83d973 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFem.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFem.ui @@ -7,7 +7,7 @@ 0 0 555 - 518 + 628 @@ -22,6 +22,79 @@ + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Analysis + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + QLayout::SetNoConstraint + + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + WorkingDir + + + Mod/Fem + + + + + + + true + + + + 100 + 0 + + + + Working directory + + + + + + + + + + @@ -80,7 +153,7 @@ - + false @@ -93,7 +166,7 @@ - + 0 @@ -142,50 +215,88 @@ - - - - true - - - - 100 - 0 - - - - Working directory - - - - - - - true - + + + + + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Z88 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + QLayout::SetNoConstraint + + + + + + + 0 0 + + + 0 + 0 + + + + + 0 + 0 + + 0 0 - - Gui::FileChooser::Directory + + Leave blank to use default Z88 solver z88r binary file - WorkingDir + z88BinaryPath Mod/Fem + + + + + 100 + 0 + + + + z88 binary + + + @@ -194,9 +305,9 @@ - + - Default analysis settings + Default solver settings @@ -407,7 +518,7 @@ - + true @@ -423,9 +534,6 @@ 0 - - Gui::FileChooser::Directory - CustomMaterialsDir diff --git a/src/Mod/Fem/Gui/DlgSettingsFemImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemImp.cpp index 371541f9b..3e867e108 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemImp.cpp @@ -48,10 +48,11 @@ void DlgSettingsFemImp::saveSettings() ("User parameter:BaseApp/Preferences/Mod/Fem"); hGrp->SetInt("AnalysisType", cb_analysis_type->currentIndex()); - fc_ccx_working_directory->onSave(); + fc_analysis_working_directory->onSave(); cb_int_editor->onSave(); fc_ext_editor->onSave(); fc_ccx_binary->onSave(); + fc_z88_binary->onSave(); cb_analysis_type->onSave(); sb_eigenmode_number->onSave(); dsb_eigenmode_high_limit->onSave(); @@ -65,10 +66,11 @@ void DlgSettingsFemImp::saveSettings() void DlgSettingsFemImp::loadSettings() { - fc_ccx_working_directory->onRestore(); + fc_analysis_working_directory->onRestore(); cb_int_editor->onRestore(); fc_ext_editor->onRestore(); fc_ccx_binary->onRestore(); + fc_z88_binary->onRestore(); cb_analysis_type->onRestore(); sb_eigenmode_number->onRestore(); dsb_eigenmode_high_limit->onRestore();