mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0025335: Visualization - method ::SelectedShape() in AIS_LocalContext and AIS_InteractiveContext overrides shape transformation
Shape location overriding fixed by combining AIS object transformation and shape location. Also incorrect highlight presentation (and sensitive) placement was possible.
This commit is contained in:
parent
de6f281fe9
commit
d81101039f
@ -1122,10 +1122,14 @@ TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
|
|||||||
{
|
{
|
||||||
if (!HasOpenedContext())
|
if (!HasOpenedContext())
|
||||||
{
|
{
|
||||||
TopoDS_Shape sh;
|
TopoDS_Shape aResShape;
|
||||||
Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(SelectedInteractive());
|
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
|
||||||
if (!shape.IsNull()) sh = shape->Shape().Located (SelectedInteractive()->Transformation());
|
if (!aShape.IsNull())
|
||||||
return sh;
|
{
|
||||||
|
aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location());
|
||||||
|
}
|
||||||
|
|
||||||
|
return aResShape;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -776,15 +776,14 @@ HasShape() const
|
|||||||
//==================================================
|
//==================================================
|
||||||
TopoDS_Shape AIS_LocalContext::SelectedShape() const
|
TopoDS_Shape AIS_LocalContext::SelectedShape() const
|
||||||
{
|
{
|
||||||
static TopoDS_Shape aSh;
|
Handle(Standard_Transient) aTr = AIS_Selection::CurrentSelection()->Value();
|
||||||
Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
|
Handle(SelectMgr_EntityOwner) anEO = *((Handle(SelectMgr_EntityOwner)*)&aTr);
|
||||||
Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
|
Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO);
|
||||||
Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
|
if( aBRO.IsNull() )
|
||||||
if( BRO.IsNull() )
|
|
||||||
{
|
{
|
||||||
return aSh;
|
return TopoDS_Shape();
|
||||||
}
|
}
|
||||||
return BRO->Shape().Located (BRO->Location());
|
return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
@ -379,10 +379,6 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
|||||||
static TopAbs_ShapeEnum TypOfSel;
|
static TopAbs_ShapeEnum TypOfSel;
|
||||||
TypOfSel = AIS_Shape::SelectionType(aMode);
|
TypOfSel = AIS_Shape::SelectionType(aMode);
|
||||||
TopoDS_Shape shape = myshape;
|
TopoDS_Shape shape = myshape;
|
||||||
if( HasTransformation() ) {
|
|
||||||
gp_Trsf trsf = Transformation();
|
|
||||||
shape = shape.Located(TopLoc_Location(trsf)*shape.Location());
|
|
||||||
}
|
|
||||||
|
|
||||||
// POP protection against crash in low layers
|
// POP protection against crash in low layers
|
||||||
|
|
||||||
|
@ -4079,6 +4079,54 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : VPickSelected
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgs)
|
||||||
|
{
|
||||||
|
static Standard_Integer aCount = 0;
|
||||||
|
TCollection_AsciiString aName = "PickedShape_";
|
||||||
|
|
||||||
|
if (theArgNb > 1)
|
||||||
|
{
|
||||||
|
aName = theArgs[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aName = aName + aCount++ + "_";
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer anIdx = 0;
|
||||||
|
for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected(), ++anIdx)
|
||||||
|
{
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
if (TheAISContext()->HasSelectedShape())
|
||||||
|
{
|
||||||
|
aShape = TheAISContext()->SelectedShape();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
|
||||||
|
aShape = (*((Handle(AIS_Shape)*) &IO))->Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
TCollection_AsciiString aCurrentName = aName;
|
||||||
|
if (anIdx > 0)
|
||||||
|
{
|
||||||
|
aCurrentName += anIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBRep::Set ((aCurrentName).ToCString(), aShape);
|
||||||
|
|
||||||
|
Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape);
|
||||||
|
GetMapOfAIS().Bind (aNewShape, aCurrentName);
|
||||||
|
TheAISContext()->Display (aNewShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : list of known objects
|
//function : list of known objects
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -4636,6 +4684,9 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("vr", "vr : reading of the shape",
|
theCommands.Add("vr", "vr : reading of the shape",
|
||||||
__FILE__,vr, group);
|
__FILE__,vr, group);
|
||||||
|
|
||||||
|
theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.",
|
||||||
|
__FILE__, VPickSelected, group);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
|
24
tests/bugs/vis/bug25335
Normal file
24
tests/bugs/vis/bug25335
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "OCC25335"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
#######################################################################################
|
||||||
|
# Visualization - method ::SelectedShape() in AIS_LocalContext and AIS_InteractiveContext overrides shape transformation
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
vinit
|
||||||
|
|
||||||
|
box b 1 1 1
|
||||||
|
vdisplay b
|
||||||
|
btranslate b 1 0 0
|
||||||
|
vselmode 2 1
|
||||||
|
vfit
|
||||||
|
vselect 299 352
|
||||||
|
vpickselected
|
||||||
|
vsetlocation b 0 1 0
|
||||||
|
vzfit
|
||||||
|
vselect 233 188
|
||||||
|
vpickselected
|
||||||
|
vsetlocation b -2 2 0
|
||||||
|
vfit
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user