Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
FEM: Z88: add preference to set z88r binary path
  • Loading branch information
berndhahnebach authored and wwmayer committed May 16, 2016
1 parent ab06fdc commit 11b31eb
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 36 deletions.
21 changes: 19 additions & 2 deletions src/Mod/Fem/FemToolsZ88.py
Expand Up @@ -26,6 +26,7 @@
__url__ = "http://www.freecadweb.org"


import FreeCAD
import FemTools
from PySide import QtCore
from PySide.QtGui import QApplication
Expand All @@ -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):
Expand All @@ -55,12 +55,12 @@ def __init__(self, analysis=None, test_mode=False):
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()
Expand All @@ -86,6 +86,23 @@ def write_inp_file(self):
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()
Expand Down
172 changes: 140 additions & 32 deletions src/Mod/Fem/Gui/DlgSettingsFem.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>555</width>
<height>518</height>
<height>628</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -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">
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<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>100</width>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Working directory</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefFileChooser" name="fc_ccx_working_directory">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Fem/Gui/DlgSettingsFemImp.cpp
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 11b31eb

Please sign in to comment.