2 #include <HYDROGUI_ObjSelector.h>
3 #include <HYDROGUI_Module.h>
4 #include <LightApp_Application.h>
5 #include <LightApp_SelectionMgr.h>
6 #include <LightApp_GVSelector.h>
7 #include <GraphicsView_Object.h>
12 HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent )
13 : QAbstractButton( theParent ), myModule( theModule )
15 QHBoxLayout* aLayout = new QHBoxLayout( this );
16 myBtn = new QToolButton( this );
17 myBtn->setCheckable( true );
18 myBtn->setChecked( false );
19 myObjName = new QLineEdit( this );
20 myObjName->setReadOnly( true );
21 aLayout->addWidget( myBtn, 0 );
22 aLayout->addWidget( myObjName, 1 );
24 SUIT_SelectionMgr* aSelMgr = theModule->getApp()->selectionMgr();
26 connect( myBtn, SIGNAL( toggled( bool ) ), this, SLOT( OnToggled( bool ) ) );
27 connect( aSelMgr, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) );
30 HYDROGUI_ObjSelector::~HYDROGUI_ObjSelector()
34 void HYDROGUI_ObjSelector::paintEvent( QPaintEvent* )
38 bool HYDROGUI_ObjSelector::hitButton( const QPoint& thePnt ) const
43 void HYDROGUI_ObjSelector::OnToggled( bool isChecked )
48 QList<HYDROGUI_ObjSelector*> aSelectors = parentWidget()->findChildren<HYDROGUI_ObjSelector*>();
49 foreach( HYDROGUI_ObjSelector* aSelector, aSelectors )
50 if( aSelector != this )
51 aSelector->myBtn->setChecked( false );
57 void HYDROGUI_ObjSelector::OnSelectionChanged()
59 if( !myBtn->isChecked() )
62 SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr();
63 SUIT_DataOwnerPtrList anOwners;
64 aSelMgr->selected( anOwners );
67 foreach( SUIT_DataOwner* anOwner, anOwners )
69 LightApp_GVDataOwner* aGrDOwner = dynamic_cast<LightApp_GVDataOwner*>( anOwner );
72 anObjName = aGrDOwner->object()->getName();
76 myObjName->setText( anObjName );