1 // Copyright (C) 2007-2012 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
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 );
107 Gets selection manager.
109 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
115 Checks: Is selctor enabled?
117 bool SUIT_Selector::isEnabled() const
123 Sets selctor anbled to \a on.
125 void SUIT_Selector::setEnabled( const bool on )
131 Checks: Is selector auto block?
133 bool SUIT_Selector::autoBlock() const
139 Sets selctor autoblock to \a on.
141 void SUIT_Selector::setAutoBlock( const bool on )
147 Puts to \a lst selection list of data owners.
149 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
156 Puts to selection list of data owners \a lst..
158 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
163 bool block = myBlock;
172 On selection changed.
174 void SUIT_Selector::selectionChanged()
176 if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
177 selectionMgr()->selectionChanged( this );
181 Checks: Is selection manager has selection mode \a mode?
183 bool SUIT_Selector::hasSelectionMode( const int mode ) const
185 if ( !selectionMgr() )
188 return selectionMgr()->hasSelectionMode( mode );
192 Puts to list \a lst selection modes from selection manager.
194 void SUIT_Selector::selectionModes( QList<int>& lst ) const
196 if ( selectionMgr() )
197 selectionMgr()->selectionModes( lst );