From 00b26b695fd65087c379e3530ec2e8b6a0ed343d Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 23 Jun 2011 12:14:05 +0000 Subject: [PATCH] 0021014: EDF 1583 SMESH: Improvement of the Python Dump for the creation of groups To remove sub-filters if necessary - SMESH_LogicalFilter( const QList&, const int ); + SMESH_LogicalFilter( const QList&, const int, bool takeOwnership=false ); private: + void deleteFilters(); --- .../SMESH_LogicalFilter.cxx | 21 ++++++++++++++++++- .../SMESH_LogicalFilter.hxx | 6 +++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx index 8da846f03..b05c2f413 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx @@ -30,7 +30,9 @@ // Purpose : Constructor //======================================================================= SMESH_LogicalFilter::SMESH_LogicalFilter (const QList& theFilters, - const int theLogOp) + const int theLogOp, + bool takeOwnership) + : myOwnership( takeOwnership ) { setFilters(theFilters); setOperation(theLogOp); @@ -42,6 +44,7 @@ SMESH_LogicalFilter::SMESH_LogicalFilter (const QList& th //======================================================================= SMESH_LogicalFilter::~SMESH_LogicalFilter() { + deleteFilters(); } //======================================================================= @@ -70,6 +73,7 @@ bool SMESH_LogicalFilter::isOk (const SUIT_DataOwner* owner) const //======================================================================= void SMESH_LogicalFilter::setFilters (const QList& theFilters) { + deleteFilters(); myFilters = theFilters; } @@ -99,3 +103,18 @@ int SMESH_LogicalFilter::getOperation() const { return myOperation; } +//================================================================================ +/*! + * \brief Deletes filters if has an ownership + */ +//================================================================================ + +void SMESH_LogicalFilter::deleteFilters() +{ + if ( myOwnership ) + { + SUIT_SelectionFilter* filter; + foreach( filter, myFilters ) + delete filter; + } +} diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx index d1c2243b3..79217bae4 100644 --- a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx @@ -38,7 +38,7 @@ class SMESHFILTERSSELECTION_EXPORT SMESH_LogicalFilter : public SUIT_SelectionFi enum { LO_OR, LO_AND, LO_NOT, LO_UNDEFINED }; public: - SMESH_LogicalFilter( const QList&, const int ); + SMESH_LogicalFilter( const QList&, const int, bool takeOwnership=false ); virtual ~SMESH_LogicalFilter(); virtual bool isOk (const SUIT_DataOwner*) const; @@ -48,9 +48,13 @@ class SMESHFILTERSSELECTION_EXPORT SMESH_LogicalFilter : public SUIT_SelectionFi const QList getFilters() const; int getOperation() const; +private: + void deleteFilters(); + private: QList myFilters; int myOperation; + bool myOwnership; }; #endif -- 2.39.2