Salome HOME
Dialogs were divided to "operation and dialog"
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SelectionOp.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 //
20 //
21 //
22 //  File   : SMESHGUI_SelectionOp.h
23 //  Author : Alexander SOLOVYOV
24 //  Module : SMESH
25
26
27 #ifndef SMESHGUI_SelectionOp_H
28 #define SMESHGUI_SelectionOp_H
29
30 #include <SMESHGUI_Operation.h>
31
32 /*
33   Class       : SMESHGUI_SelectionOp
34   Description : Base operation for all operations using object selection in viewer or objectbrowser
35                 through common widgets created by SalomeApp_Dialog::createObject
36 */
37
38 class SUIT_SelectionFilter;
39
40 class SMESHGUI_SelectionOp : public SMESHGUI_Operation
41
42   Q_OBJECT
43
44 public:
45   SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
46   virtual ~SMESHGUI_SelectionOp();
47   
48 protected:
49   virtual void                  startOperation();
50   virtual void                  commitOperation();
51   virtual void                  abortOperation();  
52   
53   virtual void                  selectionDone();
54
55   //! sets the dialog widgets to state just after operation start
56   virtual void                  initDialog();
57
58   /*! Creates filter being used when certain object selection widget is active
59    *  If no filter must be used, then function must return 0
60    *  if id is negative, then function must return filter for common using independently of active widget
61    */
62   virtual SUIT_SelectionFilter* createFilter( const int ) const;
63
64   //! Remove only filters set by this operation (they are in map myFilters )
65   void removeCustomFilters() const;
66
67 protected slots:
68   //! Installs filter corresponding to certain object selection widget
69   virtual void onActivateObject( int );
70
71   //! Removes filter corresponding to certain object selection widget
72   virtual void onDeactivateObject( int );
73
74   /*!
75     *  Empty default implementation. In successors it may be used for more advanced selection checking.
76     *  This slot is connected to signal when the selection changed in some object selection widget
77   */
78   virtual void onSelectionChanged( int );
79
80 private:
81   typedef QMap<int, SUIT_SelectionFilter*> Filters;
82   
83 private:
84   Filters         myFilters;
85   Selection_Mode  myDefSelectionMode, myOldSelectionMode;
86 };
87
88 #endif