Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_MeshOp.h
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_MESHOP_H
28 #define SMESHGUI_MESHOP_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 #include "SMESHGUI_SelectionOp.h"
34
35 class HypothesesSet;
36 class SMESHGUI_MeshDlg;
37 class SMESHGUI_ShapeByMeshOp;
38 class HypothesisData;
39
40 /*!
41  * \brief Operation for mech creation or editing
42  *
43  *  This operation is used for mech creation or editing. 
44 */
45 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
46
47   Q_OBJECT
48       
49 public:
50   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
51
52   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
53   typedef QList< THypItem > THypList;
54
55   typedef int THypType;
56   typedef QMap< THypType, THypList > TType2HypList;
57
58   typedef int THypDim;
59   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
60
61 public:
62   SMESHGUI_MeshOp( const bool, const bool = true );
63   virtual ~SMESHGUI_MeshOp();
64   
65   virtual LightApp_Dialog*       dlg() const;  
66
67 protected:
68   virtual void                   startOperation();
69   virtual void                   selectionDone();
70   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
71   virtual bool                   isValid( SUIT_Operation* ) const;
72
73 protected slots:
74   virtual bool                   onApply();
75   void                           onCreateHyp( const int, const int );
76   void                           onEditHyp( const int, const int );
77   void                           onHypoSet( const QString& );
78   void                           onGeomSelectionByMesh( bool );
79   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
80   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
81   void                           onAlgoSelected( const int, const int = -1 );
82   void                           processSet();
83   void                           onHypoCreated( int );
84   void                           onHypoEdited( int );
85
86 private:
87   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
88
89   bool                           isValid( QString& ) const;
90   void                           availableHyps( const int, 
91                                                 const int,
92                                                 QStringList&,
93                                                 THypDataList&,
94                                                 HypothesisData* = 0 ) const;
95   static void                    existingHyps( const int, 
96                                                const int, 
97                                                _PTR(SObject),
98                                                QStringList&, 
99                                                THypList&,
100                                                HypothesisData* = 0 );
101   HypothesisData*                hypData( const int,
102                                           const int,
103                                           const int ); // access to myAvailableHypData
104
105   void                           createHypothesis( const int, const int,
106                                                    const QString& );
107
108   bool                           createMesh( QString& );
109   bool                           createSubMesh( QString& );
110   bool                           editMeshOrSubMesh( QString& );
111
112   int                            currentHyp( const int, const int ) const;
113   bool                           isAccessibleDim( const int ) const;
114   void                           setCurrentHyp( const int, const int, const int );
115   void                           setDefaultName() const;
116   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
117   void                           readMesh();
118   QString                        name( _PTR(SObject) ) const;
119   int                            find( const SMESH::SMESH_Hypothesis_var&,
120                                        const THypList& ) const;
121   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
122                                                           const QString& ) const;
123   bool                           isSubshapeOk() const;
124   char*                          isSubmeshIgnored() const;
125   _PTR(SObject)                  getSubmeshByGeom() const;
126   void                           selectObject( _PTR(SObject) ) const;
127
128 private:
129   SMESHGUI_MeshDlg*              myDlg;
130   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
131   bool                           myToCreate;
132   bool                           myIsMesh;
133   bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
134
135   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
136   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
137                                                  //   edited mesh/sub-mesh
138
139   // hypdata corresponding to hypotheses present in myDlg
140   THypDataList                   myAvailableHypData[4][NbHypTypes];
141
142   bool                           myIgnoreAlgoSelection;
143   HypothesesSet* myHypoSet;
144   int myDim, myType;
145 };
146
147 #endif // SMESHGUI_MESHOP_H