Salome HOME
Update comments
[modules/gui.git] / src / SUIT / SUIT_Selector.cxx
1 #include "SUIT_Selector.h"
2
3 #include "SUIT_SelectionMgr.h"
4
5 /*!\class SUIT_Selector
6  * Class provide selector for data owners.
7  */
8
9 /*!
10   Constructor.
11 */
12 SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent ) :
13 QObject( parent ), 
14 mySelMgr( selMgr ),
15 myBlock( false ),
16 myEnabled( true ),
17 myAutoBlock( true )
18 {
19   if ( selMgr )
20     selMgr->installSelector( this );
21 }
22
23 /*!
24   Destructor.
25 */
26 SUIT_Selector::~SUIT_Selector()
27 {
28   if ( selectionMgr() )
29     selectionMgr()->removeSelector( this );
30 }
31
32 /*!
33   Gets selection manager.
34 */
35 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
36 {
37   return mySelMgr;
38 }
39
40 /*!
41   Checks: Is selctor enabled?
42 */
43 bool SUIT_Selector::isEnabled() const
44 {
45   return myEnabled;
46 }
47
48 /*!
49   Sets selctor anbled to \a on.
50 */
51 void SUIT_Selector::setEnabled( const bool on )
52 {
53   myEnabled = on;
54 }
55
56 /*!
57   Checks: Is selector auto block?
58 */
59 bool SUIT_Selector::autoBlock() const
60 {
61   return myAutoBlock;
62 }
63
64 /*!
65   Sets selctor autoblock to \a on.
66 */
67 void SUIT_Selector::setAutoBlock( const bool on )
68 {
69   myAutoBlock = on;
70 }
71
72 /*!
73   Puts to \a lst selection list of data owners.
74 */
75 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
76 {
77   lst.clear();
78   getSelection( lst );
79 }
80
81 /*!
82   Puts to selection list of data owners \a lst..
83 */
84 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
85 {
86   if ( !isEnabled() )
87     return;
88
89   bool block = myBlock;
90   myBlock = true;
91
92   setSelection( lst );
93
94   myBlock = block;
95 }
96
97 /*!
98   On selection changed.
99 */
100 void SUIT_Selector::selectionChanged()
101 {
102   if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
103     selectionMgr()->selectionChanged( this );
104 }
105
106 /*!
107   Checks: Is selection manager has selection mode \a mode?
108 */
109 bool SUIT_Selector::hasSelectionMode( const int mode ) const
110 {
111   if ( !selectionMgr() )
112     return false;
113
114   return selectionMgr()->hasSelectionMode( mode );
115 }
116
117 /*!
118   Puts to list \a lst selection modes from selection manager.
119 */
120 void SUIT_Selector::selectionModes( QValueList<int>& lst ) const
121 {
122   if ( selectionMgr() )
123     selectionMgr()->selectionModes( lst );
124 }