From 0ded2c640939024250f0b56bc057ac6c8ce8ebbb Mon Sep 17 00:00:00 2001 From: mzn Date: Tue, 31 May 2005 11:28:49 +0000 Subject: [PATCH] Add filter for the Object Browser. --- src/SalomeApp/Makefile.in | 6 ++++-- src/SalomeApp/SalomeApp_Application.cxx | 2 ++ src/SalomeApp/SalomeApp_OBFilter.cxx | 24 ++++++++++++++++++++++++ src/SalomeApp/SalomeApp_OBFilter.h | 22 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/SalomeApp/SalomeApp_OBFilter.cxx create mode 100644 src/SalomeApp/SalomeApp_OBFilter.h diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index 4a926dfef..e13e104be 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -35,7 +35,8 @@ EXPORT_HEADERS= SalomeApp.h \ SalomeApp_DataSubOwner.h \ SalomeApp_Selection.h \ SalomeApp_Filter.h \ - SalomeApp_TypeFilter.h + SalomeApp_TypeFilter.h \ + SalomeApp_OBFilter.h # .po files to transform in .qm PO_FILES = SalomeApp_images.po \ @@ -67,7 +68,8 @@ LIB_SRC= SalomeApp_Application.cxx \ SalomeApp_ModuleDlg.cxx \ SalomeApp_Selection.cxx \ SalomeApp_Filter.cxx \ - SalomeApp_TypeFilter.cxx + SalomeApp_TypeFilter.cxx \ + SalomeApp_OBFilter.cxx LIB_MOC = SalomeApp_Application.h \ SalomeApp_DataModel.h \ diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 18310dead..7aa8d3d9d 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -18,6 +18,7 @@ #include "SalomeApp_EventFilter.h" #include "SalomeApp_WidgetContainer.h" #include "SalomeApp_ModuleDlg.h" +#include "SalomeApp_OBFilter.h" #include @@ -731,6 +732,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) if ( flag == WT_ObjectBrowser ) { OB_Browser* ob = new OB_Browser( desktop() ); + ob->setFilter( new SalomeApp_OBFilter(selectionMgr()) ); ob->setCaption( tr( "OBJECT_BROWSER" ) ); ob->resize( OBJECT_BROWSER_WIDTH, ob->height() ); diff --git a/src/SalomeApp/SalomeApp_OBFilter.cxx b/src/SalomeApp/SalomeApp_OBFilter.cxx new file mode 100644 index 000000000..3a9cbf47d --- /dev/null +++ b/src/SalomeApp/SalomeApp_OBFilter.cxx @@ -0,0 +1,24 @@ +#include "SalomeApp_OBFilter.h" + +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_DataObject.h" +#include "SalomeApp_DataOwner.h" + +SalomeApp_OBFilter::SalomeApp_OBFilter( SalomeApp_SelectionMgr* theSelMgr ) +{ + mySelMgr = theSelMgr; +} + +SalomeApp_OBFilter::~SalomeApp_OBFilter() +{ +} + +bool SalomeApp_OBFilter::isOk( const SUIT_DataObject* theDataObj ) const +{ + const SalomeApp_DataObject* obj = dynamic_cast( theDataObj ); + if ( obj ) + return mySelMgr->isOk( new SalomeApp_DataOwner( obj->entry() ) ); + + return false; +} + diff --git a/src/SalomeApp/SalomeApp_OBFilter.h b/src/SalomeApp/SalomeApp_OBFilter.h new file mode 100644 index 000000000..15f3ebeb3 --- /dev/null +++ b/src/SalomeApp/SalomeApp_OBFilter.h @@ -0,0 +1,22 @@ +#ifndef SALOMEAPP_OBFILTER_H +#define SALOMEAPP_OBFILTER_H + +#include "SalomeApp.h" +#include "OB_Filter.h" + +class SalomeApp_SelectionMgr; + +class SALOMEAPP_EXPORT SalomeApp_OBFilter: public OB_Filter +{ +public: + SalomeApp_OBFilter( SalomeApp_SelectionMgr* theSelMgr ); + ~SalomeApp_OBFilter(); + + virtual bool isOk( const SUIT_DataObject* ) const; + +private: + SalomeApp_SelectionMgr* mySelMgr; + +}; + +#endif -- 2.39.2