X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ObjSelector.cxx;h=19ddb76ec31d5b748bccaf6063817fc9a7315983;hb=026402739f8239caa8c470c19402ce379d17b9d7;hp=f087c09dd135fc88aa89744c280e292c590cd83e;hpb=3769dbcedaa689e15ad79a619acd6f8bc21f47c6;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index f087c09d..19ddb76e 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -24,22 +24,31 @@ #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" #include #include -#include #include #include +#include +#include + #include #include #include -HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ) -: QAbstractButton( theParent ), myModule( theModule ) +HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, + const ObjectKind theObjectKind, + QWidget* theParent ) +: QAbstractButton( theParent ), + myObjectKind( theObjectKind ), + myModule( theModule ) { QHBoxLayout* aLayout = new QHBoxLayout( this ); + aLayout->setMargin( 0 ); + aLayout->setSpacing( 5 ); myBtn = new QToolButton( this ); myBtn->setCheckable( true ); myBtn->setChecked( false ); @@ -48,6 +57,9 @@ HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* aLayout->addWidget( myBtn, 0 ); aLayout->addWidget( myObjName, 1 ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + myBtn->setIcon( QIcon( aResMgr->loadPixmap( "HYDRO", tr( "SELECT_ICO" ) ) ) ); + SUIT_SelectionMgr* aSelMgr = theModule->getApp()->selectionMgr(); connect( myBtn, SIGNAL( toggled( bool ) ), this, SLOT( OnToggled( bool ) ) ); @@ -86,31 +98,32 @@ void HYDROGUI_ObjSelector::OnSelectionChanged() if( !myBtn->isChecked() ) return; - SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr(); - SUIT_DataOwnerPtrList anOwners; - aSelMgr->selected( anOwners ); + QString anObjName; + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::GetSelectedObject( myModule ); + if( !anObject.IsNull() ) + if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() ) + anObjName = anObject->GetName(); - HYDROGUI_DataModel* aModel = myModule->getDataModel(); + SetName( anObjName ); +} - QString anObjName; - foreach( SUIT_DataOwner* anOwner, anOwners ) - { - LightApp_DataOwner* aGrDOwner = dynamic_cast( anOwner ); - if( aGrDOwner ) - { - QString anEntry = aGrDOwner->entry(); - Handle(HYDROData_Object) anObject = aModel->objectByEntry( anEntry, KIND_IMAGE ); - if( !anObject.IsNull() ) - { - anObjName = anObject->GetName(); - break; - } - } - } - myObjName->setText( anObjName ); +void HYDROGUI_ObjSelector::SetName( const QString& theName ) +{ + myObjName->setText( theName ); } QString HYDROGUI_ObjSelector::GetName() const { return myObjName->text(); } + +void HYDROGUI_ObjSelector::Clear() +{ + myObjName->clear(); + myBtn->setChecked( false ); +} + +void HYDROGUI_ObjSelector::SetChecked( const bool theState ) +{ + myBtn->setChecked( theState ); +}