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 edfeditor                                                       *
27  *                                                                           *
28  *****************************************************************************
29  *                                                                           *
30  *  Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback                   *
31  *  Email:   Juha.Ruokolainen@csc.fi                                         *
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 EDFEDITOR_H
42 #define EDFEDITOR_H
43 
44 #include <QWidget>
45 #include <QDomDocument>
46 #include <QIcon>
47 #include <QTreeWidget>
48 #include <QHash>
49 #include "dynamiceditor.h"
50 
51 class QPushButton;
52 
53 class EdfEditor : public QWidget
54 {
55   Q_OBJECT
56 
57 public:
58   EdfEditor(QWidget *parent = 0);
59   ~EdfEditor();
60 
61   QSize minimumSizeHint() const;
62   QSize sizeHint() const;
63 
64   void setupEditor(QDomDocument *elmerDefs);
65   bool appendFrom(QString);
66 
67 signals:
68 
69 protected:
70   void keyPressEvent(QKeyEvent*);
71   void keyReleaseEvent(QKeyEvent*);
72 
73 private slots:
74   void addButtonClicked();
75   void removeButtonClicked();
76   void expandCollapseAllButtonClicked();
77   void openButtonClicked();
78   void appendButtonClicked();
79   void saveAsButtonClicked();
80   void applyButtonClicked();
81   void previewButtonClicked();
82 
83   void treeItemClicked(QTreeWidgetItem*, int);
84   void updateElement(QTreeWidgetItem*, int);
85 
86 private:
87   QIcon addIcon;
88   QIcon removeIcon;
89   QIcon collapseIcon;
90   QIcon expandIcon;
91   QIcon openIcon;
92   QIcon appendIcon;
93   QIcon saveAsIcon;
94   QIcon applyIcon;
95   QIcon previewIcon;
96 
97   QTreeWidget *edfTree;
98   QPushButton *addButton;
99   QPushButton *removeButton;
100   QPushButton *expandCollapseAllButton;
101   QPushButton *openButton;
102   QPushButton *appendButton;
103   QPushButton *saveAsButton;
104   QPushButton *applyButton;
105   QPushButton *previewButton;
106 
107   DynamicEditor *dynamicEditorSimulation;
108   DynamicEditor *dynamicEditorConstants;
109   DynamicEditor *dynamicEditorMaterial;
110   DynamicEditor *dynamicEditorSolver;
111   DynamicEditor *dynamicEditorBC;
112   DynamicEditor *dynamicEditorIC;
113   DynamicEditor *dynamicEditorEquation;
114   DynamicEditor *dynamicEditorBodyForce;
115 
116   QDomDocument *elmerDefs;
117   QHash<QTreeWidgetItem*, QDomElement> elementForItem;
118   void insertItemForElement(QDomElement, QTreeWidgetItem*);
119 
120   bool expandCollapseAll;
121   QTreeWidgetItem *lastActiveItem;
122   bool ctrlPressed;
123   bool altPressed;
124 };
125 
126 #endif // EDFEDITOR_H
127