{
if (!HasOpenedContext())
{
- TopoDS_Shape sh;
- Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(SelectedInteractive());
- if (!shape.IsNull()) sh = shape->Shape().Located (SelectedInteractive()->Transformation());
- return sh;
+ TopoDS_Shape aResShape;
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
+ if (!aShape.IsNull())
+ {
+ aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location());
+ }
+
+ return aResShape;
}
else
{
//==================================================
TopoDS_Shape AIS_LocalContext::SelectedShape() const
{
- static TopoDS_Shape aSh;
- Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
- Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
- Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
- if( BRO.IsNull() )
+ Handle(Standard_Transient) aTr = AIS_Selection::CurrentSelection()->Value();
+ Handle(SelectMgr_EntityOwner) anEO = *((Handle(SelectMgr_EntityOwner)*)&aTr);
+ Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO);
+ if( aBRO.IsNull() )
{
- return aSh;
+ return TopoDS_Shape();
}
- return BRO->Shape().Located (BRO->Location());
+ return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
}
//==================================================
static TopAbs_ShapeEnum TypOfSel;
TypOfSel = AIS_Shape::SelectionType(aMode);
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
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
//purpose :
theCommands.Add("vr", "vr : reading of the shape",
__FILE__,vr, group);
+ theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.",
+ __FILE__, VPickSelected, group);
+
}
//=====================================================================