1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0026413: Visualization, SelectMgr_ViewerSelector - Pixel tolerance is overridden by selection sensitivity

- now custom pixel tolerance from vselprecision is added to default sensitivity of the primitive;
- unnecessary field mytolerance was removed from SelectMgr_ViewerSelector;
- test case for issue #26413.
This commit is contained in:
vpa
2015-07-20 11:46:12 +03:00
committed by bugmaster
parent 631633a280
commit 29a4908e18
9 changed files with 186 additions and 84 deletions

View File

@@ -132,40 +132,12 @@ void SelectMgr_ToleranceMap::Decrement (const Standard_Real& theTolerance)
}
}
//=======================================================================
// function: Tolerance
// purpose : Returns a current tolerance that must be applied
//=======================================================================
Standard_Real SelectMgr_ToleranceMap::Tolerance()
{
return myCustomTolerance < 0.0 ? myLargestKey : myCustomTolerance;
}
//=======================================================================
// function: SetCustomTolerance
// purpose : Sets tolerance to the given one and disables adaptive checks
//=======================================================================
void SelectMgr_ToleranceMap::SetCustomTolerance (const Standard_Real theTolerance)
{
myCustomTolerance = theTolerance;
}
//=======================================================================
// function: ResetDefaults
// purpose : Unsets a custom tolerance and enables adaptive checks
//=======================================================================
void SelectMgr_ToleranceMap::ResetDefaults()
{
myCustomTolerance = -1.0;
}
//==================================================
// Function: Initialize
// Purpose :
//==================================================
SelectMgr_ViewerSelector::SelectMgr_ViewerSelector():
preferclosest(Standard_True),
mytolerance(2.0),
myToUpdateTolerance (Standard_True),
myCurRank (0),
myIsLeftChildQueuedFirst (Standard_False),
@@ -189,7 +161,6 @@ void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theS
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
@@ -208,7 +179,6 @@ void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& th
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
@@ -229,7 +199,7 @@ void SelectMgr_ViewerSelector::Clear()
Standard_Boolean SelectMgr_ViewerSelector::isToScaleFrustum (const Handle(SelectBasics_SensitiveEntity)& theEntity)
{
return mySelectingVolumeMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point
&& theEntity->SensitivityFactor() < myTolerances.Tolerance();
&& sensitivity (theEntity) < myTolerances.Tolerance();
}
//=======================================================================
@@ -255,6 +225,17 @@ SelectMgr_SelectingVolumeManager SelectMgr_ViewerSelector::scaleAndTransform (co
return aMgr;
}
//=======================================================================
// function: sensitivity
// purpose : In case if custom tolerance is set, this method will return sum of entity
// sensitivity and custom tolerance.
//=======================================================================
Standard_Real SelectMgr_ViewerSelector::sensitivity (const Handle(SelectBasics_SensitiveEntity)& theEntity) const
{
return myTolerances.IsCustomTolSet() ?
theEntity->SensitivityFactor() + myTolerances.CustomTolerance() : theEntity->SensitivityFactor();
}
//=======================================================================
// function: checkOverlap
// purpose : Internal function that checks if a particular sensitive
@@ -382,7 +363,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
if (!aScaledTrnsfFrustums.IsBound (anEnt->DynamicType()))
{
aScaledTrnsfFrustums.Bind (anEnt->DynamicType(),
scaleAndTransform (anEnt->SensitivityFactor(), theObject->InversedTransformation()));
scaleAndTransform (sensitivity (anEnt), theObject->InversedTransformation()));
}
aTmpMgr = aScaledTrnsfFrustums.Find (anEnt->DynamicType());
@@ -825,7 +806,7 @@ void SelectMgr_ViewerSelector::RebuildSensitivesTree (const Handle(SelectMgr_Sel
// purpose : Marks all added sensitive entities of all objects as
// non-selectable
//=======================================================================
void SelectMgr_ViewerSelector::resetSelectionActivationStatus()
void SelectMgr_ViewerSelector::ResetSelectionActivationStatus()
{
SelectMgr_MapOfObjectSensitivesIterator aSensitivesIter (myMapOfObjectSensitives);
for ( ; aSensitivesIter.More(); aSensitivesIter.Next())
@@ -874,3 +855,15 @@ void SelectMgr_ViewerSelector::ActiveOwners (NCollection_List<Handle(SelectBasic
}
}
}
//=======================================================================
//function : AllowOverlapDetection
//purpose : Sets the detection type: if theIsToAllow is false,
// only fully included sensitives will be detected, otherwise
// the algorithm will mark both included and overlapped entities
// as matched
//=======================================================================
void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean theIsToAllow)
{
mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
}

View File

@@ -76,13 +76,19 @@ public:
Standard_EXPORT void Decrement (const Standard_Real& theTolerance);
//! Returns a current tolerance that must be applied
Standard_EXPORT Standard_Real Tolerance();
inline Standard_Real Tolerance() const;
//! Sets tolerance to the given one and disables adaptive checks
Standard_EXPORT void SetCustomTolerance (const Standard_Real theTolerance);
inline void SetCustomTolerance (const Standard_Real theTolerance);
//! Unsets a custom tolerance and enables adaptive checks
Standard_EXPORT void ResetDefaults();
inline void ResetDefaults();
//! Returns the value of custom tolerance regardless of it validity
inline Standard_Real CustomTolerance() const;
//! Returns true if custom tolerance value is greater than zero
inline Standard_Boolean IsCustomTolSet() const;
private:
NCollection_DataMap<Standard_Real, Standard_Integer> myTolerances;
@@ -242,6 +248,14 @@ public:
//! Returns instance of selecting volume manager of the viewer selector
Standard_EXPORT SelectMgr_SelectingVolumeManager& GetManager();
//! Marks all added sensitive entities of all objects as non-selectable
Standard_EXPORT void ResetSelectionActivationStatus();
//! Is used for rectangular selection only
//! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
//! mark both included and overlapped entities as matched
Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
friend class SelectMgr_SelectionManager;
DEFINE_STANDARD_RTTI(SelectMgr_ViewerSelector, MMgt_TShared)
@@ -265,26 +279,27 @@ protected:
//! Internal function that checks if there is possible overlap
//! between some entity of selectable object theObject and
//! current selecting volume
void traverseObject (const Handle(SelectMgr_SelectableObject)& theObject);
Standard_EXPORT void traverseObject (const Handle(SelectMgr_SelectableObject)& theObject);
//! Internal function that checks if a particular sensitive
//! entity theEntity overlaps current selecting volume precisely
void checkOverlap (const Handle(SelectBasics_SensitiveEntity)& theEntity,
const Standard_Integer theEntityIdx,
SelectMgr_SelectingVolumeManager& theMgr);
Standard_EXPORT void checkOverlap (const Handle(SelectBasics_SensitiveEntity)& theEntity,
const Standard_Integer theEntityIdx,
SelectMgr_SelectingVolumeManager& theMgr);
//! Marks all added sensitive entities of all objects as non-selectable
void resetSelectionActivationStatus();
private:
//! Checks if the entity given requires to scale current selecting frustum
Standard_Boolean isToScaleFrustum (const Handle(SelectBasics_SensitiveEntity)& theEntity);
//! In case if custom tolerance is set, this method will return sum of entity sensitivity and
//! custom tolerance. Otherwise, pure entity sensitivity factor will be returned.
Standard_Real sensitivity (const Handle(SelectBasics_SensitiveEntity)& theEntity) const;
//! Applies given scale and transformation matrices to the default selecting volume manager
SelectMgr_SelectingVolumeManager scaleAndTransform (const Standard_Real theScale,
const gp_Trsf& theTrsf);
private:
void Activate (const Handle(SelectMgr_Selection)& theSelection);
void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
@@ -295,7 +310,6 @@ private:
protected:
Standard_Boolean preferclosest;
Standard_Real mytolerance;
Standard_Boolean myToUpdateTolerance;
SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
@@ -304,7 +318,7 @@ protected:
private:
Handle(TColStd_HArray1OfInteger) myIndexes;
Handle(TColStd_HArray1OfInteger) myIndexes;
Standard_Integer myCurRank;
Standard_Boolean myIsLeftChildQueuedFirst;
Standard_Integer myEntityIdx;

View File

@@ -12,9 +12,57 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
// function: Tolerance
// purpose : Returns a current tolerance that must be applied
//=======================================================================
inline Standard_Real SelectMgr_ToleranceMap::Tolerance() const
{
if (myLargestKey < Precision::Confusion())
return 2.0; // default tolerance value
return myCustomTolerance < 0.0 ? myLargestKey : myLargestKey + myCustomTolerance;
}
//=======================================================================
// function: SetCustomTolerance
// purpose : Sets tolerance to the given one and disables adaptive checks
//=======================================================================
inline void SelectMgr_ToleranceMap::SetCustomTolerance (const Standard_Real theTolerance)
{
myCustomTolerance = theTolerance;
}
//=======================================================================
// function: CustomTolerance
// purpose : Returns current value of custom tolerance regardless of it is set or not
//=======================================================================
inline Standard_Real SelectMgr_ToleranceMap::CustomTolerance() const
{
return myCustomTolerance;
}
//=======================================================================
// function: IsCustomTolSet
// purpose : Checks if custom tolerance value is greater than zero
//=======================================================================
inline Standard_Boolean SelectMgr_ToleranceMap::IsCustomTolSet() const
{
return myCustomTolerance > 0.0;
}
//=======================================================================
// function: ResetDefaults
// purpose : Unsets a custom tolerance and enables adaptive checks
//=======================================================================
inline void SelectMgr_ToleranceMap::ResetDefaults()
{
myCustomTolerance = -1.0;
}
inline Standard_Real SelectMgr_ViewerSelector::Sensitivity() const
{
return mytolerance;
return myTolerances.Tolerance();
}
inline void SelectMgr_ViewerSelector::Init()