Salome HOME
PAL10237. Add a button assigning a set of hypotheses
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 /**
2 *  SMESH SMESHGUI
3 *
4 *  Copyright (C) 2005  CEA/DEN, EDF R&D
5 *
6 *
7 *
8 *  File   : SMESHGUI_MeshOp.h
9 *  Author : Sergey LITONIN
10 *  Module : SMESHGUI
11 */
12
13 #ifndef SMESHGUI_MeshOp_H
14 #define SMESHGUI_MeshOp_H
15
16 #include "SMESHGUI_SelectionOp.h"
17 #include <qstringlist.h>
18
19 #include <SALOMEconfig.h>
20 #include CORBA_SERVER_HEADER(GEOM_Gen)
21 #include CORBA_SERVER_HEADER(SMESH_Mesh)
22
23 class SMESHGUI_MeshDlg;
24 class SMESH_TypeFilter;
25 class SMESH_NumberFilter;
26
27
28 /*!
29  * \brief Operation for mech creation or editing
30  *
31  *  This operation is used for mech creation or editing. 
32 */
33 class SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
34
35   Q_OBJECT
36       
37   enum HypType{ Algo = 0, MainHyp, AddHyp };
38
39 public:
40   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
41   virtual ~SMESHGUI_MeshOp();
42   
43   virtual SalomeApp_Dialog*      dlg() const;  
44
45 protected:
46   virtual void                   startOperation();
47   virtual void                   selectionDone();
48   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
49   virtual bool                   isValid( SUIT_Operation* ) const;
50
51 protected slots:
52   virtual bool                   onApply();
53   void                           onCreateHyp( const int theHypType, const int theIndex );
54   void                           onEditHyp( const int theHypType, const int theIndex );
55   void                           onHypoSet( const QString& theSetName );
56
57 private:
58   bool                           isValid( QString& ) const;
59   void                           availableHyps( const int theDim, 
60                                                 const int theHypType, 
61                                                 QStringList& theHyps ) const;
62   void                           existingHyps( const int theDim, 
63                                                const int theHypType, 
64                                                _PTR(SObject) theFather,
65                                                QStringList& theHyps, 
66                                                QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars );
67   
68   bool                           createMesh( QString& );
69   bool                           createSubMesh( QString& );
70   bool                           editMeshOrSubMesh( QString& );
71   
72   int                            currentHyp( const int, const int ) const;
73   bool                           isAccessibleDim( const int ) const;
74   void                           setCurrentHyp( const int, const int, const int );
75   void                           setDefaultName() const;
76   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
77   void                           readMesh();
78   QString                        name( _PTR(SObject) ) const;
79   int                            find( const SMESH::SMESH_Hypothesis_var&,
80                                        const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
81
82 private:
83   typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
84   typedef QMap< int, IdToHypListMap > DimToHypMap;
85   
86   SMESHGUI_MeshDlg*              myDlg;
87   bool                           myToCreate;
88   bool                           myIsMesh;
89   
90   DimToHypMap                    myExistingHyps; //!< all hypothesis of SMESH module
91   DimToHypMap                    myObjHyps;      //!< hypothesis assigned to the current 
92                                                  //   edited mesh/sub-mesh
93 };
94
95 #endif