]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_ComputeDlg.h
Salome HOME
Fix OwnHypothesis()
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.h
1 // Copyright (C) 2007-2013  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   QLabel*                      myWarningLabel;
225   QTableWidget*                myTable;
226   QPushButton*                 myShowBtn;
227   QPushButton*                 myPublishBtn;
228   QPushButton*                 myBadMeshBtn;
229
230   SMESHGUI_MeshInfosBox*       myBriefInfo;
231   SMESHGUI_MeshInfosBox*       myFullInfo;
232
233   friend class SMESHGUI_BaseComputeOp;
234   friend class SMESHGUI_PrecomputeOp;
235 };
236
237 class SMESHGUI_MeshOrderBox;
238
239 /*!
240  * \brief Dialog to preview and compute a mesh and show computation errors
241  */
242
243 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
244 {
245   Q_OBJECT
246
247 public:
248   SMESHGUI_PrecomputeDlg( QWidget* );
249   virtual ~SMESHGUI_PrecomputeDlg();
250   
251   void                         setPreviewModes( const QList<int>& );
252   int                          getPreviewMode() const;
253   
254   SMESHGUI_MeshOrderBox*       getMeshOrderBox() const;
255
256 signals:
257   void                         preview();
258
259 private:
260   SMESHGUI_MeshOrderBox*       myOrderBox;
261   QPushButton*                 myPreviewBtn;
262   QtxComboBox*                 myPreviewMode;
263 };
264
265 /*!
266  * \brief Thread to launch computation
267  */
268
269 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThread : public QThread
270 {
271   Q_OBJECT
272     
273 public:
274   SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var  gen,
275                               SMESH::SMESH_Mesh_var mesh,
276                               GEOM::GEOM_Object_var mainShape);
277   bool                   result();
278   void                   cancel();
279   SMESH::SMESH_Mesh_var& getMesh() { return myMesh; }
280
281 protected:
282   void run();
283   
284 private:
285   SMESH::SMESH_Gen_var  myGen;
286   SMESH::SMESH_Mesh_var myMesh;
287   GEOM::GEOM_Object_var myMainShape;
288   bool                  myResult;
289 };
290
291 /*!
292  * \brief Dialog to display Cancel button
293  */
294
295 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg_QThreadQDialog : public QDialog
296 {
297   Q_OBJECT
298     
299 public:
300   SMESHGUI_ComputeDlg_QThreadQDialog(QWidget *             parent,
301                                      SMESH::SMESH_Gen_var  gen,
302                                      SMESH::SMESH_Mesh_var mesh,
303                                      GEOM::GEOM_Object_var mainShape);
304   bool result();
305   
306 protected:
307   void timerEvent(QTimerEvent *timer);
308   void closeEvent(QCloseEvent *event);
309   
310 private slots:
311   void onCancel();
312   
313 private:
314   SMESHGUI_ComputeDlg_QThread qthread;
315   QPushButton *               cancelButton;
316   QLabel *                    nbNodesLabel;
317   QLabel *                    nbElemsLabel;
318 };
319
320 #endif // SMESHGUI_COMPUTEDLG_H