Salome HOME
ee268a4d4756896f33d182fe674f78e0fc5402f5
[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 namespace SMESH
57 {
58   class TShapeDisplayer;
59 }
60
61 /*!
62  * \brief Base operation to compute a mesh and show computation errors
63  */
64 class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation
65 {
66   Q_OBJECT
67
68 public:
69   SMESHGUI_BaseComputeOp();
70   virtual ~SMESHGUI_BaseComputeOp();
71
72   SMESH::SMESH_Mesh_ptr          getMesh();
73
74 protected:
75   virtual void                   startOperation();
76   virtual void                   stopOperation();
77
78   SMESHGUI_ComputeDlg*           computeDlg() const;
79   void                           computeMesh();
80   void                           showComputeResult( const bool,
81                                                     const bool,
82                                                     SMESH::compute_error_array_var&,
83                                                     const bool,
84                                                     const QString& );
85   SMESHGUI_ComputeDlg*           evaluateDlg() const;
86   void                           evaluateMesh();
87   void                           showEvaluateResult(const SMESH::long_array& theRes,
88                                                     const bool,
89                                                     const bool,
90                                                     SMESH::compute_error_array_var&,
91                                                     const bool,
92                                                     const QString&);
93
94   virtual bool                   isValid( SUIT_Operation* theOp ) const;
95     
96 protected slots:
97   virtual bool                   onApply();
98   void                           onPreviewShape();
99   void                           onPublishShape();
100   void                           onShowBadMesh();
101   void                           currentCellChanged();
102
103 private:
104   QTableWidget*                  table();
105
106 private:
107   QPointer<SMESHGUI_ComputeDlg>  myCompDlg;
108
109 protected:
110   SMESH::SMESH_Mesh_var            myMesh;
111   GEOM::GEOM_Object_var            myMainShape;
112   SMESH::TShapeDisplayer*          myTShapeDisplayer;
113   SMESHGUI_MeshEditPreview*        myBadMeshDisplayer;
114   Handle(SALOME_InteractiveObject) myIObject;
115 };
116
117 /*!
118  * \brief Operation to compute a mesh and show computation errors
119  */
120 class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
121 {
122   Q_OBJECT
123
124 public:
125   SMESHGUI_ComputeOp();
126   virtual ~SMESHGUI_ComputeOp();
127
128   virtual LightApp_Dialog*       dlg() const;
129
130 protected:
131   virtual void                   startOperation();
132
133 protected slots:
134 };
135
136 class SMESHGUI_MeshOrderMgr;
137
138 /*!
139  * \brief Operation to preview and compute a mesh and show computation errors
140  */
141 class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
142 {
143   Q_OBJECT
144
145 public:
146   SMESHGUI_PrecomputeOp();
147   virtual ~SMESHGUI_PrecomputeOp();
148
149   virtual LightApp_Dialog*       dlg() const;
150
151   /**
152    * \brief returns map of assigned algorithms modes
153    */
154   static void                    getAssignedAlgos(_PTR(SObject) theMesh,
155                                                   QMap<int,int>& theModeMap);
156
157 protected:
158   virtual void                   startOperation();
159   virtual void                   stopOperation();
160   virtual void                   resumeOperation();
161
162   virtual void                   initDialog();
163
164 protected slots:
165   virtual void                   onCancel();
166
167 private slots:
168   void                           onPreview();
169   void                           onCompute();
170
171 private:
172   //! private fields
173   QMap< int, int >               myMapShapeId;
174   QPointer<LightApp_Dialog>      myActiveDlg;
175   QPointer<SMESHGUI_PrecomputeDlg> myDlg;
176   SMESHGUI_MeshEditPreview*      myPreviewDisplayer;
177   //! fields for mesh order
178   typedef QList<int>             TListOfInt;
179   typedef QList<TListOfInt>      TListOfListOfInt;
180   TListOfListOfInt               myPrevOrder;
181   SMESHGUI_MeshOrderMgr*         myOrderMgr;
182 };
183
184 /*!
185  * \brief Operation to evaluate a mesh and show result
186  */
187 class SMESHGUI_EXPORT SMESHGUI_EvaluateOp: public SMESHGUI_BaseComputeOp
188 {
189   Q_OBJECT
190
191 public:
192   SMESHGUI_EvaluateOp();
193   virtual ~SMESHGUI_EvaluateOp();
194
195   virtual LightApp_Dialog*       dlg() const;
196
197 protected:
198   virtual void                   startOperation();
199
200 protected slots:
201 };
202
203 /*!
204  * \brief Dialog to compute a mesh and show computation errors
205  */
206
207 class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog
208 {
209   Q_OBJECT
210
211 public:
212   SMESHGUI_ComputeDlg( QWidget*, bool );
213   virtual ~SMESHGUI_ComputeDlg();
214
215 protected:
216   QFrame*                      createMainFrame( QWidget*, bool );
217
218   QLabel*                      myMeshName;
219   QGroupBox*                   myMemoryLackGroup;
220   QGroupBox*                   myCompErrorGroup;
221   QGroupBox*                   myHypErrorGroup;
222   QLabel*                      myHypErrorLabel;
223   QTableWidget*                myTable;
224   QPushButton*                 myShowBtn;
225   QPushButton*                 myPublishBtn;
226   QPushButton*                 myBadMeshBtn;
227
228   SMESHGUI_MeshInfosBox*       myBriefInfo;
229   SMESHGUI_MeshInfosBox*       myFullInfo;
230
231   friend class SMESHGUI_BaseComputeOp;
232   friend class SMESHGUI_PrecomputeOp;
233 };
234
235 class SMESHGUI_MeshOrderBox;
236
237 /*!
238  * \brief Dialog to preview and compute a mesh and show computation errors
239  */
240
241 class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
242 {
243   Q_OBJECT
244
245 public:
246   SMESHGUI_PrecomputeDlg( QWidget* );
247   virtual ~SMESHGUI_PrecomputeDlg();
248   
249   void                         setPreviewModes( const QList<int>& );
250   int                          getPreviewMode() const;
251   
252   SMESHGUI_MeshOrderBox*       getMeshOrderBox() const;
253
254 signals:
255   void                         preview();
256
257 private:
258   SMESHGUI_MeshOrderBox*       myOrderBox;
259   QPushButton*                 myPreviewBtn;
260   QtxComboBox*                 myPreviewMode;
261 };
262
263 #endif // SMESHGUI_COMPUTEDLG_H