Salome HOME
[bos #40653][CEA] New mesh import export formats with meshio.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.h
1 // Copyright (C) 2007-2024  CEA, EDF, 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::smIdType_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   void                           logMeshSize();
99     
100 protected slots:
101   virtual bool                   onApply();
102   void                           onPreviewShape();
103   void                           onPublishShape();
104   void                           onShowBadMesh();
105   void                           onGroupOfBadMesh();
106   void                           currentCellChanged();
107
108 private:
109   QTableWidget*                  table();
110
111 private:
112   QPointer<SMESHGUI_ComputeDlg>  myCompDlg;
113
114 protected:
115   SMESH::SMESH_Mesh_var            myMesh;
116   GEOM::GEOM_Object_var            myMainShape;
117   GEOM::GEOM_Object_var            myCurShape;
118   SMESH::TShapeDisplayer*          myTShapeDisplayer;
119   SMESHGUI_MeshEditPreview*        myBadMeshDisplayer;
120   Handle(SALOME_InteractiveObject) myIObject;
121 };
122
123 /*!
124  * \brief Operation to compute a mesh and show computation errors
125  */
126 class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
127 {
128   Q_OBJECT
129
130 public:
131   SMESHGUI_ComputeOp();
132   virtual ~SMESHGUI_ComputeOp();
133
134   virtual LightApp_Dialog*       dlg() const;
135
136 protected:
137   virtual void                   startOperation();
138
139 protected slots:
140 };
141
142 class SMESHGUI_MeshOrderMgr;
143
144 /*!
145  * \brief Operation to preview and compute a mesh and show computation errors
146  */
147 class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
148 {
149   Q_OBJECT
150
151 public:
152   SMESHGUI_PrecomputeOp();
153   virtual ~SMESHGUI_PrecomputeOp();
154
155   virtual LightApp_Dialog*       dlg() const;
156
157   /**
158    * \brief returns map of assigned algorithms modes
159    */
160   static void                    getAssignedAlgos(_PTR(SObject) theMesh,
161                                                   QMap<int,int>& theModeMap);
162
163 protected:
164   virtual void                   startOperation();
165   virtual void                   stopOperation();
166   virtual void                   resumeOperation();
167
168   virtual void                   initDialog();
169
170 protected slots:
171   virtual void                   onCancel();
172
173 private slots:
174   void                           onPreview();
175   void                           onCompute();
176
177 private:
178   //! private fields
179   QMap< int, int >               myMapShapeId;
180   QPointer<LightApp_Dialog>      myActiveDlg;
181   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
182   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
183   //! fields for mesh order
184   typedef QList<int>             TListOfInt;
185   typedef QList<TListOfInt>      TListOfListOfInt;
186   TListOfListOfInt               myPrevOrder;
187   SMESHGUI_MeshOrderMgr*         myOrderMgr;
188 };
189
190 /*!
191  * \brief Operation to evaluate a mesh and show result
192  */
193 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
194 {
195   Q_OBJECT
196
197 public:
198   SMESHGUI_EvaluateOp();
199   virtual ~SMESHGUI_EvaluateOp();
200
201   virtual LightApp_Dialog*       dlg() const;
202
203 protected:
204   virtual void                   startOperation();
205
206 protected slots:
207 };
208
209 /*!
210  * \brief Operation to show meshing errors
211  */
212 class SMESHGUI_EXPORT SMESHGUI_ShowErrorsOp: public SMESHGUI_BaseComputeOp
213 {
214   Q_OBJECT
215
216 public:
217   SMESHGUI_ShowErrorsOp();
218
219 protected:
220   virtual void                   startOperation();
221 };
222
223 /*!
224  * \brief Dialog to compute a mesh and show computation errors
225  */
226
227 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
228 {
229   Q_OBJECT
230
231 public:
232   SMESHGUI_ComputeDlg( QWidget*, bool );
233   virtual ~SMESHGUI_ComputeDlg();
234
235 protected:
236   QFrame*                      createMainFrame( QWidget*, bool );
237
238   QLabel*                      myMeshName;
239   QGroupBox*                   myMemoryLackGroup;
240   QGroupBox*                   myCompErrorGroup;
241   QGroupBox*                   myHypErrorGroup;
242   QLabel*                      myHypErrorLabel;
243   QLabel*                      myWarningLabel;
244   QTableWidget*                myTable;
245   QPushButton*                 myShowBtn;
246   QPushButton*                 myPublishBtn;
247   QPushButton*                 myBadMeshBtn;
248   QPushButton*                 myBadMeshToGroupBtn;
249
250   SMESHGUI_MeshInfosBox*       myBriefInfo;
251   SMESHGUI_MeshInfosBox*       myFullInfo;
252
253   friend class SMESHGUI_BaseComputeOp;
254   friend class SMESHGUI_PrecomputeOp;
255   friend class SMESHGUI_ShowErrorsOp;
256 };
257
258 class SMESHGUI_MeshOrderBox;
259
260 /*!
261  * \brief Dialog to preview and compute a mesh and show computation errors
262  */
263
264 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
265 {
266   Q_OBJECT
267
268 public:
269   SMESHGUI_PrecomputeDlg( QWidget* );
270   virtual ~SMESHGUI_PrecomputeDlg();
271   
272   void                         setPreviewModes( const QList<int>& );
273   int                          getPreviewMode() const;
274   
275   SMESHGUI_MeshOrderBox*       getMeshOrderBox() const;
276
277 signals:
278   void                         preview();
279
280 private:
281   SMESHGUI_MeshOrderBox*       myOrderBox;
282   QPushButton*                 myPreviewBtn;
283   QtxComboBox*                 myPreviewMode;
284 };
285
286 /*!
287  * \brief Thread to launch computation
288  */
289
290 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThread : public QThread
291 {
292   Q_OBJECT
293     
294 public:
295   SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var  gen,
296                               SMESH::SMESH_Mesh_var mesh,
297                               GEOM::GEOM_Object_var mainShape);
298   bool                   result();
299   void                   cancel();
300   SMESH::SMESH_Mesh_var& getMesh() { return myMesh; }
301
302 protected:
303   void run();
304   
305 private:
306   SMESH::SMESH_Gen_var  myGen;
307   SMESH::SMESH_Mesh_var myMesh;
308   GEOM::GEOM_Object_var myMainShape;
309   bool                  myResult;
310 };
311
312 /*!
313  * \brief Dialog to display Cancel button
314  */
315
316 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThreadQDialog : public QDialog
317 {
318   Q_OBJECT
319     
320 public:
321   SMESHGUI_ComputeDlg_QThreadQDialog(QWidget *             parent,
322                                      SMESH::SMESH_Gen_var  gen,
323                                      SMESH::SMESH_Mesh_var mesh,
324                                      GEOM::GEOM_Object_var mainShape);
325   bool result();
326   
327 protected:
328   void timerEvent(QTimerEvent *timer);
329   void closeEvent(QCloseEvent *event);
330   
331 private slots:
332   void onCancel();
333   
334 private:
335   SMESHGUI_ComputeDlg_QThread qthread;
336   QPushButton *               cancelButton;
337   QLabel *                    nbNodesLabel;
338   QLabel *                    nbElemsLabel;
339   QLabel *                    freeRAMLabel;
340   QProgressBar*               progressBar;
341 };
342
343 #endif // SMESHGUI_COMPUTEDLG_H