mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +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:
parent
bbe97eddea
commit
51023771f9
@ -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;}
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -3644,10 +3644,34 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString anOption (theArgNb >= 2 ? theArgVec[1] : "");
|
||||
anOption.LowerCase();
|
||||
if (anOption == "-detectedEntities"
|
||||
|| anOption == "-entities")
|
||||
Standard_Boolean toPrintEntities = Standard_False;
|
||||
Standard_Boolean toCheckSelected = Standard_False;
|
||||
|
||||
for (Standard_Integer anArgIdx = 1; anArgIdx < theArgNb; ++anArgIdx)
|
||||
{
|
||||
TCollection_AsciiString anOption (theArgVec[anArgIdx]);
|
||||
anOption.LowerCase();
|
||||
if (anOption == "-detectedentities"
|
||||
|| anOption == "-entities")
|
||||
{
|
||||
toPrintEntities = Standard_True;
|
||||
}
|
||||
else if (anOption == "-hasselected")
|
||||
{
|
||||
toCheckSelected = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (toCheckSelected)
|
||||
{
|
||||
aCtx->InitSelected();
|
||||
TCollection_AsciiString hasSelected (static_cast<Standard_Integer> (aCtx->HasSelectedShape()));
|
||||
theDI << "Check if context has selected shape: " << hasSelected << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (toPrintEntities)
|
||||
{
|
||||
theDI << "Detected entities:\n";
|
||||
Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
|
||||
@ -4664,9 +4688,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
__FILE__,VActivatedMode,group);
|
||||
|
||||
theCommands.Add("vstate",
|
||||
"vstate [-entities] [name1] ... [nameN]"
|
||||
"vstate [-entities] [-hasSelected] [name1] ... [nameN]"
|
||||
"\n\t\t: Reports show/hidden state for selected or named objects"
|
||||
"\n\t\t: -entities - print low-level information about detected entities",
|
||||
"\n\t\t: -entities - print low-level information about detected entities"
|
||||
"\n\t\t: -hasSelected - prints 1 if context has selected shape and 0 otherwise",
|
||||
__FILE__,VState,group);
|
||||
|
||||
theCommands.Add("vpickshapes",
|
||||
|
49
tests/bugs/vis/bug25627
Normal file
49
tests/bugs/vis/bug25627
Normal file
@ -0,0 +1,49 @@
|
||||
puts "============"
|
||||
puts "CR25627"
|
||||
puts "============"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# SelectedShape() and HasSelectedShape() of AIS_InteractiveContext
|
||||
# class do not work as expected.
|
||||
#######################################################################
|
||||
pload ALL
|
||||
|
||||
vinit
|
||||
box aBox 5 5 5
|
||||
vdisplay aBox
|
||||
vfit
|
||||
vselect 100 100
|
||||
set aSelectionRes [vstate -hasSelected]
|
||||
if { [lsearch $aSelectionRes 0] != -1 } {
|
||||
puts "ERROR: Incorrect result of HasSelectedShape of the context!"
|
||||
}
|
||||
vpickselected aSelected
|
||||
set aRes [vstate aSelected]
|
||||
if { $aRes == "aSelected doesn't exist!" } {
|
||||
puts "ERROR: No shape selected in neutral point!"
|
||||
}
|
||||
set aCompRes [compare aBox aSelected]
|
||||
if { [lsearch $aCompRes not] != -1 } {
|
||||
puts "ERROR: Selected box and selected shape from the context are not equal!"
|
||||
}
|
||||
|
||||
vselect 0 0
|
||||
vremove aSelected
|
||||
|
||||
vselmode aBox 6 1
|
||||
vselect 100 100
|
||||
set aSelectionRes [vstate -hasSelected]
|
||||
if { [lsearch $aSelectionRes 0] != -1 } {
|
||||
puts "ERROR: Incorrect result of HasSelectedShape of the context!"
|
||||
}
|
||||
vpickselected aSelected
|
||||
set aRes [vstate aSelected]
|
||||
if { $aRes == "aSelected doesn't exist!" } {
|
||||
puts "ERROR: No shape selected in local selection!"
|
||||
}
|
||||
set aCompRes [compare aBox aSelected]
|
||||
if { [lsearch $aCompRes not] != -1 } {
|
||||
puts "ERROR: Selected box and selected solid are not equal!"
|
||||
}
|
||||
|
||||
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user