#include <Message_Messenger.hxx>
#include <StdSelect_BRepOwner.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(IVtkOCC_ShapePickerAlgo,IVtk_IShapePickerAlgo)
+
// Handle implementation
-IMPLEMENT_STANDARD_HANDLE(IVtkOCC_ShapePickerAlgo, IVtk_IShapePickerAlgo)
-IMPLEMENT_STANDARD_RTTIEXT(IVtkOCC_ShapePickerAlgo, IVtk_IShapePickerAlgo)
+
//================================================================
// Function : Constructor
{
IVtk_SelectionModeList aRes;
- if (theShape)
+ if (! theShape.IsNull())
{
// Get shape implementation from shape interface.
Handle(IVtkOCC_Shape) aShapeImpl = Handle(IVtkOCC_Shape)::DownCast(theShape);
const IVtk_SelectionMode theMode,
const bool theIsTurnOn)
{
- if (!theShape)
+ if (theShape.IsNull())
{
return;
}
{
if (mySubShapesPicked.IsBound (theId))
{
- // Need non-const this to call the map's operator[]
- IVtkOCC_ShapePickerAlgo* that = const_cast< IVtkOCC_ShapePickerAlgo* >(this);
- theShapeList = that->mySubShapesPicked (theId);
+ theShapeList = mySubShapesPicked (theId);
}
}
//================================================================
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
Handle(IVtkOCC_SelectableObject) aSelectable =
Handle(IVtkOCC_SelectableObject)::DownCast (anEntityOwner->Selectable());
- if (!aSelectable)
+ if (aSelectable.IsNull())
{
- anOutput << "Error: EntityOwner having null SelectableObject picked!";
+ anOutput->SendAlarm() << "Error: EntityOwner having null SelectableObject picked!";
continue;
}
Handle(IVtkOCC_Shape) aSelShape = aSelectable->GetShape();
- if (!aSelShape)
+ if (aSelShape.IsNull())
{
- anOutput << "Error: SelectableObject with null OccShape pointer picked!";
+ anOutput->SendAlarm() << "Error: SelectableObject with null OccShape pointer picked!";
continue;
}
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();
TopoDS_Shape aSubShape = anEntityOwner->Shape();
if (aTopLevelShape.IsNull())
{
- anOutput << "Error: OccShape with null top-level TopoDS_Shape picked!";
+ anOutput->SendAlarm() << "Error: OccShape with null top-level TopoDS_Shape picked!";
continue;
}
if (aSubShape.IsNull())
{
- anOutput << "Error: EntityOwner with null TopoDS_Shape picked!";
+ anOutput->SendAlarm() << "Error: EntityOwner with null TopoDS_Shape picked!";
continue;
}
return !myShapesPicked.IsEmpty();
}
+
+//============================================================================
+// Method: RemoveSelectableActor
+// Purpose: Remove selectable object from the picker (from internal maps).
+//============================================================================
+void IVtkOCC_ShapePickerAlgo::RemoveSelectableObject(const IVtk_IShape::Handle& theShape)
+{
+ clearPicked();
+ // Get shape implementation from shape interface.
+ Handle(IVtkOCC_Shape) aShapeImpl =
+ Handle(IVtkOCC_Shape)::DownCast(theShape);
+
+ // Get selectable object from the shape implementation.
+ Handle(IVtkOCC_SelectableObject) aSelObj =
+ Handle(IVtkOCC_SelectableObject)::DownCast(aShapeImpl->GetSelectableObject());
+
+ myViewerSelector->RemoveSelectableObject(aSelObj);
+ myViewerSelector->Clear();
+ aShapeImpl->SetSelectableObject(NULL);
+}
\ No newline at end of file