1 // Copyright (C) 2007-2008 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.
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
22 #include "SUIT_Selector.h"
24 #include "SUIT_SelectionMgr.h"
28 /*!\class SUIT_Selector::Destroyer
29 Class provide the watching for qobject parent class of the selector.
32 class SUIT_Selector::Destroyer : public QObject
35 Destroyer( SUIT_Selector*, QObject* = 0 );
38 SUIT_Selector* selector() const;
39 void setSelector( SUIT_Selector* );
42 SUIT_Selector* mySelector;
45 SUIT_Selector::Destroyer::Destroyer( SUIT_Selector* s, QObject* p )
51 SUIT_Selector::Destroyer::~Destroyer()
53 SUIT_Selector* s = mySelector;
59 SUIT_Selector* SUIT_Selector::Destroyer::selector() const
64 void SUIT_Selector::Destroyer::setSelector( SUIT_Selector* s )
69 /*!\class SUIT_Selector
70 * Class provide selector for data owners.
76 SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent )
84 selMgr->installSelector( this );
87 myDestroyer = new Destroyer( this, parent );
93 SUIT_Selector::~SUIT_Selector()
96 selectionMgr()->removeSelector( this );
98 if ( myDestroyer && myDestroyer->selector() == this )
100 myDestroyer->setSelector( 0 );
106 Gets selection manager.
108 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
114 Checks: Is selctor enabled?
116 bool SUIT_Selector::isEnabled() const
122 Sets selctor anbled to \a on.
124 void SUIT_Selector::setEnabled( const bool on )
130 Checks: Is selector auto block?
132 bool SUIT_Selector::autoBlock() const
138 Sets selctor autoblock to \a on.
140 void SUIT_Selector::setAutoBlock( const bool on )
146 Puts to \a lst selection list of data owners.
148 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
155 Puts to selection list of data owners \a lst..
157 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
162 bool block = myBlock;
171 On selection changed.
173 void SUIT_Selector::selectionChanged()
175 if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
176 selectionMgr()->selectionChanged( this );
180 Checks: Is selection manager has selection mode \a mode?
182 bool SUIT_Selector::hasSelectionMode( const int mode ) const
184 if ( !selectionMgr() )
187 return selectionMgr()->hasSelectionMode( mode );
191 Puts to list \a lst selection modes from selection manager.
193 void SUIT_Selector::selectionModes( QList<int>& lst ) const
195 if ( selectionMgr() )
196 selectionMgr()->selectionModes( lst );