Salome HOME
Movement of examples to CVS EXAMPLES SAMPLES_SRC.
[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
56 private:
57   bool                           isValid( QString& ) const;
58   void                           availableHyps( const int theDim, 
59                                                 const int theHypType, 
60                                                 QStringList& theHyps ) const;
61   void                           existingHyps( const int theDim, 
62                                                const int theHypType, 
63                                                _PTR(SObject) theFather,
64                                                QStringList& theHyps, 
65                                                QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars );
66   
67   bool                           createMesh( QString& );
68   bool                           createSubMesh( QString& );
69   bool                           editMeshOrSubMesh( QString& );
70   
71   int                            currentHyp( const int, const int ) const;
72   void                           setCurrentHyp( const int, const int, const int );
73   void                           setDefaultName() const;
74   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
75   void                           readMesh();
76   QString                        name( _PTR(SObject) ) const;
77   int                            find( const SMESH::SMESH_Hypothesis_var&,
78                                        const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
79
80 private:
81   typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
82   typedef QMap< int, IdToHypListMap > DimToHypMap;
83   
84   SMESHGUI_MeshDlg*              myDlg;
85   bool                           myToCreate;
86   bool                           myIsMesh;
87   
88   DimToHypMap                    myExistingHyps; //!< all hypothesis of SMESH module
89   DimToHypMap                    myObjHyps;      //!< hypothesis assigned to the current 
90                                                  //   edited mesh/sub-mesh
91 };
92
93 #endif