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& thelist ) 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 SalomeApp_DataOwner* owner = new SalomeApp_DataOwner( aSObj );
55 thelist.append( SUIT_DataOwnerPtr( owner ) );
61 void SalomeApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& thelist )
66 QMap<QString, SalomeApp_DataObject*> themap;
67 fillEntries( themap );
69 DataObjectList objList;
70 for ( SUIT_DataOwnerPtrList::const_iterator it = thelist.begin(); it != thelist.end(); ++it )
72 const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*it).operator->() );
73 if ( owner && themap.contains( owner->entry() ) )
74 objList.append( themap[owner->entry()] );
77 myBrowser->setSelected( objList );
80 /*!On selection changed.*/
81 void SalomeApp_OBSelector::onSelectionChanged()
87 void SalomeApp_OBSelector::fillEntries( QMap<QString, SalomeApp_DataObject*>& entires )
94 for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
95 SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
97 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
99 entires.insert( obj->entry(), obj );