X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ObjSelector.cxx;h=19ddb76ec31d5b748bccaf6063817fc9a7315983;hb=026402739f8239caa8c470c19402ce379d17b9d7;hp=737b19f3702e83acd49d40a45126fd30efc8ff42;hpb=0b4df27e9f347d6187dbf30bacf80b45c21813d4;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index 737b19f3..19ddb76e 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -24,11 +24,11 @@ #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" #include #include -#include #include #include @@ -39,8 +39,12 @@ #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 ); @@ -94,28 +98,18 @@ 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 @@ -128,3 +122,8 @@ void HYDROGUI_ObjSelector::Clear() myObjName->clear(); myBtn->setChecked( false ); } + +void HYDROGUI_ObjSelector::SetChecked( const bool theState ) +{ + myBtn->setChecked( theState ); +}