Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IFSelect / IFSelect_SelectRange.cxx
CommitLineData
7fd59977 1#include <IFSelect_SelectRange.ixx>
2#include <stdio.h>
3
4
5 IFSelect_SelectRange::IFSelect_SelectRange () { }
6
7 void IFSelect_SelectRange::SetRange
8 (const Handle(IFSelect_IntParam)& rankfrom,
9 const Handle(IFSelect_IntParam)& rankto)
10 { thelower = rankfrom; theupper = rankto; }
11
12 void IFSelect_SelectRange::SetOne (const Handle(IFSelect_IntParam)& rank)
13 { thelower = theupper = rank; }
14
15 void IFSelect_SelectRange::SetFrom
16 (const Handle(IFSelect_IntParam)& rankfrom)
17 { thelower = rankfrom; theupper.Nullify(); }
18
19 void IFSelect_SelectRange::SetUntil
20 (const Handle(IFSelect_IntParam)& rankto)
21 { thelower.Nullify(); theupper = rankto; }
22
23
24 Standard_Boolean IFSelect_SelectRange::HasLower () const
25 { return (!thelower.IsNull()); }
26
27 Handle(IFSelect_IntParam) IFSelect_SelectRange::Lower () const
28 { return thelower; }
29
30 Standard_Integer IFSelect_SelectRange::LowerValue () const
31{
32 if (thelower.IsNull()) return 0;
33 return thelower->Value();
34}
35
36 Standard_Boolean IFSelect_SelectRange::HasUpper () const
37 { return (!theupper.IsNull()); }
38
39 Handle(IFSelect_IntParam) IFSelect_SelectRange::Upper () const
40 { return theupper; }
41
42 Standard_Integer IFSelect_SelectRange::UpperValue () const
43{
44 if (theupper.IsNull()) return 0;
45 return theupper->Value();
46}
47
48 Standard_Boolean IFSelect_SelectRange::Sort
49 (const Standard_Integer rank, const Handle(Standard_Transient)& ,
50 const Handle(Interface_InterfaceModel)& ) const
51{
52 Standard_Integer rankfrom = 0;
53 if (!thelower.IsNull()) rankfrom = thelower->Value();
54 Standard_Integer rankto = 0;
55 if (!theupper.IsNull()) rankto = theupper->Value();
56 return (rank >= rankfrom && (rankto == 0 || rankto >= rank));
57}
58
59 TCollection_AsciiString IFSelect_SelectRange::ExtractLabel () const
60{
61 char lab[30];
62 Standard_Integer rankfrom = 0;
63 if (!thelower.IsNull()) rankfrom = thelower->Value();
64 Standard_Integer rankto = 0;
65 if (!theupper.IsNull()) rankto = theupper->Value();
66 if (rankfrom == rankto) sprintf(lab,"Rank no %d",rankfrom);
67 else if (rankfrom == 0) sprintf(lab,"Until no %d",rankto);
68 else if (rankto == 0) sprintf(lab,"From no %d",rankto);
69 else sprintf(lab,"From %d Until %d",rankfrom,rankto);
70
71 return TCollection_AsciiString(lab);
72}