Salome HOME
Bug 0019389: Impossible to create a group with a selection in another group.
[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 //
22 //
23 //  File   : SMESHGUI_GroupDlg.h
24 //  Author : Natalia KOPNOVA
25 //  Module : SMESH
26 //  $Header$
27
28 #ifndef DIALOGBOX_GROUP_H
29 #define DIALOGBOX_GROUP_H
30
31 #include "SMESH_SMESHGUI.hxx"
32
33 #include "LightApp_SelectionMgr.h"
34 //#include "SMESH_TypeFilter.hxx"
35 #include "SUIT_SelectionFilter.h"
36
37 // QT Includes
38 #include <qdialog.h>
39 #include <qvaluelist.h>
40
41 // IDL Headers
42 #include <SALOMEconfig.h>
43 #include CORBA_SERVER_HEADER(SMESH_Mesh)
44 #include CORBA_SERVER_HEADER(SMESH_Group)
45
46 class QLineEdit;
47 class QButtonGroup;
48 class QGroupBox;
49 class QListBox;
50 class QPopupMenu;
51 class QPushButton;
52 class QToolButton;
53 class QCheckBox;
54 class QWidgetStack;
55 class QtxIntSpinBox;
56 class SMESHGUI;
57 class SMESH_Actor;
58 class SMESHGUI_FilterDlg;
59 class SMESHGUI_ShapeByMeshOp;
60 class SUIT_Operation;
61 class SVTK_Selector;
62 class SVTK_ViewWindow;
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                        const char* name = 0, 
75                        SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(), 
76                        bool modal = FALSE, WFlags fl = 0 );
77     SMESHGUI_GroupDlg( SMESHGUI*,
78                        const char* name, 
79                        SMESH::SMESH_GroupBase_ptr theGroup,
80                        bool modal = FALSE, WFlags fl = 0 );
81     ~SMESHGUI_GroupDlg();
82
83     static QString GetDefaultName(const QString& theOperation);
84
85 public slots:
86
87     void onAdd();
88     void onRemove();
89
90
91 private slots:
92
93     void onTypeChanged(int id);
94     void onGrpTypeChanged(int id);
95
96     void onOK();
97     void onClose();
98     bool onApply();
99     void onHelp();
100     void onDeactivate();
101
102     void onListSelectionChanged();
103     void onObjectSelectionChanged();
104
105     void onSelectSubMesh(bool on);
106     void onSelectGroup(bool on);
107     void onSelectGeomGroup(bool on);
108     void setCurrentSelection();
109
110     void setFilters();
111     void onSort();
112
113     void onNameChanged(const QString& text);
114     void onFilterAccepted();
115
116     void onSelectColor();
117
118     void onGeomPopup( int );
119     void onGeomSelectionButton( bool );
120
121     void onPublishShapeByMeshDlg(SUIT_Operation*);
122     void onCloseShapeByMeshDlg(SUIT_Operation*);
123
124 private:
125     void initDialog(bool create);
126     void init(SMESH::SMESH_Mesh_ptr theMesh);
127     void init(SMESH::SMESH_GroupBase_ptr theGroup);
128     void closeEvent(QCloseEvent* e);
129     void enterEvent (QEvent*);
130     void hideEvent (QHideEvent*);                          /* ESC key */
131     void keyPressEvent(QKeyEvent*);
132     void setSelectionMode(int theMode);
133     void updateButtons();
134     void updateGeomPopup();
135     bool SetAppropriateActor();
136     void setShowEntityMode();
137     void restoreShowEntityMode();
138
139     void                          setGroupColor( const SALOMEDS::Color& );
140     SALOMEDS::Color               getGroupColor() const;
141
142     void                          setGroupQColor( const QColor& );
143     QColor                        getGroupQColor() const;
144
145     void                          setDefaultGroupColor();
146
147     SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
148     LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
149     SMESH_Actor*                  myActor;                 /* Current mesh actor */
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     QWidgetStack*                 myWGStack;
166     QListBox*                     myElements;
167     QPushButton*                  myFilter;
168
169     QCheckBox*                    mySelectSubMesh;
170     QPushButton*                  mySubMeshBtn;
171     QLineEdit*                    mySubMeshLine;
172
173     QCheckBox*                    mySelectGroup;
174     QPushButton*                  myGroupBtn;
175     QLineEdit*                    myGroupLine;
176
177     QPushButton*                  myColorBtn;
178
179     QCheckBox*                    mySelectGeomGroup;
180     QToolButton*                  myGeomGroupBtn;
181     QLineEdit*                    myGeomGroupLine;
182     QPopupMenu*                   myGeomPopup;
183
184     SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
185
186     SMESH::SMESH_Mesh_var         myMesh;
187     SMESH::SMESH_Group_var        myGroup;
188     SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
189     QValueList<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
208 #endif // DIALOGBOX_GROUP_H