From 51004f1cf9b22333c80486b3af0ccf222fbce14f Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 16 Aug 2017 12:58:46 +0300 Subject: [PATCH] 0027381: Visualization - update description of method AIS_InteractiveContext::SetPixelTolerance() --- src/AIS/AIS_InteractiveContext.cxx | 6 +-- src/AIS/AIS_InteractiveContext.hxx | 14 +++--- src/SelectMgr/SelectMgr_ToleranceMap.cxx | 50 +++++++++++--------- src/StdSelect/FILES | 1 - src/StdSelect/StdSelect_ViewerSelector3d.hxx | 4 +- src/StdSelect/StdSelect_ViewerSelector3d.lxx | 18 ------- 6 files changed, 36 insertions(+), 57 deletions(-) delete mode 100644 src/StdSelect/StdSelect_ViewerSelector3d.lxx diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 3fcae94326..81b34b3c55 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -2611,11 +2611,9 @@ Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const return myDefaultDrawer->IsoOnTriangulation(); } +//======================================================================= //function : SetPixelTolerance -//purpose : Disables the mechanism of adaptive tolerance calculation in -// SelectMgr_ViewerSelector and sets the given tolerance for ALL -// sensitive entities activated. For more information, see -// SelectMgr_ViewerSelector.hxx +//purpose : //======================================================================= void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision) { diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 59b0524b7d..d195356d9e 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -397,14 +397,12 @@ public: Standard_EXPORT void UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Boolean theToUpdateViewer); - //! Disables the mechanism of adaptive tolerance calculation in SelectMgr_ViewerSelector and - //! sets the given tolerance for ALL sensitive entities activated. For more information, see - //! SelectMgr_ViewerSelector documentation - //! Warning: When a local context is open the sensitivity is apply on it - //! instead on the main context. - Standard_EXPORT void SetPixelTolerance (const Standard_Integer aPrecision = 2); - - //! Returns the pixel tolerance. + //! Setup pixel tolerance for MoveTo() operation. + Standard_EXPORT void SetPixelTolerance (const Standard_Integer thePrecision = 2); + + //! Returns the pixel tolerance, default is 2. + //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point) + //! and can be adjusted by application based on user input precision (e.g. screen pixel density, input device precision, etc.). Standard_EXPORT Standard_Integer PixelTolerance() const; //! Allows to manage sensitivity of a particular selection of interactive object theObject diff --git a/src/SelectMgr/SelectMgr_ToleranceMap.cxx b/src/SelectMgr/SelectMgr_ToleranceMap.cxx index acc0810f59..5e102fae46 100644 --- a/src/SelectMgr/SelectMgr_ToleranceMap.cxx +++ b/src/SelectMgr/SelectMgr_ToleranceMap.cxx @@ -18,9 +18,10 @@ // purpose : //======================================================================= SelectMgr_ToleranceMap::SelectMgr_ToleranceMap() +: myLargestKey (-1), + myCustomTolerance (-1) { - myLargestKey = -1; - myCustomTolerance = -1; + // } //======================================================================= @@ -38,24 +39,23 @@ SelectMgr_ToleranceMap::~SelectMgr_ToleranceMap() //======================================================================= void SelectMgr_ToleranceMap::Add (const Standard_Integer& theTolerance) { - if (myTolerances.IsBound (theTolerance)) + if (Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance)) { - Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance); - aFreq++; - - if (aFreq == 1 && theTolerance != myLargestKey) + ++(*aFreq); + if (*aFreq == 1 && theTolerance != myLargestKey) + { myLargestKey = Max (theTolerance, myLargestKey); + } + return; + } + + myTolerances.Bind (theTolerance, 1); + if (myTolerances.Extent() == 1) + { + myLargestKey = theTolerance; } else { - if (myTolerances.IsEmpty()) - { - myTolerances.Bind (theTolerance, 1); - myLargestKey = theTolerance; - return; - } - - myTolerances.Bind (theTolerance, 1); myLargestKey = Max (theTolerance, myLargestKey); } } @@ -66,18 +66,22 @@ void SelectMgr_ToleranceMap::Add (const Standard_Integer& theTolerance) //======================================================================= void SelectMgr_ToleranceMap::Decrement (const Standard_Integer& theTolerance) { - if (myTolerances.IsBound (theTolerance)) + Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance); + if (aFreq == NULL) { - Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance); - aFreq--; + return; + } - if (Abs (theTolerance - myLargestKey) < Precision::Confusion() && aFreq == 0) + --(*aFreq); + if (theTolerance == myLargestKey + && *aFreq == 0) + { + myLargestKey = 0; + for (NCollection_DataMap::Iterator anIter (myTolerances); anIter.More(); anIter.Next()) { - myLargestKey = 0; - for (NCollection_DataMap::Iterator anIter (myTolerances); anIter.More(); anIter.Next()) + if (anIter.Value() != 0) { - if (anIter.Value() != 0) - myLargestKey = Max (myLargestKey, anIter.Key()); + myLargestKey = Max (myLargestKey, anIter.Key()); } } } diff --git a/src/StdSelect/FILES b/src/StdSelect/FILES index 8284738453..df65920f3a 100644 --- a/src/StdSelect/FILES +++ b/src/StdSelect/FILES @@ -26,4 +26,3 @@ StdSelect_TypeOfResult.hxx StdSelect_TypeOfSelectionImage.hxx StdSelect_ViewerSelector3d.cxx StdSelect_ViewerSelector3d.hxx -StdSelect_ViewerSelector3d.lxx diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.hxx b/src/StdSelect/StdSelect_ViewerSelector3d.hxx index c4c093604f..adbb5b4510 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.hxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.hxx @@ -50,7 +50,7 @@ public: Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance); //! Returns the pixel tolerance. - inline Standard_Integer PixelTolerance() const; + Standard_Integer PixelTolerance() const { return myTolerances.Tolerance(); } //! Picks the sensitive entity at the pixel coordinates of //! the mouse and . The selector looks for touched areas and owners. @@ -114,6 +114,4 @@ protected: DEFINE_STANDARD_HANDLE(StdSelect_ViewerSelector3d, SelectMgr_ViewerSelector) -#include - #endif diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.lxx b/src/StdSelect/StdSelect_ViewerSelector3d.lxx deleted file mode 100644 index 6f941d9353..0000000000 --- a/src/StdSelect/StdSelect_ViewerSelector3d.lxx +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -inline Standard_Integer StdSelect_ViewerSelector3d::PixelTolerance() const -{ - return myTolerances.Tolerance(); -} -- 2.20.1