Salome HOME
Merge from BR_V5_DEV 16Feb09
[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   
94   void                          onListSelectionChanged();
95   void                          onObjectSelectionChanged();
96   
97   void                          onSelectSubMesh( bool );
98   void                          onSelectGroup( bool );
99   void                          onSelectGeomGroup( bool );
100   void                          setCurrentSelection();
101   
102   void                          setFilters();
103   void                          onSort();
104   
105   void                          onNameChanged( const QString& );
106   void                          onFilterAccepted();
107   
108   void                          onGeomPopup( QAction* );
109   void                          onGeomSelectionButton( bool );
110   
111   void                          onPublishShapeByMeshDlg( SUIT_Operation* );
112   void                          onCloseShapeByMeshDlg( SUIT_Operation* );
113
114 private:
115   void                          initDialog( bool );
116   void                          init( SMESH::SMESH_Mesh_ptr );
117   void                          init( SMESH::SMESH_GroupBase_ptr,
118                                       const bool theIsConvert = false );
119   void                          closeEvent( QCloseEvent* );
120   void                          enterEvent( QEvent* );
121   void                          hideEvent( QHideEvent* );   /* ESC key */
122   void                          keyPressEvent( QKeyEvent* );
123   void                          setSelectionMode( int );
124   void                          updateButtons();
125   void                          updateGeomPopup();
126   bool                          SetAppropriateActor();
127   void                          setShowEntityMode();
128   void                          restoreShowEntityMode();
129   
130   void                          setGroupColor( const SALOMEDS::Color& );
131   SALOMEDS::Color               getGroupColor() const;
132   
133   void                          setGroupQColor( const QColor& );
134   QColor                        getGroupQColor() const;
135   
136   void                          setDefaultGroupColor();
137   
138   SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
139   LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
140   SMESH_Actor*                  myActor;                 /* Current mesh actor */
141   int                           myGrpTypeId;             /* Current group type id : standalone or group on geometry */
142   int                           myTypeId;                /* Current type id = radio button id */
143   int                           myStoredShownEntity;     /* Store ShowEntity mode of myMesh */
144   QLineEdit*                    myCurrentLineEdit;       /* Current  LineEdit */
145   SVTK_Selector*                mySelector;
146   
147   QPushButton*                  myMeshGroupBtn;
148   QLineEdit*                    myMeshGroupLine;
149   
150   QButtonGroup*                 myTypeGroup;
151   QLineEdit*                    myName;
152   QString                       myOldName;
153   
154   QButtonGroup*                 myGrpTypeGroup;
155   
156   QStackedWidget*               myWGStack;
157   QListWidget*                  myElements;
158   QPushButton*                  myFilter;
159   
160   QCheckBox*                    mySelectSubMesh;
161   QPushButton*                  mySubMeshBtn;
162   QLineEdit*                    mySubMeshLine;
163   
164   QCheckBox*                    mySelectGroup;
165   QPushButton*                  myGroupBtn;
166   QLineEdit*                    myGroupLine;
167   
168   QtxColorButton*               myColorBtn;
169   
170   QCheckBox*                    mySelectGeomGroup;
171   QToolButton*                  myGeomGroupBtn;
172   QLineEdit*                    myGeomGroupLine;
173   QMenu*                        myGeomPopup;
174
175   QPushButton*                  myOKBtn;
176   QPushButton*                  myApplyBtn;
177   QPushButton*                  myCloseBtn;
178   QPushButton*                  myHelpBtn;
179   
180   SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
181   
182   SMESH::SMESH_Mesh_var         myMesh;
183   SMESH::SMESH_Group_var        myGroup;
184   SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
185   QList<int>                    myIdList;
186   GEOM::ListOfGO_var            myGeomObjects;
187   
188   int                           mySelectionMode;
189   //Handle(SMESH_TypeFilter)      myMeshFilter;
190   //Handle(SMESH_TypeFilter)      mySubMeshFilter;
191   //Handle(SMESH_TypeFilter)      myGroupFilter;
192   SUIT_SelectionFilter*         myMeshFilter;
193   SUIT_SelectionFilter*         mySubMeshFilter;
194   SUIT_SelectionFilter*         myGroupFilter;
195   SUIT_SelectionFilter*         myGeomFilter;
196   
197   SMESHGUI_FilterDlg*           myFilterDlg;
198   
199   bool                          myCreate, myIsBusy;
200   
201   QString                       myHelpFileName;
202   
203   QMap<QAction*, int>           myActions;
204
205   bool                          myNameChanged; //added by skl for IPAL19574
206 };
207
208 #endif // SMESHGUI_GROUPDLG_H