mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030520: VIS - IVtkTools_ShapePicker::GetPickPosition() returns incorrect point
vmoveto and ivtkmoveto commands now print topmost picked 3D point.
This commit is contained in:
parent
3bb61eb0fe
commit
1e756cb979
@ -899,6 +899,10 @@ static Standard_Integer VtkMoveTo(Draw_Interpretor& theDI,
|
|||||||
|
|
||||||
Standard_Integer anY = GetInteractor()->GetRenderWindow()->GetSize()[1] - atoi (theArgs[2]) - 1;
|
Standard_Integer anY = GetInteractor()->GetRenderWindow()->GetSize()[1] - atoi (theArgs[2]) - 1;
|
||||||
GetInteractor()->MoveTo (atoi (theArgs[1]), anY);
|
GetInteractor()->MoveTo (atoi (theArgs[1]), anY);
|
||||||
|
|
||||||
|
gp_XYZ aPickPnt;
|
||||||
|
GetInteractor()->Selector()->GetPickPosition (aPickPnt.ChangeData());
|
||||||
|
theDI << aPickPnt.X() << " " << aPickPnt.Y() << " " << aPickPnt.Z();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ public:
|
|||||||
virtual void Enable();
|
virtual void Enable();
|
||||||
virtual void Start() { }
|
virtual void Start() { }
|
||||||
|
|
||||||
|
const PSelector& Selector() const { return mySelector; }
|
||||||
void SetShapePicker (const PSelector& theSelector);
|
void SetShapePicker (const PSelector& theSelector);
|
||||||
void SetPipelines (const Handle(ShapePipelineMap)& thePipelines);
|
void SetPipelines (const Handle(ShapePipelineMap)& thePipelines);
|
||||||
void SetOCCWindow (const Handle(Aspect_Window)& theWindow);
|
void SetOCCWindow (const Handle(Aspect_Window)& theWindow);
|
||||||
|
@ -269,6 +269,7 @@ void IVtkOCC_ShapePickerAlgo::SubShapesPicked (const IVtk_IdType theId, IVtk_Sha
|
|||||||
//================================================================
|
//================================================================
|
||||||
void IVtkOCC_ShapePickerAlgo::clearPicked()
|
void IVtkOCC_ShapePickerAlgo::clearPicked()
|
||||||
{
|
{
|
||||||
|
myTopPickedPoint.SetCoord (RealLast(), RealLast(), RealLast());
|
||||||
myShapesPicked.Clear();
|
myShapesPicked.Clear();
|
||||||
mySubShapesPicked.Clear();
|
mySubShapesPicked.Clear();
|
||||||
}
|
}
|
||||||
@ -289,9 +290,11 @@ int IVtkOCC_ShapePickerAlgo::NbPicked()
|
|||||||
bool IVtkOCC_ShapePickerAlgo::processPicked()
|
bool IVtkOCC_ShapePickerAlgo::processPicked()
|
||||||
{
|
{
|
||||||
Standard_Integer aNbPicked = myViewerSelector->NbPicked();
|
Standard_Integer aNbPicked = myViewerSelector->NbPicked();
|
||||||
|
|
||||||
Handle(StdSelect_BRepOwner) anEntityOwner;
|
Handle(StdSelect_BRepOwner) anEntityOwner;
|
||||||
Handle(Message_Messenger) anOutput = Message::DefaultMessenger();
|
Handle(Message_Messenger) anOutput = Message::DefaultMessenger();
|
||||||
|
|
||||||
|
bool isTop = true;
|
||||||
for (Standard_Integer aDetectIt = 1; aDetectIt <= aNbPicked; aDetectIt++)
|
for (Standard_Integer aDetectIt = 1; aDetectIt <= aNbPicked; aDetectIt++)
|
||||||
{
|
{
|
||||||
// ViewerSelector detects sensitive entities under the mouse
|
// ViewerSelector detects sensitive entities under the mouse
|
||||||
@ -320,6 +323,11 @@ bool IVtkOCC_ShapePickerAlgo::processPicked()
|
|||||||
|
|
||||||
IVtk_IdType aTopLevelId = aSelShape->GetId();
|
IVtk_IdType aTopLevelId = aSelShape->GetId();
|
||||||
myShapesPicked.Append (aTopLevelId);
|
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
|
// Now try to guess if it's the top-level shape itself or just a sub-shape picked
|
||||||
TopoDS_Shape aTopLevelShape = aSelShape->GetShape();
|
TopoDS_Shape aTopLevelShape = aSelShape->GetShape();
|
||||||
|
@ -100,6 +100,9 @@ public: //! @name Obtain picking results
|
|||||||
//! @param [in] theShape the selectable shape
|
//! @param [in] theShape the selectable shape
|
||||||
Standard_EXPORT virtual void RemoveSelectableObject(const IVtk_IShape::Handle& theShape);
|
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:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(IVtkOCC_ShapePickerAlgo,IVtk_IShapePickerAlgo)
|
DEFINE_STANDARD_RTTIEXT(IVtkOCC_ShapePickerAlgo,IVtk_IShapePickerAlgo)
|
||||||
@ -121,6 +124,7 @@ private:
|
|||||||
IVtk_IView::Handle myView;
|
IVtk_IView::Handle myView;
|
||||||
IVtk_ShapeIdList myShapesPicked;
|
IVtk_ShapeIdList myShapesPicked;
|
||||||
IVtk_SubShapeMap mySubShapesPicked;
|
IVtk_SubShapeMap mySubShapesPicked;
|
||||||
|
gp_Pnt myTopPickedPoint;
|
||||||
Handle(IVtkOCC_ViewerSelector) myViewerSelector;
|
Handle(IVtkOCC_ViewerSelector) myViewerSelector;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,6 +193,10 @@ void IVtkTools_ShapePicker::doPickImpl (double* thePos,
|
|||||||
{
|
{
|
||||||
myOccPickerAlgo->Pick (thePos[0], thePos[1]);
|
myOccPickerAlgo->Pick (thePos[0], thePos[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickPosition[0] = myOccPickerAlgo->TopPickedPoint().X();
|
||||||
|
PickPosition[1] = myOccPickerAlgo->TopPickedPoint().Y();
|
||||||
|
PickPosition[2] = myOccPickerAlgo->TopPickedPoint().Z();
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -6704,7 +6704,7 @@ static Standard_Integer VSelect (Draw_Interpretor& di,
|
|||||||
//function : VMoveTo
|
//function : VMoveTo
|
||||||
//purpose : Emulates cursor movement to defined pixel position
|
//purpose : Emulates cursor movement to defined pixel position
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
static Standard_Integer VMoveTo (Draw_Interpretor& ,
|
static Standard_Integer VMoveTo (Draw_Interpretor& theDI,
|
||||||
Standard_Integer theNbArgs,
|
Standard_Integer theNbArgs,
|
||||||
const char** theArgVec)
|
const char** theArgVec)
|
||||||
{
|
{
|
||||||
@ -6767,6 +6767,17 @@ static Standard_Integer VMoveTo (Draw_Interpretor& ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ViewerTest::CurrentEventManager()->MoveTo (aMousePos.x(), aMousePos.y());
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user