1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0027381: Visualization - update description of method AIS_InteractiveContext::SetPixelTolerance()

This commit is contained in:
kgv 2017-08-16 12:58:46 +03:00 committed by bugmaster
parent 0ef598d064
commit 51004f1cf9
6 changed files with 36 additions and 57 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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<Standard_Integer, Standard_Integer>::Iterator anIter (myTolerances); anIter.More(); anIter.Next())
{
myLargestKey = 0;
for (NCollection_DataMap<Standard_Integer, Standard_Integer>::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());
}
}
}

View File

@ -26,4 +26,3 @@ StdSelect_TypeOfResult.hxx
StdSelect_TypeOfSelectionImage.hxx
StdSelect_ViewerSelector3d.cxx
StdSelect_ViewerSelector3d.hxx
StdSelect_ViewerSelector3d.lxx

View File

@ -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 <theXPix> and <theYPix>. The selector looks for touched areas and owners.
@ -114,6 +114,4 @@ protected:
DEFINE_STANDARD_HANDLE(StdSelect_ViewerSelector3d, SelectMgr_ViewerSelector)
#include <StdSelect_ViewerSelector3d.lxx>
#endif

View File

@ -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();
}