Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/geom.git] / src / GEOMFiltersSelection / GEOM_LogicalFilter.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #include "GEOM_LogicalFilter.h"
21
22 //=======================================================================
23 // function : GEOM_LogicalFilter
24 // purpose  : 
25 //=======================================================================
26 GEOM_LogicalFilter::GEOM_LogicalFilter( const QPtrList<SUIT_SelectionFilter>& lst, const int op )
27 : SUIT_SelectionFilter()
28 {
29   setFilters( lst ); 
30   setOperation( op );
31 }
32
33 //=======================================================================
34 // function : ~GEOM_LogicalFilter
35 // purpose  : 
36 //=======================================================================
37 GEOM_LogicalFilter::~GEOM_LogicalFilter()
38 {
39 }
40
41 //=======================================================================
42 // function : isOk
43 // purpose  : 
44 //=======================================================================
45 bool GEOM_LogicalFilter::isOk( const SUIT_DataOwner* owner ) const
46 {
47   GEOM_LogicalFilter* non_const_this = (GEOM_LogicalFilter*)this;
48   for ( SUIT_SelectionFilter* filter = non_const_this->myFilters.first(); filter; filter = non_const_this->myFilters.next() )
49   {
50     if ( myOperation == LO_OR && filter->isOk( owner ) )
51       return true;
52     if ( myOperation == LO_AND && !filter->isOk( owner ) )
53       return false;
54     if ( myOperation == LO_NOT )
55       return !filter->isOk( owner );
56   }
57
58   return ( myOperation != LO_OR );
59 }
60
61 //=======================================================================
62 // function : setFilters
63 // purpose  : 
64 //=======================================================================
65 void GEOM_LogicalFilter::setFilters( const QPtrList<SUIT_SelectionFilter>& lst )
66 {
67   myFilters = lst;
68 }
69
70 //=======================================================================
71 // function : setOperation
72 // purpose  : 
73 //=======================================================================
74 void GEOM_LogicalFilter::setOperation( const int op ) 
75 {
76   myOperation = op;
77 }
78
79 //=======================================================================
80 // function : getFilters
81 // purpose  : 
82 //=======================================================================
83 QPtrList<SUIT_SelectionFilter> GEOM_LogicalFilter::getFilters() const 
84 {
85   return myFilters;
86 }
87
88 //=======================================================================
89 // function : getOperation
90 // purpose  : 
91 //=======================================================================
92 int GEOM_LogicalFilter::getOperation() const
93 {
94   return myOperation;
95 }