Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 class SMESHGUI_GenericHypothesisCreator;
40
41 /*!
42  * \brief Operation for mech creation or editing
43  *
44  *  This operation is used for mech creation or editing. 
45 */
46 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
47
48   Q_OBJECT
49       
50 public:
51   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
52   enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL };
53
54   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
55   typedef QList< THypItem > THypList;
56
57   typedef int THypType;
58   typedef QMap< THypType, THypList > TType2HypList;
59
60   typedef int THypDim;
61   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
62
63 public:
64   SMESHGUI_MeshOp( const bool, const bool = true );
65   virtual ~SMESHGUI_MeshOp();
66   
67   virtual LightApp_Dialog*       dlg() const;  
68
69 protected:
70   virtual void                   startOperation();
71   virtual void                   commitOperation();
72   virtual void                   selectionDone();
73   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
74   virtual bool                   isValid( SUIT_Operation* ) const;
75
76 protected slots:
77   virtual bool                   onApply();
78   void                           onCreateHyp( const int, const int );
79   void                           onEditHyp( const int, const int );
80   void                           onHypoSet( const QString& );
81   void                           onGeomSelectionByMesh( bool );
82   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
83   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
84   void                           onAlgoSelected( const int, const int = -1 );
85   void                           processSet();
86   void                           onHypoCreated( int );
87   void                           onHypoEdited( int );
88   void                           onAlgoSetByMeshType( const int, const int );
89
90 private:
91   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
92   typedef QMap<QString, bool>    THypLabelIsAppMap; // typedef: map of hypothesis is applicable
93
94   bool                           isValid( QString& ) const;
95   bool                           isCompatibleToGeometry( HypothesisData* ,
96                                                          QString,
97                                                          GEOM::GEOM_Object_var);
98   bool                           isCompatibleToMeshType( HypothesisData* ,
99                                                          QString);
100   void                           availableHyps( const int, 
101                                                 const int,
102                                                 QStringList&,
103                                                 THypDataList&,
104                                                 HypothesisData* = 0,
105                                                 HypothesisData* = 0,
106                                                 const QString& = "");
107   void                           existingHyps( const int, 
108                                                const int, 
109                                                _PTR(SObject),
110                                                QStringList&, 
111                                                THypList&,
112                                                HypothesisData* = 0 ) const;
113   HypothesisData*                hypData( const int,
114                                           const int,
115                                           const int ); // access to myAvailableHypData
116
117   void                           createHypothesis( const int, const int,
118                                                    const QString& );
119
120   bool                           createMesh( QString&, QStringList& );
121   bool                           createSubMesh( QString&, QStringList& );
122   bool                           editMeshOrSubMesh( QString& );
123   bool                           checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr    mesh,
124                                                           SMESH::SMESH_subMesh_ptr submesh,
125                                                           bool                     askUser=false);
126
127   int                            currentHyp( const int, const int ) const;
128   bool                           isSelectedHyp( int, int, int ) const;
129   int                            nbDlgHypTypes( const int ) const;
130   bool                           isAccessibleDim( const int ) const;
131   void                           setCurrentHyp( const int, const int, const int, const bool=false);
132   void                           setDefaultName( const QString& prefix="" ) const;
133   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
134   void                           readMesh();
135   QString                        name( _PTR(SObject) ) const;
136   int                            find( const SMESH::SMESH_Hypothesis_var&,
137                                        const THypList& ) const;
138   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
139                                                           const QString& ) const;
140   void                           initHypCreator( SMESHGUI_GenericHypothesisCreator* aCreator );
141   bool                           isSubshapeOk() const;
142   char*                          isSubmeshIgnored() const;
143   _PTR(SObject)                  getSubmeshByGeom() const;
144   void                           selectObject( _PTR(SObject) ) const;
145   void                           createMeshTypeList( QStringList& );
146   void                           setAvailableMeshType( const QStringList& );
147   void                           setFilteredAlgoData( const int, const int );
148   QString                        currentMeshTypeName( const int ) const;
149
150 private:
151
152   SMESHGUI_MeshDlg*              myDlg;
153   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
154   bool                           myToCreate;
155   bool                           myIsMesh;
156   bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
157   bool                           myHasConcurrentSubBefore;
158
159   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
160   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current
161                                                  //   edited mesh/sub-mesh
162   // hypdata corresponding to hypotheses present in myDlg
163   THypDataList                   myAvailableHypData[4][NbHypTypes];
164   QString                        myLastGeomToSelect;
165   THypLabelIsAppMap              myHypMapIsApplicable;
166   bool                           myIgnoreAlgoSelection;
167   HypothesesSet*                 myHypoSet;
168   int                            myDim, myType, myMaxShapeDim;
169
170   QString                        myObjectToSelect;
171 };
172
173 #endif // SMESHGUI_MESHOP_H