Salome HOME
Update mail address
[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/ or email : webmaster.salome@opencascade.com
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_ShapeByMeshOp;
44 class HypothesisData;
45
46 /*!
47  * \brief Operation for mech creation or editing
48  *
49  *  This operation is used for mech creation or editing. 
50 */
51 class SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
52
53   Q_OBJECT
54       
55 public:
56
57   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
58
59   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
60   virtual ~SMESHGUI_MeshOp();
61   
62   virtual LightApp_Dialog*       dlg() const;  
63
64 protected:
65   virtual void                   startOperation();
66   virtual void                   selectionDone();
67   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
68   virtual bool                   isValid( SUIT_Operation* ) const;
69
70 protected slots:
71   virtual bool                   onApply();
72   void                           onCreateHyp( const int theHypType, const int theIndex );
73   void                           onEditHyp( const int theHypType, const int theIndex );
74   void                           onHypoSet( const QString& theSetName );
75   void                           onGeomSelectionByMesh( bool );
76   void                           onPublishShapeByMeshDlg(SUIT_Operation*);
77   void                           onCloseShapeByMeshDlg(SUIT_Operation*);
78   void                           onAlgoSelected( const int theIndex,
79                                                  const int theDim = -1);
80
81 private:
82
83   typedef QValueList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
84
85   bool                           isValid( QString& ) const;
86   void                           availableHyps( const int       theDim, 
87                                                 const int       theHypType,
88                                                 QStringList&    theHyps,
89                                                 THypDataList&   theDataList,
90                                                 HypothesisData* theAlgoData = 0 ) const;
91   void                           existingHyps( const int     theDim, 
92                                                const int     theHypType, 
93                                                _PTR(SObject) theFather,
94                                                QStringList&  theHyps, 
95                                                QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars,
96                                                HypothesisData* theAlgoData = 0);
97   HypothesisData*                hypData( const int theDim,
98                                           const int theHypType,
99                                           const int theIndex); // access to myAvailableHypData
100
101   void                           createHypothesis(const int theDim, const int theType,
102                                                   const QString& theTypeName);
103
104   bool                           createMesh( QString& );
105   bool                           createSubMesh( QString& );
106   bool                           editMeshOrSubMesh( QString& );
107
108   int                            currentHyp( const int, const int ) const;
109   bool                           isAccessibleDim( const int ) const;
110   void                           setCurrentHyp( const int, const int, const int );
111   void                           setDefaultName() const;
112   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
113   void                           readMesh();
114   QString                        name( _PTR(SObject) ) const;
115   int                            find( const SMESH::SMESH_Hypothesis_var&,
116                                        const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
117   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
118                                                           const QString& aServerLib ) const;
119   bool                           isSubshapeOk() const;
120   _PTR(SObject)                  getSubmeshByGeom() const;
121   void                           selectObject( _PTR(SObject) ) const;
122
123 private:
124   typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
125   typedef QMap< int, IdToHypListMap > DimToHypMap;
126
127   SMESHGUI_MeshDlg*              myDlg;
128   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
129   bool                           myToCreate;
130   bool                           myIsMesh;
131
132   DimToHypMap                    myExistingHyps; //!< all hypothesis of SMESH module
133   DimToHypMap                    myObjHyps;      //!< hypothesis assigned to the current 
134                                                  //   edited mesh/sub-mesh
135
136   // hypdata corresponding to hypotheses present in myDlg
137   THypDataList                   myAvailableHypData[3][NbHypTypes];
138
139   bool                           myIgnoreAlgoSelection;
140 };
141
142 #endif