Salome HOME
Merge from OCC_development_generic_2006
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 /**
21 *  SMESH SMESHGUI
22 *
23 *  Copyright (C) 2005  CEA/DEN, EDF R&D
24 *
25 *
26 *
27 *  File   : SMESHGUI_MeshOp.h
28 *  Author : Sergey LITONIN
29 *  Module : SMESHGUI
30 */
31
32 #ifndef SMESHGUI_MeshOp_H
33 #define SMESHGUI_MeshOp_H
34
35 #include "SMESHGUI_SelectionOp.h"
36 #include <qstringlist.h>
37
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(GEOM_Gen)
40 #include CORBA_SERVER_HEADER(SMESH_Mesh)
41
42 class SMESHGUI_MeshDlg;
43 class SMESHGUI_ShapeByMeshDlg;
44
45 /*!
46  * \brief Operation for mech creation or editing
47  *
48  *  This operation is used for mech creation or editing. 
49 */
50 class SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
51
52   Q_OBJECT
53       
54   enum HypType{ Algo = 0, MainHyp, AddHyp };
55
56 public:
57   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
58   virtual ~SMESHGUI_MeshOp();
59   
60   virtual LightApp_Dialog*       dlg() const;  
61
62 protected:
63   virtual void                   startOperation();
64   virtual void                   selectionDone();
65   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
66   virtual bool                   isValid( SUIT_Operation* ) const;
67
68 protected slots:
69   virtual bool                   onApply();
70   void                           onCreateHyp( const int theHypType, const int theIndex );
71   void                           onEditHyp( const int theHypType, const int theIndex );
72   void                           onHypoSet( const QString& theSetName );
73   void                           onGeomSelectionByMesh( bool );
74   void                           onPublishShapeByMeshDlg();
75   void                           onCloseShapeByMeshDlg();
76
77 private:
78   bool                           isValid( QString& ) const;
79   void                           availableHyps( const int theDim, 
80                                                 const int theHypType, 
81                                                 QStringList& theHyps ) const;
82   void                           existingHyps( const int theDim, 
83                                                const int theHypType, 
84                                                _PTR(SObject) theFather,
85                                                QStringList& theHyps, 
86                                                QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars );
87   
88   bool                           createMesh( QString& );
89   bool                           createSubMesh( QString& );
90   bool                           editMeshOrSubMesh( QString& );
91   
92   int                            currentHyp( const int, const int ) const;
93   bool                           isAccessibleDim( const int ) const;
94   void                           setCurrentHyp( const int, const int, const int );
95   void                           setDefaultName() const;
96   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
97   void                           readMesh();
98   QString                        name( _PTR(SObject) ) const;
99   int                            find( const SMESH::SMESH_Hypothesis_var&,
100                                        const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
101   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
102                                                           const QString& aServerLib ) const;
103   bool                           isSubshapeOk() const;
104   _PTR(SObject)                  getSubmeshByGeom() const;
105   void                           selectObject( _PTR(SObject) ) const;
106
107 private:
108   typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
109   typedef QMap< int, IdToHypListMap > DimToHypMap;
110   
111   SMESHGUI_MeshDlg*              myDlg;
112   SMESHGUI_ShapeByMeshDlg*       myShapeByMeshDlg;
113   bool                           myToCreate;
114   bool                           myIsMesh;
115   
116   DimToHypMap                    myExistingHyps; //!< all hypothesis of SMESH module
117   DimToHypMap                    myObjHyps;      //!< hypothesis assigned to the current 
118                                                  //   edited mesh/sub-mesh
119 };
120
121 #endif