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