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