FEM: Add AnalysisType to Prefs and use it in analysis control window.
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>429</height>
|
||||
<height>453</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -193,6 +193,73 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_analysis_params">
|
||||
<property name="title">
|
||||
<string>Default analysis type</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Gui::PrefComboBox" name="cb_analysis_type">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>148</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Default type on analysis</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AnalysisType</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Static</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Resources/Fem.qrc">
|
||||
<normaloff>:/icons/fem-new-analysis.svg</normaloff>:/icons/fem-new-analysis.svg</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Frequency</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Resources/Fem.qrc">
|
||||
<normaloff>:/icons/fem-frequency-analysis.svg</normaloff>:/icons/fem-frequency-analysis.svg</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_materials">
|
||||
<property name="title">
|
||||
@@ -336,6 +403,11 @@
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Resources/Fem.qrc"/>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "Gui/Application.h"
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include <Gui/PrefWidgets.h>
|
||||
|
||||
@@ -43,10 +44,15 @@ DlgSettingsFemImp::~DlgSettingsFemImp()
|
||||
|
||||
void DlgSettingsFemImp::saveSettings()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Mod/Fem");
|
||||
hGrp->SetInt("AnalysisType", cb_analysis_type->currentIndex());
|
||||
|
||||
fc_ccx_working_directory->onSave();
|
||||
cb_int_editor->onSave();
|
||||
fc_ext_editor->onSave();
|
||||
fc_ccx_binary->onSave();
|
||||
cb_analysis_type->onSave();
|
||||
cb_use_built_in_materials->onSave();
|
||||
cb_use_mat_from_config_dir->onSave();
|
||||
cb_use_mat_from_custom_dir->onSave();
|
||||
@@ -59,10 +65,16 @@ void DlgSettingsFemImp::loadSettings()
|
||||
cb_int_editor->onRestore();
|
||||
fc_ext_editor->onRestore();
|
||||
fc_ccx_binary->onRestore();
|
||||
cb_analysis_type->onRestore();
|
||||
cb_use_built_in_materials->onRestore();
|
||||
cb_use_mat_from_config_dir->onRestore();
|
||||
cb_use_mat_from_custom_dir->onRestore();
|
||||
fc_custom_mat_dir->onRestore();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Mod/Fem");
|
||||
int index = hGrp->GetInt("AnalysisType", 0);
|
||||
if (index > -1) cb_analysis_type->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +83,9 @@ void DlgSettingsFemImp::loadSettings()
|
||||
void DlgSettingsFemImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
int c_index = cb_analysis_type->currentIndex();
|
||||
retranslateUi(this);
|
||||
cb_analysis_type->setCurrentIndex(c_index);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>193</width>
|
||||
<height>384</height>
|
||||
<width>258</width>
|
||||
<height>458</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,56 +15,103 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_working_dir">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<widget class="QGroupBox" name="gb_working_dir">
|
||||
<property name="title">
|
||||
<string>Working directory</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_working_dir">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_choose_working_dir">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_analysis_type">
|
||||
<property name="title">
|
||||
<string>Analysis type</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Gui::PrefRadioButton" name="rb_static_analysis">
|
||||
<property name="text">
|
||||
<string>Static</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefRadioButton" name="rb_frequency_analysis">
|
||||
<property name="text">
|
||||
<string>Frequency</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_actions">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pb_write_inp">
|
||||
<property name="text">
|
||||
<string>Write .inp file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_choose_working_dir">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pb_edit_inp">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
<string>Edit .inp file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pb_run_ccx">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run Calculix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_write_inp">
|
||||
<property name="text">
|
||||
<string>Write Calculix Input File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_edit_inp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit Calculix Input File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_run_ccx">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run Calculix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit_Output">
|
||||
<property name="lineWrapMode">
|
||||
@@ -86,6 +133,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::PrefRadioButton</class>
|
||||
<extends>QRadioButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -58,6 +58,13 @@ class _JobControlTaskPanel:
|
||||
self.working_dir = self.fem_prefs.GetString("WorkingDir", '/tmp')
|
||||
|
||||
self.analysis_object = analysis_object
|
||||
try:
|
||||
self.analysis_type = FreeCAD.FEM_analysis["type"]
|
||||
except:
|
||||
analysis_type = self.fem_prefs.GetInt("AnalysisType", 0)
|
||||
self.analysis_type = FemTools.known_analysis_types[analysis_type]
|
||||
FreeCAD.FEM_analysis = {"type": self.analysis_type}
|
||||
|
||||
self.Calculix = QtCore.QProcess()
|
||||
self.Timer = QtCore.QTimer()
|
||||
self.Timer.start(300)
|
||||
@@ -69,6 +76,8 @@ class _JobControlTaskPanel:
|
||||
QtCore.QObject.connect(self.form.pb_write_inp, QtCore.SIGNAL("clicked()"), self.write_input_file_handler)
|
||||
QtCore.QObject.connect(self.form.pb_edit_inp, QtCore.SIGNAL("clicked()"), self.editCalculixInputFile)
|
||||
QtCore.QObject.connect(self.form.pb_run_ccx, QtCore.SIGNAL("clicked()"), self.runCalculix)
|
||||
QtCore.QObject.connect(self.form.rb_static_analysis, QtCore.SIGNAL("clicked()"), self.select_static_analysis)
|
||||
QtCore.QObject.connect(self.form.rb_frequency_analysis, QtCore.SIGNAL("clicked()"), self.select_frequency_analysis)
|
||||
|
||||
QtCore.QObject.connect(self.Calculix, QtCore.SIGNAL("started()"), self.calculixStarted)
|
||||
QtCore.QObject.connect(self.Calculix, QtCore.SIGNAL("stateChanged(QProcess::ProcessState)"), self.calculixStateChanged)
|
||||
@@ -158,6 +167,10 @@ class _JobControlTaskPanel:
|
||||
def update(self):
|
||||
'fills the widgets'
|
||||
self.form.le_working_dir.setText(self.working_dir)
|
||||
if self.analysis_type == 'static':
|
||||
self.form.rb_static_analysis.setChecked(True)
|
||||
elif self.analysis_type == 'frequency':
|
||||
self.form.rb_frequency_analysis.setChecked(True)
|
||||
return
|
||||
|
||||
def accept(self):
|
||||
@@ -182,6 +195,7 @@ class _JobControlTaskPanel:
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.inp_file_name = ""
|
||||
fea = FemTools()
|
||||
fea.set_analysis_type(self.analysis_type)
|
||||
fea.update_objects()
|
||||
fea.write_inp_file()
|
||||
if fea.inp_file_name != "":
|
||||
@@ -242,6 +256,20 @@ class _JobControlTaskPanel:
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def store_analysis_type(self, analysis_type):
|
||||
if self.analysis_type != analysis_type:
|
||||
self.analysis_type = analysis_type
|
||||
FreeCAD.FEM_analysis["type"] = analysis_type
|
||||
self.form.pb_edit_inp.setEnabled(False)
|
||||
self.form.pb_run_ccx.setEnabled(False)
|
||||
|
||||
def select_static_analysis(self):
|
||||
self.store_analysis_type('static')
|
||||
|
||||
def select_frequency_analysis(self):
|
||||
self.change_analysis_type('frequency')
|
||||
|
||||
|
||||
#Code duplication!!!!
|
||||
def get_working_dir():
|
||||
fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
|
||||
|
||||
Reference in New Issue
Block a user