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