Salome HOME
Merge from BR_phase16 branch (09/12/09)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.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_GroupDlg.h
24 // Author : Natalia KOPNOVA, Open CASCADE S.A.S.
25 //
26 #ifndef SMESHGUI_GROUPDLG_H
27 #define SMESHGUI_GROUPDLG_H
28
29 // SMESH includes
30 #include "SMESH_SMESHGUI.hxx"
31
32 // Qt includes
33 #include <QDialog>
34 #include <QList>
35 #include <QMap>
36
37 // IDL includes
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SMESH_Mesh)
40 #include CORBA_SERVER_HEADER(SMESH_Group)
41
42 class QLineEdit;
43 class QButtonGroup;
44 class QListWidget;
45 class QMenu;
46 class QPushButton;
47 class QToolButton;
48 class QCheckBox;
49 class QStackedWidget;
50 class QAction;
51 class SMESHGUI;
52 class SMESH_Actor;
53 class SMESHGUI_FilterDlg;
54 class SMESHGUI_ShapeByMeshOp;
55 class QtxColorButton;
56 class SUIT_Operation;
57 class SVTK_Selector;
58 class SUIT_SelectionFilter;
59 class LightApp_SelectionMgr;
60
61 //=================================================================================
62 // class    : SMESHGUI_GroupDlg
63 // purpose  :
64 //=================================================================================
65 class SMESHGUI_EXPORT SMESHGUI_GroupDlg : public QDialog
66
67   Q_OBJECT
68
69 public:
70   SMESHGUI_GroupDlg( SMESHGUI*,
71                      SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
72   SMESHGUI_GroupDlg( SMESHGUI*,
73                      SMESH::SMESH_GroupBase_ptr,
74                      const bool theIsConvert = false );
75   ~SMESHGUI_GroupDlg();
76   
77   static QString                GetDefaultName( const QString& );
78   
79 public slots:
80   void onAdd();
81   void onRemove();
82
83 private slots:
84   void                          onTypeChanged( int );
85   void                          onGrpTypeChanged( int );
86   void                          onColorChanged( QColor );
87   
88   void                          onOK();
89   void                          onClose();
90   bool                          onApply();
91   void                          onHelp();
92   void                          onDeactivate();
93   void                          onVisibilityChanged();
94   
95   void                          onListSelectionChanged();
96   void                          onObjectSelectionChanged();
97   
98   void                          onSelectSubMesh( bool );
99   void                          onSelectGroup( bool );
100   void                          onSelectGeomGroup( bool );
101   void                          setCurrentSelection();
102   
103   void                          setFilters();
104   void                          onSort();
105   
106   void                          onNameChanged( const QString& );
107   void                          onFilterAccepted();
108   
109   void                          onGeomPopup( QAction* );
110   void                          onGeomSelectionButton( bool );
111   
112   void                          onPublishShapeByMeshDlg( SUIT_Operation* );
113   void                          onCloseShapeByMeshDlg( SUIT_Operation* );
114
115 private:
116   void                          initDialog( bool );
117   void                          init( SMESH::SMESH_Mesh_ptr );
118   void                          init( SMESH::SMESH_GroupBase_ptr,
119                                       const bool theIsConvert = false );
120   void                          closeEvent( QCloseEvent* );
121   void                          enterEvent( QEvent* );
122   void                          hideEvent( QHideEvent* );   /* ESC key */
123   void                          keyPressEvent( QKeyEvent* );
124   void                          setSelectionMode( int );
125   void                          updateButtons();
126   void                          updateGeomPopup();
127   bool                          SetAppropriateActor();
128   void                          setShowEntityMode();
129   void                          restoreShowEntityMode();
130
131   bool                          IsActorVisible( SMESH_Actor* );
132   
133   void                          setGroupColor( const SALOMEDS::Color& );
134   SALOMEDS::Color               getGroupColor() const;
135   
136   void                          setGroupQColor( const QColor& );
137   QColor                        getGroupQColor() const;
138   
139   void                          setDefaultGroupColor();
140   
141   SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
142   LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
143   int                           myGrpTypeId;             /* Current group type id : standalone or group on geometry */
144   int                           myTypeId;                /* Current type id = radio button id */
145   int                           myStoredShownEntity;     /* Store ShowEntity mode of myMesh */
146   QLineEdit*                    myCurrentLineEdit;       /* Current  LineEdit */
147   SVTK_Selector*                mySelector;
148   
149   QPushButton*                  myMeshGroupBtn;
150   QLineEdit*                    myMeshGroupLine;
151   
152   QButtonGroup*                 myTypeGroup;
153   QLineEdit*                    myName;
154   QString                       myOldName;
155   
156   QButtonGroup*                 myGrpTypeGroup;
157   
158   QStackedWidget*               myWGStack;
159   QListWidget*                  myElements;
160   QPushButton*                  myFilter;
161   
162   QCheckBox*                    mySelectSubMesh;
163   QPushButton*                  mySubMeshBtn;
164   QLineEdit*                    mySubMeshLine;
165   
166   QCheckBox*                    mySelectGroup;
167   QPushButton*                  myGroupBtn;
168   QLineEdit*                    myGroupLine;
169   
170   QtxColorButton*               myColorBtn;
171   
172   QCheckBox*                    mySelectGeomGroup;
173   QToolButton*                  myGeomGroupBtn;
174   QLineEdit*                    myGeomGroupLine;
175   QMenu*                        myGeomPopup;
176
177   QPushButton*                  myOKBtn;
178   QPushButton*                  myApplyBtn;
179   QPushButton*                  myCloseBtn;
180   QPushButton*                  myHelpBtn;
181   
182   SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
183   
184   SMESH::SMESH_Mesh_var         myMesh;
185   QList<SMESH_Actor*>           myActorsList;
186   SMESH::SMESH_Group_var        myGroup;
187   SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
188   QList<int>                    myIdList;
189   GEOM::ListOfGO_var            myGeomObjects;
190   
191   int                           mySelectionMode;
192   //Handle(SMESH_TypeFilter)      myMeshFilter;
193   //Handle(SMESH_TypeFilter)      mySubMeshFilter;
194   //Handle(SMESH_TypeFilter)      myGroupFilter;
195   SUIT_SelectionFilter*         myMeshFilter;
196   SUIT_SelectionFilter*         mySubMeshFilter;
197   SUIT_SelectionFilter*         myGroupFilter;
198   SUIT_SelectionFilter*         myGeomFilter;
199   
200   SMESHGUI_FilterDlg*           myFilterDlg;
201   
202   bool                          myCreate, myIsBusy;
203   
204   QString                       myHelpFileName;
205   
206   QMap<QAction*, int>           myActions;
207
208   bool                          myNameChanged; //added by skl for IPAL19574
209 };
210
211 #endif // SMESHGUI_GROUPDLG_H