Salome HOME
Nerge with PAL/SALOME 2.1.0d
[modules/smesh.git] / src / SMESHFiltersSelection / SMESH_LogicalFilter.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //              
24 //  File   : SMESH_LogicalFilter.cxx
25 //  Author : Sergey LITONIN
26 //  Module : SMESH
27
28 #include "SMESH_LogicalFilter.hxx"
29
30 /*
31   Class       : SMESH_LogicalFilter
32   Description : Filter for combaining several filters with logical operation (OR or AND)
33 */
34
35 IMPLEMENT_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter )
36 IMPLEMENT_STANDARD_RTTIEXT( SMESH_LogicalFilter, SALOME_Filter )
37
38 //=======================================================================
39 // name    : SMESH_LogicalFilter::SMESH_LogicalFilter
40 // Purpose : Constructor
41 //=======================================================================
42 SMESH_LogicalFilter::SMESH_LogicalFilter( const SMESH_ListOfFilter& theFilters,
43                                         const int                theLogOp )
44 {
45   myFilters = theFilters;
46   myLogOp = theLogOp;
47 }
48
49 //=======================================================================
50 // name    : SMESH_LogicalFilter::~SMESH_LogicalFilter
51 // Purpose : Destructor
52 //=======================================================================
53 SMESH_LogicalFilter::~SMESH_LogicalFilter()
54 {
55 }
56
57 //=======================================================================
58 // name    : SMESH_LogicalFilter::IsOk
59 // Purpose : Verify validity of entry object
60 //=======================================================================
61 Standard_Boolean SMESH_LogicalFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const
62 {
63   SMESH_ListOfFilter::Iterator anIter( myFilters );
64   for ( ; anIter.More(); anIter.Next() )
65   {
66     Handle(SALOME_Filter) aFilter = anIter.Value();
67     if ( !aFilter.IsNull() )
68     {
69       if ( myLogOp == LO_OR &&  anIter.Value()->IsOk( theIO ) )
70         return true;
71       if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) )
72         return false;
73     }
74   }
75
76   return myLogOp == LO_OR ? false : true;
77 }
78
79 //=======================================================================
80 // name    : SMESH_LogicalFilter::SetFilters
81 // Purpose : Set new list of filters. Old wilters are removed
82 //=======================================================================
83 void SMESH_LogicalFilter::SetFilters( const SMESH_ListOfFilter& theFilters )
84 {
85   myFilters = theFilters;
86 }
87
88 //=======================================================================
89 // name    : SMESH_LogicalFilter::SetLogOp
90 // Purpose : Set logical operation
91 //=======================================================================
92 void SMESH_LogicalFilter::SetLogOp( const int theLogOp )
93 {
94   myLogOp = theLogOp;
95 }
96
97 //=======================================================================
98 // name    : SMESH_LogicalFilter::GetFilters
99 // Purpose : Get list of filters
100 //=======================================================================
101 const SMESH_ListOfFilter& SMESH_LogicalFilter::GetFilters() const
102 {
103   return myFilters;
104 }
105
106 //=======================================================================
107 // name    : SMESH_LogicalFilter::GetLogOp
108 // Purpose : Get logical operation
109 //=======================================================================
110 int SMESH_LogicalFilter::GetLogOp() const
111 {
112   return myLogOp;
113 }
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148