From: mzn Date: Fri, 27 May 2005 13:01:28 +0000 (+0000) Subject: New filters scheme. X-Git-Tag: T3_0_0_a1~89 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8a2eb8e0ccb7b852a502a77d15cb6facac11eb88;p=modules%2Fgui.git New filters scheme. --- diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index ab30ac389..4a926dfef 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -33,7 +33,9 @@ EXPORT_HEADERS= SalomeApp.h \ SalomeApp_NameDlg.h \ SalomeApp_ImportOperation.h \ SalomeApp_DataSubOwner.h \ - SalomeApp_Selection.h + SalomeApp_Selection.h \ + SalomeApp_Filter.h \ + SalomeApp_TypeFilter.h # .po files to transform in .qm PO_FILES = SalomeApp_images.po \ @@ -63,7 +65,9 @@ LIB_SRC= SalomeApp_Application.cxx \ SalomeApp_ImportOperation.cxx \ SalomeApp_DataSubOwner.cxx \ SalomeApp_ModuleDlg.cxx \ - SalomeApp_Selection.cxx + SalomeApp_Selection.cxx \ + SalomeApp_Filter.cxx \ + SalomeApp_TypeFilter.cxx LIB_MOC = SalomeApp_Application.h \ SalomeApp_DataModel.h \ @@ -93,7 +97,7 @@ RESOURCES_FILES = icon_about.png \ CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) -LIBS+= -L$(GUI_ROOT_DIR)/lib/salome -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow +LIBS+= -L$(GUI_ROOT_DIR)/lib/salome -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole @CONCLUDE@ diff --git a/src/SalomeApp/SalomeApp_Filter.cxx b/src/SalomeApp/SalomeApp_Filter.cxx new file mode 100644 index 000000000..6404e5c9d --- /dev/null +++ b/src/SalomeApp/SalomeApp_Filter.cxx @@ -0,0 +1,15 @@ +#include "SalomeApp_Filter.h" + +SalomeApp_Filter::SalomeApp_Filter( SalomeApp_Study* study ) +{ + myStudy = study; +} + +SalomeApp_Filter::~SalomeApp_Filter() +{ +} + +SalomeApp_Study* SalomeApp_Filter::getStudy() const +{ + return myStudy; +} diff --git a/src/SalomeApp/SalomeApp_Filter.h b/src/SalomeApp/SalomeApp_Filter.h new file mode 100644 index 000000000..01d3fe2fb --- /dev/null +++ b/src/SalomeApp/SalomeApp_Filter.h @@ -0,0 +1,22 @@ +#ifndef SALOMEAPP_FILTER_H +#define SALOMEAPP_FILTER_H + +#include "SalomeApp.h" +#include "SUIT_SelectionFilter.h" + +class SalomeApp_Study; + +class SALOMEAPP_EXPORT SalomeApp_Filter: public SUIT_SelectionFilter +{ +public: + SalomeApp_Filter(SalomeApp_Study* study); + ~SalomeApp_Filter(); + +protected: + SalomeApp_Study* getStudy() const; + +private: + SalomeApp_Study* myStudy; +}; + +#endif diff --git a/src/SalomeApp/SalomeApp_TypeFilter.cxx b/src/SalomeApp/SalomeApp_TypeFilter.cxx new file mode 100644 index 000000000..59fdff028 --- /dev/null +++ b/src/SalomeApp/SalomeApp_TypeFilter.cxx @@ -0,0 +1,38 @@ +#include "SalomeApp_TypeFilter.h" + +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_Study.h" + +#include + +SalomeApp_TypeFilter::SalomeApp_TypeFilter( SalomeApp_Study* study, const QString& kind ) + : SalomeApp_Filter( study ) +{ + myKind = kind; +} + +SalomeApp_TypeFilter::~SalomeApp_TypeFilter() +{ +} + +bool SalomeApp_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const +{ + const SalomeApp_DataOwner* owner = dynamic_cast ( sOwner ); + + SalomeApp_Study* aDoc = getStudy(); + if (owner && aDoc && aDoc->studyDS()) + { + _PTR(Study) aStudy = aDoc->studyDS(); + QString entry = owner->entry(); + + _PTR(SObject) aSObj( aStudy->FindObjectID( entry.latin1() ) ); + if (aSObj) + { + _PTR(SComponent) aComponent(aSObj->GetFatherComponent()); + if ( aComponent && (aComponent->ComponentDataType() == myKind) ) + return true; + } + } + + return false; +} diff --git a/src/SalomeApp/SalomeApp_TypeFilter.h b/src/SalomeApp/SalomeApp_TypeFilter.h new file mode 100644 index 000000000..59efba9d2 --- /dev/null +++ b/src/SalomeApp/SalomeApp_TypeFilter.h @@ -0,0 +1,20 @@ +#ifndef SALOMEAPP_TYPEFILTER_H +#define SALOMEAPP_TYPEFILTER_H + +#include + +#include "SalomeApp_Filter.h" + +class SALOMEAPP_EXPORT SalomeApp_TypeFilter: public SalomeApp_Filter +{ +public: + SalomeApp_TypeFilter( SalomeApp_Study* study, const QString& kind ); + ~SalomeApp_TypeFilter(); + + virtual bool isOk( const SUIT_DataOwner* ) const; + +private: + QString myKind; +}; + +#endif