#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
#include <GraphicsView_Object.h>
#include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
#include <QLineEdit>
#include <QToolButton>
-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 );
if( !myBtn->isChecked() )
return;
- SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr();
- SUIT_DataOwnerPtrList anOwners;
- aSelMgr->selected( anOwners );
+ QString anObjName;
+ Handle(HYDROData_Object) 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<LightApp_DataOwner*>( 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
myObjName->clear();
myBtn->setChecked( false );
}
+
+void HYDROGUI_ObjSelector::SetChecked( const bool theState )
+{
+ myBtn->setChecked( theState );
+}