Version: 6.3.1

src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SMESH_LogicalFilter.cxx
00024 //  Module : SMESH
00025 //
00026 #include "SMESH_LogicalFilter.hxx"
00027 
00028 //=======================================================================
00029 // name    : SMESH_LogicalFilter::SMESH_LogicalFilter
00030 // Purpose : Constructor
00031 //=======================================================================
00032 SMESH_LogicalFilter::SMESH_LogicalFilter (const QList<SUIT_SelectionFilter*>& theFilters,
00033                                           const int                           theLogOp)
00034 {
00035   setFilters(theFilters);
00036   setOperation(theLogOp);
00037 }
00038 
00039 //=======================================================================
00040 // name    : SMESH_LogicalFilter::~SMESH_LogicalFilter
00041 // Purpose : Destructor
00042 //=======================================================================
00043 SMESH_LogicalFilter::~SMESH_LogicalFilter()
00044 {
00045 }
00046 
00047 //=======================================================================
00048 // name    : SMESH_LogicalFilter::IsOk
00049 // Purpose : Verify validity of entry object
00050 //=======================================================================
00051 bool SMESH_LogicalFilter::isOk (const SUIT_DataOwner* owner) const
00052 {
00053   SUIT_SelectionFilter* filter;
00054   foreach( filter, myFilters )
00055   {
00056     if (myOperation == LO_OR && filter->isOk(owner))
00057       return true;
00058     if (myOperation == LO_AND && !filter->isOk(owner))
00059       return false;
00060     if (myOperation == LO_NOT)
00061       return !filter->isOk(owner);
00062   }
00063 
00064   return (myOperation != LO_OR);
00065 }
00066 
00067 //=======================================================================
00068 // name    : SMESH_LogicalFilter::setFilters
00069 // Purpose : Set new list of filters. Old wilters are removed
00070 //=======================================================================
00071 void SMESH_LogicalFilter::setFilters (const QList<SUIT_SelectionFilter*>& theFilters)
00072 {
00073   myFilters = theFilters;
00074 }
00075 
00076 //=======================================================================
00077 // name    : SMESH_LogicalFilter::setOperation
00078 // Purpose : Set logical operation
00079 //=======================================================================
00080 void SMESH_LogicalFilter::setOperation (const int theLogOp)
00081 {
00082   myOperation = theLogOp;
00083 }
00084 
00085 //=======================================================================
00086 // name    : SMESH_LogicalFilter::getFilters
00087 // Purpose : Get list of filters
00088 //=======================================================================
00089 const QList<SUIT_SelectionFilter*> SMESH_LogicalFilter::getFilters() const
00090 {
00091   return myFilters;
00092 }
00093 
00094 //=======================================================================
00095 // name    : SMESH_LogicalFilter::getOperation
00096 // Purpose : Get logical operation
00097 //=======================================================================
00098 int SMESH_LogicalFilter::getOperation() const
00099 {
00100   return myOperation;
00101 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS