FEM: Z88: add preference to set z88r binary path

This commit is contained in:
Bernd Hahnebach 2016-05-14 19:47:28 +01:00 committed by wmayer
parent ab06fdc2a5
commit 11b31eba09
3 changed files with 164 additions and 37 deletions

View File

@ -26,6 +26,7 @@ __author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org" __url__ = "http://www.freecadweb.org"
import FreeCAD
import FemTools import FemTools
from PySide import QtCore from PySide import QtCore
from PySide.QtGui import QApplication from PySide.QtGui import QApplication
@ -37,7 +38,6 @@ class FemToolsZ88(FemTools.FemTools):
## The constructor ## The constructor
# @param analysis - analysis object to be used as the core object. # @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. # "__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 # Rises exception if analysis is not set and there is no active analysis
def __init__(self, analysis=None, test_mode=False): def __init__(self, analysis=None, test_mode=False):
@ -55,12 +55,12 @@ class FemToolsZ88(FemTools.FemTools):
if self.solver: if self.solver:
self.set_analysis_type() self.set_analysis_type()
self.setup_working_dir() self.setup_working_dir()
self.setup_z88()
else: else:
raise Exception('FEM: No solver found!') raise Exception('FEM: No solver found!')
else: else:
raise Exception('FEM: No active analysis found!') raise Exception('FEM: No active analysis found!')
self.z88_binary = "/home/hugo/z88progr/z88v14os/bin/unix64/z88r"
self.z88_is_running = False self.z88_is_running = False
self.z88_testrun = QtCore.QProcess() self.z88_testrun = QtCore.QProcess()
self.z88_solverun = 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]) print("Unexpected error when writing Z88 input files:", sys.exc_info()[0])
raise 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): def run(self):
# TODO: reimplement the process handling for z88 binary # TODO: reimplement the process handling for z88 binary
message = self.check_prerequisites() message = self.check_prerequisites()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>555</width> <width>555</width>
<height>518</height> <height>628</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -22,6 +22,79 @@
</property> </property>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="gb_analysis">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>Analysis</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QGridLayout" name="gl_analysis">
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_analysis_working_directory" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="prefEntry" stdset="0">
<cstring>WorkingDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_analysis_working_directory">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Working directory</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="gb_calculix"> <widget class="QGroupBox" name="gb_calculix">
<property name="sizePolicy"> <property name="sizePolicy">
@ -80,7 +153,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ext_editor"> <widget class="Gui::PrefFileChooser" name="fc_ext_editor" native="true">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -93,7 +166,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ccx_binary"> <widget class="Gui::PrefFileChooser" name="fc_ccx_binary" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -142,50 +215,88 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> </layout>
<widget class="QLabel" name="l_ccx_working_directory"> </item>
<property name="enabled"> </layout>
<bool>true</bool> </item>
</property> </layout>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Working directory</string>
</property>
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item>
<widget class="Gui::PrefFileChooser" name="fc_ccx_working_directory"> <widget class="QGroupBox" name="gb_z88">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>Z88</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QGridLayout" name="gl_z88">
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_z88_binary" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize"> <property name="baseSize">
<size> <size>
<width>0</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="mode"> <property name="toolTip">
<enum>Gui::FileChooser::Directory</enum> <string>Leave blank to use default Z88 solver z88r binary file</string>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>WorkingDir</cstring> <cstring>z88BinaryPath</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring> <cstring>Mod/Fem</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="l_z88_binary">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>z88 binary</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -194,9 +305,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="gb_analysis_params"> <widget class="QGroupBox" name="gb_solver_params">
<property name="title"> <property name="title">
<string>Default analysis settings</string> <string>Default solver settings</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
@ -407,7 +518,7 @@
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1"> <item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fc_custom_mat_dir"> <widget class="Gui::PrefFileChooser" name="fc_custom_mat_dir" native="true">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -423,9 +534,6 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>CustomMaterialsDir</cstring> <cstring>CustomMaterialsDir</cstring>
</property> </property>

View File

@ -48,10 +48,11 @@ void DlgSettingsFemImp::saveSettings()
("User parameter:BaseApp/Preferences/Mod/Fem"); ("User parameter:BaseApp/Preferences/Mod/Fem");
hGrp->SetInt("AnalysisType", cb_analysis_type->currentIndex()); hGrp->SetInt("AnalysisType", cb_analysis_type->currentIndex());
fc_ccx_working_directory->onSave(); fc_analysis_working_directory->onSave();
cb_int_editor->onSave(); cb_int_editor->onSave();
fc_ext_editor->onSave(); fc_ext_editor->onSave();
fc_ccx_binary->onSave(); fc_ccx_binary->onSave();
fc_z88_binary->onSave();
cb_analysis_type->onSave(); cb_analysis_type->onSave();
sb_eigenmode_number->onSave(); sb_eigenmode_number->onSave();
dsb_eigenmode_high_limit->onSave(); dsb_eigenmode_high_limit->onSave();
@ -65,10 +66,11 @@ void DlgSettingsFemImp::saveSettings()
void DlgSettingsFemImp::loadSettings() void DlgSettingsFemImp::loadSettings()
{ {
fc_ccx_working_directory->onRestore(); fc_analysis_working_directory->onRestore();
cb_int_editor->onRestore(); cb_int_editor->onRestore();
fc_ext_editor->onRestore(); fc_ext_editor->onRestore();
fc_ccx_binary->onRestore(); fc_ccx_binary->onRestore();
fc_z88_binary->onRestore();
cb_analysis_type->onRestore(); cb_analysis_type->onRestore();
sb_eigenmode_number->onRestore(); sb_eigenmode_number->onRestore();
dsb_eigenmode_high_limit->onRestore(); dsb_eigenmode_high_limit->onRestore();