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