Salome HOME
Copyright update 2021
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.h
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : SMESHGUI_ComputeDlg.h
21 // Author : Edward AGAPOV, Open CASCADE S.A.S.
22 //
23 #ifndef SMESHGUI_COMPUTEDLG_H
24 #define SMESHGUI_COMPUTEDLG_H
25
26 // SMESH includes
27 #include "SMESH_SMESHGUI.hxx"
28
29 #include "SMESHGUI_Dialog.h"
30 #include "SMESHGUI_Operation.h"
31
32 // SALOME GUI includes
33 #include <SALOME_InteractiveObject.hxx>
34
35 // Qt includes
36 #include <QMap>
37 #include <QList>
38 #include <QPointer>
39 #include <QGroupBox>
40 #include <QThread>
41
42 // IDL includes
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SMESH_Gen)
45 #include CORBA_SERVER_HEADER(SMESH_Mesh)
46
47 class QFrame;
48 class QPushButton;
49 class QTableWidget;
50 class QLabel;
51 class QtxComboBox;
52 class QProgressBar;
53 class SMESHGUI_ComputeDlg;
54 class SMESHGUI_MeshInfosBox;
55 class SMESHGUI_PrecomputeDlg;
56 class SMESHGUI_MeshEditPreview;
57
58 namespace SMESH
59 {
60   class TShapeDisplayer;
61 }
62
63 /*!
64  * \brief Base operation to compute a mesh and show computation errors
65  */
66 class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation
67 {
68   Q_OBJECT
69
70 public:
71   SMESHGUI_BaseComputeOp();
72   virtual ~SMESHGUI_BaseComputeOp();
73
74   SMESH::SMESH_Mesh_ptr          getMesh();
75   virtual LightApp_Dialog*       dlg() const;
76
77 protected:
78   virtual void                   startOperation();
79   virtual void                   stopOperation();
80
81   SMESHGUI_ComputeDlg*           computeDlg() const;
82   void                           computeMesh();
83   void                           showComputeResult( const bool,
84                                                     const bool,
85                                                     SMESH::compute_error_array_var&,
86                                                     const bool,
87                                                     const QString& );
88   SMESHGUI_ComputeDlg*           evaluateDlg() const;
89   void                           evaluateMesh();
90   void                           showEvaluateResult(const SMESH::long_array& theRes,
91                                                     const bool,
92                                                     const bool,
93                                                     SMESH::compute_error_array_var&,
94                                                     const bool,
95                                                     const QString&);
96
97   virtual bool                   isValid( SUIT_Operation* theOp ) const;
98     
99 protected slots:
100   virtual bool                   onApply();
101   void                           onPreviewShape();
102   void                           onPublishShape();
103   void                           onShowBadMesh();
104   void                           onGroupOfBadMesh();
105   void                           currentCellChanged();
106
107 private:
108   QTableWidget*                  table();
109
110 private:
111   QPointer<SMESHGUI_ComputeDlg>  myCompDlg;
112
113 protected:
114   SMESH::SMESH_Mesh_var            myMesh;
115   GEOM::GEOM_Object_var            myMainShape;
116   GEOM::GEOM_Object_var            myCurShape;
117   SMESH::TShapeDisplayer*          myTShapeDisplayer;
118   SMESHGUI_MeshEditPreview*        myBadMeshDisplayer;
119   Handle(SALOME_InteractiveObject) myIObject;
120 };
121
122 /*!
123  * \brief Operation to compute a mesh and show computation errors
124  */
125 class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
126 {
127   Q_OBJECT
128
129 public:
130   SMESHGUI_ComputeOp();
131   virtual ~SMESHGUI_ComputeOp();
132
133   virtual LightApp_Dialog*       dlg() const;
134
135 protected:
136   virtual void                   startOperation();
137
138 protected slots:
139 };
140
141 class SMESHGUI_MeshOrderMgr;
142
143 /*!
144  * \brief Operation to preview and compute a mesh and show computation errors
145  */
146 class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
147 {
148   Q_OBJECT
149
150 public:
151   SMESHGUI_PrecomputeOp();
152   virtual ~SMESHGUI_PrecomputeOp();
153
154   virtual LightApp_Dialog*       dlg() const;
155
156   /**
157    * \brief returns map of assigned algorithms modes
158    */
159   static void                    getAssignedAlgos(_PTR(SObject) theMesh,
160                                                   QMap<int,int>& theModeMap);
161
162 protected:
163   virtual void                   startOperation();
164   virtual void                   stopOperation();
165   virtual void                   resumeOperation();
166
167   virtual void                   initDialog();
168
169 protected slots:
170   virtual void                   onCancel();
171
172 private slots:
173   void                           onPreview();
174   void                           onCompute();
175
176 private:
177   //! private fields
178   QMap< int, int >               myMapShapeId;
179   QPointer<LightApp_Dialog>      myActiveDlg;
180   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
181   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
182   //! fields for mesh order
183   typedef QList<int>             TListOfInt;
184   typedef QList<TListOfInt>      TListOfListOfInt;
185   TListOfListOfInt               myPrevOrder;
186   SMESHGUI_MeshOrderMgr*         myOrderMgr;
187 };
188
189 /*!
190  * \brief Operation to evaluate a mesh and show result
191  */
192 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
193 {
194   Q_OBJECT
195
196 public:
197   SMESHGUI_EvaluateOp();
198   virtual ~SMESHGUI_EvaluateOp();
199
200   virtual LightApp_Dialog*       dlg() const;
201
202 protected:
203   virtual void                   startOperation();
204
205 protected slots:
206 };
207
208 /*!
209  * \brief Operation to show meshing errors
210  */
211 class SMESHGUI_EXPORT SMESHGUI_ShowErrorsOp: public SMESHGUI_BaseComputeOp
212 {
213   Q_OBJECT
214
215 public:
216   SMESHGUI_ShowErrorsOp();
217
218 protected:
219   virtual void                   startOperation();
220 };
221
222 /*!
223  * \brief Dialog to compute a mesh and show computation errors
224  */
225
226 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
227 {
228   Q_OBJECT
229
230 public:
231   SMESHGUI_ComputeDlg( QWidget*, bool );
232   virtual ~SMESHGUI_ComputeDlg();
233
234 protected:
235   QFrame*                      createMainFrame( QWidget*, bool );
236
237   QLabel*                      myMeshName;
238   QGroupBox*                   myMemoryLackGroup;
239   QGroupBox*                   myCompErrorGroup;
240   QGroupBox*                   myHypErrorGroup;
241   QLabel*                      myHypErrorLabel;
242   QLabel*                      myWarningLabel;
243   QTableWidget*                myTable;
244   QPushButton*                 myShowBtn;
245   QPushButton*                 myPublishBtn;
246   QPushButton*                 myBadMeshBtn;
247   QPushButton*                 myBadMeshToGroupBtn;
248
249   SMESHGUI_MeshInfosBox*       myBriefInfo;
250   SMESHGUI_MeshInfosBox*       myFullInfo;
251
252   friend class SMESHGUI_BaseComputeOp;
253   friend class SMESHGUI_PrecomputeOp;
254   friend class SMESHGUI_ShowErrorsOp;
255 };
256
257 class SMESHGUI_MeshOrderBox;
258
259 /*!
260  * \brief Dialog to preview and compute a mesh and show computation errors
261  */
262
263 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
264 {
265   Q_OBJECT
266
267 public:
268   SMESHGUI_PrecomputeDlg( QWidget* );
269   virtual ~SMESHGUI_PrecomputeDlg();
270   
271   void                         setPreviewModes( const QList<int>& );
272   int                          getPreviewMode() const;
273   
274   SMESHGUI_MeshOrderBox*       getMeshOrderBox() const;
275
276 signals:
277   void                         preview();
278
279 private:
280   SMESHGUI_MeshOrderBox*       myOrderBox;
281   QPushButton*                 myPreviewBtn;
282   QtxComboBox*                 myPreviewMode;
283 };
284
285 /*!
286  * \brief Thread to launch computation
287  */
288
289 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThread : public QThread
290 {
291   Q_OBJECT
292     
293 public:
294   SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var  gen,
295                               SMESH::SMESH_Mesh_var mesh,
296                               GEOM::GEOM_Object_var mainShape);
297   bool                   result();
298   void                   cancel();
299   SMESH::SMESH_Mesh_var& getMesh() { return myMesh; }
300
301 protected:
302   void run();
303   
304 private:
305   SMESH::SMESH_Gen_var  myGen;
306   SMESH::SMESH_Mesh_var myMesh;
307   GEOM::GEOM_Object_var myMainShape;
308   bool                  myResult;
309 };
310
311 /*!
312  * \brief Dialog to display Cancel button
313  */
314
315 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThreadQDialog : public QDialog
316 {
317   Q_OBJECT
318     
319 public:
320   SMESHGUI_ComputeDlg_QThreadQDialog(QWidget *             parent,
321                                      SMESH::SMESH_Gen_var  gen,
322                                      SMESH::SMESH_Mesh_var mesh,
323                                      GEOM::GEOM_Object_var mainShape);
324   bool result();
325   
326 protected:
327   void timerEvent(QTimerEvent *timer);
328   void closeEvent(QCloseEvent *event);
329   
330 private slots:
331   void onCancel();
332   
333 private:
334   SMESHGUI_ComputeDlg_QThread qthread;
335   QPushButton *               cancelButton;
336   QLabel *                    nbNodesLabel;
337   QLabel *                    nbElemsLabel;
338   QLabel *                    freeRAMLabel;
339   QProgressBar*               progressBar;
340 };
341
342 #endif // SMESHGUI_COMPUTEDLG_H