- 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.
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
- mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
- mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
//! allows a better sensitivity for
//! a specific entity in selection algorithms
//! useful for small sized entities.
- Standard_Real SensitivityFactor() const;
+ Standard_EXPORT Standard_Real SensitivityFactor() const;
//! Returns the number of sub-entities or elements in
//! sensitive entity. Is used to determine if entity is
}
}
-//=======================================================================
-// 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),
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
- mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
- mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
Standard_Boolean SelectMgr_ViewerSelector::isToScaleFrustum (const Handle(SelectBasics_SensitiveEntity)& theEntity)
{
return mySelectingVolumeMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point
- && theEntity->SensitivityFactor() < myTolerances.Tolerance();
+ && sensitivity (theEntity) < myTolerances.Tolerance();
}
//=======================================================================
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
if (!aScaledTrnsfFrustums.IsBound (anEnt->DynamicType()))
{
aScaledTrnsfFrustums.Bind (anEnt->DynamicType(),
- scaleAndTransform (anEnt->SensitivityFactor(), theObject->InversedTransformation()));
+ scaleAndTransform (sensitivity (anEnt), theObject->InversedTransformation()));
}
aTmpMgr = aScaledTrnsfFrustums.Find (anEnt->DynamicType());
// 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())
}
}
}
+
+//=======================================================================
+//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);
+}
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;
//! 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)
//! 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);
protected:
Standard_Boolean preferclosest;
- Standard_Real mytolerance;
Standard_Boolean myToUpdateTolerance;
SelectMgr_IndexedDataMapOfOwnerCriterion mystored;
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr;
private:
- Handle(TColStd_HArray1OfInteger) myIndexes;
+ Handle(TColStd_HArray1OfInteger) myIndexes;
Standard_Integer myCurRank;
Standard_Boolean myIsLeftChildQueuedFirst;
Standard_Integer myEntityIdx;
// 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()
//=======================================================================
void StdSelect_ViewerSelector3d::SetPixelTolerance (const Standard_Real theTolerance)
{
- if (mytolerance != theTolerance)
+ if (myTolerances.Tolerance() != theTolerance)
{
if (theTolerance < 0.0)
myTolerances.ResetDefaults();
else
myTolerances.SetCustomTolerance (theTolerance);
- mytolerance = myTolerances.Tolerance();
myToUpdateTolerance = Standard_True;
}
}
if(myToUpdateTolerance)
{
- mySelectingVolumeMgr.SetPixelTolerance (mytolerance);
+ mySelectingVolumeMgr.SetPixelTolerance (myTolerances.Tolerance());
myToUpdateTolerance = Standard_False;
}
const Handle(SelectMgr_SelectableObject)& aSelectable = theOwner->Selectable();
return (aSelectable->GetClipPlanes().Size() > 0);
}
-
-//=======================================================================
-//function : ResetSelectionActivationStatus
-//purpose : Marks all sensitive entities, stored in viewer selector,
-// as inactive for selection
-//=======================================================================
-void StdSelect_ViewerSelector3d::ResetSelectionActivationStatus()
-{
- resetSelectionActivationStatus();
-}
-
-//=======================================================================
-//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 StdSelect_ViewerSelector3d::AllowOverlapDetection (const Standard_Boolean theIsToAllow)
-{
- mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
-}
const Handle(V3d_View)& theView,
const Standard_Boolean theToClearOthers = Standard_True);
- //! Marks all sensitive entities, stored in viewer selector, as inactive for selection
- Standard_EXPORT void ResetSelectionActivationStatus();
-
Standard_EXPORT virtual Standard_Boolean HasDepthClipping (const Handle(SelectMgr_EntityOwner)& theOwner) const Standard_OVERRIDE;
- //! 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);
-
DEFINE_STANDARD_RTTI(StdSelect_ViewerSelector3d, SelectMgr_ViewerSelector)
protected:
inline Standard_Real StdSelect_ViewerSelector3d::PixelTolerance() const
{
- return mytolerance;
+ return myTolerances.Tolerance();
}
--- /dev/null
+puts "============"
+puts "CR26413"
+puts "============"
+puts ""
+###################################################################################
+puts "Visualization, SelectMgr_ViewerSelector - Pixel tolerance is overridden by selection sensitivity"
+###################################################################################
+
+pload VISUALIZATION MODELING
+
+vinit View1
+box b 1 1 1
+vdisplay b
+vfit
+
+set x_on_edge 320
+set y_on_edge 340
+set x_on_vert 383
+set y_on_vert 306
+
+set x_sel_precise 228
+set y_sel_precise 393
+set x_sel_tol 228
+set y_sel_tol 400
+
+set x_notol 374
+set y_notol 309
+set x_tol 370
+set y_tol 312
+
+vselmode b 2 1
+
+# check precise selection of the edge
+vmoveto ${x_sel_precise} ${y_sel_precise}
+checkcolor ${x_on_edge} ${y_on_edge} 0 1 1
+# check selection in neighborhood of the edge
+vmoveto 0 0
+vmoveto ${x_sel_tol} ${y_sel_tol}
+checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
+
+vmoveto 0 0
+# increase selection precision
+vselprecision 8
+
+# check precise selection of the edge
+vmoveto ${x_sel_precise} ${y_sel_precise}
+checkcolor ${x_on_edge} ${y_on_edge} 0 1 1
+# check selection in neighborhood of the edge
+vmoveto 0 0
+vmoveto $x_sel_tol ${y_sel_tol}
+checkcolor ${x_on_edge} ${y_on_edge} 0 1 1
+
+# check that after precision reset selection works as usual
+vmoveto 0 0
+vselprecision -1
+vmoveto ${x_sel_precise} ${y_sel_precise}
+checkcolor ${x_on_edge} ${y_on_edge} 0 1 1
+vmoveto 0 0
+vmoveto ${x_sel_tol} ${y_sel_tol}
+checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
+
+# check that point sensitivity is inreased for all types of
+# sensitive entities
+vmoveto 0 0
+vselmode b 1 1
+vselprecision -1
+
+vmoveto ${x_notol} ${y_notol}
+# check that vertex is highlighted and edge is not
+checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
+checkcolor ${x_on_vert} ${y_on_vert} 0 1 1
+
+vmoveto 0 0
+vselprecision 8
+vmoveto ${x_tol} ${y_tol}
+# check that vertex is highlighted and edge is not
+checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
+checkcolor $x_on_vert $y_on_vert 0 1 1
+
+vdump ${imagedir}/${casename}