]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_MeshOp.h
Salome HOME
c658fb74e33568594bcfa6fd53b3784d597ab978
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 /**
21 *  SMESH SMESHGUI
22 *
23 *  Copyright (C) 2005  CEA/DEN, EDF R&D
24 *
25 *
26 *
27 *  File   : SMESHGUI_MeshOp.h
28 *  Author : Sergey LITONIN
29 *  Module : SMESHGUI
30 */
31
32 #ifndef SMESHGUI_MeshOp_H
33 #define SMESHGUI_MeshOp_H
34
35 #include "SMESH_SMESHGUI.hxx"
36
37 #include "SMESHGUI_SelectionOp.h"
38
39 #include <SALOMEconfig.h>
40 #include CORBA_CLIENT_HEADER(GEOM_Gen)
41 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
42
43 #include <qstringlist.h>
44
45 class SMESHGUI_MeshDlg;
46 class SMESHGUI_ShapeByMeshOp;
47 class HypothesisData;
48
49 /*!
50  * \brief Operation for mech creation or editing
51  *
52  *  This operation is used for mech creation or editing. 
53 */
54 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
55
56   Q_OBJECT
57       
58 public:
59
60   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
61
62   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
63   typedef QValueList< THypItem > THypList;
64
65   typedef int THypType;
66   typedef QMap< THypType, THypList > TType2HypList;
67
68   typedef int THypDim;
69   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
70
71   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
72   virtual ~SMESHGUI_MeshOp();
73   
74   virtual LightApp_Dialog*       dlg() const;  
75
76 protected:
77   virtual void                   startOperation();
78   virtual void                   selectionDone();
79   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
80   virtual bool                   isValid( SUIT_Operation* ) const;
81
82 protected slots:
83   virtual bool                   onApply();
84   void                           onCreateHyp( const int theHypType, const int theIndex );
85   void                           onEditHyp( const int theHypType, const int theIndex );
86   void                           onHypoSet( const QString& theSetName );
87   void                           onGeomSelectionByMesh( bool );
88   void                           onPublishShapeByMeshDlg(SUIT_Operation*);
89   void                           onCloseShapeByMeshDlg(SUIT_Operation*);
90   void                           onAlgoSelected( const int theIndex,
91                                                  const int theDim = -1);
92
93 private:
94
95   typedef QValueList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
96
97   bool                           isValid( QString& ) const;
98   void                           availableHyps( const int       theDim, 
99                                                 const int       theHypType,
100                                                 QStringList&    theHyps,
101                                                 THypDataList&   theDataList,
102                                                 HypothesisData* theAlgoData = 0 ) const;
103   void                           existingHyps( const int     theDim, 
104                                                const int     theHypType, 
105                                                _PTR(SObject) theFather,
106                                                QStringList&  theHyps, 
107                                                THypList& theHypList,
108                                                HypothesisData* theAlgoData = 0);
109   HypothesisData*                hypData( const int theDim,
110                                           const int theHypType,
111                                           const int theIndex); // access to myAvailableHypData
112
113   void                           createHypothesis(const int theDim, const int theType,
114                                                   const QString& theTypeName);
115
116   bool                           createMesh( QString& );
117   bool                           createSubMesh( QString& );
118   bool                           editMeshOrSubMesh( QString& );
119
120   int                            currentHyp( const int, const int ) const;
121   bool                           isAccessibleDim( const int ) const;
122   void                           setCurrentHyp( const int, const int, const int );
123   void                           setDefaultName() const;
124   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
125   void                           readMesh();
126   QString                        name( _PTR(SObject) ) const;
127   int                            find( const SMESH::SMESH_Hypothesis_var&,
128                                        const THypList& theHypList) const;
129   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
130                                                           const QString& aServerLib ) const;
131   bool                           isSubshapeOk() const;
132   _PTR(SObject)                  getSubmeshByGeom() const;
133   void                           selectObject( _PTR(SObject) ) const;
134
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
142   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
143   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
144                                                  //   edited mesh/sub-mesh
145
146   // hypdata corresponding to hypotheses present in myDlg
147   THypDataList                   myAvailableHypData[4][NbHypTypes];
148
149   bool                           myIgnoreAlgoSelection;
150 };
151
152 #endif