vmoveto and ivtkmoveto commands now print topmost picked 3D point.
Standard_Integer anY = GetInteractor()->GetRenderWindow()->GetSize()[1] - atoi (theArgs[2]) - 1;
GetInteractor()->MoveTo (atoi (theArgs[1]), anY);
+
+ gp_XYZ aPickPnt;
+ GetInteractor()->Selector()->GetPickPosition (aPickPnt.ChangeData());
+ theDI << aPickPnt.X() << " " << aPickPnt.Y() << " " << aPickPnt.Z();
return 0;
}
virtual void Enable();
virtual void Start() { }
+ const PSelector& Selector() const { return mySelector; }
void SetShapePicker (const PSelector& theSelector);
void SetPipelines (const Handle(ShapePipelineMap)& thePipelines);
void SetOCCWindow (const Handle(Aspect_Window)& theWindow);
//================================================================
void IVtkOCC_ShapePickerAlgo::clearPicked()
{
+ myTopPickedPoint.SetCoord (RealLast(), RealLast(), RealLast());
myShapesPicked.Clear();
mySubShapesPicked.Clear();
}
bool IVtkOCC_ShapePickerAlgo::processPicked()
{
Standard_Integer aNbPicked = myViewerSelector->NbPicked();
+
Handle(StdSelect_BRepOwner) anEntityOwner;
Handle(Message_Messenger) anOutput = Message::DefaultMessenger();
+ bool isTop = true;
for (Standard_Integer aDetectIt = 1; aDetectIt <= aNbPicked; aDetectIt++)
{
// ViewerSelector detects sensitive entities under the mouse
IVtk_IdType aTopLevelId = aSelShape->GetId();
myShapesPicked.Append (aTopLevelId);
+ if (isTop)
+ {
+ isTop = false;
+ myTopPickedPoint = myViewerSelector->PickedPoint (aDetectIt);
+ }
// Now try to guess if it's the top-level shape itself or just a sub-shape picked
TopoDS_Shape aTopLevelShape = aSelShape->GetShape();
//! @param [in] theShape the selectable shape
Standard_EXPORT virtual void RemoveSelectableObject(const IVtk_IShape::Handle& theShape);
+ //! Return topmost picked 3D point or (Inf, Inf, Inf) if undefined.
+ const gp_Pnt& TopPickedPoint() const { return myTopPickedPoint; }
+
public:
DEFINE_STANDARD_RTTIEXT(IVtkOCC_ShapePickerAlgo,IVtk_IShapePickerAlgo)
IVtk_IView::Handle myView;
IVtk_ShapeIdList myShapesPicked;
IVtk_SubShapeMap mySubShapesPicked;
+ gp_Pnt myTopPickedPoint;
Handle(IVtkOCC_ViewerSelector) myViewerSelector;
};
{
myOccPickerAlgo->Pick (thePos[0], thePos[1]);
}
+
+ PickPosition[0] = myOccPickerAlgo->TopPickedPoint().X();
+ PickPosition[1] = myOccPickerAlgo->TopPickedPoint().Y();
+ PickPosition[2] = myOccPickerAlgo->TopPickedPoint().Z();
}
//============================================================================
//function : VMoveTo
//purpose : Emulates cursor movement to defined pixel position
//=======================================================================
-static Standard_Integer VMoveTo (Draw_Interpretor& ,
+static Standard_Integer VMoveTo (Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
{
}
ViewerTest::CurrentEventManager()->MoveTo (aMousePos.x(), aMousePos.y());
+ gp_Pnt aTopPnt (RealLast(), RealLast(), RealLast());
+ const Handle(SelectMgr_EntityOwner)& aDetOwner = aContext->DetectedOwner();
+ for (Standard_Integer aDetIter = 1; aDetIter <= aContext->MainSelector()->NbPicked(); ++aDetIter)
+ {
+ if (aContext->MainSelector()->Picked (aDetIter) == aDetOwner)
+ {
+ aTopPnt = aContext->MainSelector()->PickedPoint (aDetIter);
+ break;
+ }
+ }
+ theDI << aTopPnt.X() << " " << aTopPnt.Y() << " " << aTopPnt.Z();
return 0;
}