Salome HOME
ab64b33e318766f35630ad8f9fab863faba1c9f1
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : SMESHGUI_ComputeDlg.h
23 // Author : Edward AGAPOV, Open CASCADE S.A.S.
24 //
25 #ifndef SMESHGUI_COMPUTEDLG_H
26 #define SMESHGUI_COMPUTEDLG_H
27
28 // SMESH includes
29 #include "SMESH_SMESHGUI.hxx"
30
31 #include "SMESHGUI_Dialog.h"
32 #include "SMESHGUI_Operation.h"
33
34 // SALOME GUI includes
35 #include <SALOME_InteractiveObject.hxx>
36
37 // Qt includes
38 #include <QMap>
39 #include <QList>
40 #include <QPointer>
41 #include <QGroupBox>
42
43 // IDL includes
44 #include <SALOMEconfig.h>
45 #include CORBA_SERVER_HEADER(SMESH_Gen)
46 #include CORBA_SERVER_HEADER(SMESH_Mesh)
47
48 class QFrame;
49 class QPushButton;
50 class QTableWidget;
51 class QLabel;
52 class QtxComboBox;
53 class SMESHGUI_ComputeDlg;
54 class SMESHGUI_MeshInfosBox;
55 class SMESHGUI_PrecomputeDlg;
56 class SMESHGUI_MeshEditPreview;
57
58 class SMESH::compute_error_array;
59
60 namespace SMESH
61 {
62   class TShapeDisplayer;
63 }
64
65 /*!
66  * \brief Base operation to compute a mesh and show computation errors
67  */
68 class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation
69 {
70   Q_OBJECT
71
72 public:
73   SMESHGUI_BaseComputeOp();
74   virtual ~SMESHGUI_BaseComputeOp();
75
76   SMESH::SMESH_Mesh_ptr          getMesh();
77
78 protected:
79   virtual void                   startOperation();
80   virtual void                   stopOperation();
81
82   SMESHGUI_ComputeDlg*           computeDlg() const;
83   void                           computeMesh();
84   void                           showComputeResult( const bool,
85                                                     const bool,
86                                                     SMESH::compute_error_array_var&,
87                                                     const bool,
88                                                     const QString& );
89   SMESHGUI_ComputeDlg*           evaluateDlg() const;
90   void                           evaluateMesh();
91   void                           showEvaluateResult(const SMESH::long_array& theRes,
92                                                     const bool,
93                                                     const bool,
94                                                     SMESH::compute_error_array_var&,
95                                                     const bool,
96                                                     const QString&);
97
98   virtual bool                   isValid( SUIT_Operation* theOp ) const;
99     
100 protected slots:
101   virtual bool                   onApply();
102   void                           onPreviewShape();
103   void                           onPublishShape();
104   void                           onShowBadMesh();
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   SMESH::TShapeDisplayer*          myTShapeDisplayer;
117   SMESHGUI_MeshEditPreview*        myBadMeshDisplayer;
118   Handle(SALOME_InteractiveObject) myIObject;
119 };
120
121 /*!
122  * \brief Operation to compute a mesh and show computation errors
123  */
124 class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
125 {
126   Q_OBJECT
127
128 public:
129   SMESHGUI_ComputeOp();
130   virtual ~SMESHGUI_ComputeOp();
131
132   virtual LightApp_Dialog*       dlg() const;
133
134 protected:
135   virtual void                   startOperation();
136
137 protected slots:
138 };
139
140 class SMESHGUI_MeshOrderMgr;
141
142 /*!
143  * \brief Operation to preview and compute a mesh and show computation errors
144  */
145 class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
146 {
147   Q_OBJECT
148
149 public:
150   SMESHGUI_PrecomputeOp();
151   virtual ~SMESHGUI_PrecomputeOp();
152
153   virtual LightApp_Dialog*       dlg() const;
154
155   /**
156    * \brief returns map of assigned algorithms modes
157    */
158   static void                    getAssignedAlgos(_PTR(SObject) theMesh,
159                                                   QMap<int,int>& theModeMap);
160
161 protected:
162   virtual void                   startOperation();
163   virtual void                   stopOperation();
164   virtual void                   resumeOperation();
165
166   virtual void                   initDialog();
167
168 protected slots:
169   virtual void                   onCancel();
170
171 private slots:
172   void                           onPreview();
173   void                           onCompute();
174
175 private:
176   //! private fields
177   QMap< int, int >               myMapShapeId;
178   QPointer<LightApp_Dialog>      myActiveDlg;
179   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
180   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
181   //! fields for mesh order
182   typedef QList<int>             TListOfInt;
183   typedef QList<TListOfInt>      TListOfListOfInt;
184   TListOfListOfInt               myPrevOrder;
185   SMESHGUI_MeshOrderMgr*         myOrderMgr;
186 };
187
188 /*!
189  * \brief Operation to evaluate a mesh and show result
190  */
191 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
192 {
193   Q_OBJECT
194
195 public:
196   SMESHGUI_EvaluateOp();
197   virtual ~SMESHGUI_EvaluateOp();
198
199   virtual LightApp_Dialog*       dlg() const;
200
201 protected:
202   virtual void                   startOperation();
203
204 protected slots:
205 };
206
207 /*!
208  * \brief Dialog to compute a mesh and show computation errors
209  */
210
211 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
212 {
213   Q_OBJECT
214
215 public:
216   SMESHGUI_ComputeDlg( QWidget*, bool );
217   virtual ~SMESHGUI_ComputeDlg();
218
219 protected:
220   QFrame*                      createMainFrame( QWidget*, bool );
221
222   QLabel*                      myMeshName;
223   QGroupBox*                   myMemoryLackGroup;
224   QGroupBox*                   myCompErrorGroup;
225   QGroupBox*                   myHypErrorGroup;
226   QLabel*                      myHypErrorLabel;
227   QTableWidget*                myTable;
228   QPushButton*                 myShowBtn;
229   QPushButton*                 myPublishBtn;
230   QPushButton*                 myBadMeshBtn;
231
232   SMESHGUI_MeshInfosBox*       myBriefInfo;
233   SMESHGUI_MeshInfosBox*       myFullInfo;
234
235   friend class SMESHGUI_BaseComputeOp;
236   friend class SMESHGUI_PrecomputeOp;
237 };
238
239 class SMESHGUI_MeshOrderBox;
240
241 /*!
242  * \brief Dialog to preview and compute a mesh and show computation errors
243  */
244
245 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
246 {
247   Q_OBJECT
248
249 public:
250   SMESHGUI_PrecomputeDlg( QWidget* );
251   virtual ~SMESHGUI_PrecomputeDlg();
252   
253   void                         setPreviewModes( const QList<int>& );
254   int                          getPreviewMode() const;
255   
256   SMESHGUI_MeshOrderBox*       getMeshOrderBox() const;
257
258 signals:
259   void                         preview();
260
261 private:
262   SMESHGUI_MeshOrderBox*       myOrderBox;
263   QPushButton*                 myPreviewBtn;
264   QtxComboBox*                 myPreviewMode;
265 };
266
267 #endif // SMESHGUI_COMPUTEDLG_H