1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027834: Visualization, SelectMgr_ViewerSelector - iteration through detected Entities should be sorted

SelectMgr_SortCriterion now stores detected SensitiveEntity and 3D point.
SelectMgr_ToleranceMap class definition has been moved out to dedicated file (from SelectMgr_ViewerSelector).

SelectMgr_ViewerSelector - the methods implementing class-as-iterator
Init(), More(), Next(), Picked() and InitDetected(), MoreDetected(),
NextDetected(), DetectedEntity() have been deprecated.
User should access detection results by using index.
New methods PickedData(), PickedEntity(), PickedPoint() have been added
for accessing auxiliary information about picked object in sorted order.
This commit is contained in:
kgv
2016-09-02 19:11:23 +03:00
committed by bugmaster
parent 1ce0716bb1
commit aa75c0cf9d
10 changed files with 307 additions and 435 deletions

View File

@@ -76,13 +76,6 @@
#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() << ")"