├── CMakeLists.txt
├── README.md
├── application.qrc
├── browse_lineedit.cpp
├── browse_lineedit.h
├── dealii_parameter_gui.pro
├── images
├── logo_dealii.png
├── logo_dealii_64.png
├── logo_dealii_gui.png
└── logo_dealii_gui_128.png
├── info_message.cpp
├── info_message.h
├── lgpl-2.1.txt
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── parameter_delegate.cpp
├── parameter_delegate.h
├── parameter_gui.png
├── parameters.xml
├── prm_parameter_writer.cpp
├── prm_parameter_writer.h
├── settings_dialog.cpp
├── settings_dialog.h
├── xml_parameter_reader.cpp
├── xml_parameter_reader.h
├── xml_parameter_writer.cpp
└── xml_parameter_writer.h
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ## ---------------------------------------------------------------------
2 | ##
3 | ## Copyright (C) 2012 - 2016 by Martin Steigemann and Wolfgang Bangerth
4 | ##
5 | ## This file is part of the deal.II library.
6 | ##
7 | ## The deal.II library is free software; you can use it, redistribute
8 | ## it, and/or modify it under the terms of the GNU Lesser General
9 | ## Public License as published by the Free Software Foundation; either
10 | ## version 2.1 of the License, or (at your option) any later version.
11 | ## The full text of the license can be found in the file LICENSE at
12 | ## the top level of the deal.II distribution.
13 | ##
14 | ## ---------------------------------------------------------------------
15 |
16 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
17 | PROJECT(parameter_gui)
18 |
19 | IF("${DEAL_II_EXECUTABLE_RELDIR}" STREQUAL "")
20 | SET(DEAL_II_EXECUTABLE_RELDIR "bin")
21 | ENDIF()
22 |
23 | FIND_PACKAGE(Qt5 QUIET COMPONENTS Core Gui Xml Widgets)
24 |
25 | IF(${Qt5_FOUND})
26 | ELSE()
27 | FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtXml)
28 | INCLUDE(${QT_USE_FILE})
29 | ENDIF()
30 |
31 | MARK_AS_ADVANCED(QT_QMAKE_EXECUTABLE)
32 |
33 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
34 |
35 | IF(${Qt5_FOUND})
36 | QT5_WRAP_CPP(SOURCE_MOC
37 | browse_lineedit.h
38 | info_message.h
39 | settings_dialog.h
40 | mainwindow.h
41 | parameter_delegate.h
42 | )
43 |
44 | QT5_ADD_RESOURCES(SOURCE_RCC
45 | application.qrc
46 | )
47 | ELSE()
48 | QT4_WRAP_CPP(SOURCE_MOC
49 | browse_lineedit.h
50 | info_message.h
51 | settings_dialog.h
52 | mainwindow.h
53 | parameter_delegate.h
54 | )
55 |
56 | QT4_ADD_RESOURCES(SOURCE_RCC
57 | application.qrc
58 | )
59 | ENDIF()
60 |
61 |
62 | ADD_EXECUTABLE(parameter_gui_exe
63 | browse_lineedit.cpp
64 | info_message.cpp
65 | settings_dialog.cpp
66 | main.cpp
67 | mainwindow.cpp
68 | parameter_delegate.cpp
69 | xml_parameter_reader.cpp
70 | xml_parameter_writer.cpp
71 | prm_parameter_writer.cpp
72 | ${SOURCE_MOC}
73 | ${SOURCE_RCC}
74 | )
75 | SET_TARGET_PROPERTIES(parameter_gui_exe
76 | PROPERTIES
77 | OUTPUT_NAME parameter_gui
78 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DEAL_II_EXECUTABLE_RELDIR}"
79 | )
80 | TARGET_LINK_LIBRARIES(parameter_gui_exe ${QT_LIBRARIES})
81 |
82 | INSTALL(TARGETS parameter_gui_exe
83 | RUNTIME DESTINATION ${DEAL_II_EXECUTABLE_RELDIR}
84 | COMPONENT parameter_gui
85 | )
86 | EXPORT(TARGETS parameter_gui_exe
87 | FILE
88 | ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
89 | APPEND
90 | )
91 |
92 | IF(${Qt5_FOUND})
93 | QT5_USE_MODULES(parameter_gui_exe Core Gui Xml Widgets)
94 | ENDIF()
95 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # This repository contains the parameter_gui project.
2 |
3 | It is copyrighted by Martin Steigemann and Wolfgang Bangerth and
4 | distributed under the same license as the deal.II library, i.e. The GNU
5 | Lesser General Public License (LGPL) version 2.1 or later.
6 |
7 | Requirements:
8 | =============
9 |
10 | - CMake
11 | - Qt toolkit
12 |
13 | Usage:
14 | ======
15 |
16 | To use the parameter GUI you first need to write a description of all the
17 | parameters, their default values, patterns and documentation strings into a
18 | file in a format that the GUI can understand; this is done using the
19 | ParameterHandler::print_parameters() function with ParameterHandler::XML as
20 | second argument, as discussed in more detail below in the Representation
21 | of Parameters section. This file can then be loaded using the
22 | executable of this GUI.
23 |
24 | Once loaded, the GUI displays subsections and individual parameters in tree
25 | form (see also the discussion in the Representation of Parameters
26 | section below). Here is a screen shot with some sub-sections expanded and
27 | one parameter selected for editing:
28 |
29 | 
30 |
31 | Using the GUI, you can edit the values of individual parameters and save
32 | the result in the same format as before. It can then be read in using the
33 | ParameterHandler::read_input_from_xml() function.
34 |
--------------------------------------------------------------------------------
/application.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/logo_dealii_64.png
4 | images/logo_dealii_gui.png
5 | images/logo_dealii_gui_128.png
6 |
7 |
8 |
--------------------------------------------------------------------------------
/browse_lineedit.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 | #include "browse_lineedit.h"
17 |
18 | #include
19 |
20 | namespace dealii
21 | {
22 | namespace ParameterGui
23 | {
24 | BrowseLineEdit::BrowseLineEdit(const BrowseType type, QWidget *parent)
25 | : QFrame(parent, 0),
26 | browse_type(type)
27 | {
28 | line_editor = new QLineEdit;
29 | connect(line_editor, SIGNAL(editingFinished()), this, SLOT(editing_finished()));
30 |
31 | browse_button = new QPushButton("&Browse...");
32 | connect(browse_button, SIGNAL(clicked()), this, SLOT(browse()));
33 |
34 | setFocusPolicy (Qt::StrongFocus);
35 |
36 | QHBoxLayout *layout = new QHBoxLayout;
37 |
38 | layout->setContentsMargins(1,1,1,1);
39 | layout->addWidget(line_editor);
40 | layout->addWidget(browse_button);
41 | setLayout(layout);
42 |
43 | setAutoFillBackground(true);
44 | setBackgroundRole(QPalette::Highlight);
45 | }
46 |
47 |
48 |
49 |
50 | QSize BrowseLineEdit::sizeHint() const
51 | {
52 | QSize size_line_editor = line_editor->sizeHint(),
53 | size_browse_button = browse_button->sizeHint();
54 |
55 | int w = size_line_editor.rwidth() + size_browse_button.rwidth(),
56 | h = qMax(size_line_editor.rheight(), size_browse_button.rheight());
57 |
58 | return QSize (w, h);
59 | }
60 |
61 |
62 |
63 | QSize BrowseLineEdit::minimumSizeHint() const
64 | {
65 | QSize size_line_editor = line_editor->minimumSizeHint(),
66 | size_browse_button = browse_button->minimumSizeHint();
67 |
68 | int w = size_line_editor.rwidth() + size_browse_button.rwidth(),
69 | h = qMax(size_line_editor.rheight(), size_browse_button.rheight());
70 |
71 | return QSize (w, h);
72 | }
73 |
74 |
75 |
76 | QString BrowseLineEdit::text() const
77 | {
78 | return line_editor->text();
79 | }
80 |
81 |
82 |
83 | void BrowseLineEdit::setText(const QString &str)
84 | {
85 | line_editor->setText(str);
86 | }
87 |
88 |
89 |
90 | void BrowseLineEdit::editing_finished()
91 | {
92 | emit editingFinished();
93 | }
94 |
95 |
96 |
97 | void BrowseLineEdit::browse()
98 | {
99 | QString name = "";
100 |
101 | switch (browse_type)
102 | {
103 | case file:
104 | {
105 | name = QFileDialog::getOpenFileName(this, tr("Open File"),
106 | QDir::currentPath(),
107 | tr("All Files (*.*)"));
108 | break;
109 | };
110 |
111 | case files:
112 | {
113 | QStringList names = QFileDialog::getOpenFileNames(this, tr("Open Files"),
114 | QDir::currentPath(),
115 | tr("All Files (*.*)"));
116 | name = names.join(",");
117 | break;
118 | };
119 |
120 | case directory:
121 | {
122 | name = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
123 | QDir::homePath(),
124 | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
125 | break;
126 | };
127 | };
128 |
129 | if (!name.isEmpty() && !name.isNull())
130 | line_editor->setText(name);
131 | }
132 | }
133 | }
134 |
135 |
--------------------------------------------------------------------------------
/browse_lineedit.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #ifndef BROWSELINEEDIT_H
18 | #define BROWSELINEEDIT_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 |
26 | namespace dealii
27 | {
28 | /*! @addtogroup ParameterGui
29 | *@{
30 | */
31 | namespace ParameterGui
32 | {
33 | /**
34 | * The BrowseLineEdit class provides a special line editor for the parameterGUI.
35 | * While editing file- or directory names it is much more easier to have a file-dialog
36 | * and just click on existing files or directories. This editor provides a simple QLineEditor
37 | * and a browse-button which opens a file- or a directory dialog. Clicking on existing files or directories
38 | * copies the path to the line editor. Depending on the BrowseType given in the constructor
39 | * the browse button opens a file or a directory dialog.
40 | *
41 | * @note This class is used in the graphical user interface for the @ref ParameterHandler class.
42 | * It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
43 | *
44 | * @ingroup ParameterGui
45 | * @author Martin Steigemann, Wolfgang Bangerth, 2010
46 | */
47 | class BrowseLineEdit : public QFrame
48 | {
49 | Q_OBJECT
50 |
51 | public:
52 | /**
53 | * The browse button opens a file or
54 | * a directory dialog. This can be specified
55 | * in the constructor by setting this flag BrowseType.
56 | */
57 | enum BrowseType {file = 0, directory = 1, files = 2};
58 |
59 | /**
60 | * Constructor. The type of the browse dialog can be specified
61 | * by the flag BrowseType, the default is file.
62 | */
63 | BrowseLineEdit (const BrowseType type = file,
64 | QWidget *parent = 0);
65 |
66 | /**
67 | * Reimplemented from the QWidget class.
68 | * Returns the size of the editor.
69 | */
70 | QSize sizeHint() const;
71 |
72 | /**
73 | * Reimplemented from the QWidget class.
74 | */
75 | QSize minimumSizeHint() const;
76 |
77 | /**
78 | * Returns the text of the line editor.
79 | */
80 | QString text() const;
81 |
82 | /**
83 | * This pattern stores the type of the browse dialog.
84 | */
85 | BrowseType browse_type;
86 |
87 | public slots:
88 | /**
89 | * A slot to set @p str as text of the line editor.
90 | */
91 | void setText(const QString &str);
92 |
93 | signals:
94 | /**
95 | * This signal will be emitted, if editing is finished.
96 | */
97 | void editingFinished();
98 |
99 | private slots:
100 | /**
101 | * This slot should be always called, if editing is finished.
102 | */
103 | void editing_finished();
104 |
105 | /**
106 | * This function opens a file- or a directory dialog as specified in the
107 | * constructor.
108 | */
109 | void browse();
110 |
111 | private:
112 | /**
113 | * The line editor.
114 | */
115 | QLineEdit *line_editor;
116 |
117 | /**
118 | * The browse button.
119 | */
120 | QPushButton *browse_button;
121 | };
122 | }
123 | /**@}*/
124 | }
125 |
126 |
127 | #endif
128 |
--------------------------------------------------------------------------------
/dealii_parameter_gui.pro:
--------------------------------------------------------------------------------
1 | ######################################################################
2 | # Automatically generated by qmake (2.01a) So. Dez 12 15:30:12 2010
3 | ######################################################################
4 |
5 | TEMPLATE = app
6 | TARGET =
7 | DEPENDPATH += .
8 | INCLUDEPATH += .
9 | DESTDIR = ../../lib/bin
10 |
11 | # Input
12 | HEADERS += browse_lineedit.h \
13 | info_message.h \
14 | settings_dialog.h \
15 | mainwindow.h \
16 | parameter_delegate.h \
17 | xml_parameter_reader.h \
18 | xml_parameter_writer.h \
19 | prm_parameter_writer.h
20 | SOURCES += browse_lineedit.cpp \
21 | info_message.cpp \
22 | settings_dialog.cpp \
23 | main.cpp \
24 | mainwindow.cpp \
25 | parameter_delegate.cpp \
26 | xml_parameter_reader.cpp \
27 | xml_parameter_writer.cpp \
28 | prm_parameter_writer.cpp
29 | RESOURCES += application.qrc
30 |
--------------------------------------------------------------------------------
/images/logo_dealii.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dealii/parameter_gui/b7c0251b57dfbcc3fe873b25a6eb604a11a63e1d/images/logo_dealii.png
--------------------------------------------------------------------------------
/images/logo_dealii_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dealii/parameter_gui/b7c0251b57dfbcc3fe873b25a6eb604a11a63e1d/images/logo_dealii_64.png
--------------------------------------------------------------------------------
/images/logo_dealii_gui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dealii/parameter_gui/b7c0251b57dfbcc3fe873b25a6eb604a11a63e1d/images/logo_dealii_gui.png
--------------------------------------------------------------------------------
/images/logo_dealii_gui_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dealii/parameter_gui/b7c0251b57dfbcc3fe873b25a6eb604a11a63e1d/images/logo_dealii_gui_128.png
--------------------------------------------------------------------------------
/info_message.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "info_message.h"
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace dealii
26 | {
27 | namespace ParameterGui
28 | {
29 | InfoMessage::InfoMessage(QSettings *parent_settings,
30 | QWidget *parent)
31 | : QDialog(parent, 0)
32 | {
33 | // this variable stores, if the
34 | // the info message should be shown again
35 | show_again = true;
36 | QGridLayout * grid = new QGridLayout(this);
37 |
38 | // set an icon
39 | icon = new QLabel(this);
40 | #ifndef QT_NO_MESSAGEBOX
41 | icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
42 | icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
43 | #endif
44 | // add the icon in the upper left corner
45 | grid->addWidget(icon, 0, 0, Qt::AlignTop);
46 |
47 | // set the new message
48 | message = new QTextEdit(this);
49 | message->setReadOnly(true);
50 |
51 | // and add the message on the right
52 | grid->addWidget(message, 0, 1);
53 |
54 | // add a check box
55 | again = new QCheckBox(this);
56 | again->setChecked(true);
57 | again->setText(QErrorMessage::tr("&Show this message again"));
58 | grid->addWidget(again, 1, 1, Qt::AlignTop);
59 |
60 | // and finally a OK button
61 | ok = new QPushButton(this);
62 | ok->setText(QErrorMessage::tr("&OK"));
63 | #ifdef QT_SOFTKEYS_ENABLED
64 | // define the action for the button
65 | ok_action = new QAction(ok);
66 | ok_action->setSoftKeyRole(QAction::PositiveSoftKey);
67 | ok_action->setText(ok->text());
68 | connect(ok_action, SIGNAL(triggered()), this, SLOT(accept()));
69 | addAction(ok_action);
70 | #endif
71 | connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
72 | // and set the focus on the button
73 | ok->setFocus();
74 | grid->addWidget(ok, 2, 0, 1, 2, Qt::AlignCenter);
75 |
76 | grid->setColumnStretch(1, 42);
77 | grid->setRowStretch(0, 42);
78 |
79 | settings = parent_settings;
80 |
81 | // we store settings of this class in the group infoMessage
82 | settings->beginGroup("infoMessage");
83 | show_again = settings->value("showInformation", true).toBool();
84 | settings->endGroup();
85 | }
86 |
87 |
88 |
89 | void InfoMessage::setInfoMessage(const QString &message)
90 | {
91 | // set the message
92 | this->message->setText(message);
93 | }
94 |
95 |
96 |
97 | void InfoMessage::showMessage()
98 | {
99 | // and show the message
100 | if (show_again)
101 | show();
102 | }
103 |
104 |
105 |
106 | void InfoMessage::done(int r)
107 | {
108 | // if the box is not checked, store this to settings
109 | if(!again->isChecked())
110 | {
111 | settings->beginGroup("infoMessage");
112 | settings->setValue("showInformation", false);
113 | settings->endGroup();
114 | };
115 |
116 | QDialog::done(r);
117 | }
118 | }
119 | }
120 |
121 |
--------------------------------------------------------------------------------
/info_message.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #ifndef INFOMESSAGE_H
18 | #define INFOMESSAGE_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 |
27 | namespace dealii
28 | {
29 | /*! @addtogroup ParameterGui
30 | *@{
31 | */
32 | namespace ParameterGui
33 | {
34 | /**
35 | * The InfoMessage class implements a special info message for the parameterGUI.
36 | * Besides showing a info message itself, the dialog shows a checkbox "Show this message again".
37 | * If the user unchecks this box, this is stored in the "settings.ini" file and will be reloaded
38 | * the next time the user opens the parameterGUI. The intention of such a info message is the following.
39 | * The user should have some information on how using the GUI "at hand"
40 | * such as "how to edit parameter values" for example. But after reading this message, the user knows
41 | * it and the message should not appear permanently.
42 | *
43 | * @note This class is used in the graphical user interface for the @ref ParameterHandler class.
44 | * It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
45 | *
46 | * @ingroup ParameterGui
47 | * @author Martin Steigemann, Wolfgang Bangerth, 2010
48 | */
49 | class InfoMessage : public QDialog
50 | {
51 | Q_OBJECT
52 |
53 | public:
54 | /**
55 | * Constructor
56 | */
57 | InfoMessage (QSettings *settings,
58 | QWidget *parent = 0);
59 |
60 | /**
61 | * With this function the @p message which will be shown in the
62 | * dialog can be set.
63 | */
64 | void setInfoMessage(const QString &message);
65 |
66 | public slots:
67 | /**
68 | * Show the dialog with the message.
69 | */
70 | void showMessage();
71 |
72 | protected:
73 | /**
74 | * Reimplemented from QDialog.
75 | */
76 | void done(int r);
77 |
78 | private:
79 | /**
80 | * This variable stores, if the message should be shown again the next time.
81 | */
82 | bool show_again;
83 |
84 | /**
85 | * The Ok button.
86 | */
87 | QPushButton *ok;
88 |
89 | /**
90 | * The checkboxShow this message again.
91 | */
92 | QCheckBox *again;
93 |
94 | /**
95 | * The message editor.
96 | */
97 | QTextEdit *message;
98 |
99 | /**
100 | * An icon for the dialog.
101 | */
102 | QLabel *icon;
103 |
104 | #ifdef QT_SOFTKEYS_ENABLED
105 | /**
106 | * A action for pressing the Ok button.
107 | */
108 | QAction *ok_action;
109 | #endif
110 |
111 | /**
112 | * An object for storing settings in a file.
113 | */
114 | QSettings *settings;
115 | };
116 | }
117 | /**@}*/
118 | }
119 |
120 |
121 | #endif
122 |
--------------------------------------------------------------------------------
/lgpl-2.1.txt:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489 |
490 | Also add information on how to contact you by electronic and paper mail.
491 |
492 | You should also get your employer (if you work as a programmer) or your
493 | school, if any, to sign a "copyright disclaimer" for the library, if
494 | necessary. Here is a sample; alter the names:
495 |
496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498 |
499 | , 1 April 1990
500 | Ty Coon, President of Vice
501 |
502 | That's all there is to it!
503 |
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | #include "mainwindow.h"
22 |
23 | /*! @addtogroup ParameterGui
24 | *@{
25 | */
26 |
27 | /**
28 | * Main function for the parameterGUI.
29 | * The parameterGUI is a graphical user interface for editing parameter files based on the XML format,
30 | * created by the ParameterHandler::print_parameters() function with ParameterHandler::XML as second argument.
31 | *
32 | * @image html logo_dealii_gui.png
33 | *
34 | * @note This class is used in the graphical user interface for the @ref ParameterHandler class.
35 | * It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
36 | *
37 | *
38 | *
This program uses Qt version > 4.3. Qt is licensed under the GNU General Public License
39 | * version 3.0. Please see http://qt.nokia.com/products/licensing for an overview of Qt licensing.
40 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). Qt is a Nokia product.
41 | * See http://qt.nokia.com/ for more information.
42 | *
43 | *
44 | * @ingroup ParameterGui
45 | * @author Martin Steigemann, Wolfgang Bangerth, 2010
46 | */
47 | int main(int argc, char *argv[])
48 | {
49 | // init resources such as icons or graphics
50 | Q_INIT_RESOURCE(application);
51 |
52 | QApplication app(argc, argv);
53 |
54 | // setup a splash screen
55 | QSplashScreen * splash = new QSplashScreen;
56 | splash->setPixmap(QPixmap(":/images/logo_dealii_gui.png"));
57 | splash->show();
58 |
59 | // and close it after 3000 ms
60 | QTimer::singleShot(3000, splash, SLOT(close()));
61 |
62 | // setup the application name
63 | app.setApplicationName("parameterGUI for deal.II");
64 |
65 | // give command line arguments to main_win
66 | // if a parameter file is specified at the
67 | // command line, give it to the MainWindow.
68 | dealii::ParameterGui::MainWindow * main_win =
69 | new dealii::ParameterGui::MainWindow (argv[1]);
70 |
71 | // show the main window with a short delay
72 | // so we can see the splash screen
73 | QTimer::singleShot(1500, main_win, SLOT(show()));
74 |
75 | return app.exec();
76 | }
77 | /**@}*/
78 |
79 |
--------------------------------------------------------------------------------
/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "mainwindow.h"
18 | #include "parameter_delegate.h"
19 | #include "xml_parameter_reader.h"
20 | #include "xml_parameter_writer.h"
21 | #include "prm_parameter_writer.h"
22 |
23 | #include
24 | #if QT_VERSION >= 0x050000
25 | #include
26 | #else
27 | #include
28 | #endif
29 |
30 | namespace dealii
31 | {
32 | namespace ParameterGui
33 | {
34 | MainWindow::MainWindow(const QString &filename)
35 | {
36 | // load settings
37 | gui_settings = new QSettings ("deal.II", "parameterGUI");
38 |
39 | // tree for showing XML tags
40 | tree_widget = new QTreeWidget;
41 |
42 | // Setup the tree and the window first:
43 | #if QT_VERSION >= 0x050000
44 | tree_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
45 | #else
46 | tree_widget->header()->setResizeMode(QHeaderView::ResizeToContents);
47 | #endif
48 | tree_widget->setHeaderLabels(QStringList() << tr("(Sub)Sections/Parameters")
49 | << tr("Value"));
50 |
51 | // enables mouse events e.g. showing ToolTips
52 | // and documentation in the StatusLine
53 | tree_widget->setMouseTracking(true);
54 | tree_widget->setEditTriggers(QAbstractItemView::DoubleClicked|
55 | QAbstractItemView::SelectedClicked|
56 | QAbstractItemView::EditKeyPressed);
57 |
58 | //Enable right click menu in tree
59 | tree_widget->setContextMenuPolicy(Qt::ActionsContextMenu);
60 | context_menu = new QMenu(tree_widget);
61 |
62 | // set the delegate for editing items
63 | tree_widget->setItemDelegate(new ParameterDelegate(1));
64 |
65 | setCentralWidget(tree_widget);
66 |
67 | connect(tree_widget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(set_documentation_text(QTreeWidgetItem *, QTreeWidgetItem *)));
68 | // connect: if the tree changes, the window will know
69 | connect(tree_widget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(item_changed(QTreeWidgetItem *, int)));
70 | connect(tree_widget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(tree_was_modified()));
71 |
72 | QDockWidget *documentation_widget = new QDockWidget(tr("Parameter documentation:"), this);
73 | documentation_text_widget = new QTextEdit(QString (""), documentation_widget);
74 | documentation_text_widget->setReadOnly(true);
75 |
76 | documentation_widget->setAllowedAreas(Qt::AllDockWidgetAreas);
77 | documentation_widget->setWidget(documentation_text_widget);
78 |
79 | addDockWidget(Qt::BottomDockWidgetArea, documentation_widget);
80 |
81 | // create window actions as "Open",...
82 | create_actions();
83 | // and menus
84 | create_menus();
85 | // and the toolbar
86 | create_toolbar();
87 |
88 | statusBar()->showMessage(tr("Ready, start editing by double-clicking or hitting F2!"));
89 | setWindowTitle(tr("[*]parameterGUI"));
90 |
91 | gui_settings->beginGroup("MainWindow");
92 | resize(gui_settings->value("size", QSize(800, 600)).toSize());
93 | move(gui_settings->value("pos", QPoint(0, 0)).toPoint());
94 | gui_settings->endGroup();
95 |
96 | // if there is a file_name, try to load the file.
97 | // a valid file has the xml extension, so we require size() > 3
98 | if (filename.size() > 3)
99 | load_file(filename);
100 |
101 | apply_settings();
102 | }
103 |
104 |
105 |
106 | void MainWindow::set_documentation_text(QTreeWidgetItem *selected_item,
107 | QTreeWidgetItem *previous_item)
108 | {
109 | documentation_text_widget->clear();
110 | documentation_text_widget->insertPlainText(selected_item->text(3));
111 | }
112 |
113 |
114 |
115 | void MainWindow::item_changed(QTreeWidgetItem *item,
116 | int column)
117 | {
118 | if (column != 1)
119 | return;
120 |
121 | bool has_default_value;
122 |
123 | if (item->text(5).startsWith("[Double"))
124 | has_default_value = item->data(1,Qt::DisplayRole).toReal() == item->data(2,Qt::DisplayRole).toReal();
125 | else
126 | has_default_value = item->data(1,Qt::DisplayRole).toString() == item->data(2,Qt::DisplayRole).toString();
127 |
128 | if (has_default_value)
129 | {
130 | QFont font = item->font(1);
131 | font.setWeight(QFont::Normal);
132 | item->setFont(1,font);
133 |
134 | const bool hide_items_with_default_value = gui_settings->value("Settings/hideDefault", false).toBool();
135 | if (hide_items_with_default_value)
136 | item->setHidden(true);
137 | }
138 | else
139 | {
140 | QFont font = item->font(1);
141 | font.setWeight(QFont::Bold);
142 | item->setFont(1,font);
143 | }
144 | }
145 |
146 |
147 |
148 | void MainWindow::set_to_default()
149 | {
150 | QTreeWidgetItem * current_item = tree_widget->currentItem();
151 | current_item->setText(1,current_item->text(2));
152 | }
153 |
154 |
155 |
156 | void MainWindow::open()
157 | {
158 | // check, if the content was modified
159 | if (maybe_save())
160 | {
161 | // open a file dialog
162 | QString file_name =
163 | QFileDialog::getOpenFileName(this, tr("Open XML Parameter File"),
164 | QDir::currentPath(),
165 | tr("XML Files (*.xml)"));
166 |
167 | // if a file was selected, load the content
168 | if (!file_name.isEmpty())
169 | load_file(file_name);
170 | }
171 | }
172 |
173 |
174 |
175 | bool MainWindow::save()
176 | {
177 | // if there is no file to save changes, open a dialog
178 | if (current_file.isEmpty())
179 | return save_as();
180 | else
181 | return save_file(current_file);
182 | }
183 |
184 |
185 |
186 | bool MainWindow::save_as()
187 | {
188 | const QString default_save_format = gui_settings->value("Settings/DefaultSaveFormat").toString();
189 |
190 | QString filters;
191 | if (default_save_format == "prm")
192 | filters = tr("PRM Files (*.prm);;XML Files (*.xml)");
193 | else
194 | filters = tr("XML Files (*.xml);;PRM Files (*.prm)");
195 |
196 | // open a file dialog
197 | QString file_name =
198 | QFileDialog::getSaveFileName(this, tr("Save Parameter File"),
199 | QDir::currentPath() + QDir::separator() + current_file,
200 | filters);
201 |
202 | // return if a file was saved
203 | if (file_name.isEmpty())
204 | return false;
205 | else
206 | return save_file(file_name);
207 | }
208 |
209 |
210 |
211 | void MainWindow::about()
212 | {
213 | #ifdef Q_WS_MAC
214 | static QPointer old_msg_box;
215 |
216 | if (old_msg_box)
217 | {
218 | old_msg_box->show();
219 | old_msg_box->raise();
220 | old_msg_box->activateWindow();
221 | return;
222 | };
223 | #endif
224 |
225 | QString title = "About parameterGUI";
226 |
227 | QString trAboutparameterGUIcaption;
228 | trAboutparameterGUIcaption = QMessageBox::tr(
229 | "
parameterGUI: A GraphicalUserInterface for parameter handling in deal.II
The parameterGUI is a graphical user interface for editing XML parameter files "
236 | "created by the ParameterHandler class of deal.II. Please see "
237 | "dealii.org/doc for more information. "
238 | "The parameterGUI parses XML files into a tree structure and provides "
239 | " special editors for different types of parameters.
"
240 |
241 | "
Editing parameter values: "
242 | "Parameters can be edited by (double-)clicking on the value or "
243 | "by pressing the platform edit key (F2 on Linux) over an parameter item.
"
244 |
245 | "
Editors for parameter values: "
246 | "Editor fields are aware of the type of the parameter, and show reasonable "
247 | "input fields including (where possible) error checking."
248 | "
1.0140[Double -1.79769e+308...1.79769e+308 (inclusive)]21.41[Double -1.79769e+308...1.79769e+308 (inclusive)]1242[Integer range -2147483648...2147483647 (inclusive)]0.5143[Double -1.79769e+308...1.79769e+308 (inclusive)]0.250.2544[Double -1.79769e+308...1.79769e+308 (inclusive)]25010045[Double -1.79769e+308...1.79769e+308 (inclusive)]110.110.46[Double -1.79769e+308...1.79769e+308 (inclusive)]-110.-110.47[Double -1.79769e+308...1.79769e+308 (inclusive)]180.180.48[Double -1.79769e+308...1.79769e+308 (inclusive)]-180.-180.49[Double -1.79769e+308...1.79769e+308 (inclusive)]222250[Integer range -2147483648...2147483647 (inclusive)]363651[Integer range -2147483648...2147483647 (inclusive)]1152[Integer range -2147483648...2147483647 (inclusive)]31053[Integer range -2147483648...2147483647 (inclusive)]falsetrue54[Bool]truefalse55[Bool]falsefalse56[Bool]falsefalse57[Bool]2500001000058[Integer range -2147483648...2147483647 (inclusive)]ParaSailsBoomerAMG59[Selection BoomerAMG|Euclid|ParaSails ]0.20.2560[Double -1.79769e+308...1.79769e+308 (inclusive)]0.90.961[Double -1.79769e+308...1.79769e+308 (inclusive)]0062[Integer range -2147483648...2147483647 (inclusive)]falsefalse63[Bool]4164[Integer range -2147483648...2147483647 (inclusive)]2065[Selection 0|1|2 ]1166[Integer range -2147483648...2147483647 (inclusive)]0.10.167[Double -1.79769e+308...1.79769e+308 (inclusive)]0.050.0568[Double -1.79769e+308...1.79769e+308 (inclusive)]0.0.69[Double -1.79769e+308...1.79769e+308 (inclusive)]/home/masteige/projects/mcrack/mcrack2d/examples/test/meshes/mesh.ucd/home/masteige/mcrack2d/examples//meshes/mesh.ucd70[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/meshes/crack_path_out_T=001_tip=P1.data/home/masteige/mcrack2d/examples/crack_path_in.data71[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/meshes/crack_path_out.data/home/masteige/mcrack2d/examples/crack_path_out.data72[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/matrix_M.data/home/masteige/mcrack2d/examples/Matrix_M_in.data73[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/matrix_M_out.data/home/masteige/mcrack2d/examples/Matrix_M_out.data74[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/da_dN_curve.data/home/masteige/mcrack2d/examples/da_dN_curve.data75[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/examples/test/results.data/home/masteige/mcrack2d/examples/results/results.data76[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/common/scripts/extract_mesh.py/home/masteige/mcrack2d/common/scripts/extract_mesh.py77[FileName (Type: input)]/home/masteige/projects/mcrack/mcrack2d/common/material_database//home/masteige/mcrack2d/common/material_database78[DirectoryName]/home/masteige/projects/mcrack/mcrack2d/examples/test//home/masteige/mcrack2d/examples79[DirectoryName]/home/masteige/projects/mcrack/mcrack2d/examples/test/graphics//home/masteige/mcrack2d/examples/graphics80[DirectoryName]/home/masteige/projects/mcrack/mcrack2d/examples/test/meshes//home/masteige/mcrack2d/examples/meshes81[DirectoryName]/home/masteige/projects/mcrack/mcrack2d/examples/test/results/home/masteige/mcrack2d/examples/results82[DirectoryName]
--------------------------------------------------------------------------------
/prm_parameter_writer.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2017 by Rene Gassmoeller
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "prm_parameter_writer.h"
18 |
19 | namespace dealii
20 | {
21 | namespace ParameterGui
22 | {
23 | PRMParameterWriter::PRMParameterWriter(QTreeWidget *tree_widget)
24 | : tree_widget(tree_widget)
25 | {
26 | }
27 |
28 |
29 |
30 | bool PRMParameterWriter::write_prm_file(QIODevice *device)
31 | {
32 | // loop over the elements
33 | for (int i = 0; i < tree_widget->topLevelItemCount(); ++i)
34 | {
35 | const QString item_string = item_to_string(tree_widget->topLevelItem(i),0);
36 | device->write(item_string.toLatin1());
37 | }
38 |
39 | return true;
40 | }
41 |
42 |
43 |
44 | QString PRMParameterWriter::item_to_string(const QTreeWidgetItem *item,
45 | const unsigned int indentation_level)
46 | {
47 | QString item_string;
48 |
49 | // if the entry has no children we have a parameter
50 | if (item->childCount() == 0)
51 | {
52 | bool non_default_value;
53 |
54 | if (item->text(5).startsWith("[Double"))
55 | non_default_value = item->data(1,Qt::DisplayRole).toReal() != item->data(2,Qt::DisplayRole).toReal();
56 | else
57 | non_default_value = item->data(1,Qt::DisplayRole).toString() != item->data(2,Qt::DisplayRole).toString();
58 |
59 |
60 | if (non_default_value)
61 | {
62 | for (unsigned int i=0; itext(0) + " = " + item->data(1,Qt::EditRole).toString() + "\n");
66 | }
67 | }
68 | else
69 | {
70 | for (int i = 0; i < item->childCount(); ++i)
71 | item_string.push_back(item_to_string(item->child(i),indentation_level+1));
72 |
73 | if (!item_string.isEmpty())
74 | {
75 | item_string.push_front("subsection " + item->text(0).toLatin1() + "\n");
76 | for (unsigned int i=0; i
21 | #include
22 |
23 |
24 | namespace dealii
25 | {
26 | /*! @addtogroup ParameterGui
27 | *@{
28 | */
29 | namespace ParameterGui
30 | {
31 | /**
32 | * The PRMParameterWriter class provides an interface to write parameters
33 | * stored in a QTreeWidget to a file in deal.II's PRM format.
34 | * This class only writes parameters that deviate from their default values to
35 | * improve the readability of the created file.
36 | *
37 | * @note This class is used in the graphical user interface for the
38 | * @ref ParameterHandler class.
39 | * It is not compiled into the deal.II libraries and can not be used by
40 | * applications using deal.II.
41 | *
42 | * @ingroup ParameterGui
43 | * @author Rene Gassmoeller, 2017
44 | */
45 | class PRMParameterWriter
46 | {
47 | public:
48 | /**
49 | * Constructor.
50 | * Parameter values from @p tree_widget will be written.
51 | */
52 | PRMParameterWriter (QTreeWidget *tree_widget);
53 |
54 | /**
55 | * This function writes the parameter values stored in tree_widget
56 | * to @p device in the PRM format.
57 | */
58 | bool write_prm_file (QIODevice *device);
59 |
60 | private:
61 | /**
62 | * This function creates a string that corresponds to the data written
63 | * to a prm file for a given @p item of tree_widget.
64 | * If the @p item is a parameter it is only written if its value differs
65 | * from its default value. If the @p item is a subsection, a start element
66 | * subsection is written and write_item is called
67 | * recursively to write the next item.
68 | * If no items in this subsection differ from their default values then
69 | * the subsection is not written.
70 | * @p indentation_level describes the level the current item belongs to.
71 | * 0 describes a top level item and each subsection increases the level
72 | * by one.
73 | *
74 | */
75 | QString item_to_string (const QTreeWidgetItem *item,
76 | const unsigned int indentation_level);
77 |
78 | /**
79 | * A pointer to the QTreeWidget structure
80 | * which stores the parameters.
81 | */
82 | QTreeWidget *tree_widget;
83 | };
84 | }
85 | /**@}*/
86 | }
87 |
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/settings_dialog.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2017 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "settings_dialog.h"
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | namespace dealii
25 | {
26 | namespace ParameterGui
27 | {
28 | SettingsDialog::SettingsDialog(QSettings *gui_settings,
29 | QWidget *parent)
30 | : QDialog(parent, 0)
31 | {
32 | setWindowTitle("Settings");
33 |
34 | settings = gui_settings;
35 | loadSettings();
36 |
37 | QFormLayout * grid = new QFormLayout(this);
38 |
39 | // add a choose font button
40 | change_font = new QPushButton(this);
41 | change_font->setText(QErrorMessage::tr("Change font"));
42 | connect(change_font, SIGNAL(clicked()), this, SLOT(selectFont()));
43 | grid->addRow("Change Font",change_font);
44 |
45 | // add a checkbox
46 | hide_default = new QCheckBox(this);
47 | hide_default->setChecked(hide_default_values);
48 | connect(hide_default, SIGNAL(stateChanged(int)), this, SLOT(changeHideDefault(int)));
49 | grid->addRow("Hide default values",hide_default);
50 |
51 | // add an OK button
52 | ok = new QPushButton(this);
53 | ok->setText(QErrorMessage::tr("&OK"));
54 | connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
55 |
56 | // add a Cancel button
57 | cancel = new QPushButton(this);
58 | cancel->setText(QErrorMessage::tr("&Cancel"));
59 | connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
60 | grid->addRow(ok,cancel);
61 |
62 | connect(this, SIGNAL(accepted()), this, SLOT(writeSettings()));
63 | }
64 |
65 |
66 |
67 | void SettingsDialog::selectFont()
68 | {
69 | bool ok;
70 | QFont new_font = QFontDialog::getFont(
71 | &ok, selected_font, this);
72 | if (ok) {
73 | selected_font = new_font;
74 | }
75 | }
76 |
77 |
78 |
79 | void SettingsDialog::changeHideDefault(int state)
80 | {
81 | hide_default_values = state;
82 | }
83 |
84 |
85 |
86 | void SettingsDialog::loadSettings()
87 | {
88 | settings->beginGroup("Settings");
89 | hide_default_values = settings->value("hideDefault", false).toBool();
90 |
91 | QString stored_font_string = settings->value("Font", QFont().toString()).toString();
92 | selected_font.fromString(stored_font_string);
93 | settings->endGroup();
94 | }
95 |
96 |
97 |
98 | void SettingsDialog::writeSettings()
99 | {
100 | settings->beginGroup("Settings");
101 |
102 | settings->setValue("hideDefault", hide_default_values);
103 | settings->setValue("Font", selected_font.toString());
104 |
105 | settings->endGroup();
106 | }
107 | }
108 | }
109 |
110 |
--------------------------------------------------------------------------------
/settings_dialog.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2017 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #ifndef SETTINGSDIALOG_H
18 | #define SETTINGSDIALOG_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 |
25 | namespace dealii
26 | {
27 | /*! @addtogroup ParameterGui
28 | *@{
29 | */
30 | namespace ParameterGui
31 | {
32 | /**
33 | * The SettingsDialog class implements a settings dialog for the parameterGUI.
34 | * The dialog shows all available settings, and when the user clicks on 'OK'
35 | * stores them in the QSettings object handed over in the constructor (which
36 | * in turn stores them on disk to allow persistent settings).
37 | *
38 | * @ingroup ParameterGui
39 | * @author Rene Gassmoeller, 2017
40 | */
41 | class SettingsDialog : public QDialog
42 | {
43 | Q_OBJECT
44 |
45 | public:
46 | /**
47 | * Constructor
48 | */
49 | SettingsDialog (QSettings *settings,
50 | QWidget *parent = 0);
51 |
52 | public slots:
53 | /**
54 | * Function that displays a font selection dialog and stores the result.
55 | */
56 | void selectFont();
57 |
58 | /**
59 | * Function that stores the checked state of the "Hide default" checkbox.
60 | */
61 | void changeHideDefault(int state);
62 |
63 | /**
64 | * Function that stores the new settings in the settings object
65 | * (i.e. on disk).
66 | */
67 | void writeSettings();
68 |
69 | /**
70 | * Function that loads the settings from the settings file.
71 | */
72 | void loadSettings();
73 |
74 | private:
75 | /**
76 | * This variable stores if the default values should be hidden. This
77 | * might seem duplicative, since it is also stored in settings,
78 | * but this variable stores the 'current' state of the checkbox,
79 | * while settings is only updated after clicking OK.
80 | */
81 | bool hide_default_values;
82 |
83 | /**
84 | * The selected font as shown in the Change Font dialog.
85 | */
86 | QFont selected_font;
87 |
88 | /**
89 | * The Ok button.
90 | */
91 | QPushButton *ok;
92 |
93 | /**
94 | * The Cancel button.
95 | */
96 | QPushButton *cancel;
97 |
98 | /**
99 | * The Change font button.
100 | */
101 | QPushButton *change_font;
102 |
103 | /**
104 | * The checkboxHide default values.
105 | */
106 | QCheckBox *hide_default;
107 |
108 | /**
109 | * An object for storing settings in a file.
110 | */
111 | QSettings *settings;
112 | };
113 | }
114 | /**@}*/
115 | }
116 |
117 |
118 | #endif
119 |
--------------------------------------------------------------------------------
/xml_parameter_reader.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "xml_parameter_reader.h"
18 |
19 | namespace dealii
20 | {
21 | namespace ParameterGui
22 | {
23 | XMLParameterReader::XMLParameterReader(QTreeWidget *tree_widget)
24 | : tree_widget(tree_widget)
25 | {
26 | QStyle * style = tree_widget->style();
27 |
28 | subsection_icon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off);
29 | subsection_icon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
30 |
31 | parameter_icon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
32 | }
33 |
34 |
35 |
36 | bool XMLParameterReader::read_xml_file(QIODevice *device)
37 | {
38 | xml.setDevice(device);
39 |
40 | // We look for a StartElement "ParameterHandler"
41 | // and start parsing after this.
42 | //
43 | //
44 | // ...
45 | //
46 | //
47 |
48 | while (xml.readNext() != QXmlStreamReader::Invalid)
49 | {
50 | if (xml.isStartElement())
51 | if (xml.name() == "ParameterHandler")
52 | {
53 | parse_parameters();
54 |
55 | return !xml.error();;
56 | };
57 | };
58 |
59 | xml.raiseError(QObject::tr("The file is not an ParameterHandler XML file."));
60 |
61 | return !xml.error();
62 | }
63 |
64 |
65 |
66 | QString XMLParameterReader::error_string() const
67 | {
68 | return QObject::tr("%1\nLine %2, column %3")
69 | .arg(xml.errorString())
70 | .arg(xml.lineNumber())
71 | .arg(xml.columnNumber());
72 | }
73 |
74 |
75 |
76 | void XMLParameterReader::parse_parameters()
77 | {
78 | Q_ASSERT(xml.isStartElement() && xml.name() == "ParameterHandler");
79 |
80 | // go to the next
81 | while (xml.readNext() != QXmlStreamReader::Invalid)
82 | {
83 | // if it is the closing element of ParameterHandler, break the loop
84 | if (xml.isEndElement() && xml.name() == "ParameterHandler")
85 | break;
86 |
87 | // if it is a start element it must be a subsection or a parameter
88 | if (xml.isStartElement())
89 | read_subsection_element(0);
90 | };
91 | }
92 |
93 |
94 |
95 | void XMLParameterReader::read_subsection_element(QTreeWidgetItem *parent)
96 | {
97 | // The structure of the parameter file is assumed to be of the form
98 | //
99 | //
100 | //
101 | // ...
102 | //
103 | // ...
104 | // ...
105 | // ...
106 | //
107 | //
108 | // ...
109 | //
110 | // ...
111 | //
112 | //
113 | // ...
114 | //
115 | // ...
116 | //
117 | //
118 | // Any subsection has a user-specified name also any parameter, but we do not know
119 | // the userspecified names and we can not assume anything. So, when parsing the file,
120 | // we do not know, if the actual is a or a
121 | // in a subsection. To decide, if the element is a subsection- or a parameter-name,
122 | // we assume, that if the next is , we have a
123 | // and a parameter has the entries , , ,
124 | // and
125 |
126 | // the actual element is
127 | Q_ASSERT(xml.isStartElement());
128 |
129 | // create a new subsection in the tree
130 | QTreeWidgetItem * subsection = create_child_item(parent);
131 |
132 | subsection->setIcon(0, subsection_icon);
133 | subsection->setText(0, demangle(xml.name().toString()));
134 |
135 | // the folder is not expanded
136 | tree_widget->setItemExpanded(subsection, 0);
137 |
138 | // read the next element
139 | while (xml.readNext() != QXmlStreamReader::Invalid)
140 | {
141 | // if the next element is , break the loop
142 | if (xml.isEndElement())
143 | break;
144 |
145 | if (xml.isStartElement())
146 | {
147 | // it can be , then we have found a parameter,
148 | if (xml.name() == "value")
149 | {
150 | // values can be edited
151 | subsection->setFlags(subsection->flags() | Qt::ItemIsEditable);
152 | read_parameter_element (subsection);
153 | }
154 | // or it can be a new
155 | else
156 | {
157 | // subsections can not be edited
158 | subsection->setFlags(subsection->flags() | Qt::NoItemFlags);
159 | read_subsection_element (subsection);
160 | };
161 | };
162 | };
163 | }
164 |
165 |
166 |
167 | void XMLParameterReader::read_parameter_element(QTreeWidgetItem *parent)
168 | {
169 | // the actual element is ,
170 | // then we have found a parameter-item
171 | Q_ASSERT(xml.isStartElement() && xml.name() == "value");
172 |
173 | QString value = xml.readElementText();
174 | // store as text to the item
175 | parent->setText(1, value);
176 | // change the icon of parent
177 | parent->setIcon(0, parameter_icon);
178 |
179 | // go to the next
180 | while (xml.readNext() != QXmlStreamReader::Invalid)
181 | {
182 | if (xml.isStartElement())
183 | {
184 | // if it is store it
185 | if (xml.isStartElement() && xml.name() == "default_value")
186 | {
187 | QString default_value = xml.readElementText();
188 | parent->setText(2, default_value);
189 | }
190 | // if it is store it
191 | else if (xml.isStartElement() && xml.name() == "documentation")
192 | {
193 | QString documentation = xml.readElementText();
194 | parent->setText(3, documentation);
195 | }
196 | // if it is store it as text,
197 | // we only need this value for writing back to XML later
198 | else if (xml.isStartElement() && xml.name() == "pattern")
199 | {
200 | QString pattern = xml.readElementText();
201 | parent->setText(4, pattern);
202 | }
203 | // if it is store it as text
204 | else if (xml.isStartElement() && xml.name() == "pattern_description")
205 | {
206 | QString pattern_description = xml.readElementText();
207 |
208 | // show the type and default
209 | // in the StatusLine when
210 | // hovering over column 0 or 1
211 | parent->setText(5, pattern_description);
212 | parent->setStatusTip(0, "Type: " + pattern_description + " Default: " + parent->text(2));
213 | parent->setStatusTip(1, "Type: " + pattern_description + " Default: " + parent->text(2));
214 |
215 | // in order to store values as correct data types,
216 | // we check the following types in the pattern_description:
217 | QRegExp rx_string("\\b(Anything|FileName|DirectoryName|Selection|List|MultipleSelection)\\b"),
218 | rx_integer("\\b(Integer)\\b"),
219 | rx_double("\\b(Float|Floating|Double)\\b"),
220 | rx_bool("\\b(Bool)\\b");
221 |
222 | // store the type "Anything" or "Filename" as a QString
223 | if (rx_string.indexIn (pattern_description) != -1)
224 | {
225 | QString value = parent->text(1);
226 |
227 | parent->setData(1, Qt::EditRole, value);
228 | parent->setData(1, Qt::DisplayRole, value);
229 | }
230 | // store the type "Integer" as an int
231 | else if (rx_integer.indexIn (pattern_description) != -1)
232 | {
233 | QString text = parent->text(1);
234 |
235 | bool ok = true;
236 | int value = text.toInt(&ok);
237 |
238 | if (ok)
239 | {
240 | parent->setData(1, Qt::EditRole, value);
241 | parent->setData(1, Qt::DisplayRole, value);
242 | }
243 | else
244 | xml.raiseError(QObject::tr("Cannot convert integer type to integer!"));
245 | }
246 | // store the type "Double" as an double
247 | else if (rx_double.indexIn (pattern_description) != -1)
248 | {
249 | QString text = parent->text(1);
250 |
251 | bool ok = true;
252 |
253 | double value = text.toDouble(&ok);
254 |
255 | if (ok)
256 | {
257 | parent->setData(1, Qt::EditRole, value);
258 | parent->setData(1, Qt::DisplayRole, value);
259 | }
260 | else
261 | xml.raiseError(QObject::tr("Cannot convert double type to double!"));
262 | }
263 |
264 | // store the type "Bool" as an boolean
265 | if (rx_bool.indexIn (pattern_description) != -1)
266 | {
267 | QRegExp test(parent->text(1));
268 |
269 | bool value = true;
270 |
271 | if (test.exactMatch("true"))
272 | value = true;
273 | else if (test.exactMatch("false"))
274 | value = false;
275 | else
276 | xml.raiseError(QObject::tr("Cannot convert boolean type to boolean!"));
277 |
278 | // this is needed because we use for booleans the standard delegate
279 | parent->setText(1, "");
280 | parent->setData(1, Qt::EditRole, value);
281 | parent->setData(1, Qt::DisplayRole, value);
282 | }
283 |
284 | break;
285 | }
286 | // if there is any other element, raise an error
287 | else
288 | {
289 | xml.raiseError(QObject::tr("Incomplete or unknown Parameter!"));
290 | break;
291 | }
292 | }
293 | }
294 | }
295 |
296 |
297 |
298 | QTreeWidgetItem *XMLParameterReader::create_child_item(QTreeWidgetItem *item)
299 | {
300 | // create a new child-item
301 | QTreeWidgetItem * child_item;
302 |
303 | // if item is not empty, append the new item as a child
304 | if (item)
305 | child_item = new QTreeWidgetItem(item);
306 | // otherwise create a new item in the tree
307 | else
308 | child_item = new QTreeWidgetItem(tree_widget);
309 |
310 | // set xml.tag_name as data
311 | child_item->setData(0, Qt::DisplayRole, xml.name().toString());
312 | child_item->setText(0, xml.name().toString());
313 |
314 | return child_item;
315 | }
316 |
317 |
318 |
319 | QString XMLParameterReader::demangle (const QString &s)
320 | {
321 | // this function is copied from the ParameterHandler class
322 | std::string s_temp (s.toStdString());
323 |
324 | std::string u;
325 | u.reserve (s_temp.size());
326 |
327 | for (unsigned int i=0; i(c));
379 |
380 | // skip the two characters
381 | i += 2;
382 | }
383 |
384 | QString v (u.c_str());
385 |
386 | return v;
387 | }
388 | }
389 | }
390 |
391 |
--------------------------------------------------------------------------------
/xml_parameter_reader.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #ifndef XMLPARAMETERREADER_H
18 | #define XMLPARAMETERREADER_H
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 |
26 | namespace dealii
27 | {
28 | /*! @addtogroup ParameterGui
29 | *@{
30 | */
31 | namespace ParameterGui
32 | {
33 | /**
34 | * The XMLParameterReader class provides an interface to parse parameters from XML files to a QTreeWidget.
35 | * This class makes extensive use of the QXmlStreamReader class, which implements the basic functionalities
36 | * for parsing XML files.
37 | *
38 | * @note This class is used in the graphical user interface for the @ref ParameterHandler class.
39 | * It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
40 | *
41 | * @ingroup ParameterGui
42 | * @author Martin Steigemann, Wolfgang Bangerth, 2010
43 | */
44 | class XMLParameterReader
45 | {
46 | public:
47 | /**
48 | * Constructor.
49 | * The parameter values will be stored in @p tree_widget.
50 | */
51 | XMLParameterReader (QTreeWidget *tree_widget);
52 |
53 | /**
54 | * This function reads the parameters from @p device into the tree_widget.
55 | * We use the QXmlStreamReader class for this.
56 | * There must be a start element
57 | * <ParameterHandler>
58 | * and an end element </ParameterHandler>
59 | * otherwise an exception is thrown.
60 | */
61 | bool read_xml_file (QIODevice *device);
62 |
63 | /**
64 | * This function returns an error message.
65 | */
66 | QString error_string () const;
67 |
68 | private:
69 | /**
70 | * This function implements a loop over the XML file
71 | * and parses XML elements. It calls @ref read_subsection_element
72 | * till the </ParameterHandler> element is found
73 | * or the end of the file is reached. In this case, an exception is thrown.
74 | */
75 | void parse_parameters ();
76 |
77 | /**
78 | * This functions parses a subsection.
79 | * and adds it as a child to @p parent.
80 | * If the next element is <value>,
81 | * this functions calls @ref read_parameter_element
82 | * otherwise the function itself recursively.
83 | */
84 | void read_subsection_element (QTreeWidgetItem *parent);
85 |
86 | /**
87 | * This function parses a parameter and
88 | * and adds it as a child to @p parent.
89 | * A parameter description consists of five elements:
90 | * @code
91 | * value
92 | * default_value
93 | * documentation
94 | * pattern
95 | * [pattern_description]
96 | * @endcode
97 | * If a parameter description is incomplete, an exception
98 | * is thrown.
99 | */
100 | void read_parameter_element (QTreeWidgetItem *parent);
101 |
102 | /**
103 | * Reimplemented from the @ref ParameterHandler class.
104 | * Unmangle a string @p s into its original form.
105 | */
106 | QString demangle (const QString &s);
107 |
108 | /**
109 | * This helper function creates a new child of @p item in the tree.
110 | */
111 | QTreeWidgetItem *create_child_item(QTreeWidgetItem *item);
112 |
113 | /**
114 | * The QXmlStreamReader object for reading XML elements.
115 | */
116 | QXmlStreamReader xml;
117 |
118 | /**
119 | * A pointer to the tree structure.
120 | */
121 | QTreeWidget *tree_widget;
122 |
123 | /**
124 | * An icon for subsections in the tree structure.
125 | */
126 | QIcon subsection_icon;
127 |
128 | /**
129 | * An icon for parameters in the tree structure.
130 | */
131 | QIcon parameter_icon;
132 | };
133 | }
134 | /**@}*/
135 | }
136 |
137 |
138 | #endif
139 |
--------------------------------------------------------------------------------
/xml_parameter_writer.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #include "xml_parameter_writer.h"
18 |
19 | namespace dealii
20 | {
21 | namespace ParameterGui
22 | {
23 | XMLParameterWriter::XMLParameterWriter(QTreeWidget *tree_widget)
24 | : tree_widget(tree_widget)
25 | {
26 | xml.setAutoFormatting(true);
27 | }
28 |
29 |
30 |
31 | bool XMLParameterWriter::write_xml_file(QIODevice *device)
32 | {
33 | xml.setDevice(device);
34 |
35 | // write the head
36 | xml.writeStartDocument();
37 |
38 | // write the root element
39 | xml.writeStartElement("ParameterHandler");
40 |
41 | // loop over the elements and write them
42 | for (int i = 0; i < tree_widget->topLevelItemCount(); ++i)
43 | write_item(tree_widget->topLevelItem(i));
44 |
45 | // close the first element
46 | xml.writeEndDocument();
47 |
48 | return true;
49 | }
50 |
51 |
52 |
53 | void XMLParameterWriter::write_item(QTreeWidgetItem *item)
54 | {
55 | // store the element name
56 | QString tag_name = mangle(item->text(0));
57 |
58 | // and write to the file
59 | xml.writeStartElement(tag_name);
60 |
61 | // if the "value"-entry of this item is not empty, write a parameter
62 | if (!item->text(1).isEmpty())
63 | {
64 | xml.writeTextElement("value", item->data(1,Qt::EditRole).toString());
65 | xml.writeTextElement("default_value", item->text(2));
66 | xml.writeTextElement("documentation", item->text(3));
67 | xml.writeTextElement("pattern", item->text(4));
68 | xml.writeTextElement("pattern_description", item->text(5));
69 | };
70 |
71 | // go over the childrens recursively
72 | for (int i = 0; i < item->childCount(); ++i)
73 | write_item(item->child(i));
74 |
75 | // write closing
76 | xml.writeEndElement();
77 | }
78 |
79 |
80 |
81 | QString XMLParameterWriter::mangle (const QString &s)
82 | {
83 | // this function is copied from the ParameterHandler class and adapted to mangle QString
84 | std::string s_temp (s.toStdString());
85 |
86 | std::string u;
87 | u.reserve (s_temp.size());
88 |
89 | static const std::string allowed_characters
90 | ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
91 |
92 | // for all parts of the string, see if it is an allowed character or not
93 | for (unsigned int i=0; i(s_temp[i])/16]);
102 | u.push_back (hex[static_cast(s_temp[i])%16]);
103 | }
104 |
105 | QString v (u.c_str());
106 |
107 | return v;
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/xml_parameter_writer.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------
2 | //
3 | // Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
4 | //
5 | // This file is part of the deal.II library.
6 | //
7 | // The deal.II library is free software; you can use it, redistribute
8 | // it, and/or modify it under the terms of the GNU Lesser General
9 | // Public License as published by the Free Software Foundation; either
10 | // version 2.1 of the License, or (at your option) any later version.
11 | // The full text of the license can be found in the file LICENSE at
12 | // the top level of the deal.II distribution.
13 | //
14 | // ---------------------------------------------------------------------
15 |
16 |
17 | #ifndef XMLPARAMETERWRITER_H
18 | #define XMLPARAMETERWRITER_H
19 |
20 | #include
21 | #include
22 | #include
23 |
24 |
25 | namespace dealii
26 | {
27 | /*! @addtogroup ParameterGui
28 | *@{
29 | */
30 | namespace ParameterGui
31 | {
32 | /**
33 | * The XMLParameterWriter class provides an interface to write parameters stored in a QTreeWidget to a file in XML format.
34 | * This class makes extensive use of the QXmlStreamWriter class, which implements the basic functionalities for writing
35 | * XML files.
36 | *
37 | * @note This class is used in the graphical user interface for the @ref ParameterHandler class.
38 | * It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
39 | *
40 | * @ingroup ParameterGui
41 | * @author Martin Steigemann, Wolfgang Bangerth, 2010
42 | */
43 | class XMLParameterWriter
44 | {
45 | public:
46 | /**
47 | * Constructor.
48 | * Parameter values from @p tree_widget will be written.
49 | */
50 | XMLParameterWriter (QTreeWidget *tree_widget);
51 |
52 | /**
53 | * This function writes the parameter values stored in tree_widget
54 | * to @p device in XML format. We use the QXmlStreamWriter class
55 | * for this. The root element is
56 | * <ParameterHandler>
57 | */
58 | bool write_xml_file (QIODevice *device);
59 |
60 | private:
61 | /**
62 | * This function writes a given @p item of tree_widget
63 | * to a file in XML format. For this the QXmlStreamWriter class is used.
64 | * If the @p item is a parameter, the elements that describes this parameter
65 | * are written:
66 | * @code
67 | * value
68 | * default_value
69 | * documentation
70 | * pattern
71 | * [pattern_description]
72 | * @endcode
73 | * If the @p item is a subsection, a start element this_subsection is written
74 | * and write_item is called recursively to write the next item.
75 | */
76 | void write_item (QTreeWidgetItem *item);
77 |
78 | /**
79 | * Reimplemented from the @ref ParameterHandler class.
80 | * Mangle a string @p s so that it
81 | * doesn't contain any special
82 | * characters or spaces.
83 | */
84 | QString mangle (const QString &s);
85 |
86 | /**
87 | * An QXmlStreamWriter object
88 | * which implements the functionalities
89 | * we need for writing parameters to XML files.
90 | */
91 | QXmlStreamWriter xml;
92 |
93 | /**
94 | * A pointer to the QTreeWidget structure
95 | * which stores the parameters.
96 | */
97 | QTreeWidget *tree_widget;
98 | };
99 | }
100 | /**@}*/
101 | }
102 |
103 |
104 | #endif
105 |
--------------------------------------------------------------------------------