Salome HOME
NPAL16812: Elements Info dialog is added. The size of dialog is modified.
[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 "SMESHGUI_SelectionOp.h"
36
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(GEOM_Gen)
39 #include CORBA_SERVER_HEADER(SMESH_Mesh)
40
41 #include <qstringlist.h>
42
43 class SMESHGUI_MeshDlg;
44 class SMESHGUI_ShapeByMeshOp;
45 class HypothesisData;
46
47 /*!
48  * \brief Operation for mech creation or editing
49  *
50  *  This operation is used for mech creation or editing. 
51 */
52 class SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
53
54   Q_OBJECT
55       
56 public:
57
58   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
59
60   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
61   typedef QValueList< THypItem > THypList;
62
63   typedef int THypType;
64   typedef QMap< THypType, THypList > TType2HypList;
65
66   typedef int THypDim;
67   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
68
69   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
70   virtual ~SMESHGUI_MeshOp();
71   
72   virtual LightApp_Dialog*       dlg() const;  
73
74 protected:
75   virtual void                   startOperation();
76   virtual void                   selectionDone();
77   virtual SUIT_SelectionFilter*  createFilter( const int ) const;
78   virtual bool                   isValid( SUIT_Operation* ) const;
79
80 protected slots:
81   virtual bool                   onApply();
82   void                           onCreateHyp( const int theHypType, const int theIndex );
83   void                           onEditHyp( const int theHypType, const int theIndex );
84   void                           onHypoSet( const QString& theSetName );
85   void                           onGeomSelectionByMesh( bool );
86   void                           onPublishShapeByMeshDlg(SUIT_Operation*);
87   void                           onCloseShapeByMeshDlg(SUIT_Operation*);
88   void                           onAlgoSelected( const int theIndex,
89                                                  const int theDim = -1);
90
91 private:
92
93   typedef QValueList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
94
95   bool                           isValid( QString& ) const;
96   void                           availableHyps( const int       theDim, 
97                                                 const int       theHypType,
98                                                 QStringList&    theHyps,
99                                                 THypDataList&   theDataList,
100                                                 HypothesisData* theAlgoData = 0 ) const;
101   void                           existingHyps( const int     theDim, 
102                                                const int     theHypType, 
103                                                _PTR(SObject) theFather,
104                                                QStringList&  theHyps, 
105                                                THypList& theHypList,
106                                                HypothesisData* theAlgoData = 0);
107   HypothesisData*                hypData( const int theDim,
108                                           const int theHypType,
109                                           const int theIndex); // access to myAvailableHypData
110
111   void                           createHypothesis(const int theDim, const int theType,
112                                                   const QString& theTypeName);
113
114   bool                           createMesh( QString& );
115   bool                           createSubMesh( QString& );
116   bool                           editMeshOrSubMesh( QString& );
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;
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& theHypList) const;
127   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
128                                                           const QString& aServerLib ) const;
129   bool                           isSubshapeOk() const;
130   _PTR(SObject)                  getSubmeshByGeom() const;
131   void                           selectObject( _PTR(SObject) ) const;
132
133 private:
134   SMESHGUI_MeshDlg*              myDlg;
135   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
136   bool                           myToCreate;
137   bool                           myIsMesh;
138
139   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
140   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
141                                                  //   edited mesh/sub-mesh
142
143   // hypdata corresponding to hypotheses present in myDlg
144   THypDataList                   myAvailableHypData[4][NbHypTypes];
145
146   bool                           myIgnoreAlgoSelection;
147 };
148
149 #endif