Salome HOME
Porting to Mandrake 10.1 and new products:
[modules/kernel.git] / src / SALOMEGUI / SALOME_NumberFilter.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   : SALOME_NumberFilter.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #include "SALOME_NumberFilter.ixx"
30 #include "SALOME_Selection.h"
31 #include "SALOME_InteractiveObject.hxx"
32
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_Study.h"
36 using namespace std;
37
38 SALOME_NumberFilter::SALOME_NumberFilter(NumberFilter TheKind, Standard_Integer aValue):
39 myKind(TheKind),
40 myValue(aValue){}
41
42 Standard_Boolean SALOME_NumberFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const 
43 {
44   bool result = false;
45   QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
46   SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
47   int nbSel = Sel->IObjectCount();
48
49   switch ( myKind )
50     {
51     case 0 : // INFERIOR
52       {
53         if ( (nbSel + 1 ) < myValue )
54           result = true;
55         else
56           result = false;
57         break;
58       }
59     case 1 : // INFERIOR_OR_EQUAL
60       {
61         if ( (nbSel + 1 ) <= myValue )
62           result = true;
63         else
64           result = false;
65         break;
66       }
67     case 2 : // SUPERIOR
68       {
69         result = true;
70         break;
71       }
72     case 3 : // SUPERIOR_OR_EQUAL
73       {
74         result = true;
75         break;
76       }
77     case 4 : // EQUAL
78       {
79         if ( (nbSel + 1 ) == myValue )
80           result = true;
81         else
82           result = false;
83         break;
84       }
85     }
86
87   return result;
88 }