Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/src/dynamiceditor.h
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI dynamiceditor *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
41
#ifndef DYNAMICEDITOR_H
42
#define DYNAMICEDITOR_H
43
44
enum BodyTypes {
45
BODY_MATERIAL,
46
BODY_INITIAL,
47
BODY_FORCE,
48
BODY_EQUATION
49
};
50
51
enum MatTypes {
52
MAT_APPLY,
53
MAT_OK,
54
MAT_NEW,
55
MAT_DELETE
56
};
57
58
// #ifndef WITH_QT5
59
#include <QWidget>
60
#include <QtGui>
61
#include <QIcon>
62
#include <QDomDocument>
63
#include <QLayout>
64
// #else
65
// #include <QtGui>
66
// #include <QIcon>
67
// #include <QDomDocument>
68
// #include <QLayout>
69
// #endif
70
71
#if WITH_QT5 || WITH_QT6
72
#include <QtWidgets>
73
#endif
74
75
class QTabWidget;
76
class QPushButton;
77
78
class hash_entry_t
79
{
80
public:
81
QWidget *widget,*label;
82
QDomElement elem;
83
};
84
85
class DynLineEdit : public QWidget
86
{
87
Q_OBJECT
88
89
public:
90
DynLineEdit(QWidget *parent=0);
91
~DynLineEdit();
92
QString name;
93
QLineEdit *lineEdit;
94
95
private:
96
QTextEdit *textEdit;
97
QLabel *label;
98
QFrame *frame;
99
QLayout *layout;
100
QPushButton *closeButton;
101
102
private slots:
103
void editSlot();
104
void lineEditClose();
105
};
106
107
class DynamicEditor : public QWidget
108
{
109
Q_OBJECT
110
111
public:
112
DynamicEditor(QWidget *parent = 0);
113
~DynamicEditor();
114
115
QSize minimumSizeHint() const;
116
QSize sizeHint() const;
117
118
void setupTabs(QDomDocument *doc, const QString &Section, int ID);
119
120
QTabWidget *tabWidget;
121
QLineEdit *nameEdit;
122
int tabs;
123
124
QGroupBox *spareBox;
125
QScrollArea *spareScroll;
126
127
QPushButton *whatsThisButton;
128
QPushButton *okButton;
129
QPushButton *newButton;
130
QPushButton *applyButton;
131
QPushButton *spareButton;
132
QPushButton *discardButton;
133
134
QAction *menuAction; // action for menu item
135
int ID; // id in propertyarray
136
137
bool touched;
138
139
QHash<QString, hash_entry_t> hash;
140
141
void dumpHash(QDomDocument*, QDomElement*);
142
void populateHash(QDomElement*);
143
144
signals:
145
void dynamicEditorReady(int, int);
146
void dynamicEditorSpareButtonClicked(int, int);
147
148
private slots:
149
void whatsThisButtonClicked();
150
void okButtonClicked();
151
void newButtonClicked();
152
void applyButtonClicked();
153
void discardButtonClicked();
154
void spareButtonClicked();
155
void lSlot(int);
156
void comboSlot(QString);
157
void textChangedSlot(QString);
158
159
private:
160
hash_entry_t h;
161
162
QIcon newIcon;
163
QIcon addIcon;
164
QIcon okIcon;
165
QIcon removeIcon;
166
167
QDomElement root;
168
QDomElement all_stuff;
169
QDomElement element;
170
QDomElement name;
171
QDomElement section;
172
QDomElement param;
173
};
174
175
#endif // DYNAMICEDITOR_H
176
177