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 objectbrowser.h                                                 *
27  *                                                                           *
28  *****************************************************************************
29  *                                                                           *
30  *  Author: Saeki Takayuki                                                   *
31  *  Original Date: 11 Jan 2020                                               *
32  *                                                                           *
33  *****************************************************************************/
34 
35 #ifndef OBJECTBROWSER_H
36 #define OBJECTBROWSER_H
37 
38 #include <QWidget>
39 #include "projectio.h"
40 #include "dynamiceditor.h"
41 #include "glwidget.h"
42 #include "boundarypropertyeditor.h"
43 
44 
45 class ObjectBrowser : public QDockWidget
46 {
47   Q_OBJECT
48 
49 //signals:
50 
51 public:
52   ObjectBrowser(QMainWindow *parent, Qt::WindowFlags flags=0);
53   ~ObjectBrowser();
54 
55 //public slots:
56 
57 private slots:
58   void modelSetupSlot();
59   void addEquationSlot();
60   void addMaterialSlot();
61   void addBodyForceSlot();
62   void addInitialConditionSlot();
63   void addBoundaryConditionSlot();
64   void equationSelectedSlot(QAction*);
65   void materialSelectedSlot(QAction*);
66   void bodyForceSelectedSlot(QAction*);
67   void initialConditionSelectedSlot(QAction*);
68   void boundaryConditionSelectedSlot(QAction*);
69   void equationEditorFinishedSlot(int signal, int id);
70   void materialEditorFinishedSlot(int signal, int id);
71   void bodyForceEditorFinishedSlot(int signal, int id);
72   void initialConditionEditorFinishedSlot(int signal, int id);
73   void boundaryConditionEditorFinishedSlot(int signal, int id);
74   void treeItemClickedSlot(QTreeWidgetItem *item, int column);
75   void treeItemDoubleClickedSlot(QTreeWidgetItem *item, int column);
76   void treeItemExpandedSlot(QTreeWidgetItem* item);
77   void treeItemSelectionChangedSlot();
78 
79   void openSlot();
80   void loadSlot();
81   void loadProjectSlot();
82   void saveProjectSlot();
83   void newProjectSlot();
84   void modelClearSlot();
85 
86   void viewFullScreenSlot();
87   void viewNormalModeSlot();
88 
89   void boundaryDividedSlot(double);
90   void boundaryUnifiedSlot();
91 
92   void boundarySelectedSlot(list_t*);
93 
94   void boundaryComboChanged(BoundaryPropertyEditor *,QString);
95   void bodyComboChanged(BodyPropertyEditor *,QString);
96   void bodyPropertyEditorAccepted(bool);
97   void bodyPropertyEditorDiscarded(bool);
98   void boundaryPropertyEditorAccepted(bool);
99   void boundaryPropertyEditorDiscarded(bool);
100   void bodyCheckBoxChangedSlot(int);
101   void boundaryCheckBoxChangedSlot(int);
102 
103   void focusChangedSlot(QWidget*, QWidget*);
104 
105   void meshingStartedSlot();
106   void meshingTerminatedSlot();
107   void meshingFinishedSlot();
108 
109 private:
110   QMainWindow *mainWindow;
111   QTreeWidget *tree;
112 
113   QTreeWidgetItem *geometryTopLevelTreeItem;
114   QTreeWidgetItem *modelTopLevelTreeItem;
115   QTreeWidgetItem *bodyPropertyParentTreeItem;
116   QTreeWidgetItem *boundaryPropertyParentTreeItem;
117   QTreeWidgetItem *geometryParentTreeItem;
118   QTreeWidgetItem *setupParentTreeItem;
119   QTreeWidgetItem *equationParentTreeItem;
120   QTreeWidgetItem *materialParentTreeItem;
121   QTreeWidgetItem *bodyForceParentTreeItem;
122   QTreeWidgetItem *initialConditionParentTreeItem;
123   QTreeWidgetItem *boundaryConditionParentTreeItem;
124   void addToTree(DynamicEditor*, bool select = false);
125   void updateBoundaryProperties(BoundaryPropertyEditor* selectThis = NULL);
126   void updateBodyProperties(BodyPropertyEditor* selectThis = NULL);
127   void updateEquation();
128   void updateMaterial();
129   void updateBodyForce();
130   void updateInitialCondition();
131   void updateBoundaryCondition();
132   void snap(QWidget*);
133   void selectTreeItemByID(QTreeWidgetItem* parent, int id);
134 
135   int boundaryListToBodyIndex(list_t*);
136   list_t* selectBoundary(BoundaryPropertyEditor *pe, bool append = false, bool select = true);
137   list_t* selectBody(BodyPropertyEditor *pe, bool append = false, bool select = true);
138   list_t* boundaryList(int index);
139   list_t* bodyList(int index);
140 
141   bool connect1(const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoConnection);
142 };
143 
144 #endif // OBJECTBROWSER_H
145