Salome HOME
d670495426e9e22878092180a65fecd251681203
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2007-2014  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
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   enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL };
52
53   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
54   typedef QList< THypItem > THypList;
55
56   typedef int THypType;
57   typedef QMap< THypType, THypList > TType2HypList;
58
59   typedef int THypDim;
60   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
61
62 public:
63   SMESHGUI_MeshOp( const bool, const bool = true );
64   virtual ~SMESHGUI_MeshOp();
65   
66   virtual LightApp_Dialog*       dlg() const;  
67
68 protected:
69   virtual void                   startOperation();
70   virtual void                   commitOperation();
71   virtual void                   selectionDone();
72   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
73   virtual bool                   isValid( SUIT_Operation* ) const;
74
75 protected slots:
76   virtual bool                   onApply();
77   void                           onCreateHyp( const int, const int );
78   void                           onEditHyp( const int, const int );
79   void                           onHypoSet( const QString& );
80   void                           onGeomSelectionByMesh( bool );
81   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
82   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
83   void                           onAlgoSelected( const int, const int = -1 );
84   void                           processSet();
85   void                           onHypoCreated( int );
86   void                           onHypoEdited( int );
87   void                           onAlgoSetByMeshType( const int, const int );
88
89 private:
90   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
91
92   bool                           isValid( QString& ) const;
93   void                           availableHyps( const int, 
94                                                 const int,
95                                                 QStringList&,
96                                                 THypDataList&,
97                                                 HypothesisData* = 0 ) const;
98   static void                    existingHyps( const int, 
99                                                const int, 
100                                                _PTR(SObject),
101                                                QStringList&, 
102                                                THypList&,
103                                                HypothesisData* = 0 );
104   HypothesisData*                hypData( const int,
105                                           const int,
106                                           const int ); // access to myAvailableHypData
107
108   void                           createHypothesis( const int, const int,
109                                                    const QString& );
110
111   bool                           createMesh( QString&, QStringList& );
112   bool                           createSubMesh( QString&, QStringList& );
113   bool                           editMeshOrSubMesh( QString& );
114   bool                           checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr    mesh,
115                                                           SMESH::SMESH_subMesh_ptr submesh,
116                                                           bool                     askUser=false);
117
118   int                            currentHyp( const int, const int ) const;
119   bool                           isAccessibleDim( const int ) const;
120   void                           setCurrentHyp( const int, const int, const int );
121   void                           setDefaultName( const QString& prefix="" ) const;
122   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
123   void                           readMesh();
124   QString                        name( _PTR(SObject) ) const;
125   int                            find( const SMESH::SMESH_Hypothesis_var&,
126                                        const THypList& ) const;
127   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
128                                                           const QString& ) const;
129   bool                           isSubshapeOk() const;
130   char*                          isSubmeshIgnored() const;
131   _PTR(SObject)                  getSubmeshByGeom() const;
132   void                           selectObject( _PTR(SObject) ) const;
133   void                           createMeshTypeList( QStringList& );
134   void                           setAvailableMeshType( const QStringList& );
135 private:
136   SMESHGUI_MeshDlg*              myDlg;
137   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
138   bool                           myToCreate;
139   bool                           myIsMesh;
140   bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
141   bool                           myHasConcurrentSubBefore;
142
143   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
144   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
145                                                  //   edited mesh/sub-mesh
146   // hypdata corresponding to hypotheses present in myDlg
147   THypDataList                   myAvailableHypData[4][NbHypTypes];
148
149   bool                           myIgnoreAlgoSelection;
150   HypothesesSet* myHypoSet;
151   int myDim, myType, myMaxShapeDim;
152
153   QString                        myObjectToSelect;
154 };
155
156 #endif // SMESHGUI_MESHOP_H