FEM: Add preferences dialog
This patch add FEM preferrences dialog. There is currently only one option to define if internal or external editor should be used to open CalculiX input .inp files. Disabling internal editor allows to define path to external editor. Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
b36c34b105
commit
d13c279d5a
|
@ -30,7 +30,9 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/WidgetFactory.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include "ViewProviderFemMesh.h"
|
||||
#include "ViewProviderFemMeshShape.h"
|
||||
#include "ViewProviderFemMeshShapeNetgen.h"
|
||||
|
@ -103,6 +105,8 @@ void FemGuiExport initFemGui()
|
|||
|
||||
Base::Interpreter().loadModule("FemLib");
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<FemGui::DlgSettingsFemImp> ("FEM");
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadFemResource();
|
||||
|
|
|
@ -41,6 +41,7 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS})
|
|||
|
||||
|
||||
set(FemGui_MOC_HDRS
|
||||
DlgSettingsFemImp.h
|
||||
Hypothesis.h
|
||||
TaskObjectName.h
|
||||
TaskCreateNodeSet.h
|
||||
|
@ -61,6 +62,7 @@ fc_wrap_cpp(FemGui_MOC_SRCS ${FemGui_MOC_HDRS})
|
|||
SOURCE_GROUP("Moc" FILES ${FemGui_MOC_SRCS})
|
||||
|
||||
set(FemGui_UIC_SRCS
|
||||
DlgSettingsFem.ui
|
||||
Hypothesis.ui
|
||||
TaskCreateNodeSet.ui
|
||||
TaskObjectName.ui
|
||||
|
@ -76,6 +78,9 @@ qt4_wrap_ui(FemGui_UIC_HDRS ${FemGui_UIC_SRCS})
|
|||
|
||||
SET(FemGui_DLG_SRCS
|
||||
${FemGui_UIC_HDRS}
|
||||
DlgSettingsFem.ui
|
||||
DlgSettingsFemImp.cpp
|
||||
DlgSettingsFemImp.h
|
||||
Hypothesis.ui
|
||||
Hypothesis.cpp
|
||||
Hypothesis.h
|
||||
|
|
200
src/Mod/Fem/Gui/DlgSettingsFem.ui
Normal file
200
src/Mod/Fem/Gui/DlgSettingsFem.ui
Normal file
|
@ -0,0 +1,200 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FemGui::DlgSettingsFemImp</class>
|
||||
<widget class="QWidget" name="FemGui::DlgSettingsFemImp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FEM</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout1">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="gb_calculix">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>CalculiX</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetNoConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_calculix">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="cb_int_editor">
|
||||
<property name="text">
|
||||
<string>Use internal editor for .inp files</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>UseInternalEditor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hl_ext_editor">
|
||||
<item>
|
||||
<widget class="QLabel" name="l_ext_editor">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>External editor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefFileChooser" name="fc_ext_editor">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ExternalEditorPath</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::FileChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/FileDialog.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefFileChooser</class>
|
||||
<extends>Gui::FileChooser</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Resources/Fem.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cb_int_editor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>l_ext_editor</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>100</x>
|
||||
<y>47</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>99</x>
|
||||
<y>76</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cb_int_editor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>l_ext_editor</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>125</x>
|
||||
<y>49</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>120</x>
|
||||
<y>74</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cb_int_editor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>fc_ext_editor</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>327</x>
|
||||
<y>54</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>323</x>
|
||||
<y>79</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cb_int_editor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>fc_ext_editor</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>409</x>
|
||||
<y>50</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>406</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
69
src/Mod/Fem/Gui/DlgSettingsFemImp.cpp
Normal file
69
src/Mod/Fem/Gui/DlgSettingsFemImp.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2015 FreeCAD Developers *
|
||||
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||
* Based on src/Mod/Raytracing/Gui/DlgSettingsRayImp.cpp *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include <Gui/PrefWidgets.h>
|
||||
|
||||
using namespace FemGui;
|
||||
|
||||
DlgSettingsFemImp::DlgSettingsFemImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
{
|
||||
this->setupUi(this);
|
||||
}
|
||||
|
||||
DlgSettingsFemImp::~DlgSettingsFemImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
void DlgSettingsFemImp::saveSettings()
|
||||
{
|
||||
cb_int_editor->onSave();
|
||||
fc_ext_editor->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsFemImp::loadSettings()
|
||||
{
|
||||
cb_int_editor->onRestore();
|
||||
fc_ext_editor->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgSettingsFemImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgSettingsFemImp.cpp"
|
50
src/Mod/Fem/Gui/DlgSettingsFemImp.h
Normal file
50
src/Mod/Fem/Gui/DlgSettingsFemImp.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/**************************************************************************
|
||||
* Copyright (c) 2015 FreeCAD Developers *
|
||||
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||
* Based on src/Mod/Raytracing/Gui/DlgSettingsRayImp.h *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FEMGUI_DLGSETTINGSFEMIMP_H
|
||||
#define FEMGUI_DLGSETTINGSFEMIMP_H
|
||||
|
||||
#include "ui_DlgSettingsFem.h"
|
||||
#include <Gui/PropertyPage.h>
|
||||
|
||||
namespace FemGui {
|
||||
|
||||
class DlgSettingsFemImp : public Gui::Dialog::PreferencePage, public Ui_DlgSettingsFemImp
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgSettingsFemImp( QWidget* parent = 0 );
|
||||
~DlgSettingsFemImp();
|
||||
|
||||
protected:
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
void changeEvent(QEvent *e);
|
||||
};
|
||||
|
||||
} // namespace FemGui
|
||||
|
||||
#endif // FEMGUI_DLGSETTINGSFEMIMP_H
|
|
@ -17,6 +17,7 @@
|
|||
<file>icons/Fem_Result.svg</file>
|
||||
<file>icons/Fem_ResultDisplacement.svg</file>
|
||||
<file>icons/Fem_ResultStress.svg</file>
|
||||
<file>icons/preferences-fem.svg</file>
|
||||
<file>translations/Fem_af.qm</file>
|
||||
<file>translations/Fem_de.qm</file>
|
||||
<file>translations/Fem_fi.qm</file>
|
||||
|
|
1692
src/Mod/Fem/Gui/Resources/icons/preferences-fem.svg
Executable file
1692
src/Mod/Fem/Gui/Resources/icons/preferences-fem.svg
Executable file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 96 KiB |
|
@ -226,6 +226,7 @@ class _JobControlTaskPanel:
|
|||
|
||||
self.obj = object
|
||||
#self.params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
|
||||
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
|
||||
self.Calculix = QtCore.QProcess()
|
||||
self.Timer = QtCore.QTimer()
|
||||
self.Timer.start(300)
|
||||
|
@ -543,24 +544,22 @@ class _JobControlTaskPanel:
|
|||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def start_ext_editor(self, ext_editor_path, filename):
|
||||
self.ext_editor_process = QtCore.QProcess()
|
||||
self.ext_editor_process.execute(ext_editor_path, [filename])
|
||||
|
||||
def editCalculixInputFile(self):
|
||||
filename = self.Basename + '.inp'
|
||||
print 'editCalculixInputFile {}'.format(filename)
|
||||
|
||||
# FIXME: That code should be removed as soon as there is "Preferred editor" option
|
||||
# added to Preferences, to allow existing SciTE users override built-in editor
|
||||
#
|
||||
#import webbrowser
|
||||
# If inp-file extension is assigned the os will use the appropriate binary
|
||||
# (normally an Editor) to open the file. Works perfectly on Windows if SciTE is installed.
|
||||
# However using webbrower.open is not portable and not supported
|
||||
# https://docs.python.org/3.4/library/webbrowser.html
|
||||
#webbrowser.open(filename)
|
||||
|
||||
# The Abaqus syntax highlighter works similarly to that one of SciTE so that our
|
||||
# own editor can be used now
|
||||
import FemGui
|
||||
FemGui.open(filename)
|
||||
if self.fem_prefs.GetBool("UseInternalEditor",True):
|
||||
FemGui.open(filename)
|
||||
else:
|
||||
ext_editor_path = self.fem_prefs.GetString("ExternalEditorPath","")
|
||||
if ext_editor_path:
|
||||
self.start_ext_editor(ext_editor_path, filename)
|
||||
else:
|
||||
print "External editor is not defined in FEM preferences. Falling back to internal editor"
|
||||
FemGui.open(filename)
|
||||
|
||||
def runCalculix(self):
|
||||
print 'runCalculix'
|
||||
|
|
Loading…
Reference in New Issue
Block a user