mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0026209: Visualization - provide a method to fit view to the specific bounding box
Methods V3d_View::FitAll and NIS_View::FitAll3d now take arbitrary bounding box as a parameter; Option -selected added to vfit command to fit only selected entities in Draw; F key press now fits selected objects if any by default.
This commit is contained in:
@@ -68,6 +68,9 @@ namespace
|
||||
return TCollection_AsciiString ("AIS_CurContext_")
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR));
|
||||
}
|
||||
|
||||
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
|
||||
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -2824,3 +2827,65 @@ void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& th
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FitSelected
|
||||
//purpose : Fits the view corresponding to the bounds of selected objects
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
|
||||
const Standard_Real theMargin,
|
||||
const Standard_Boolean theToUpdate)
|
||||
{
|
||||
Standard_CString aSelName = HasOpenedContext() ?
|
||||
myLocalContexts (myCurLocalIndex)->SelectionName().ToCString()
|
||||
: myCurrentName.ToCString();
|
||||
|
||||
Bnd_Box aBndSelected;
|
||||
|
||||
const Handle(AIS_Selection)& aSelection = AIS_Selection::Selection (aSelName);
|
||||
AIS_MapOfObjectOwners anObjectOwnerMap;
|
||||
for (aSelection->Init(); aSelection->More(); aSelection->Next())
|
||||
{
|
||||
const Handle(AIS_InteractiveObject)& anObj =
|
||||
Handle(AIS_InteractiveObject)::DownCast (aSelection->Value());
|
||||
if (!anObj.IsNull())
|
||||
{
|
||||
if (anObj->IsInfinite())
|
||||
continue;
|
||||
|
||||
Bnd_Box aTmpBnd;
|
||||
anObj->BoundingBox (aTmpBnd);
|
||||
aBndSelected.Add (aTmpBnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner)& anOwner =
|
||||
Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Value());
|
||||
if (anOwner.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap;
|
||||
if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap))
|
||||
{
|
||||
anOwnerMap = new SelectMgr_IndexedMapOfOwner();
|
||||
anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap);
|
||||
}
|
||||
|
||||
anOwnerMap->Add (anOwner);
|
||||
}
|
||||
}
|
||||
|
||||
for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_SelectableObject) anObject = anIter.Key();
|
||||
Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue());
|
||||
aBndSelected.Add (aTmpBox);
|
||||
}
|
||||
|
||||
anObjectOwnerMap.Clear();
|
||||
|
||||
if (aBndSelected.IsVoid())
|
||||
return;
|
||||
|
||||
theView->FitAll (aBndSelected, theMargin, theToUpdate);
|
||||
}
|
||||
|
Reference in New Issue
Block a user