Salome HOME
91c39ed72bb8b16ce305e4630a9d3cf2d5f35d9c
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2007-2013  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                   commitOperation();
70   virtual void                   selectionDone();
71   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
72   virtual bool                   isValid( SUIT_Operation* ) const;
73
74 protected slots:
75   virtual bool                   onApply();
76   void                           onCreateHyp( const int, const int );
77   void                           onEditHyp( const int, const int );
78   void                           onHypoSet( const QString& );
79   void                           onGeomSelectionByMesh( bool );
80   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
81   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
82   void                           onAlgoSelected( const int, const int = -1 );
83   void                           processSet();
84   void                           onHypoCreated( int );
85   void                           onHypoEdited( int );
86
87 private:
88   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
89
90   bool                           isValid( QString& ) const;
91   void                           availableHyps( const int, 
92                                                 const int,
93                                                 QStringList&,
94                                                 THypDataList&,
95                                                 HypothesisData* = 0 ) const;
96   static void                    existingHyps( const int, 
97                                                const int, 
98                                                _PTR(SObject),
99                                                QStringList&, 
100                                                THypList&,
101                                                HypothesisData* = 0 );
102   HypothesisData*                hypData( const int,
103                                           const int,
104                                           const int ); // access to myAvailableHypData
105
106   void                           createHypothesis( const int, const int,
107                                                    const QString& );
108
109   bool                           createMesh( QString&, QStringList& );
110   bool                           createSubMesh( QString&, QStringList& );
111   bool                           editMeshOrSubMesh( QString& );
112
113   int                            currentHyp( const int, const int ) const;
114   bool                           isAccessibleDim( const int ) const;
115   void                           setCurrentHyp( const int, const int, const int );
116   void                           setDefaultName() const;
117   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
118   void                           readMesh();
119   QString                        name( _PTR(SObject) ) const;
120   int                            find( const SMESH::SMESH_Hypothesis_var&,
121                                        const THypList& ) const;
122   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
123                                                           const QString& ) const;
124   bool                           isSubshapeOk() const;
125   char*                          isSubmeshIgnored() const;
126   _PTR(SObject)                  getSubmeshByGeom() const;
127   void                           selectObject( _PTR(SObject) ) const;
128
129 private:
130   SMESHGUI_MeshDlg*              myDlg;
131   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
132   bool                           myToCreate;
133   bool                           myIsMesh;
134   bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
135
136   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
137   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
138                                                  //   edited mesh/sub-mesh
139
140   // hypdata corresponding to hypotheses present in myDlg
141   THypDataList                   myAvailableHypData[4][NbHypTypes];
142
143   bool                           myIgnoreAlgoSelection;
144   HypothesesSet* myHypoSet;
145   int myDim, myType;
146
147   QString                        myObjectToSelect;
148 };
149
150 #endif // SMESHGUI_MESHOP_H