Salome HOME
Copyright update 2022
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2007-2022  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 // IDL includes
36 #include <SALOMEconfig.h>
37 #include CORBA_CLIENT_HEADER(SMESH_Gen)
38 #include CORBA_CLIENT_HEADER(GEOM_Gen)
39
40 class HypothesesSet;
41 class SMESHGUI_MeshDlg;
42 class SMESHGUI_ShapeByMeshOp;
43 class HypothesisData;
44 class SMESHGUI_GenericHypothesisCreator;
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_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
52
53   Q_OBJECT
54       
55 public:
56   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
57   enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL };
58
59   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
60   typedef QList< THypItem > THypList;
61
62   typedef int THypType;
63   typedef QMap< THypType, THypList > TType2HypList;
64
65   typedef int THypDim;
66   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
67
68 public:
69   SMESHGUI_MeshOp( const bool, const bool = true );
70   virtual ~SMESHGUI_MeshOp();
71   
72   virtual LightApp_Dialog*       dlg() const;  
73
74 protected:
75   virtual void                   startOperation();
76   virtual void                   commitOperation();
77   virtual void                   selectionDone();
78   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
79   virtual bool                   isValid( SUIT_Operation* ) const;
80
81 protected slots:
82   virtual bool                   onApply();
83   void                           onCreateHyp( const int, const int );
84   void                           onEditHyp( const int, const int );
85   void                           onHypoSet( const QString& );
86   void                           onGeomSelectionByMesh( bool );
87   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
88   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
89   void                           onAlgoSelected( const int, const int = -1 );
90   void                           onHypoCreated( int );
91   void                           onHypoEdited( int );
92   void                           onAlgoSetByMeshType( const int, const int );
93
94 private:
95   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
96   typedef QMap<QString, bool>    THypLabelIsAppMap; // typedef: map of hypothesis is applicable
97
98   bool                           isValid( QString& ) const;
99   bool                           isCompatibleToGeometry( HypothesisData* , const int);
100   bool                           isCompatibleToMeshType( HypothesisData* , const int);
101   void                           availableHyps( const int, 
102                                                 const int,
103                                                 QStringList&,
104                                                 THypDataList&,
105                                                 HypothesisData* = 0,
106                                                 HypothesisData* = 0,
107                                                 const QString& = "");
108   void                           existingHyps( const int, 
109                                                const int, 
110                                                _PTR(SObject),
111                                                QStringList&, 
112                                                THypList&,
113                                                HypothesisData* = 0 ) const;
114   HypothesisData*                hypData( const int,
115                                           const int,
116                                           const int ); // access to myAvailableHypData
117
118   void                           createHypothesis( const int, const int,
119                                                    const QString& );
120
121   bool                           createMesh( QString&, QStringList& );
122   bool                           createSubMesh( QString&, QStringList& );
123   bool                           editMeshOrSubMesh( QString& );
124   void                           createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh,
125                                                                GEOM::GEOM_Object_ptr mainShape );
126   bool                           checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr    mesh,
127                                                           SMESH::SMESH_subMesh_ptr submesh,
128                                                           bool                     askUser=false);
129
130   int                            currentHyp( const int, const int ) const;
131   bool                           isSelectedHyp( int, int, int ) const;
132   int                            nbDlgHypTypes( const int ) const;
133   bool                           isAccessibleDim( const int ) const;
134   void                           setCurrentHyp( const int, const int, const int, const bool=false);
135   void                           setDefaultName( const QString& prefix="" ) const;
136   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
137   void                           readMesh();
138   QString                        name( _PTR(SObject) ) const;
139   int                            find( const SMESH::SMESH_Hypothesis_var&,
140                                        const THypList& ) const;
141   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
142                                                           const QString&,
143                                                           const SMESH::HypInitParams* prm=0) const;
144   void                           initHypCreator( SMESHGUI_GenericHypothesisCreator* aCreator );
145   bool                           getAverageSize( double & averageSize );
146   bool                           isSubshapeOk() const;
147   char*                          isSubmeshIgnored() const;
148   _PTR(SObject)                  getSubmeshByGeom() const;
149   void                           selectObject( _PTR(SObject) ) const;
150   void                           updateMeshTypeList();
151   void                           updateHypoSets();
152   void                           setFilteredAlgoData();
153   QStringList                    getHypoNames();
154
155 private:
156
157   SMESHGUI_MeshDlg*              myDlg;
158   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
159   bool                           myToCreate;
160   bool                           myIsMesh;
161   bool                           myIsOnGeometry; //!< TRUE if edited mesh is based on geometry
162   bool                           myHasConcurrentSubBefore;
163   bool                           myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited
164   // The geometry of "invalid sub-mesh" is not a sub-shape of the main shape;
165   // it is created for the case where a valid sub-shape not found by CopyMeshWithGeom()
166
167   QString                        myGeomEntry;
168   GEOM::GEOM_Object_var          myGeom;
169
170   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
171   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current
172                                                  //   edited mesh/sub-mesh
173   // hypdata corresponding to hypotheses present in myDlg
174   THypDataList                   myAvailableHypData[4][NbHypTypes];
175   QString                        myLastGeomEntry;
176   THypLabelIsAppMap              myHypMapIsApplicable;
177   bool                           myIgnoreAlgoSelection;
178   int                            myDim, myType, myMaxShapeDim;
179
180   HypothesesSet*                 myHypoSet; // applied hypo-set
181   double                         myAverageSize; // entered at hypo-set processing
182
183   QString                        myObjectToSelect;
184 };
185
186 #endif // SMESHGUI_MESHOP_H