1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SUIT_Selector.h"
25 #include "SUIT_SelectionMgr.h"
29 /*!\class SUIT_Selector::Destroyer
30 Class provide the watching for qobject parent class of the selector.
33 class SUIT_Selector::Destroyer : public QObject
36 Destroyer( SUIT_Selector*, QObject* = 0 );
39 SUIT_Selector* selector() const;
40 void setSelector( SUIT_Selector* );
43 SUIT_Selector* mySelector;
46 SUIT_Selector::Destroyer::Destroyer( SUIT_Selector* s, QObject* p )
52 SUIT_Selector::Destroyer::~Destroyer()
54 SUIT_Selector* s = mySelector;
60 SUIT_Selector* SUIT_Selector::Destroyer::selector() const
65 void SUIT_Selector::Destroyer::setSelector( SUIT_Selector* s )
70 /*!\class SUIT_Selector
71 * Class provide selector for data owners.
77 SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent )
85 selMgr->installSelector( this );
88 myDestroyer = new Destroyer( this, parent );
94 SUIT_Selector::~SUIT_Selector()
97 selectionMgr()->removeSelector( this );
99 if ( myDestroyer && myDestroyer->selector() == this )
101 myDestroyer->setSelector( 0 );
108 Gets selection manager.
110 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
116 Checks: Is selctor enabled?
118 bool SUIT_Selector::isEnabled() const
124 Sets selctor anbled to \a on.
126 void SUIT_Selector::setEnabled( const bool on )
132 Checks: Is selector auto block?
134 bool SUIT_Selector::autoBlock() const
140 Sets selctor autoblock to \a on.
142 void SUIT_Selector::setAutoBlock( const bool on )
148 Puts to \a lst selection list of data owners.
150 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
157 Puts to selection list of data owners \a lst..
159 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
164 bool block = myBlock;
173 On selection changed.
175 void SUIT_Selector::selectionChanged()
177 if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
178 selectionMgr()->selectionChanged( this );
182 Checks: Is selection manager has selection mode \a mode?
184 bool SUIT_Selector::hasSelectionMode( const int mode ) const
186 if ( !selectionMgr() )
189 return selectionMgr()->hasSelectionMode( mode );
193 Puts to list \a lst selection modes from selection manager.
195 void SUIT_Selector::selectionModes( QList<int>& lst ) const
197 if ( selectionMgr() )
198 selectionMgr()->selectionModes( lst );
202 Get owner of this selector.
204 QObject* SUIT_Selector::owner() const
206 return myDestroyer ? myDestroyer->parent() : 0;