mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0030484: Visualization, SelectMgr_ViewerSelector - Graphic3d_TMF_2d persistence sorting issues
Added property to SelectableObject for selection focused on display priority. Modified SelectMgr_ViewerSelector CompareResults based on the focus priority property. Added display priority to the sorting criterion Added tests for multiple types of sensitive entities. Modified vpriority command to change an object's selection priority.
This commit is contained in:
@@ -28,14 +28,16 @@ class SelectMgr_SortCriterion
|
||||
public:
|
||||
|
||||
Handle(Select3D_SensitiveEntity) Entity; //!< detected entity
|
||||
gp_Pnt Point; //!< 3D point
|
||||
Graphic3d_Vec3 Normal; //!< surface normal or 0 vector if undefined
|
||||
Standard_Real Depth; //!< distance from the view plane to the entity
|
||||
Standard_Real MinDist; //!< distance from the clicked point to the entity on the view plane
|
||||
Standard_Real Tolerance; //!< tolerance used for selecting candidates
|
||||
Standard_Integer Priority; //!< selection priority
|
||||
Standard_Integer ZLayerPosition; //!< ZLayer rendering order index, stronger than a depth
|
||||
Standard_Integer NbOwnerMatches; //!< overall number of entities collected for the same owner
|
||||
gp_Pnt Point; //!< 3D point
|
||||
Graphic3d_Vec3 Normal; //!< surface normal or 0 vector if undefined
|
||||
Standard_Real Depth; //!< distance from the view plane to the entity
|
||||
Standard_Real MinDist; //!< distance from the clicked point to the entity on the view plane
|
||||
Standard_Real Tolerance; //!< tolerance used for selecting candidates
|
||||
Standard_Integer SelectionPriority; //!< selection priority
|
||||
Standard_Integer DisplayPriority; //!< display priority
|
||||
Standard_Integer ZLayerPosition; //!< ZLayer rendering order index, stronger than a depth
|
||||
Standard_Integer NbOwnerMatches; //!< overall number of entities collected for the same owner
|
||||
Standard_Boolean IsPreferPriority; //!< flag to signal comparison to be done over priority
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
@@ -45,9 +47,11 @@ public:
|
||||
: Depth (0.0),
|
||||
MinDist (0.0),
|
||||
Tolerance(0.0),
|
||||
Priority (0),
|
||||
SelectionPriority (0),
|
||||
DisplayPriority(0),
|
||||
ZLayerPosition (0),
|
||||
NbOwnerMatches (0) {}
|
||||
NbOwnerMatches (0),
|
||||
IsPreferPriority (Standard_False) {}
|
||||
|
||||
//! Compare with another item by depth, priority and minDist.
|
||||
bool IsCloserDepth (const SelectMgr_SortCriterion& theOther) const
|
||||
@@ -86,13 +90,18 @@ public:
|
||||
}
|
||||
|
||||
// if two objects have similar depth, select the one with higher priority
|
||||
if (Priority > theOther.Priority)
|
||||
if (SelectionPriority > theOther.SelectionPriority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DisplayPriority > theOther.DisplayPriority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// if priorities are equal, one closest to the mouse
|
||||
return Priority == theOther.Priority
|
||||
return SelectionPriority == theOther.SelectionPriority
|
||||
&& MinDist < theOther.MinDist;
|
||||
}
|
||||
|
||||
@@ -105,13 +114,14 @@ public:
|
||||
return ZLayerPosition > theOther.ZLayerPosition;
|
||||
}
|
||||
|
||||
if (Priority > theOther.Priority)
|
||||
if (SelectionPriority != theOther.SelectionPriority)
|
||||
{
|
||||
return true;
|
||||
return SelectionPriority > theOther.SelectionPriority;
|
||||
}
|
||||
else if (Priority != theOther.Priority)
|
||||
|
||||
if (DisplayPriority != theOther.DisplayPriority)
|
||||
{
|
||||
return false;
|
||||
return DisplayPriority > theOther.DisplayPriority;
|
||||
}
|
||||
|
||||
//if (Abs (Depth - theOther.Depth) <= (Tolerance + theOther.Tolerance))
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <SelectMgr_ViewerSelector.hxx>
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <BVH_Tree.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
@@ -54,13 +55,13 @@ namespace
|
||||
{
|
||||
const SelectMgr_SortCriterion& anElemLeft = myMapOfCriterion->FindFromIndex (theLeft);
|
||||
const SelectMgr_SortCriterion& anElemRight = myMapOfCriterion->FindFromIndex (theRight);
|
||||
if (myToPreferClosest)
|
||||
if ((anElemLeft.IsPreferPriority && anElemRight.IsPreferPriority) || !myToPreferClosest)
|
||||
{
|
||||
return anElemLeft.IsCloserDepth (anElemRight);
|
||||
return anElemLeft.IsHigherPriority (anElemRight);
|
||||
}
|
||||
else
|
||||
{
|
||||
return anElemLeft.IsHigherPriority (anElemRight);
|
||||
return anElemLeft.IsCloserDepth (anElemRight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,13 +271,32 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(Select3D_SensitiveEnti
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectMgr_SortCriterion aCriterion;
|
||||
myZLayerOrderMap.Find (!aSelectable.IsNull() ? aSelectable->ZLayer() : Graphic3d_ZLayerId_Default, aCriterion.ZLayerPosition);
|
||||
aCriterion.Entity = theEntity;
|
||||
aCriterion.Priority = anOwner->Priority();
|
||||
aCriterion.Depth = aPickResult.Depth();
|
||||
aCriterion.MinDist = aPickResult.DistToGeomCenter();
|
||||
aCriterion.Entity = theEntity;
|
||||
aCriterion.SelectionPriority = anOwner->Priority();
|
||||
aCriterion.Depth = aPickResult.Depth();
|
||||
aCriterion.MinDist = aPickResult.DistToGeomCenter();
|
||||
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelectable);
|
||||
if (!aSelectable.IsNull())
|
||||
{
|
||||
if (aSelectable->Presentations().Size() > 0 && !aSelectable->TransformPersistence().IsNull())
|
||||
{
|
||||
if (aSelectable->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
|
||||
{
|
||||
aCriterion.IsPreferPriority = Standard_True;
|
||||
aCriterion.DisplayPriority = Graphic3d_DisplayPriority_INVALID;
|
||||
if (!anObj.IsNull())
|
||||
{
|
||||
Handle(Prs3d_Presentation) aPrs = anObj->Presentation();
|
||||
if (!aPrs.IsNull())
|
||||
{
|
||||
aCriterion.DisplayPriority = aPrs->DisplayPriority();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectMgr_SortCriterion* aPrevCriterion = mystored.ChangeSeek (anOwner))
|
||||
{
|
||||
|
Reference in New Issue
Block a user