1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IFSelect_SelectRange.ixx>
18 IFSelect_SelectRange::IFSelect_SelectRange () { }
20 void IFSelect_SelectRange::SetRange
21 (const Handle(IFSelect_IntParam)& rankfrom,
22 const Handle(IFSelect_IntParam)& rankto)
23 { thelower = rankfrom; theupper = rankto; }
25 void IFSelect_SelectRange::SetOne (const Handle(IFSelect_IntParam)& rank)
26 { thelower = theupper = rank; }
28 void IFSelect_SelectRange::SetFrom
29 (const Handle(IFSelect_IntParam)& rankfrom)
30 { thelower = rankfrom; theupper.Nullify(); }
32 void IFSelect_SelectRange::SetUntil
33 (const Handle(IFSelect_IntParam)& rankto)
34 { thelower.Nullify(); theupper = rankto; }
37 Standard_Boolean IFSelect_SelectRange::HasLower () const
38 { return (!thelower.IsNull()); }
40 Handle(IFSelect_IntParam) IFSelect_SelectRange::Lower () const
43 Standard_Integer IFSelect_SelectRange::LowerValue () const
45 if (thelower.IsNull()) return 0;
46 return thelower->Value();
49 Standard_Boolean IFSelect_SelectRange::HasUpper () const
50 { return (!theupper.IsNull()); }
52 Handle(IFSelect_IntParam) IFSelect_SelectRange::Upper () const
55 Standard_Integer IFSelect_SelectRange::UpperValue () const
57 if (theupper.IsNull()) return 0;
58 return theupper->Value();
61 Standard_Boolean IFSelect_SelectRange::Sort
62 (const Standard_Integer rank, const Handle(Standard_Transient)& ,
63 const Handle(Interface_InterfaceModel)& ) const
65 Standard_Integer rankfrom = 0;
66 if (!thelower.IsNull()) rankfrom = thelower->Value();
67 Standard_Integer rankto = 0;
68 if (!theupper.IsNull()) rankto = theupper->Value();
69 return (rank >= rankfrom && (rankto == 0 || rankto >= rank));
72 TCollection_AsciiString IFSelect_SelectRange::ExtractLabel () const
75 Standard_Integer rankfrom = 0;
76 if (!thelower.IsNull()) rankfrom = thelower->Value();
77 Standard_Integer rankto = 0;
78 if (!theupper.IsNull()) rankto = theupper->Value();
79 if (rankfrom == rankto) sprintf(lab,"Rank no %d",rankfrom);
80 else if (rankfrom == 0) sprintf(lab,"Until no %d",rankto);
81 else if (rankto == 0) sprintf(lab,"From no %d",rankto);
82 else sprintf(lab,"From %d Until %d",rankfrom,rankto);
84 return TCollection_AsciiString(lab);