0031939: Coding - correction of spelling errors in comments
[occt.git] / src / IFSelect / IFSelect_SelectRange.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14
42cf5bc1 15#include <IFSelect_IntParam.hxx>
16#include <IFSelect_SelectRange.hxx>
17#include <Interface_InterfaceModel.hxx>
18#include <Standard_DomainError.hxx>
19#include <Standard_Transient.hxx>
20#include <Standard_Type.hxx>
21#include <TCollection_AsciiString.hxx>
7fd59977 22
42cf5bc1 23#include <stdio.h>
92efcf78 24IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SelectRange,IFSelect_SelectExtract)
25
b311480e 26IFSelect_SelectRange::IFSelect_SelectRange () { }
7fd59977 27
28 void IFSelect_SelectRange::SetRange
29 (const Handle(IFSelect_IntParam)& rankfrom,
30 const Handle(IFSelect_IntParam)& rankto)
31 { thelower = rankfrom; theupper = rankto; }
32
33 void IFSelect_SelectRange::SetOne (const Handle(IFSelect_IntParam)& rank)
34 { thelower = theupper = rank; }
35
36 void IFSelect_SelectRange::SetFrom
37 (const Handle(IFSelect_IntParam)& rankfrom)
38 { thelower = rankfrom; theupper.Nullify(); }
39
40 void IFSelect_SelectRange::SetUntil
41 (const Handle(IFSelect_IntParam)& rankto)
42 { thelower.Nullify(); theupper = rankto; }
43
44
45 Standard_Boolean IFSelect_SelectRange::HasLower () const
46 { return (!thelower.IsNull()); }
47
48 Handle(IFSelect_IntParam) IFSelect_SelectRange::Lower () const
49 { return thelower; }
50
51 Standard_Integer IFSelect_SelectRange::LowerValue () const
52{
53 if (thelower.IsNull()) return 0;
54 return thelower->Value();
55}
56
57 Standard_Boolean IFSelect_SelectRange::HasUpper () const
58 { return (!theupper.IsNull()); }
59
60 Handle(IFSelect_IntParam) IFSelect_SelectRange::Upper () const
61 { return theupper; }
62
63 Standard_Integer IFSelect_SelectRange::UpperValue () const
64{
65 if (theupper.IsNull()) return 0;
66 return theupper->Value();
67}
68
69 Standard_Boolean IFSelect_SelectRange::Sort
70 (const Standard_Integer rank, const Handle(Standard_Transient)& ,
71 const Handle(Interface_InterfaceModel)& ) const
72{
73 Standard_Integer rankfrom = 0;
74 if (!thelower.IsNull()) rankfrom = thelower->Value();
75 Standard_Integer rankto = 0;
76 if (!theupper.IsNull()) rankto = theupper->Value();
77 return (rank >= rankfrom && (rankto == 0 || rankto >= rank));
78}
79
80 TCollection_AsciiString IFSelect_SelectRange::ExtractLabel () const
81{
82 char lab[30];
83 Standard_Integer rankfrom = 0;
84 if (!thelower.IsNull()) rankfrom = thelower->Value();
85 Standard_Integer rankto = 0;
86 if (!theupper.IsNull()) rankto = theupper->Value();
87 if (rankfrom == rankto) sprintf(lab,"Rank no %d",rankfrom);
88 else if (rankfrom == 0) sprintf(lab,"Until no %d",rankto);
89 else if (rankto == 0) sprintf(lab,"From no %d",rankto);
90 else sprintf(lab,"From %d Until %d",rankfrom,rankto);
91
92 return TCollection_AsciiString(lab);
93}