0027834: Visualization, SelectMgr_ViewerSelector - iteration through detected Entitie...
[occt.git] / src / ViewerTest / ViewerTest.cxx
index 0b1e63a..a342d1a 100644 (file)
 #include <TCollection_AsciiString.hxx>
 #include <Draw_PluginMacro.hxx>
 
-// avoid warnings on 'extern "C"' functions returning C++ classes
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE
-#pragma warning(4:4190)
-#pragma warning (disable:4996)
-#endif
-
 extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
 
 #include <Quantity_Color.hxx>
@@ -4467,67 +4460,20 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     theDI << "Detected entities:\n";
     Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
     SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
-    for (aSelector->InitDetected(); aSelector->MoreDetected(); aSelector->NextDetected())
+    for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
     {
-      const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->DetectedEntity();
+      const SelectMgr_SortCriterion&              aPickData = aSelector->PickedData (aPickIter);
+      const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
       Handle(SelectMgr_EntityOwner) anOwner    = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
       Handle(AIS_InteractiveObject) anObj      = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
-      gp_GTrsf anInvTrsf;
-      if (anObj->TransformPersistence().Flags)
-      {
-        const Graphic3d_Mat4d& aProjection = aMgr.ProjectionMatrix();
-        const Graphic3d_Mat4d& aWorldView  = aMgr.WorldViewMatrix();
-
-        Standard_Integer aViewportWidth = 0;
-        Standard_Integer aViewportHeight = 0;
-        aMgr.WindowSize (aViewportWidth, aViewportHeight);
-
-        Graphic3d_Mat4d aMat = anObj->TransformPersistence().Compute (aMgr.Camera(), aProjection, aWorldView, aViewportWidth, aViewportHeight);
-
-        anInvTrsf.SetValue (1, 1, aMat.GetValue (0, 0));
-        anInvTrsf.SetValue (1, 2, aMat.GetValue (0, 1));
-        anInvTrsf.SetValue (1, 3, aMat.GetValue (0, 2));
-        anInvTrsf.SetValue (2, 1, aMat.GetValue (1, 0));
-        anInvTrsf.SetValue (2, 2, aMat.GetValue (1, 1));
-        anInvTrsf.SetValue (2, 3, aMat.GetValue (1, 2));
-        anInvTrsf.SetValue (3, 1, aMat.GetValue (2, 0));
-        anInvTrsf.SetValue (3, 2, aMat.GetValue (2, 1));
-        anInvTrsf.SetValue (3, 3, aMat.GetValue (2, 2));
-        anInvTrsf.SetTranslationPart (gp_XYZ(aMat.GetValue (0, 3), aMat.GetValue (1, 3), aMat.GetValue (2, 3)));
-        anInvTrsf.Invert();
-      }
-      if (anObj->HasTransformation())
-      {
-        anInvTrsf = anObj->InversedTransformation() * anInvTrsf;
-      }
-      if (anEntity->HasInitLocation())
-      {
-        anInvTrsf = anEntity->InvInitLocation() * anInvTrsf;
-      }
-      const Standard_Integer aScale = anEntity->SensitivityFactor() < aSelector->PixelTolerance()
-        ? anEntity->SensitivityFactor() : 1;
-      const Standard_Boolean isToScaleAndTransform = anInvTrsf.Form() != gp_Identity || aScale != 1;
-      SelectMgr_SelectingVolumeManager anEntMgr =
-        isToScaleAndTransform ? aMgr.ScaleAndTransform (aScale, anInvTrsf)
-                              : aMgr;
-      SelectBasics_PickResult aResult;
-      anEntity->Matches (anEntMgr, aResult);
-
-      gp_Pnt aDetectedPnt = anEntMgr.DetectedPoint (aResult.Depth());
-
-      if (anInvTrsf.Form() != gp_Identity)
-      {
-        anInvTrsf.Inverted().Transforms (aDetectedPnt.ChangeCoord());
-      }
-
       TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
       aName.LeftJustify (20, ' ');
       char anInfoStr[512];
       Sprintf (anInfoStr,
                " Depth: %+.3f Distance: %+.3f Point: %+.3f %+.3f %+.3f",
-               aResult.Depth(),
-               aResult.DistToGeomCenter(),
-               aDetectedPnt.X(), aDetectedPnt.Y(), aDetectedPnt.Z());
+               aPickData.Depth,
+               aPickData.MinDist,
+               aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z());
       theDI << "  " << aName
             << anInfoStr
             << " (" << anEntity->DynamicType()->Name() << ")"