1 #include "SalomeApp_OBSelector.h"
3 #include "SalomeApp_DataOwner.h"
4 #include "SalomeApp_DataObject.h"
6 #include <OB_Browser.h>
8 #include <SUIT_DataObjectIterator.h>
13 SalomeApp_OBSelector::SalomeApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr )
14 : SUIT_Selector( mgr, ob ),
18 connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
25 SalomeApp_OBSelector::~SalomeApp_OBSelector()
32 OB_Browser* SalomeApp_OBSelector::browser() const
40 void SalomeApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& list ) const
45 DataObjectList objlist;
46 myBrowser->getSelected( objlist );
47 for ( DataObjectListIterator it( objlist ); it.current(); ++it )
49 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
52 Handle( SALOME_InteractiveObject ) aSObj = new SALOME_InteractiveObject
53 ( obj->entry(), obj->componentDataType(), obj->name() );
54 list.append( SUIT_DataOwnerPtr( new SalomeApp_DataOwner( aSObj ) ) );
60 void SalomeApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& list )
65 QMap<QString, SalomeApp_DataObject*> map;
68 DataObjectList objList;
69 for ( SUIT_DataOwnerPtrList::const_iterator it = list.begin(); it != list.end(); ++it )
71 const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*it).operator->() );
72 if ( owner && map.contains( owner->entry() ) )
73 objList.append( map[owner->entry()] );
76 myBrowser->setSelected( objList );
79 /*!On selection changed.*/
80 void SalomeApp_OBSelector::onSelectionChanged()
86 void SalomeApp_OBSelector::fillEntries( QMap<QString, SalomeApp_DataObject*>& entires )
93 for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
94 SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
96 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
98 entires.insert( obj->entry(), obj );