Salome HOME
Update copyright
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.h
1 // Copyright (C) 2007-2011  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   void                          setIsApplyAndClose( const bool theFlag );
146   bool                          isApplyAndClose() const;
147   
148   SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
149   LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
150   int                           myGrpTypeId;             /* Current group type id : standalone or group on geometry */
151   int                           myTypeId;                /* Current type id = radio button id */
152   int                           myStoredShownEntity;     /* Store ShowEntity mode of myMesh */
153   QLineEdit*                    myCurrentLineEdit;       /* Current  LineEdit */
154   SVTK_Selector*                mySelector;
155   
156   QPushButton*                  myMeshGroupBtn;
157   QLineEdit*                    myMeshGroupLine;
158   
159   QButtonGroup*                 myTypeGroup;
160   QLineEdit*                    myName;
161   QString                       myOldName;
162   
163   QButtonGroup*                 myGrpTypeGroup;
164   
165   QStackedWidget*               myWGStack;
166   QCheckBox*                    mySelectAll;
167   QLabel*                       myElementsLab;
168   QListWidget*                  myElements;
169   QPushButton*                  myFilter;
170   QPushButton*                  myAddBtn;
171   QPushButton*                  myRemoveBtn;
172   QPushButton*                  mySortBtn;
173   
174   QGroupBox*                    mySelectBox;
175   QCheckBox*                    mySelectSubMesh;
176   QPushButton*                  mySubMeshBtn;
177   QLineEdit*                    mySubMeshLine;
178   QCheckBox*                    mySelectGroup;
179   QPushButton*                  myGroupBtn;
180   QLineEdit*                    myGroupLine;
181   
182   QtxColorButton*               myColorBtn;
183   
184   QCheckBox*                    mySelectGeomGroup;
185   QToolButton*                  myGeomGroupBtn;
186   QLineEdit*                    myGeomGroupLine;
187   QMenu*                        myGeomPopup;
188
189   QPushButton*                  myOKBtn;
190   QPushButton*                  myApplyBtn;
191   QPushButton*                  myCloseBtn;
192   QPushButton*                  myHelpBtn;
193   
194   SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
195   
196   SMESH::SMESH_Mesh_var         myMesh;
197   QList<SMESH_Actor*>           myActorsList;
198   SMESH::SMESH_Group_var        myGroup;
199   SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
200   QList<int>                    myIdList;
201   GEOM::ListOfGO_var            myGeomObjects;
202   
203   int                           mySelectionMode;
204   //Handle(SMESH_TypeFilter)      myMeshFilter;
205   //Handle(SMESH_TypeFilter)      mySubMeshFilter;
206   //Handle(SMESH_TypeFilter)      myGroupFilter;
207   SUIT_SelectionFilter*         myMeshFilter;
208   SUIT_SelectionFilter*         mySubMeshFilter;
209   SUIT_SelectionFilter*         myGroupFilter;
210   SUIT_SelectionFilter*         myGeomFilter;
211   
212   SMESHGUI_FilterDlg*           myFilterDlg;
213   
214   bool                          myCreate, myIsBusy;
215   
216   QString                       myHelpFileName;
217   
218   QMap<QAction*, int>           myActions;
219
220   bool                          myNameChanged; //added by skl for IPAL19574
221
222   QString                       myObjectToSelect;
223   bool                          myIsApplyAndClose;
224 };
225
226 #endif // SMESHGUI_GROUPDLG_H