1 // File: SelectMgr_SortCriterion.cxx
2 // Created: Thu Mar 26 17:32:47 1998
3 // Author: Robert COUBLANC
4 // <rob@robox.paris1.matra-dtv.fr>
7 #include <SelectMgr_SortCriterion.ixx>
8 #include <Precision.hxx>
10 //=======================================================================
11 //function : SelectMgr_SortCriterion
12 //purpose : Empty constructor
13 //=======================================================================
15 SelectMgr_SortCriterion::SelectMgr_SortCriterion()
20 myPreferClosest(Standard_True)
23 //=======================================================================
24 //function : SelectMgr_SortCriterion
25 //purpose : Constructor
26 //=======================================================================
28 SelectMgr_SortCriterion::SelectMgr_SortCriterion(const Standard_Integer Prior,
29 const Standard_Real Depth,
30 const Standard_Real Dist,
31 const Standard_Real Tol,
32 const Standard_Boolean PreferClosest)
37 myPreferClosest(PreferClosest)
40 //=======================================================================
41 //function : IsGreater
42 //purpose : priorite d'abor, puis profondeur + distance...
43 //=======================================================================
44 Standard_Boolean SelectMgr_SortCriterion::IsGreater
45 (const SelectMgr_SortCriterion& SC) const
47 if ( myPreferClosest )
49 // closest object is selected unless difference is within tolerance
50 if ( Abs (myDepth - SC.Depth()) > myTol + SC.Tol() )
51 return myDepth < SC.Depth();
53 // if two objects have similar depth, select the one with higher
54 // priority or, if priorities are equal, one closest to the mouse
55 return myPrior > SC.Priority() ? Standard_True :
56 myPrior < SC.Priority() ? Standard_False :
57 myDist < SC.MinDist();
60 // old logic (OCCT version <= 6.3.1)
61 if(myPrior>SC.Priority()) return Standard_True;
62 if(myPrior<SC.Priority()) return Standard_False;
63 if(Abs(myDepth-SC.Depth())<=Precision::Confusion())
64 return myDist < SC.MinDist();
65 return (myDepth < SC.Depth() );
68 //=======================================================================
70 //purpose : On n'utilise que les criteres de profondeur et de priorite...
71 //=======================================================================
72 Standard_Boolean SelectMgr_SortCriterion::IsLower
73 (const SelectMgr_SortCriterion& SC) const
75 if ( myPreferClosest )
77 // closest object is selected unless difference is within tolerance
78 if ( myPreferClosest && Abs (myDepth - SC.Depth()) > myTol + SC.Tol() )
79 return myDepth > SC.Depth();
81 // if two objects have similar depth, select the one with higher
82 // priority or, if priorities are equal, one closest to the mouse
83 return myPrior < SC.Priority() ? Standard_True :
84 myPrior > SC.Priority() ? Standard_False :
85 myDist > SC.MinDist();
88 // old logic (OCCT version <= 6.3.1)
89 if(myPrior>SC.Priority()) return Standard_False;
90 if(myPrior<SC.Priority()) return Standard_True;
91 if(Abs(myDepth-SC.Depth())<=Precision::Confusion())
92 return myDist > SC.MinDist();
93 return (myDepth > SC.Depth() );