Salome HOME
Merge branch 'master' into gni/adaptation
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AdaptDlg.h
1 // Copyright (C) 2011-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // SMESH SMESHGUI : GUI for the adaptation in the SMESH component
21 // File   : SMESHGUI_AdaptDlg.h
22 // Author : GĂ©rald NICOLAS, EDF
23 //
24 #ifndef SMESHGUI_ADAPTDLG_H
25 #define SMESHGUI_ADAPTDLG_H
26
27 // SMESH includes
28 #include "SMESH_SMESHGUI.hxx"
29
30 // Qt includes
31 #include <QDialog>
32 #include <QList>
33 #include <QMap>
34
35 // IDL includes
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SMESH_Mesh)
38 #include CORBA_SERVER_HEADER(SMESH_Group)
39 #include CORBA_SERVER_HEADER(SMESH_Filter)
40
41 class QGroupBox;
42 class QLabel;
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 class SMESH_LogicalFilter;
62
63 //=================================================================================
64 // class    : SMESHGUI_AdaptDlg
65 // purpose  :
66 //=================================================================================
67 class SMESHGUI_EXPORT SMESHGUI_AdaptDlg : public QDialog
68 {
69   Q_OBJECT
70
71 public:
72   SMESHGUI_AdaptDlg( SMESHGUI*,
73                      int theCommandID,
74                      SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
75   ~SMESHGUI_AdaptDlg();
76   
77   static QString                GetDefaultName( const QString& );
78   
79 public slots:
80   void onAdd();
81   void onRemove();
82
83 protected slots:
84   virtual void                  reject();
85
86 private slots:
87   void                          onTypeChanged( int );
88   void                          onGrpTypeChanged( int );
89   void                          onColorChanged( QColor );
90   
91   void                          onOK();
92   bool                          onApply();
93   void                          onHelp();
94   void                          onDeactivate();
95   void                          onVisibilityChanged();
96   
97   void                          onListSelectionChanged();
98   void                          onObjectSelectionChanged();
99   
100   void                          onSelectAll();
101   void                          onSelectSubMesh( bool );
102   void                          onSelectGroup( bool );
103   void                          onSelectGeomGroup( bool );
104   void                          setCurrentSelection();
105   
106   void                          setFilters();
107   void                          onSort();
108   
109   void                          onNameChanged( const QString& );
110   void                          onFilterAccepted();
111   
112   void                          onGeomPopup( QAction* );
113   void                          onGeomSelectionButton( bool );
114   
115   void                          onPublishShapeByMeshDlg( SUIT_Operation* );
116   void                          onCloseShapeByMeshDlg( SUIT_Operation* );
117
118   void                          onOpenView();
119   void                          onCloseView();
120
121 private:
122   void                          initDialog( bool );
123   void                          init( SMESH::SMESH_Mesh_ptr );
124   void                          init( SMESH::SMESH_GroupBase_ptr );
125   void                          enterEvent( QEvent* );
126   void                          keyPressEvent( QKeyEvent* );
127   void                          setSelectionMode( int );
128   void                          updateButtons();
129   void                          updateGeomPopup();
130   bool                          SetAppropriateActor();
131   void                          setShowEntityMode();
132   void                          restoreShowEntityMode();
133
134   bool                          IsActorVisible( SMESH_Actor* );
135   
136   void                          setGroupColor( const SALOMEDS::Color& );
137   SALOMEDS::Color               getGroupColor() const;
138   
139   void                          setGroupQColor( const QColor& );
140   QColor                        getGroupQColor() const;
141   void                          setDefaultName() const;
142   void                          setDefaultGroupColor();
143
144   void                          setIsApplyAndClose( const bool theFlag );
145   bool                          isApplyAndClose() const;
146
147  private:
148
149   SMESHGUI*                     mySMESHGUI;              /* Current SMESHGUI object */
150   LightApp_SelectionMgr*        mySelectionMgr;          /* User shape selection */
151   int                           myGrpTypeId;             /* Current group type id : standalone or group on geometry */
152   int                           myTypeId;                /* Current type id = radio button id */
153   int                           myStoredShownEntity;     /* Store ShowEntity mode of myMesh */
154   QLineEdit*                    myCurrentLineEdit;       /* Current  LineEdit */
155   SVTK_Selector*                mySelector;
156   
157   QPushButton*                  myMeshGroupBtn;
158   QLineEdit*                    myMeshGroupLine;
159   
160   QButtonGroup*                 myTypeGroup;
161   QLineEdit*                    myName;
162   QString                       myOldName;
163   
164   QButtonGroup*                 myGrpTypeGroup;
165   
166   QStackedWidget*               myWGStack;
167   QCheckBox*                    mySelectAll;
168   QCheckBox*                    myAllowElemsModif;
169   QLabel*                       myElementsLab;
170   QListWidget*                  myElements;
171   QPushButton*                  myFilterBtn;
172   QPushButton*                  myAddBtn;
173   QPushButton*                  myRemoveBtn;
174   QPushButton*                  mySortBtn;
175   
176   QGroupBox*                    mySelectBox;
177   QCheckBox*                    mySelectSubMesh;
178   QPushButton*                  mySubMeshBtn;
179   QLineEdit*                    mySubMeshLine;
180   QCheckBox*                    mySelectGroup;
181   QPushButton*                  myGroupBtn;
182   QLineEdit*                    myGroupLine;
183   
184   QtxColorButton*               myColorBtn;
185   
186   QCheckBox*                    mySelectGeomGroup;
187   QToolButton*                  myGeomGroupBtn;
188   QLineEdit*                    myGeomGroupLine;
189   QMenu*                        myGeomPopup;
190
191   QPushButton*                  myOKBtn;
192   QPushButton*                  myApplyBtn;
193   QPushButton*                  myCloseBtn;
194   QPushButton*                  myHelpBtn;
195   
196   SMESHGUI_ShapeByMeshOp*       myShapeByMeshOp;
197   
198   SMESH::SMESH_Mesh_var         myMesh;
199   QList<SMESH_Actor*>           myActorsList;
200   SMESH::SMESH_Group_var        myGroup;
201   SMESH::SMESH_GroupOnGeom_var  myGroupOnGeom;
202   SMESH::SMESH_GroupOnFilter_var myGroupOnFilter;
203   SMESH::Filter_var             myFilter;
204   QList<int>                    myIdList;
205   GEOM::ListOfGO_var            myGeomObjects;
206   
207   int                           mySelectionMode;
208   //Handle(SMESH_TypeFilter)      myMeshFilter;
209   //Handle(SMESH_TypeFilter)      mySubMeshFilter;
210   //Handle(SMESH_TypeFilter)      myGroupFilter;
211   SUIT_SelectionFilter*         myMeshFilter;
212   SMESH_LogicalFilter*          mySubMeshFilter;
213   SMESH_LogicalFilter*          myGroupFilter;
214   SUIT_SelectionFilter*         myGeomFilter;
215   
216   SMESHGUI_FilterDlg*           myFilterDlg;
217   
218   bool                          myCreate, myIsBusy;
219   
220   QString                       myHelpFileName;
221   
222   QMap<QAction*, int>           myActions;
223
224   bool                          myNameChanged; //added by skl for IPAL19574
225   int                           myNbChangesOfContents; // nb add's and remove's
226
227   QString                       myObjectToSelect;
228   bool                          myIsApplyAndClose;
229 };
230
231 #endif // SMESHGUI_ADAPTDLG_H