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"
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()

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>555</width>
<height>518</height>
<height>628</height>
</rect>
</property>
<property name="windowTitle">
@ -22,6 +22,79 @@
</property>
<item row="1" column="0">
<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>
<widget class="QGroupBox" name="gb_calculix">
<property name="sizePolicy">
@ -80,7 +153,7 @@
</widget>
</item>
<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">
<bool>false</bool>
</property>
@ -93,7 +166,7 @@
</widget>
</item>
<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">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -142,50 +215,88 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="l_ccx_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>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ccx_working_directory">
<property name="enabled">
<bool>true</bool>
</property>
<item>
<widget class="QGroupBox" name="gb_z88">
<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>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">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
<property name="toolTip">
<string>Leave blank to use default Z88 solver z88r binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>WorkingDir</cstring>
<cstring>z88BinaryPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem</cstring>
</property>
</widget>
</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>
</item>
</layout>
@ -194,9 +305,9 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_analysis_params">
<widget class="QGroupBox" name="gb_solver_params">
<property name="title">
<string>Default analysis settings</string>
<string>Default solver settings</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
@ -407,7 +518,7 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<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">
<bool>true</bool>
</property>
@ -423,9 +534,6 @@
<height>0</height>
</size>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>CustomMaterialsDir</cstring>
</property>

View File

@ -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();