0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IVtkOCC / IVtkOCC_ShapePickerAlgo.cxx
index dca1ebf..fac7391 100644 (file)
@@ -269,6 +269,7 @@ void IVtkOCC_ShapePickerAlgo::SubShapesPicked (const IVtk_IdType theId, IVtk_Sha
 //================================================================
 void IVtkOCC_ShapePickerAlgo::clearPicked()
 {
+  myTopPickedPoint.SetCoord (RealLast(), RealLast(), RealLast());
   myShapesPicked.Clear();
   mySubShapesPicked.Clear();
 }
@@ -289,9 +290,11 @@ int IVtkOCC_ShapePickerAlgo::NbPicked()
 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
@@ -307,31 +310,36 @@ bool IVtkOCC_ShapePickerAlgo::processPicked()
 
       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.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;
       }