f26b33dab10d5155b52767d7375f93f502a3e8b9
[occt.git] / src / SelectMgr / SelectMgr_ViewerSelector.lxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 //=======================================================================
16 // function: Tolerance
17 // purpose : Returns a current tolerance that must be applied
18 //=======================================================================
19 inline Standard_Integer SelectMgr_ToleranceMap::Tolerance() const
20 {
21   if (myLargestKey < Precision::Confusion())
22     return 2; // default tolerance value
23
24   return myCustomTolerance < 0 ? myLargestKey : myLargestKey + myCustomTolerance;
25 }
26
27 //=======================================================================
28 // function: SetCustomTolerance
29 // purpose : Sets tolerance to the given one and disables adaptive checks
30 //=======================================================================
31 inline void SelectMgr_ToleranceMap::SetCustomTolerance (const Standard_Integer theTolerance)
32 {
33   myCustomTolerance = theTolerance;
34 }
35
36 //=======================================================================
37 // function: CustomTolerance
38 // purpose : Returns current value of custom tolerance regardless of it is set or not
39 //=======================================================================
40 inline Standard_Integer SelectMgr_ToleranceMap::CustomTolerance() const
41 {
42   return myCustomTolerance;
43 }
44
45 //=======================================================================
46 // function: IsCustomTolSet
47 // purpose : Checks if custom tolerance value is greater than zero
48 //=======================================================================
49 inline Standard_Boolean SelectMgr_ToleranceMap::IsCustomTolSet() const
50 {
51   return myCustomTolerance > 0;
52 }
53
54 //=======================================================================
55 // function: ResetDefaults
56 // purpose : Unsets a custom tolerance and enables adaptive checks
57 //=======================================================================
58 inline void SelectMgr_ToleranceMap::ResetDefaults()
59 {
60   myCustomTolerance = -1;
61 }
62
63 inline Standard_Real SelectMgr_ViewerSelector::Sensitivity() const
64 {
65   return myTolerances.Tolerance();
66 }
67
68 inline void SelectMgr_ViewerSelector::Init() 
69 {
70   myCurRank = 1;
71 }
72
73 inline void SelectMgr_ViewerSelector::Next()
74 {
75   myCurRank++;
76 }
77
78 inline void SelectMgr_ViewerSelector::SetPickClosest (const Standard_Boolean preferClosest)
79 {
80   preferclosest = preferClosest;
81 }
82
83 inline void SelectMgr_ViewerSelector::InitDetected()
84 {
85   myDetectedIter.Initialize (myMapOfDetected);
86 }
87
88 inline void SelectMgr_ViewerSelector::NextDetected()
89 {
90   myDetectedIter.Next();
91 }
92
93 inline Standard_Boolean SelectMgr_ViewerSelector::MoreDetected()
94 {
95   return myDetectedIter.More();
96 }
97
98 inline SelectMgr_SelectingVolumeManager& SelectMgr_ViewerSelector::GetManager()
99 {
100   return mySelectingVolumeMgr;
101 }