1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025627: SelectedShape() and HasSelectedShape() of AIS_InteractiveContext class do not work as expected.

Location calculation in SelectedShape() was corrected;
Method HasSelectedShape() that does not take into account shape decomposition was added.

Test case for issue 25627
This commit is contained in:
vpa
2014-12-19 15:24:09 +03:00
committed by bugmaster
parent bbe97eddea
commit 51023771f9
5 changed files with 114 additions and 10 deletions

View File

@@ -1046,9 +1046,7 @@ Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
#endif
return Standard_False;
}
return myLocalContexts(myCurLocalIndex)->HasShape();
return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
}
//=======================================================================
@@ -1064,7 +1062,9 @@ TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
if (!aShape.IsNull())
{
aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location());
TopLoc_Location aLocTrsf = SelectedInteractive()->Transformation().Form() == gp_Identity ?
TopLoc_Location() : TopLoc_Location (SelectedInteractive()->Transformation());
aResShape = aShape->Shape().Located (aLocTrsf * aShape->Shape().Location());
}
return aResShape;
@@ -1088,6 +1088,8 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::Interactive() const
Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
{
if(!HasOpenedContext()){
if (AIS_Selection::Selection(myCurrentName.ToCString())->Extent() == 0)
return NULL;
Handle(Standard_Transient) TR =AIS_Selection::Selection(myCurrentName.ToCString())->Value();
Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR);
return IO;}

View File

@@ -388,6 +388,11 @@ is
HasShape(me) returns Boolean from Standard;
---Purpose: returns TRUE if the detected entity is a shape
-- coming from a Decomposition of an element.
HasSelectedShape(me) returns Boolean from Standard;
---Purpose: returns true if current selection is not empty
-- and the owner of selected object contains a shape.
-- This method does not take into account decomposition
-- status of detected shape.
SelectedShape(me) returns Shape from TopoDS;
SelectedOwner(me) returns EntityOwner from SelectMgr;

View File

@@ -772,6 +772,28 @@ HasShape() const
return (hasshape&&comes);
}
//================================================================
// Function : HasSelectedShape
// Purpose : Checks if there is a selected shape regardless of its decomposition status
//================================================================
Standard_Boolean AIS_LocalContext::HasSelectedShape() const
{
if (AIS_Selection::CurrentSelection()->Extent() == 0)
return Standard_False;
Handle(Standard_Transient) aCurSelection = AIS_Selection::CurrentSelection()->Value();
if (aCurSelection.IsNull())
return Standard_False;
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aCurSelection);
Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (aBrepOwner.IsNull())
{
return Standard_False;
}
return aBrepOwner->HasShape();
}
//==================================================
// Function:
// Purpose :
@@ -785,6 +807,7 @@ TopoDS_Shape AIS_LocalContext::SelectedShape() const
{
return TopoDS_Shape();
}
return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
}