Salome HOME
Porting SMESH module to Qt 4
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.h
1 // SMESH SMESHGUI : GUI for SMESH component
2 //
3 // Copyright (C) 2003  CEA
4 // 
5 // This library is free software; you can redistribute it and/or 
6 // modify it under the terms of the GNU Lesser General Public 
7 // License as published by the Free Software Foundation; either 
8 // version 2.1 of the License. 
9 // 
10 // This library is distributed in the hope that it will be useful, 
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 // Lesser General Public License for more details. 
14 // 
15 // You should have received a copy of the GNU Lesser General Public 
16 // License along with this library; if not, write to the Free Software 
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 // File   : SMESHGUI_GroupDlg.h
22 // Author : Natalia KOPNOVA, Open CASCADE S.A.S.
23 //
24
25 #ifndef SMESHGUI_GROUPDLG_H
26 #define SMESHGUI_GROUPDLG_H
27
28 // SMESH includes
29 #include "SMESH_SMESHGUI.hxx"
30
31 // Qt includes
32 #include <QDialog>
33 #include <QList>
34 #include <QMap>
35
36 // IDL includes
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Mesh)
39 #include CORBA_SERVER_HEADER(SMESH_Group)
40
41 class QLineEdit;
42 class QButtonGroup;
43 class QListWidget;
44 class QMenu;
45 class QPushButton;
46 class QToolButton;
47 class QCheckBox;
48 class QStackedWidget;
49 class QAction;
50 class SMESHGUI;
51 class SMESH_Actor;
52 class SMESHGUI_FilterDlg;
53 class SMESHGUI_ShapeByMeshOp;
54 class QtxColorButton;
55 class SUIT_Operation;
56 class SVTK_Selector;
57 class SUIT_SelectionFilter;
58 class LightApp_SelectionMgr;
59
60 //=================================================================================
61 // class    : SMESHGUI_GroupDlg
62 // purpose  :
63 //=================================================================================
64 class SMESHGUI_EXPORT SMESHGUI_GroupDlg : public QDialog
65
66   Q_OBJECT
67
68 public:
69   SMESHGUI_GroupDlg( SMESHGUI*,
70                      SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
71   SMESHGUI_GroupDlg( SMESHGUI*,
72                      SMESH::SMESH_GroupBase_ptr );
73   ~SMESHGUI_GroupDlg();
74   
75   static QString                GetDefaultName( const QString& );
76   
77 public slots:
78   void onAdd();
79   void onRemove();
80
81 private slots:
82   void                          onTypeChanged( int );
83   void                          onGrpTypeChanged( int );
84   
85   void                          onOK();
86   void                          onClose();
87   bool                          onApply();
88   void                          onHelp();
89   void                          onDeactivate();
90   
91   void                          onListSelectionChanged();
92   void                          onObjectSelectionChanged();
93   
94   void                          onSelectSubMesh( bool );
95   void                          onSelectGroup( bool );
96   void                          onSelectGeomGroup( bool );
97   void                          setCurrentSelection();
98   
99   void                          setFilters();
100   void                          onSort();
101   
102   void                          onNameChanged( const QString& );
103   void                          onFilterAccepted();
104   
105   void                          onGeomPopup( QAction* );
106   void                          onGeomSelectionButton( bool );
107   
108   void                          onPublishShapeByMeshDlg( SUIT_Operation* );
109   void                          onCloseShapeByMeshDlg( SUIT_Operation* );
110
111 private:
112   void                          initDialog( bool );
113   void                          init( SMESH::SMESH_Mesh_ptr );
114   void                          init( SMESH::SMESH_GroupBase_ptr );
115   void                          closeEvent( QCloseEvent* );
116   void                          enterEvent( QEvent* );
117   void                          hideEvent( QHideEvent* );   /* ESC key */
118   void                          keyPressEvent( QKeyEvent* );
119   void                          setSelectionMode( int );
120   void                          updateButtons();
121   void                          updateGeomPopup();
122   
123   void                          setGroupColor( const SALOMEDS::Color& );
124   SALOMEDS::Color               getGroupColor() const;
125   
126   void                          setGroupQColor( const QColor& );
127   QColor                        getGroupQColor() const;
128   
129   void                          setDefaultGroupColor();
130   
131   SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
132   LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
133   SMESH_Actor*                  myActor;                 /* Current mesh actor */
134   int                           myGrpTypeId;             /* Current group type id : standalone or group on geometry */
135   int                           myTypeId;                /* Current type id = radio button id */
136   QLineEdit*                    myCurrentLineEdit;       /* Current  LineEdit */
137   SVTK_Selector*                mySelector;
138   
139   QPushButton*                  myMeshGroupBtn;
140   QLineEdit*                    myMeshGroupLine;
141   
142   QButtonGroup*                 myTypeGroup;
143   QLineEdit*                    myName;
144   QString                       myOldName;
145   
146   QButtonGroup*                 myGrpTypeGroup;
147   
148   QStackedWidget*               myWGStack;
149   QListWidget*                  myElements;
150   QPushButton*                  myFilter;
151   
152   QCheckBox*                    mySelectSubMesh;
153   QPushButton*                  mySubMeshBtn;
154   QLineEdit*                    mySubMeshLine;
155   
156   QCheckBox*                    mySelectGroup;
157   QPushButton*                  myGroupBtn;
158   QLineEdit*                    myGroupLine;
159   
160   QtxColorButton*               myColorBtn;
161   
162   QCheckBox*                    mySelectGeomGroup;
163   QToolButton*                  myGeomGroupBtn;
164   QLineEdit*                    myGeomGroupLine;
165   QMenu*                        myGeomPopup;
166
167   QPushButton*                  myOKBtn;
168   QPushButton*                  myApplyBtn;
169   QPushButton*                  myCloseBtn;
170   QPushButton*                  myHelpBtn;
171   
172   SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
173   
174   SMESH::SMESH_Mesh_var         myMesh;
175   SMESH::SMESH_Group_var        myGroup;
176   SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
177   QList<int>                    myIdList;
178   GEOM::ListOfGO_var            myGeomObjects;
179   
180   int                           mySelectionMode;
181   //Handle(SMESH_TypeFilter)      myMeshFilter;
182   //Handle(SMESH_TypeFilter)      mySubMeshFilter;
183   //Handle(SMESH_TypeFilter)      myGroupFilter;
184   SUIT_SelectionFilter*         myMeshFilter;
185   SUIT_SelectionFilter*         mySubMeshFilter;
186   SUIT_SelectionFilter*         myGroupFilter;
187   SUIT_SelectionFilter*         myGeomFilter;
188   
189   SMESHGUI_FilterDlg*           myFilterDlg;
190   
191   bool                          myCreate, myIsBusy;
192   
193   QString                       myHelpFileName;
194   
195   QMap<QAction*, int>           myActions;
196 };
197
198 #endif // SMESHGUI_GROUPDLG_H