Salome HOME
bc979d3fa4b273c7f66fcdd64bf5ea062700af9a
[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 <QPointer>
40 #include <QGroupBox>
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 class SMESH::compute_error_array;
58
59 namespace SMESH
60 {
61   class TShapeDisplayer;
62 }
63
64 /*!
65  * \brief Base operation to compute a mesh and show computation errors
66  */
67 class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation
68 {
69   Q_OBJECT
70
71 public:
72   SMESHGUI_BaseComputeOp();
73   virtual ~SMESHGUI_BaseComputeOp();
74
75   SMESH::SMESH_Mesh_ptr          getMesh();
76
77 protected:
78   virtual void                   startOperation();
79   virtual void                   stopOperation();
80
81   SMESHGUI_ComputeDlg*           computeDlg() const;
82   void                           computeMesh();
83   void                           showComputeResult( const bool,
84                                                     const bool,
85                                                     SMESH::compute_error_array_var&,
86                                                     const bool,
87                                                     const QString& );
88   SMESHGUI_ComputeDlg*           evaluateDlg() const;
89   void                           evaluateMesh();
90   void                           showEvaluateResult(const SMESH::long_array& theRes,
91                                                     const bool,
92                                                     const bool,
93                                                     SMESH::compute_error_array_var&,
94                                                     const bool,
95                                                     const QString&);
96
97   virtual bool                   isValid( SUIT_Operation* theOp ) const;
98     
99 protected slots:
100   virtual bool                   onApply();
101   void                           onPreviewShape();
102   void                           onPublishShape();
103   void                           onShowBadMesh();
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 /*!
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   QMap< int, int >               myMapShapeId;
174   QPointer<LightApp_Dialog>      myActiveDlg;
175   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
176   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
177 };
178
179 /*!
180  * \brief Operation to evaluate a mesh and show result
181  */
182 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
183 {
184   Q_OBJECT
185
186 public:
187   SMESHGUI_EvaluateOp();
188   virtual ~SMESHGUI_EvaluateOp();
189
190   virtual LightApp_Dialog*       dlg() const;
191
192 protected:
193   virtual void                   startOperation();
194
195 protected slots:
196 };
197
198 /*!
199  * \brief Dialog to compute a mesh and show computation errors
200  */
201
202 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
203 {
204   Q_OBJECT
205
206 public:
207   SMESHGUI_ComputeDlg( QWidget*, bool );
208   virtual ~SMESHGUI_ComputeDlg();
209
210 protected:
211   QFrame*                      createMainFrame( QWidget*, bool );
212
213   QLabel*                      myMeshName;
214   QGroupBox*                   myMemoryLackGroup;
215   QGroupBox*                   myCompErrorGroup;
216   QGroupBox*                   myHypErrorGroup;
217   QLabel*                      myHypErrorLabel;
218   QTableWidget*                myTable;
219   QPushButton*                 myShowBtn;
220   QPushButton*                 myPublishBtn;
221   QPushButton*                 myBadMeshBtn;
222
223   SMESHGUI_MeshInfosBox*       myBriefInfo;
224   SMESHGUI_MeshInfosBox*       myFullInfo;
225
226   friend class SMESHGUI_BaseComputeOp;
227   friend class SMESHGUI_PrecomputeOp;
228 };
229
230 /*!
231  * \brief Dialog to preview and compute a mesh and show computation errors
232  */
233
234 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
235 {
236   Q_OBJECT
237
238 public:
239   SMESHGUI_PrecomputeDlg( QWidget* );
240   virtual ~SMESHGUI_PrecomputeDlg();
241   
242   void                         setPreviewModes( const QList<int>& );
243   int                          getPreviewMode() const;
244
245 signals:
246   void                         preview();
247
248 private:
249   QPushButton*                 myPreviewBtn;
250   QtxComboBox*                 myPreviewMode;
251 };
252
253 #endif // SMESHGUI_COMPUTEDLG_H