1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <IFSelect_SelectRange.ixx>
22 IFSelect_SelectRange::IFSelect_SelectRange () { }
24 void IFSelect_SelectRange::SetRange
25 (const Handle(IFSelect_IntParam)& rankfrom,
26 const Handle(IFSelect_IntParam)& rankto)
27 { thelower = rankfrom; theupper = rankto; }
29 void IFSelect_SelectRange::SetOne (const Handle(IFSelect_IntParam)& rank)
30 { thelower = theupper = rank; }
32 void IFSelect_SelectRange::SetFrom
33 (const Handle(IFSelect_IntParam)& rankfrom)
34 { thelower = rankfrom; theupper.Nullify(); }
36 void IFSelect_SelectRange::SetUntil
37 (const Handle(IFSelect_IntParam)& rankto)
38 { thelower.Nullify(); theupper = rankto; }
41 Standard_Boolean IFSelect_SelectRange::HasLower () const
42 { return (!thelower.IsNull()); }
44 Handle(IFSelect_IntParam) IFSelect_SelectRange::Lower () const
47 Standard_Integer IFSelect_SelectRange::LowerValue () const
49 if (thelower.IsNull()) return 0;
50 return thelower->Value();
53 Standard_Boolean IFSelect_SelectRange::HasUpper () const
54 { return (!theupper.IsNull()); }
56 Handle(IFSelect_IntParam) IFSelect_SelectRange::Upper () const
59 Standard_Integer IFSelect_SelectRange::UpperValue () const
61 if (theupper.IsNull()) return 0;
62 return theupper->Value();
65 Standard_Boolean IFSelect_SelectRange::Sort
66 (const Standard_Integer rank, const Handle(Standard_Transient)& ,
67 const Handle(Interface_InterfaceModel)& ) const
69 Standard_Integer rankfrom = 0;
70 if (!thelower.IsNull()) rankfrom = thelower->Value();
71 Standard_Integer rankto = 0;
72 if (!theupper.IsNull()) rankto = theupper->Value();
73 return (rank >= rankfrom && (rankto == 0 || rankto >= rank));
76 TCollection_AsciiString IFSelect_SelectRange::ExtractLabel () const
79 Standard_Integer rankfrom = 0;
80 if (!thelower.IsNull()) rankfrom = thelower->Value();
81 Standard_Integer rankto = 0;
82 if (!theupper.IsNull()) rankto = theupper->Value();
83 if (rankfrom == rankto) sprintf(lab,"Rank no %d",rankfrom);
84 else if (rankfrom == 0) sprintf(lab,"Until no %d",rankto);
85 else if (rankto == 0) sprintf(lab,"From no %d",rankto);
86 else sprintf(lab,"From %d Until %d",rankfrom,rankto);
88 return TCollection_AsciiString(lab);