Salome HOME
618db50c583b253c8b7ad91b4933001a5ae95a6d
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.h
1 //  Copyright (C) 2007-2010  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
41 // IDL includes
42 #include <SALOMEconfig.h>
43 #include CORBA_SERVER_HEADER(SMESH_Gen)
44 #include CORBA_SERVER_HEADER(SMESH_Mesh)
45
46 class QFrame;
47 class QPushButton;
48 class QTableWidget;
49 class QLabel;
50 class QtxComboBox;
51 class SMESHGUI_ComputeDlg;
52 class SMESHGUI_MeshInfosBox;
53 class SMESHGUI_PrecomputeDlg;
54 class SMESHGUI_MeshEditPreview;
55
56 class SMESH::compute_error_array;
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                           currentCellChanged();
104
105 private:
106   QTableWidget*                  table();
107
108 private:
109   QPointer<SMESHGUI_ComputeDlg>  myCompDlg;
110
111 protected:
112   SMESH::SMESH_Mesh_var            myMesh;
113   GEOM::GEOM_Object_var            myMainShape;
114   SMESH::TShapeDisplayer*          myTShapeDisplayer;
115   SMESHGUI_MeshEditPreview*        myBadMeshDisplayer;
116   Handle(SALOME_InteractiveObject) myIObject;
117 };
118
119 /*!
120  * \brief Operation to compute a mesh and show computation errors
121  */
122 class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
123 {
124   Q_OBJECT
125
126 public:
127   SMESHGUI_ComputeOp();
128   virtual ~SMESHGUI_ComputeOp();
129
130   virtual LightApp_Dialog*       dlg() const;
131
132 protected:
133   virtual void                   startOperation();
134
135 protected slots:
136 };
137
138 class SMESHGUI_MeshOrderMgr;
139
140 /*!
141  * \brief Operation to preview and compute a mesh and show computation errors
142  */
143 class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
144 {
145   Q_OBJECT
146
147 public:
148   SMESHGUI_PrecomputeOp();
149   virtual ~SMESHGUI_PrecomputeOp();
150
151   virtual LightApp_Dialog*       dlg() const;
152
153   /**
154    * \brief returns map of assigned algorithms modes
155    */
156   static void                    getAssignedAlgos(_PTR(SObject) theMesh,
157                                                   QMap<int,int>& theModeMap);
158
159 protected:
160   virtual void                   startOperation();
161   virtual void                   stopOperation();
162   virtual void                   resumeOperation();
163
164   virtual void                   initDialog();
165
166 protected slots:
167   virtual void                   onCancel();
168
169 private slots:
170   void                           onPreview();
171   void                           onCompute();
172
173 private:
174   //! private fields
175   QMap< int, int >               myMapShapeId;
176   QPointer<LightApp_Dialog>      myActiveDlg;
177   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
178   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
179   //! fields for mesh order
180   typedef QList<int>             TListOfInt;
181   typedef QList<TListOfInt>      TListOfListOfInt;
182   TListOfListOfInt               myPrevOrder;
183   SMESHGUI_MeshOrderMgr*         myOrderMgr;
184 };
185
186 /*!
187  * \brief Operation to evaluate a mesh and show result
188  */
189 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
190 {
191   Q_OBJECT
192
193 public:
194   SMESHGUI_EvaluateOp();
195   virtual ~SMESHGUI_EvaluateOp();
196
197   virtual LightApp_Dialog*       dlg() const;
198
199 protected:
200   virtual void                   startOperation();
201
202 protected slots:
203 };
204
205 /*!
206  * \brief Dialog to compute a mesh and show computation errors
207  */
208
209 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
210 {
211   Q_OBJECT
212
213 public:
214   SMESHGUI_ComputeDlg( QWidget*, bool );
215   virtual ~SMESHGUI_ComputeDlg();
216
217 protected:
218   QFrame*                      createMainFrame( QWidget*, bool );
219
220   QLabel*                      myMeshName;
221   QGroupBox*                   myMemoryLackGroup;
222   QGroupBox*                   myCompErrorGroup;
223   QGroupBox*                   myHypErrorGroup;
224   QLabel*                      myHypErrorLabel;
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 #endif // SMESHGUI_COMPUTEDLG_H