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