Salome HOME
d3d7bffd30b6cc7ca9a15407397792b4be2566cf
[modules/gui.git] / src / SUIT / SUIT_SelectionMgr.h
1 // Copyright (C) 2007-2023  CEA, EDF, 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, or (at your option) any later version.
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 #ifndef SUIT_SELECTIONMGR_H
24 #define SUIT_SELECTIONMGR_H
25
26 #include "SUIT_DataOwner.h"
27
28 #include <QList>
29 #include <QObject>
30
31 class SUIT_Selector;
32 class SUIT_SelectionFilter;
33
34 #ifdef WIN32
35 #pragma warning ( disable : 4251 )
36 #endif
37
38 class SUIT_EXPORT SUIT_SelectionMgr : public QObject
39 {
40   Q_OBJECT
41
42 public:
43   SUIT_SelectionMgr( const bool = true, QObject* = 0 );
44   virtual ~SUIT_SelectionMgr();
45
46   void            clearSelected();
47   virtual void    selected( SUIT_DataOwnerPtrList&, const QString& = QString(), const bool = false ) const;
48   virtual void    setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
49
50   void            selectors( QList<SUIT_Selector*>& ) const;
51   void            selectors( const QString&, QList<SUIT_Selector*>& ) const;
52
53
54   void            setEnabled( const bool, const QString& = QString() );
55
56
57   bool            hasSelectionMode( const int ) const;
58   void            selectionModes( QList<int>& ) const;
59
60   void            setSelectionModes( const int );
61   virtual void    setSelectionModes( const QList<int>& );
62
63   void            appendSelectionModes( const int );
64   virtual void    appendSelectionModes( const QList<int>& );
65
66   void            removeSelectionModes( const int );
67   virtual void    removeSelectionModes( const QList<int>& );
68
69
70   bool            isOk( const SUIT_DataOwner* ) const;
71   bool            isOk( const SUIT_DataOwnerPtr& ) const;
72
73   bool            hasFilter( SUIT_SelectionFilter* ) const;
74
75   virtual void    installFilter( SUIT_SelectionFilter*, const bool = true );
76   virtual void    removeFilter( SUIT_SelectionFilter* );
77   virtual void    clearFilters();
78
79   bool            autoDeleteFilter() const;
80   void            setAutoDeleteFilter( const bool );
81
82   bool            isSynchronizing() const;
83
84 signals:
85   void            selectionChanged();
86
87 protected:
88   virtual void    selectionChanged( SUIT_Selector* );
89
90   virtual void    installSelector( SUIT_Selector* );
91   virtual void    removeSelector( SUIT_Selector* );
92
93 private:
94   void            filterOwners( const SUIT_DataOwnerPtrList&, SUIT_DataOwnerPtrList& ) const;
95
96   typedef QList<SUIT_Selector*>        SelectorList;
97   typedef QList<SUIT_SelectionFilter*> SelFilterList;
98
99 private:
100   SelFilterList   myFilters;
101   QList<int>      mySelModes;
102   SelectorList    mySelectors;
103   int             myIterations;
104   bool            myAutoDelFilter;
105   bool            myIsSelChangeEnabled;
106
107   friend class SUIT_Selector;
108 };
109
110 #ifdef WIN32
111 #pragma warning ( default : 4251 )
112 #endif
113
114 #endif