Salome HOME
untabify
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 //  Copyright (C) 2007-2008  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 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_MeshOp.h
24 // Author : Sergey LITONIN, Open CASCADE S.A.S.
25 //
26 #ifndef SMESHGUI_MESHOP_H
27 #define SMESHGUI_MESHOP_H
28
29 // SMESH includes
30 #include "SMESH_SMESHGUI.hxx"
31
32 #include "SMESHGUI_SelectionOp.h"
33
34 class HypothesesSet;
35 class SMESHGUI_MeshDlg;
36 class SMESHGUI_ShapeByMeshOp;
37 class HypothesisData;
38
39 /*!
40  * \brief Operation for mech creation or editing
41  *
42  *  This operation is used for mech creation or editing. 
43 */
44 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
45
46   Q_OBJECT
47       
48 public:
49   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
50
51   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
52   typedef QList< THypItem > THypList;
53
54   typedef int THypType;
55   typedef QMap< THypType, THypList > TType2HypList;
56
57   typedef int THypDim;
58   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
59
60 public:
61   SMESHGUI_MeshOp( const bool, const bool = true );
62   virtual ~SMESHGUI_MeshOp();
63   
64   virtual LightApp_Dialog*       dlg() const;  
65
66 protected:
67   virtual void                   startOperation();
68   virtual void                   selectionDone();
69   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
70   virtual bool                   isValid( SUIT_Operation* ) const;
71
72 protected slots:
73   virtual bool                   onApply();
74   void                           onCreateHyp( const int, const int );
75   void                           onEditHyp( const int, const int );
76   void                           onHypoSet( const QString& );
77   void                           onGeomSelectionByMesh( bool );
78   void                           onPublishShapeByMeshDlg( SUIT_Operation* );
79   void                           onCloseShapeByMeshDlg( SUIT_Operation* );
80   void                           onAlgoSelected( const int, const int = -1 );
81   void                           processSet();
82   void                           onHypoCreated( int );
83   void                           onHypoEdited( int );
84
85 private:
86   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
87
88   bool                           isValid( QString& ) const;
89   void                           availableHyps( const int, 
90                                                 const int,
91                                                 QStringList&,
92                                                 THypDataList&,
93                                                 HypothesisData* = 0 ) const;
94   static void                    existingHyps( const int, 
95                                                const int, 
96                                                _PTR(SObject),
97                                                QStringList&, 
98                                                THypList&,
99                                                HypothesisData* = 0 );
100   HypothesisData*                hypData( const int,
101                                           const int,
102                                           const int ); // access to myAvailableHypData
103
104   void                           createHypothesis( const int, const int,
105                                                    const QString& );
106
107   bool                           createMesh( QString& );
108   bool                           createSubMesh( QString& );
109   bool                           editMeshOrSubMesh( QString& );
110
111   int                            currentHyp( const int, const int ) const;
112   bool                           isAccessibleDim( const int ) const;
113   void                           setCurrentHyp( const int, const int, const int );
114   void                           setDefaultName() const;
115   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
116   void                           readMesh();
117   QString                        name( _PTR(SObject) ) const;
118   int                            find( const SMESH::SMESH_Hypothesis_var&,
119                                        const THypList& ) const;
120   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
121                                                           const QString& ) const;
122   bool                           isSubshapeOk() const;
123   char*                          isSubmeshIgnored() const;
124   _PTR(SObject)                  getSubmeshByGeom() const;
125   void                           selectObject( _PTR(SObject) ) const;
126
127 private:
128   SMESHGUI_MeshDlg*              myDlg;
129   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
130   bool                           myToCreate;
131   bool                           myIsMesh;
132   bool                           myIsOnGeometry; //!< TRUE if edited mesh accotiated with geometrical object
133
134   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
135   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
136                                                  //   edited mesh/sub-mesh
137
138   // hypdata corresponding to hypotheses present in myDlg
139   THypDataList                   myAvailableHypData[4][NbHypTypes];
140
141   bool                           myIgnoreAlgoSelection;
142   HypothesesSet* myHypoSet;
143   int myDim, myType;
144 };
145
146 #endif // SMESHGUI_MESHOP_H