0025418: Debug output to be limited to OCC development environment
[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#include <IFSelect_SelectRange.ixx>
15#include <stdio.h>
16
17
b311480e 18IFSelect_SelectRange::IFSelect_SelectRange () { }
7fd59977 19
20 void IFSelect_SelectRange::SetRange
21 (const Handle(IFSelect_IntParam)& rankfrom,
22 const Handle(IFSelect_IntParam)& rankto)
23 { thelower = rankfrom; theupper = rankto; }
24
25 void IFSelect_SelectRange::SetOne (const Handle(IFSelect_IntParam)& rank)
26 { thelower = theupper = rank; }
27
28 void IFSelect_SelectRange::SetFrom
29 (const Handle(IFSelect_IntParam)& rankfrom)
30 { thelower = rankfrom; theupper.Nullify(); }
31
32 void IFSelect_SelectRange::SetUntil
33 (const Handle(IFSelect_IntParam)& rankto)
34 { thelower.Nullify(); theupper = rankto; }
35
36
37 Standard_Boolean IFSelect_SelectRange::HasLower () const
38 { return (!thelower.IsNull()); }
39
40 Handle(IFSelect_IntParam) IFSelect_SelectRange::Lower () const
41 { return thelower; }
42
43 Standard_Integer IFSelect_SelectRange::LowerValue () const
44{
45 if (thelower.IsNull()) return 0;
46 return thelower->Value();
47}
48
49 Standard_Boolean IFSelect_SelectRange::HasUpper () const
50 { return (!theupper.IsNull()); }
51
52 Handle(IFSelect_IntParam) IFSelect_SelectRange::Upper () const
53 { return theupper; }
54
55 Standard_Integer IFSelect_SelectRange::UpperValue () const
56{
57 if (theupper.IsNull()) return 0;
58 return theupper->Value();
59}
60
61 Standard_Boolean IFSelect_SelectRange::Sort
62 (const Standard_Integer rank, const Handle(Standard_Transient)& ,
63 const Handle(Interface_InterfaceModel)& ) const
64{
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));
70}
71
72 TCollection_AsciiString IFSelect_SelectRange::ExtractLabel () const
73{
74 char lab[30];
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);
83
84 return TCollection_AsciiString(lab);
85}