Loading files
3d097a032This file is pinned to the selected release. Download the original to open it in your design tool.
// Created on: 1997-01-17
// Created by: Robert COUBLANC
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_GlobalStatus.hxx>
#include <NCollection_DataMap.hxx>
#include <AIS_ConnectedInteractive.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
#include <Precision.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_Transient.hxx>
#include <NCollection_Map.hxx>
#include <TopLoc_Location.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <AIS_Shape.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
namespace
{
typedef NCollection_DataMap<
occ::handle<SelectMgr_SelectableObject>,
occ::handle<NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>>
AIS_MapOfObjectOwners;
typedef NCollection_DataMap<
occ::handle<SelectMgr_SelectableObject>,
occ::handle<NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>>::
Iterator AIS_MapIteratorOfMapOfObjectOwners;
//! Initialize default highlighting attributes.
static void initDefaultHilightAttributes(const occ::handle<Prs3d_Drawer>& theDrawer,
const Quantity_Color& theColor)
{
theDrawer->SetMethod(Aspect_TOHM_COLOR);
theDrawer->SetDisplayMode(0);
theDrawer->SetColor(theColor);
theDrawer->SetupOwnShadingAspect();
theDrawer->SetupOwnPointAspect();
theDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
theDrawer->SetWireAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
theDrawer->SetPlaneAspect(new Prs3d_PlaneAspect());
*theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect();
theDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
theDrawer->SetUnFreeBoundaryAspect(
new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->UnFreeBoundaryAspect()->Aspect() =
*theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
theDrawer->SetDatumAspect(new Prs3d_DatumAspect());
theDrawer->ShadingAspect()->SetColor(theColor);
theDrawer->WireAspect()->SetColor(theColor);
theDrawer->LineAspect()->SetColor(theColor);
theDrawer->PlaneAspect()->ArrowAspect()->SetColor(theColor);
theDrawer->PlaneAspect()->IsoAspect()->SetColor(theColor);
theDrawer->PlaneAspect()->EdgesAspect()->SetColor(theColor);
theDrawer->FreeBoundaryAspect()->SetColor(theColor);
theDrawer->UnFreeBoundaryAspect()->SetColor(theColor);
theDrawer->PointAspect()->SetColor(theColor);
for (int aPartIter = 0; aPartIter < Prs3d_DatumParts_None; ++aPartIter)
{
if (occ::handle<Prs3d_LineAspect> aLineAsp =
theDrawer->DatumAspect()->LineAspect((Prs3d_DatumParts)aPartIter))
{
aLineAsp->SetColor(theColor);
}
}
theDrawer->WireAspect()->SetWidth(2.0);
theDrawer->LineAspect()->SetWidth(2.0);
theDrawer->PlaneAspect()->EdgesAspect()->SetWidth(2.0);
theDrawer->FreeBoundaryAspect()->SetWidth(2.0);
theDrawer->UnFreeBoundaryAspect()->SetWidth(2.0);
theDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_POINT);
theDrawer->PointAspect()->SetScale(2.0);
// the triangulation should be computed using main presentation attributes,
// and should not be overridden by highlighting
theDrawer->SetAutoTriangulation(false);
}
} // namespace
//=================================================================================================
AIS_InteractiveContext::AIS_InteractiveContext(const occ::handle<V3d_Viewer>& MainViewer)
: myMainPM(new PrsMgr_PresentationManager(MainViewer->StructureManager())),
myMainVwr(MainViewer),
myToHilightSelected(true),
mySelection(new AIS_Selection()),
myFilters(new SelectMgr_AndOrFilter(SelectMgr_FilterType_OR)),
myDefaultDrawer(new Prs3d_Drawer()),
myCurDetected(0),
myCurHighlighted(0),
myPickingStrategy(SelectMgr_PickingStrategy_FirstAcceptable),
myAutoHilight(true),
myIsAutoActivateSelMode(true)
{
mgrSelector = new SelectMgr_SelectionManager(new StdSelect_ViewerSelector3d());
myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer();
myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer();
myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer();
myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer();
myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer();
myDefaultDrawer->SetupOwnDefaults();
myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default);
myDefaultDrawer->SetDisplayMode(0);
{
const occ::handle<Prs3d_Drawer>& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic];
aStyle->Link(myDefaultDrawer);
initDefaultHilightAttributes(aStyle, Quantity_NOC_CYAN1);
aStyle->SetZLayer(Graphic3d_ZLayerId_Top);
}
{
const occ::handle<Prs3d_Drawer>& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic];
aStyle->Link(myDefaultDrawer);
initDefaultHilightAttributes(aStyle, Quantity_NOC_CYAN1);
aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost);
}
{
const occ::handle<Prs3d_Drawer>& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected];
aStyle->Link(myDefaultDrawer);
initDefaultHilightAttributes(aStyle, Quantity_NOC_GRAY80);
aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
}
{
const occ::handle<Prs3d_Drawer>& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected];
aStyle->Link(myDefaultDrawer);
initDefaultHilightAttributes(aStyle, Quantity_NOC_GRAY80);
aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
}
{
const occ::handle<Prs3d_Drawer>& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
aStyle->SetMethod(Aspect_TOHM_COLOR);
aStyle->SetColor(Quantity_NOC_GRAY40);
}
InitAttributes();
}
//=================================================================================================
AIS_InteractiveContext::~AIS_InteractiveContext()
{
// clear the current selection
mySelection->Clear();
mgrSelector.Nullify();
occ::handle<AIS_InteractiveContext> aNullContext;
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
const occ::handle<AIS_InteractiveObject>& anObj = anObjIter.Key();
anObj->SetContext(aNullContext);
for (NCollection_Sequence<occ::handle<SelectMgr_Selection>>::Iterator aSelIter(
anObj->Selections());
aSelIter.More();
aSelIter.Next())
{
aSelIter.Value()->UpdateBVHStatus(SelectMgr_TBU_Renew);
}
}
}
//=================================================================================================
occ::handle<V3d_View> AIS_InteractiveContext::LastActiveView() const
{
if (myLastActiveView == nullptr || myMainVwr.IsNull())
{
return occ::handle<V3d_View>();
}
// as a precaution - check that myLastActiveView pointer is a valid active View
for (NCollection_List<occ::handle<V3d_View>>::Iterator aViewIter =
myMainVwr->ActiveViewIterator();
aViewIter.More();
aViewIter.Next())
{
if (aViewIter.Value() == myLastActiveView)
{
return aViewIter.Value();
}
}
return occ::handle<V3d_View>();
}
//=================================================================================================
void AIS_InteractiveContext::UpdateCurrentViewer()
{
if (!myMainVwr.IsNull())
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::DisplayedObjects(
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
theListOfIO.Append(anObjIter.Key());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::DisplayedObjects(
const AIS_KindOfInteractive theKind,
const int theSign,
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
ObjectsByDisplayStatus(theKind, theSign, PrsMgr_DisplayStatus_Displayed, theListOfIO);
}
//=================================================================================================
void AIS_InteractiveContext::ErasedObjects(
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
ObjectsByDisplayStatus(PrsMgr_DisplayStatus_Erased, theListOfIO);
}
//=================================================================================================
void AIS_InteractiveContext::ErasedObjects(
const AIS_KindOfInteractive theKind,
const int theSign,
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
ObjectsByDisplayStatus(theKind, theSign, PrsMgr_DisplayStatus_Erased, theListOfIO);
}
//=================================================================================================
void AIS_InteractiveContext::ObjectsByDisplayStatus(
const PrsMgr_DisplayStatus theStatus,
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (anObjIter.Key()->DisplayStatus() == theStatus)
{
theListOfIO.Append(anObjIter.Key());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::ObjectsByDisplayStatus(
const AIS_KindOfInteractive theKind,
const int theSign,
const PrsMgr_DisplayStatus theStatus,
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO) const
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (theStatus != PrsMgr_DisplayStatus_None && anObjIter.Key()->DisplayStatus() != theStatus)
{
continue;
}
else if (anObjIter.Key()->Type() != theKind)
{
continue;
}
if (theSign == -1 || anObjIter.Key()->Signature() == theSign)
{
theListOfIO.Append(anObjIter.Key());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::ObjectsInside(
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO,
const AIS_KindOfInteractive theKind,
const int theSign) const
{
if (theKind == AIS_KindOfInteractive_None && theSign == -1)
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
theListOfIO.Append(anObjIter.Key());
}
return;
}
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (anObjIter.Key()->Type() != theKind)
{
continue;
}
if (theSign == -1 || anObjIter.Key()->Signature() == theSign)
{
theListOfIO.Append(anObjIter.Key());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::ObjectsForView(
NCollection_List<occ::handle<AIS_InteractiveObject>>& theListOfIO,
const occ::handle<V3d_View>& theView,
const bool theIsVisibleInView,
const PrsMgr_DisplayStatus theStatus) const
{
occ::handle<Graphic3d_CView> aViewImpl = theView->View();
const int aViewId = aViewImpl->Identification();
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (theStatus != PrsMgr_DisplayStatus_None && anObjIter.Key()->DisplayStatus() != theStatus)
{
theListOfIO.Append(anObjIter.Key());
continue;
}
occ::handle<Graphic3d_ViewAffinity> anAffinity = anObjIter.Key()->ViewAffinity();
const bool isVisible = anAffinity->IsVisible(aViewId);
if (isVisible == theIsVisibleInView)
{
theListOfIO.Append(anObjIter.Key());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::Display(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
int aDispMode = 0, aHiMod = -1, aSelMode = -1;
GetDefModes(theIObj, aDispMode, aHiMod, aSelMode);
Display(theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1, theToUpdateViewer);
}
//=================================================================================================
void AIS_InteractiveContext::SetViewAffinity(const occ::handle<AIS_InteractiveObject>& theIObj,
const occ::handle<V3d_View>& theView,
const bool theIsVisible)
{
if (theIObj.IsNull() || !myObjects.IsBound(theIObj))
{
return;
}
occ::handle<Graphic3d_ViewAffinity> anAffinity = theIObj->ViewAffinity();
occ::handle<Graphic3d_CView> aViewImpl = theView->View();
anAffinity->SetVisible(aViewImpl->Identification(), theIsVisible);
}
//=================================================================================================
void AIS_InteractiveContext::Display(const occ::handle<AIS_InteractiveObject>& theIObj,
const int theDispMode,
const int theSelectionMode,
const bool theToUpdateViewer,
const PrsMgr_DisplayStatus theDispStatus)
{
if (theIObj.IsNull())
{
return;
}
if (theDispStatus == PrsMgr_DisplayStatus_Erased)
{
Erase(theIObj, theToUpdateViewer);
Load(theIObj, theSelectionMode);
if (occ::handle<AIS_GlobalStatus>* aStatusPtr = myObjects.ChangeSeek(theIObj))
{
(*aStatusPtr)->SetDisplayMode(theDispMode);
}
return;
}
setContextToObject(theIObj);
if (!myObjects.IsBound(theIObj))
{
setObjectStatus(theIObj, PrsMgr_DisplayStatus_Displayed, theDispMode, theSelectionMode);
theIObj->ViewAffinity()->SetVisible(true); // reset view affinity mask
myMainVwr->StructureManager()->RegisterObject(theIObj, theIObj->ViewAffinity());
myMainPM->Display(theIObj, theDispMode);
if (theSelectionMode != -1)
{
const occ::handle<SelectMgr_SelectableObject>& anObj = theIObj; // to avoid ambiguity
if (!mgrSelector->Contains(anObj))
{
mgrSelector->Load(theIObj);
}
mgrSelector->Activate(theIObj, theSelectionMode);
}
}
else
{
occ::handle<AIS_GlobalStatus> aStatus = myObjects(theIObj);
// Mark the presentation modes hidden of interactive object different from aDispMode.
// Then make sure aDispMode is displayed and maybe highlighted.
// Finally, activate selection mode <SelMode> if not yet activated.
const int anOldMode = aStatus->DisplayMode();
if (anOldMode != theDispMode)
{
if (myMainPM->IsHighlighted(theIObj, anOldMode))
{
unhighlightGlobal(theIObj);
}
myMainPM->SetVisibility(theIObj, anOldMode, false);
}
aStatus->SetDisplayMode(theDispMode);
theIObj->SetDisplayStatus(PrsMgr_DisplayStatus_Displayed);
myMainPM->Display(theIObj, theDispMode);
if (aStatus->IsHilighted())
{
highlightGlobal(theIObj, aStatus->HilightStyle(), theDispMode);
}
if (theSelectionMode != -1)
{
const occ::handle<SelectMgr_SelectableObject>& anObj = theIObj; // to avoid ambiguity
if (!mgrSelector->Contains(anObj))
{
mgrSelector->Load(theIObj);
}
if (!mgrSelector->IsActivated(theIObj, theSelectionMode))
{
aStatus->AddSelectionMode(theSelectionMode);
mgrSelector->Activate(theIObj, theSelectionMode);
}
}
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::Load(const occ::handle<AIS_InteractiveObject>& theIObj,
const int theSelMode)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
if (!myObjects.IsBound(theIObj))
{
int aDispMode, aHiMod, aSelModeDef;
GetDefModes(theIObj, aDispMode, aHiMod, aSelModeDef);
setObjectStatus(theIObj,
PrsMgr_DisplayStatus_Erased,
aDispMode,
theSelMode != -1 ? theSelMode : aSelModeDef);
theIObj->ViewAffinity()->SetVisible(true); // reset view affinity mask
myMainVwr->StructureManager()->RegisterObject(theIObj, theIObj->ViewAffinity());
}
// Register theIObj in the selection manager to prepare further activation of selection
const occ::handle<SelectMgr_SelectableObject>& anObj = theIObj; // to avoid ambiguity
if (!mgrSelector->Contains(anObj))
{
mgrSelector->Load(theIObj);
}
}
//=================================================================================================
void AIS_InteractiveContext::Erase(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
if (!theIObj->IsAutoHilight())
{
theIObj->ClearSelected();
}
EraseGlobal(theIObj, false);
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::EraseAll(const bool theToUpdateViewer)
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
if (anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
Erase(anObjIter.Key(), false);
}
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::DisplayAll(const bool theToUpdateViewer)
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
const PrsMgr_DisplayStatus aStatus = anObjIter.Key()->DisplayStatus();
if (aStatus == PrsMgr_DisplayStatus_Erased)
{
Display(anObjIter.Key(), false);
}
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::DisplaySelected(const bool theToUpdateViewer)
{
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(aSelIter.Value()->Selectable());
Display(anObj, false);
}
if (theToUpdateViewer && !mySelection->Objects().IsEmpty())
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::EraseSelected(const bool theToUpdateViewer)
{
bool isFound = false;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Init(mySelection->Objects()))
{
occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(aSelIter.Value()->Selectable());
Erase(anObj, false);
isFound = true;
}
if (isFound && theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
PrsMgr_DisplayStatus AIS_InteractiveContext::DisplayStatus(
const occ::handle<AIS_InteractiveObject>& theIObj) const
{
if (theIObj.IsNull())
{
return PrsMgr_DisplayStatus_None;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
return aStatus != nullptr ? theIObj->DisplayStatus() : PrsMgr_DisplayStatus_None;
}
//=================================================================================================
void AIS_InteractiveContext::Remove(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
if (theIObj->HasInteractiveContext())
{
if (theIObj->myCTXPtr != this)
{
throw Standard_ProgramError(
"AIS_InteractiveContext - object has been displayed in another context!");
}
theIObj->SetContext(occ::handle<AIS_InteractiveContext>());
}
ClearGlobal(theIObj, theToUpdateViewer);
}
//=================================================================================================
void AIS_InteractiveContext::RemoveAll(const bool theToUpdateViewer)
{
ClearDetected();
NCollection_List<occ::handle<AIS_InteractiveObject>> aList;
ObjectsInside(aList);
for (NCollection_List<occ::handle<AIS_InteractiveObject>>::Iterator aListIterator(aList);
aListIterator.More();
aListIterator.Next())
{
Remove(aListIterator.Value(), false);
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::HilightWithColor(const occ::handle<AIS_InteractiveObject>& theObj,
const occ::handle<Prs3d_Drawer>& theStyle,
const bool theIsToUpdate)
{
if (theObj.IsNull())
{
return;
}
setContextToObject(theObj);
if (!myObjects.IsBound(theObj))
{
return;
}
const occ::handle<AIS_GlobalStatus>& aStatus = myObjects(theObj);
aStatus->SetHilightStatus(true);
if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
highlightGlobal(theObj, theStyle, aStatus->DisplayMode());
aStatus->SetHilightStyle(theStyle);
}
if (theIsToUpdate)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::Unhilight(const occ::handle<AIS_InteractiveObject>& theObj,
const bool theToUpdateViewer)
{
occ::handle<AIS_GlobalStatus>* aStatus =
!theObj.IsNull() ? myObjects.ChangeSeek(theObj) : nullptr;
if (aStatus == nullptr)
{
return;
}
(*aStatus)->SetHilightStatus(false);
(*aStatus)->SetHilightStyle(occ::handle<Prs3d_Drawer>());
if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
unhighlightGlobal(theObj);
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=======================================================================
// function : IsHilighted
// purpose : Returns true if the objects global status is set to highlighted.
//=======================================================================
bool AIS_InteractiveContext::IsHilighted(const occ::handle<AIS_InteractiveObject>& theObj) const
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
return aStatus != nullptr && (*aStatus)->IsHilighted();
}
//=======================================================================
// function : IsHilighted
// purpose : Returns true if the owner is highlighted with selection style.
//=======================================================================
bool AIS_InteractiveContext::IsHilighted(const occ::handle<SelectMgr_EntityOwner>& theOwner) const
{
if (theOwner.IsNull() || !theOwner->HasSelectable())
{
return false;
}
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
if (anObj->GlobalSelOwner() == theOwner)
{
if (!myObjects.IsBound(anObj))
{
return false;
}
return myObjects(anObj)->IsHilighted();
}
const occ::handle<Prs3d_Drawer>& aStyle = getSelStyle(anObj, theOwner);
const int aHiMode = getHilightMode(anObj, aStyle, -1);
return theOwner->IsHilighted(myMainPM, aHiMode);
}
//=================================================================================================
bool AIS_InteractiveContext::HighlightStyle(const occ::handle<AIS_InteractiveObject>& theObj,
occ::handle<Prs3d_Drawer>& theStyle) const
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
if (aStatus != nullptr && (*aStatus)->IsHilighted())
{
theStyle = (*aStatus)->HilightStyle();
return true;
}
theStyle.Nullify();
return false;
}
//=================================================================================================
bool AIS_InteractiveContext::HighlightStyle(const occ::handle<SelectMgr_EntityOwner>& theOwner,
occ::handle<Prs3d_Drawer>& theStyle) const
{
if (theOwner.IsNull() || !theOwner->HasSelectable())
{
return false;
}
if (IsHilighted(theOwner))
{
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
if (anObj->GlobalSelOwner() == theOwner)
{
theStyle = myObjects(anObj)->HilightStyle();
}
else
{
// since part selection style is not stored in global status,
// check if the object has own selection style. If not, it can
// only be highlighted with default selection style (because
// sub-intensity does not modify any selection states)
theStyle = getSelStyle(anObj, theOwner);
}
return true;
}
else
{
theStyle.Nullify();
return false;
}
}
//=================================================================================================
bool AIS_InteractiveContext::IsDisplayed(const occ::handle<AIS_InteractiveObject>& theObj) const
{
if (theObj.IsNull())
{
return false;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
return aStatus != nullptr && theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed;
}
//=================================================================================================
bool AIS_InteractiveContext::IsDisplayed(const occ::handle<AIS_InteractiveObject>& theIObj,
const int theMode) const
{
if (theIObj.IsNull())
{
return false;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
return aStatus != nullptr && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
&& (*aStatus)->DisplayMode() == theMode;
}
//=================================================================================================
Graphic3d_DisplayPriority AIS_InteractiveContext::DisplayPriority(
const occ::handle<AIS_InteractiveObject>& theIObj) const
{
if (theIObj.IsNull())
{
return Graphic3d_DisplayPriority_INVALID;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
if (aStatus != nullptr
&& (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
|| theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased))
{
int aDispMode = theIObj->HasDisplayMode()
? theIObj->DisplayMode()
: (theIObj->AcceptDisplayMode(myDefaultDrawer->DisplayMode())
? myDefaultDrawer->DisplayMode()
: 0);
return myMainPM->DisplayPriority(theIObj, aDispMode);
}
return Graphic3d_DisplayPriority_INVALID;
}
//=================================================================================================
void AIS_InteractiveContext::SetDisplayPriority(const occ::handle<AIS_InteractiveObject>& theIObj,
const Graphic3d_DisplayPriority thePriority)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
if (aStatus != nullptr
&& (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
|| theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased))
{
int aDisplayMode = theIObj->HasDisplayMode()
? theIObj->DisplayMode()
: (theIObj->AcceptDisplayMode(myDefaultDrawer->DisplayMode())
? myDefaultDrawer->DisplayMode()
: 0);
myMainPM->SetDisplayPriority(theIObj, aDisplayMode, thePriority);
}
}
//=================================================================================================
void AIS_InteractiveContext::Redisplay(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer,
const bool theAllModes)
{
RecomputePrsOnly(theIObj, theToUpdateViewer, theAllModes);
RecomputeSelectionOnly(theIObj);
}
//=================================================================================================
void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive theKOI,
const int /*theSign*/,
const bool theToUpdateViewer)
{
bool isRedisplayed = false;
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
const occ::handle<AIS_InteractiveObject>& anObj = anObjIter.Key();
if (anObj->Type() != theKOI)
{
continue;
}
Redisplay(anObj, false);
isRedisplayed =
anObjIter.Key()->DisplayStatus() == PrsMgr_DisplayStatus_Displayed || isRedisplayed;
}
if (theToUpdateViewer && isRedisplayed)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::RecomputePrsOnly(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer,
const bool theAllModes)
{
if (theIObj.IsNull())
{
return;
}
theIObj->SetToUpdate();
theIObj->UpdatePresentations(theAllModes);
if (!theToUpdateViewer)
{
return;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
if (aStatus != nullptr && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainVwr->Update();
}
if (!myMainVwr->ActiveViews().IsEmpty())
{
theIObj->RecomputeTransformation(myMainVwr->ActiveViewIterator().Value()->Camera());
}
}
//=================================================================================================
void AIS_InteractiveContext::RecomputeSelectionOnly(const occ::handle<AIS_InteractiveObject>& theIO)
{
if (theIO.IsNull())
{
return;
}
NCollection_List<int> aModes;
ActivatedModes(theIO, aModes);
for (NCollection_List<int>::Iterator aModesIter(aModes); aModesIter.More(); aModesIter.Next())
{
mgrSelector->Deactivate(theIO, aModesIter.Value());
}
mgrSelector->RecomputeSelection(theIO);
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIO);
if (aStatus == nullptr || theIO->DisplayStatus() != PrsMgr_DisplayStatus_Displayed)
{
return;
}
for (NCollection_List<int>::Iterator aModesIter(aModes); aModesIter.More(); aModesIter.Next())
{
mgrSelector->Activate(theIO, aModesIter.Value());
}
}
//=================================================================================================
void AIS_InteractiveContext::Update(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
theIObj->UpdatePresentations();
mgrSelector->Update(theIObj);
if (theUpdateViewer)
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theIObj);
if (aStatus != nullptr && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainVwr->Update();
}
}
}
//=================================================================================================
void AIS_InteractiveContext::SetLocation(const occ::handle<AIS_InteractiveObject>& theIObj,
const TopLoc_Location& theLoc)
{
if (theIObj.IsNull())
{
return;
}
if (theIObj->HasTransformation() && theLoc.IsIdentity())
{
theIObj->ResetTransformation();
mgrSelector->Update(theIObj, false);
return;
}
else if (theLoc.IsIdentity())
{
return;
}
// first reset the previous location to properly clean everything...
if (theIObj->HasTransformation())
{
theIObj->ResetTransformation();
}
theIObj->SetLocalTransformation(theLoc.Transformation());
mgrSelector->Update(theIObj, false);
// if the object or its part is highlighted dynamically, it is necessary to apply location
// transformation to its highlight structure immediately
if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable(theIObj))
{
const int aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
myLastPicked->UpdateHighlightTrsf(myMainVwr, myMainPM, aHiMod);
}
}
//=================================================================================================
void AIS_InteractiveContext::ResetLocation(const occ::handle<AIS_InteractiveObject>& theIObj)
{
if (theIObj.IsNull())
{
return;
}
theIObj->ResetTransformation();
mgrSelector->Update(theIObj, false);
}
//=================================================================================================
bool AIS_InteractiveContext::HasLocation(const occ::handle<AIS_InteractiveObject>& theIObj) const
{
return !theIObj.IsNull() && theIObj->HasTransformation();
}
//=================================================================================================
TopLoc_Location AIS_InteractiveContext::Location(
const occ::handle<AIS_InteractiveObject>& theIObj) const
{
return theIObj->Transformation();
}
//=================================================================================================
void AIS_InteractiveContext::SetDisplayMode(const int theMode, const bool theToUpdateViewer)
{
if (theMode == myDefaultDrawer->DisplayMode())
{
return;
}
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjIter(myObjects);
anObjIter.More();
anObjIter.Next())
{
occ::handle<AIS_InteractiveObject> anObj = anObjIter.Key();
bool toProcess = anObj->IsKind(STANDARD_TYPE(AIS_Shape))
|| anObj->IsKind(STANDARD_TYPE(AIS_ConnectedInteractive))
|| anObj->IsKind(STANDARD_TYPE(AIS_MultipleConnectedInteractive));
if (!toProcess || anObj->HasDisplayMode() || !anObj->AcceptDisplayMode(theMode))
{
continue;
}
const occ::handle<AIS_GlobalStatus>& aStatus = anObjIter.Value();
aStatus->SetDisplayMode(theMode);
if (anObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainPM->Display(anObj, theMode);
if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable(anObj))
{
myMainPM->BeginImmediateDraw();
unhighlightGlobal(anObj);
myMainPM->EndImmediateDraw(myMainVwr);
}
if (aStatus->IsSubIntensityOn())
{
highlightWithSubintensity(anObj, theMode);
}
myMainPM->SetVisibility(anObj, myDefaultDrawer->DisplayMode(), false);
}
}
myDefaultDrawer->SetDisplayMode(theMode);
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetDisplayMode(const occ::handle<AIS_InteractiveObject>& theIObj,
const int theMode,
const bool theToUpdateViewer)
{
setContextToObject(theIObj);
if (!myObjects.IsBound(theIObj))
{
theIObj->SetDisplayMode(theMode);
return;
}
else if (!theIObj->AcceptDisplayMode(theMode))
{
return;
}
occ::handle<AIS_GlobalStatus> aStatus = myObjects(theIObj);
if (theIObj->DisplayStatus() != PrsMgr_DisplayStatus_Displayed)
{
aStatus->SetDisplayMode(theMode);
theIObj->SetDisplayMode(theMode);
return;
}
// erase presentations for all display modes different from <aMode>
const int anOldMode = aStatus->DisplayMode();
if (anOldMode != theMode)
{
if (myMainPM->IsHighlighted(theIObj, anOldMode))
{
unhighlightGlobal(theIObj);
}
myMainPM->SetVisibility(theIObj, anOldMode, false);
}
aStatus->SetDisplayMode(theMode);
myMainPM->Display(theIObj, theMode);
if (aStatus->IsHilighted())
{
highlightGlobal(theIObj, getSelStyle(theIObj, theIObj->GlobalSelOwner()), theMode);
}
if (aStatus->IsSubIntensityOn())
{
highlightWithSubintensity(theIObj, theMode);
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
theIObj->SetDisplayMode(theMode);
}
//=================================================================================================
void AIS_InteractiveContext::UnsetDisplayMode(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull() || !theIObj->HasDisplayMode())
{
return;
}
if (!myObjects.IsBound(theIObj))
{
theIObj->UnsetDisplayMode();
return;
}
const int anOldMode = theIObj->DisplayMode();
if (myDefaultDrawer->DisplayMode() == anOldMode)
{
return;
}
const occ::handle<AIS_GlobalStatus>& aStatus = myObjects(theIObj);
aStatus->SetDisplayMode(myDefaultDrawer->DisplayMode());
if (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
if (myMainPM->IsHighlighted(theIObj, anOldMode))
{
unhighlightGlobal(theIObj);
}
myMainPM->SetVisibility(theIObj, anOldMode, false);
myMainPM->Display(theIObj, myDefaultDrawer->DisplayMode());
if (aStatus->IsHilighted())
{
highlightSelected(theIObj->GlobalSelOwner());
}
if (aStatus->IsSubIntensityOn())
{
highlightWithSubintensity(theIObj, myDefaultDrawer->DisplayMode());
}
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
theIObj->UnsetDisplayMode();
}
//=================================================================================================
void AIS_InteractiveContext::SetCurrentFacingModel(
const occ::handle<AIS_InteractiveObject>& theIObj,
const Aspect_TypeOfFacingModel theModel)
{
if (!theIObj.IsNull())
{
theIObj->SetCurrentFacingModel(theModel);
}
}
//=================================================================================================
void AIS_InteractiveContext::SetColor(const occ::handle<AIS_InteractiveObject>& theIObj,
const Quantity_Color& theColor,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
theIObj->SetColor(theColor);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::IsoOnTriangulation(const bool theIsEnabled,
const occ::handle<AIS_InteractiveObject>& theObject)
{
if (theObject.IsNull())
{
return;
}
theObject->SetIsoOnTriangulation(theIsEnabled);
}
//=================================================================================================
void AIS_InteractiveContext::SetDeviationCoefficient(
const occ::handle<AIS_InteractiveObject>& theIObj,
const double theCoefficient,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
// to be modified after the related methods of AIS_Shape are passed to InteractiveObject
setContextToObject(theIObj);
if (theIObj->Type() != AIS_KindOfInteractive_Object
&& theIObj->Type() != AIS_KindOfInteractive_Shape)
{
return;
}
else if (theIObj->Signature() != 0)
{
return;
}
occ::handle<AIS_Shape> aShape = occ::down_cast<AIS_Shape>(theIObj);
aShape->SetOwnDeviationCoefficient(theCoefficient);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetDeviationAngle(const occ::handle<AIS_InteractiveObject>& theIObj,
const double theAngle,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
setContextToObject(theIObj);
if (theIObj->Type() != AIS_KindOfInteractive_Shape)
{
return;
}
else if (theIObj->Signature() != 0)
{
return;
}
occ::handle<AIS_Shape> aShape = occ::down_cast<AIS_Shape>(theIObj);
aShape->SetOwnDeviationAngle(theAngle);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetAngleAndDeviation(const occ::handle<AIS_InteractiveObject>& theIObj,
const double theAngle,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
// To be modified after the related methods of AIS_Shape are passed to InteractiveObject
setContextToObject(theIObj);
if (theIObj->Type() != AIS_KindOfInteractive_Shape)
{
return;
}
if (theIObj->Signature() != 0)
{
return;
}
occ::handle<AIS_Shape> aShape = occ::down_cast<AIS_Shape>(theIObj);
aShape->SetAngleAndDeviation(theAngle);
aShape->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::UnsetColor(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
theIObj->UnsetColor();
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
bool AIS_InteractiveContext::HasColor(const occ::handle<AIS_InteractiveObject>& theIObj) const
{
return theIObj->HasColor();
}
//=================================================================================================
void AIS_InteractiveContext::Color(const occ::handle<AIS_InteractiveObject>& theIObj,
Quantity_Color& theColor) const
{
theIObj->Color(theColor);
}
//=================================================================================================
double AIS_InteractiveContext::Width(const occ::handle<AIS_InteractiveObject>& theIObj) const
{
return theIObj->Width();
}
//=================================================================================================
void AIS_InteractiveContext::SetWidth(const occ::handle<AIS_InteractiveObject>& theIObj,
const double theWidth,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
theIObj->SetWidth(theWidth);
theIObj->UpdatePresentations();
if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable(theIObj))
{
if (myLastPicked->IsAutoHilight())
{
const int aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
myLastPicked->HilightWithColor(myMainPM,
myLastPicked->IsSelected() ? getSelStyle(theIObj, myLastPicked)
: getHiStyle(theIObj, myLastPicked),
aHiMode);
}
else
{
theIObj->HilightOwnerWithColor(myMainPM,
myLastPicked->IsSelected() ? getSelStyle(theIObj, myLastPicked)
: getHiStyle(theIObj, myLastPicked),
myLastPicked);
}
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::UnsetWidth(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
theIObj->UnsetWidth();
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetMaterial(const occ::handle<AIS_InteractiveObject>& theIObj,
const Graphic3d_MaterialAspect& theMaterial,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
theIObj->SetMaterial(theMaterial);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::UnsetMaterial(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
theIObj->UnsetMaterial();
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetTransparency(const occ::handle<AIS_InteractiveObject>& theIObj,
const double theValue,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
if (!theIObj->IsTransparent() && theValue <= 0.005)
{
return;
}
if (theValue <= 0.005)
{
UnsetTransparency(theIObj, theToUpdateViewer);
return;
}
theIObj->SetTransparency(theValue);
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::UnsetTransparency(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
theIObj->UnsetTransparency();
theIObj->UpdatePresentations();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetSelectedAspect(const occ::handle<Prs3d_BasicAspect>& theAspect,
const bool theToUpdateViewer)
{
Standard_DISABLE_DEPRECATION_WARNINGS bool isFound = false;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
isFound = true;
occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(aSelIter.Value()->Selectable());
anObj->SetAspect(theAspect);
}
Standard_ENABLE_DEPRECATION_WARNINGS
if (isFound && theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::SetLocalAttributes(const occ::handle<AIS_InteractiveObject>& theIObj,
const occ::handle<Prs3d_Drawer>& theDrawer,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
theIObj->SetAttributes(theDrawer);
Update(theIObj, theToUpdateViewer);
}
//=================================================================================================
void AIS_InteractiveContext::UnsetLocalAttributes(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateViewer)
{
if (theIObj.IsNull())
{
return;
}
setContextToObject(theIObj);
theIObj->UnsetAttributes();
Update(theIObj, theToUpdateViewer);
}
//=================================================================================================
void AIS_InteractiveContext::Status(const occ::handle<AIS_InteractiveObject>& theIObj,
TCollection_ExtendedString& theStatus) const
{
theStatus = "";
if (theIObj.IsNull() || !myObjects.IsBound(theIObj))
{
return;
}
theStatus += "\t ____________________________________________";
theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:";
const occ::handle<AIS_GlobalStatus>& aStatus = myObjects(theIObj);
switch (theIObj->DisplayStatus())
{
case PrsMgr_DisplayStatus_Displayed: {
theStatus += "\t| -->Displayed\n";
break;
}
case PrsMgr_DisplayStatus_Erased: {
theStatus += "\t| -->Erased\n";
break;
}
default:
break;
}
theStatus += "\t| Active Display Modes in the MainViewer :\n";
theStatus += "\t|\t Mode ";
theStatus += TCollection_AsciiString(aStatus->DisplayMode());
theStatus += "\n";
if (IsSelected(theIObj))
{
theStatus += "\t| Selected\n";
}
theStatus += "\t| Active Selection Modes in the MainViewer :\n";
for (NCollection_List<int>::Iterator aSelModeIter(aStatus->SelectionModes()); aSelModeIter.More();
aSelModeIter.Next())
{
theStatus += "\t\t Mode ";
theStatus += TCollection_AsciiString(aSelModeIter.Value());
theStatus += "\n";
}
theStatus += "\t ____________________________________________";
}
//=================================================================================================
void AIS_InteractiveContext::GetDefModes(const occ::handle<AIS_InteractiveObject>& theIObj,
int& theDispMode,
int& theHiMode,
int& theSelMode) const
{
if (theIObj.IsNull())
{
return;
}
theDispMode =
theIObj->HasDisplayMode()
? theIObj->DisplayMode()
: (theIObj->AcceptDisplayMode(myDefaultDrawer->DisplayMode()) ? myDefaultDrawer->DisplayMode()
: 0);
theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode;
theSelMode = theIObj->GlobalSelectionMode();
}
//=================================================================================================
void AIS_InteractiveContext::EraseGlobal(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateviewer)
{
occ::handle<AIS_GlobalStatus> aStatus;
if (theIObj.IsNull() || !myObjects.Find(theIObj, aStatus)
|| theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Erased)
{
return;
}
const int aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
unselectOwners(theIObj);
myMainPM->SetVisibility(theIObj, aStatus->DisplayMode(), false);
if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable(theIObj))
{
clearDynamicHighlight();
}
// make sure highlighting presentations are properly erased
theIObj->ErasePresentations(false);
if (IsSelected(theIObj) && aStatus->DisplayMode() != aDispMode)
{
myMainPM->SetVisibility(theIObj, aDispMode, false);
}
for (NCollection_List<int>::Iterator aSelModeIter(aStatus->SelectionModes()); aSelModeIter.More();
aSelModeIter.Next())
{
mgrSelector->Deactivate(theIObj, aSelModeIter.Value());
}
aStatus->ClearSelectionModes();
theIObj->SetDisplayStatus(PrsMgr_DisplayStatus_Erased);
if (theToUpdateviewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::unselectOwners(const occ::handle<AIS_InteractiveObject>& theObject)
{
NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>> aSeq;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
if (aSelIter.Value()->IsSameSelectable(theObject))
{
aSeq.Append(aSelIter.Value());
}
}
for (NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>::Iterator aDelIter(aSeq);
aDelIter.More();
aDelIter.Next())
{
AddOrRemoveSelected(aDelIter.Value(), false);
}
}
//=================================================================================================
void AIS_InteractiveContext::ClearGlobal(const occ::handle<AIS_InteractiveObject>& theIObj,
const bool theToUpdateviewer)
{
occ::handle<AIS_GlobalStatus> aStatus;
if (theIObj.IsNull() || !myObjects.Find(theIObj, aStatus))
{
// for cases when reference shape of connected interactives was not displayed
// but its selection primitives were calculated
const occ::handle<SelectMgr_SelectableObject>& anObj = theIObj; // to avoid ambiguity
mgrSelector->Remove(anObj);
return;
}
unselectOwners(theIObj);
myMainPM->Erase(theIObj, -1);
theIObj->ErasePresentations(true); // make sure highlighting presentations are properly erased
// Object removes from Detected sequence
for (int aDetIter = NCollection_Sequence<int>::Lower(); aDetIter <= myDetectedSeq.Upper();)
{
occ::handle<SelectMgr_EntityOwner> aPicked = MainSelector()->Picked(myDetectedSeq(aDetIter));
occ::handle<AIS_InteractiveObject> anObj;
if (!aPicked.IsNull())
{
anObj = occ::down_cast<AIS_InteractiveObject>(aPicked->Selectable());
}
if (!anObj.IsNull() && anObj == theIObj)
{
myDetectedSeq.Remove(aDetIter);
if (myCurDetected == aDetIter)
{
myCurDetected = std::min(myDetectedSeq.Upper(), aDetIter);
}
if (myCurHighlighted == aDetIter)
{
myCurHighlighted = 0;
}
}
else
{
aDetIter++;
}
}
// remove IO from the selection manager to avoid memory leaks
const occ::handle<SelectMgr_SelectableObject>& anObj = theIObj; // to avoid ambiguity
mgrSelector->Remove(anObj);
setObjectStatus(theIObj, PrsMgr_DisplayStatus_None, -1, -1);
theIObj->ViewAffinity()->SetVisible(true); // reset view affinity mask
myMainVwr->StructureManager()->UnregisterObject(theIObj);
if (!myLastPicked.IsNull())
{
if (myLastPicked->IsSameSelectable(theIObj))
{
clearDynamicHighlight();
myLastPicked.Nullify();
}
}
if (theToUpdateviewer && theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::ClearGlobalPrs(const occ::handle<AIS_InteractiveObject>& theIObj,
const int theMode,
const bool theToUpdateViewer)
{
const occ::handle<AIS_GlobalStatus>* aStatus =
!theIObj.IsNull() ? myObjects.Seek(theIObj) : nullptr;
if (aStatus == nullptr)
{
return;
}
if ((*aStatus)->DisplayMode() == theMode)
{
const int aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
if (aDispMode == theMode && myMainPM->IsHighlighted(theIObj, theMode))
{
unhighlightGlobal(theIObj);
}
myMainPM->Erase(theIObj, theMode);
}
if (theIObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed && theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
bool AIS_InteractiveContext::ClearDetected(bool theToRedrawImmediate)
{
myCurDetected = 0;
myCurHighlighted = 0;
myDetectedSeq.Clear();
bool toUpdate = false;
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
toUpdate = true;
clearDynamicHighlight();
}
myLastPicked.Nullify();
MainSelector()->ClearPicked();
if (toUpdate && theToRedrawImmediate)
{
myMainVwr->RedrawImmediate();
}
return toUpdate;
}
//=================================================================================================
void AIS_InteractiveContext::SetIsoNumber(const int theNb, const AIS_TypeOfIso theType)
{
switch (theType)
{
case AIS_TOI_IsoU:
myDefaultDrawer->UIsoAspect()->SetNumber(theNb);
break;
case AIS_TOI_IsoV:
myDefaultDrawer->VIsoAspect()->SetNumber(theNb);
break;
case AIS_TOI_Both:
myDefaultDrawer->UIsoAspect()->SetNumber(theNb);
myDefaultDrawer->VIsoAspect()->SetNumber(theNb);
break;
}
}
//=================================================================================================
int AIS_InteractiveContext::IsoNumber(const AIS_TypeOfIso theType)
{
switch (theType)
{
case AIS_TOI_IsoU:
return myDefaultDrawer->UIsoAspect()->Number();
case AIS_TOI_IsoV:
return myDefaultDrawer->VIsoAspect()->Number();
case AIS_TOI_Both:
return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number()
? myDefaultDrawer->UIsoAspect()->Number()
: -1;
}
return 0;
}
//=================================================================================================
void AIS_InteractiveContext::SetPixelTolerance(const int thePrecision)
{
MainSelector()->SetPixelTolerance(thePrecision);
}
//=================================================================================================
int AIS_InteractiveContext::PixelTolerance() const
{
return MainSelector()->PixelTolerance();
}
//=======================================================================
// function : SetSelectionSensitivity
// purpose : Allows to manage sensitivity of a particular selection of interactive object theObject
//=======================================================================
void AIS_InteractiveContext::SetSelectionSensitivity(
const occ::handle<AIS_InteractiveObject>& theObject,
const int theMode,
const int theNewSensitivity)
{
mgrSelector->SetSelectionSensitivity(theObject, theMode, theNewSensitivity);
}
//=================================================================================================
void AIS_InteractiveContext::InitAttributes()
{
Graphic3d_MaterialAspect aMat(Graphic3d_NameOfMaterial_Brass);
myDefaultDrawer->ShadingAspect()->SetMaterial(aMat);
// myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70);
occ::handle<Prs3d_LineAspect> aLineAspect = myDefaultDrawer->HiddenLineAspect();
aLineAspect->SetColor(Quantity_NOC_GRAY20);
aLineAspect->SetWidth(1.0);
aLineAspect->SetTypeOfLine(Aspect_TOL_DASH);
// tolerance to 2 pixels...
SetPixelTolerance(2);
// Customizing the drawer for trihedrons and planes...
occ::handle<Prs3d_DatumAspect> aTrihAspect = myDefaultDrawer->DatumAspect();
const double aLength = 100.0;
aTrihAspect->SetAxisLength(aLength, aLength, aLength);
const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4;
aTrihAspect->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aColor);
aTrihAspect->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aColor);
aTrihAspect->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(aColor);
occ::handle<Prs3d_PlaneAspect> aPlaneAspect = myDefaultDrawer->PlaneAspect();
const double aPlaneLength = 200.0;
aPlaneAspect->SetPlaneLength(aPlaneLength, aPlaneLength);
aPlaneAspect->EdgesAspect()->SetColor(Quantity_NOC_SKYBLUE);
}
//=================================================================================================
double AIS_InteractiveContext::TrihedronSize() const
{
return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
}
//=================================================================================================
void AIS_InteractiveContext::SetTrihedronSize(const double theVal, const bool /*updateviewer*/)
{
myDefaultDrawer->DatumAspect()->SetAxisLength(theVal, theVal, theVal);
Redisplay(AIS_KindOfInteractive_Datum, 3, false);
Redisplay(AIS_KindOfInteractive_Datum, 4, true);
}
//=================================================================================================
void AIS_InteractiveContext::SetPlaneSize(const double theValX,
const double theValY,
const bool theToUpdateViewer)
{
myDefaultDrawer->PlaneAspect()->SetPlaneLength(theValX, theValY);
Redisplay(AIS_KindOfInteractive_Datum, 7, theToUpdateViewer);
}
//=================================================================================================
void AIS_InteractiveContext::SetPlaneSize(const double theVal, const bool theToUpdateViewer)
{
SetPlaneSize(theVal, theVal, theToUpdateViewer);
}
//=================================================================================================
bool AIS_InteractiveContext::PlaneSize(double& theX, double& theY) const
{
theX = myDefaultDrawer->PlaneAspect()->PlaneXLength();
theY = myDefaultDrawer->PlaneAspect()->PlaneYLength();
return (std::abs(theX - theY) <= Precision::Confusion());
}
//=================================================================================================
void AIS_InteractiveContext::SetZLayer(const occ::handle<AIS_InteractiveObject>& theIObj,
const Graphic3d_ZLayerId theLayerId)
{
if (theIObj.IsNull())
{
return;
}
theIObj->SetZLayer(theLayerId);
}
//=================================================================================================
Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer(
const occ::handle<AIS_InteractiveObject>& theIObj) const
{
return !theIObj.IsNull() ? theIObj->ZLayer() : Graphic3d_ZLayerId_UNKNOWN;
}
//=======================================================================
// function : RebuildSelectionStructs
// purpose : Rebuilds 1st level of BVH selection forcibly
//=======================================================================
void AIS_InteractiveContext::RebuildSelectionStructs()
{
MainSelector()->RebuildObjectsTree(true);
}
//=======================================================================
// function : Disconnect
// purpose : Disconnects selectable object from an assembly and updates selection structures
//=======================================================================
void AIS_InteractiveContext::Disconnect(
const occ::handle<AIS_InteractiveObject>& theAssembly,
const occ::handle<AIS_InteractiveObject>& theObjToDisconnect)
{
if (theAssembly->IsInstance(STANDARD_TYPE(AIS_MultipleConnectedInteractive)))
{
occ::handle<AIS_MultipleConnectedInteractive> theObj(
occ::down_cast<AIS_MultipleConnectedInteractive>(theAssembly));
theObj->Disconnect(theObjToDisconnect);
if (!myObjects.IsBound(theObjToDisconnect))
{
// connected presentation might contain displayed presentations
myMainPM->Erase(theObjToDisconnect, -1);
theObjToDisconnect->ErasePresentations(true);
}
const occ::handle<SelectMgr_SelectableObject>& anObj = theObjToDisconnect; // to avoid ambiguity
mgrSelector->Remove(anObj);
}
else if (theAssembly->IsInstance(STANDARD_TYPE(AIS_ConnectedInteractive))
&& theObjToDisconnect.IsNull())
{
occ::handle<AIS_ConnectedInteractive> theObj(
occ::down_cast<AIS_ConnectedInteractive>(theAssembly));
theObj->Disconnect();
const occ::handle<SelectMgr_SelectableObject>& anObj = theObj; // to avoid ambiguity
mgrSelector->Remove(anObj);
}
else
{
return;
}
}
//=======================================================================
// function : FitSelected
// purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
void AIS_InteractiveContext::FitSelected(const occ::handle<V3d_View>& theView)
{
FitSelected(theView, 0.01, true);
}
//=================================================================================================
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection(const occ::handle<V3d_View>& theView) const
{
Bnd_Box aBndSelected;
AIS_MapOfObjectOwners anObjectOwnerMap;
const int aViewId = !theView.IsNull() ? theView->View()->Identification() : -1;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
const occ::handle<SelectMgr_EntityOwner>& anOwner = aSelIter.Value();
occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(anOwner->Selectable());
if (anObj->IsInfinite())
{
continue;
}
occ::handle<Graphic3d_ViewAffinity> anAffinity = anObj->ViewAffinity();
const bool isVisible = aViewId == -1 || anAffinity->IsVisible(aViewId);
if (!isVisible)
{
continue;
}
if (anOwner == anObj->GlobalSelOwner())
{
Bnd_Box aTmpBnd;
anObj->BoundingBox(aTmpBnd);
aBndSelected.Add(aTmpBnd);
}
else
{
occ::handle<NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>
anOwnerMap;
if (!anObjectOwnerMap.Find(anOwner->Selectable(), anOwnerMap))
{
anOwnerMap =
new NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>();
anObjectOwnerMap.Bind(anOwner->Selectable(), anOwnerMap);
}
anOwnerMap->Add(anOwner);
}
}
for (AIS_MapIteratorOfMapOfObjectOwners anIter(anObjectOwnerMap); anIter.More(); anIter.Next())
{
const occ::handle<SelectMgr_SelectableObject>& anObject = anIter.Key();
Bnd_Box aTmpBox = anObject->BndBoxOfSelected(anIter.ChangeValue());
aBndSelected.Add(aTmpBox);
}
return aBndSelected;
}
//=======================================================================
// function : FitSelected
// purpose : Fits the view corresponding to the bounds of selected objects
//=======================================================================
void AIS_InteractiveContext::FitSelected(const occ::handle<V3d_View>& theView,
const double theMargin,
const bool theToUpdate)
{
Bnd_Box aBndSelected = BoundingBoxOfSelection(theView);
if (!aBndSelected.IsVoid())
{
theView->FitAll(aBndSelected, theMargin, theToUpdate);
}
}
//=================================================================================================
void AIS_InteractiveContext::SetTransformPersistence(
const occ::handle<AIS_InteractiveObject>& theObject,
const occ::handle<Graphic3d_TransformPers>& theTrsfPers)
{
theObject->SetTransformPersistence(theTrsfPers);
if (!myObjects.IsBound(theObject))
{
return;
}
mgrSelector->UpdateSelection(theObject);
const Graphic3d_ZLayerId aLayerId = theObject->ZLayer();
const occ::handle<V3d_Viewer>& aCurViewer = CurrentViewer();
for (NCollection_List<occ::handle<V3d_View>>::Iterator anActiveViewIter(
aCurViewer->ActiveViewIterator());
anActiveViewIter.More();
anActiveViewIter.Next())
{
anActiveViewIter.Value()->View()->InvalidateBVHData(aLayerId);
anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox(aLayerId);
}
}
//=================================================================================================
gp_Pnt AIS_InteractiveContext::GravityPoint(const occ::handle<V3d_View>& theView) const
{
return theView->GravityPoint();
}
//=================================================================================================
void AIS_InteractiveContext::setContextToObject(const occ::handle<AIS_InteractiveObject>& theObj)
{
if (theObj->HasInteractiveContext())
{
if (theObj->myCTXPtr != this)
{
throw Standard_ProgramError(
"AIS_InteractiveContext - object has been already displayed in another context!");
}
}
else
{
theObj->SetContext(this);
}
for (NCollection_List<occ::handle<PrsMgr_PresentableObject>>::Iterator aPrsIter(
theObj->Children());
aPrsIter.More();
aPrsIter.Next())
{
if (occ::handle<AIS_InteractiveObject> aChild =
occ::down_cast<AIS_InteractiveObject>(aPrsIter.Value()))
{
setContextToObject(aChild);
}
}
}
//=================================================================================================
void AIS_InteractiveContext::setObjectStatus(const occ::handle<AIS_InteractiveObject>& theIObj,
const PrsMgr_DisplayStatus theStatus,
const int theDispMode,
const int theSelectionMode)
{
theIObj->SetDisplayStatus(theStatus);
if (theStatus != PrsMgr_DisplayStatus_None)
{
occ::handle<AIS_GlobalStatus> aStatus = new AIS_GlobalStatus();
aStatus->SetDisplayMode(theDispMode);
if (theSelectionMode != -1)
{
aStatus->AddSelectionMode(theSelectionMode);
}
myObjects.Bind(theIObj, aStatus);
}
else
{
myObjects.UnBind(theIObj);
}
for (NCollection_List<occ::handle<PrsMgr_PresentableObject>>::Iterator aPrsIter(
theIObj->Children());
aPrsIter.More();
aPrsIter.Next())
{
occ::handle<AIS_InteractiveObject> aChild(
occ::down_cast<AIS_InteractiveObject>(aPrsIter.Value()));
if (aChild.IsNull())
{
continue;
}
setObjectStatus(aChild, theStatus, theDispMode, theSelectionMode);
}
}
//=================================================================================================
void AIS_InteractiveContext::highlightWithColor(const occ::handle<SelectMgr_EntityOwner>& theOwner,
const occ::handle<V3d_Viewer>& theViewer)
{
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
if (anObj.IsNull())
{
return;
}
const occ::handle<Prs3d_Drawer>& aStyle = getHiStyle(anObj, theOwner);
const int aHiMode = getHilightMode(anObj, aStyle, -1);
myMainPM->BeginImmediateDraw();
theOwner->HilightWithColor(myMainPM, aStyle, aHiMode);
myMainPM->EndImmediateDraw(theViewer.IsNull() ? myMainVwr : theViewer);
}
//=================================================================================================
void AIS_InteractiveContext::highlightSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner)
{
NCollection_List<occ::handle<SelectMgr_EntityOwner>> anOwners;
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
if (anObj.IsNull())
{
return;
}
if (!theOwner->IsAutoHilight())
{
NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>> aSeq;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
if (aSelIter.Value()->IsSameSelectable(anObj))
{
anOwners.Append(aSelIter.Value());
}
}
}
else
{
anOwners.Append(theOwner);
}
highlightOwners(anOwners, occ::handle<Prs3d_Drawer>());
}
//=================================================================================================
void AIS_InteractiveContext::highlightGlobal(const occ::handle<AIS_InteractiveObject>& theObj,
const occ::handle<Prs3d_Drawer>& theStyle,
const int theDispMode)
{
if (theObj.IsNull())
{
return;
}
const int aHiMode = getHilightMode(theObj, theStyle, theDispMode);
const occ::handle<SelectMgr_EntityOwner>& aGlobOwner = theObj->GlobalSelOwner();
if (aGlobOwner.IsNull())
{
myMainPM->Color(theObj, theStyle, aHiMode);
return;
}
NCollection_List<occ::handle<SelectMgr_EntityOwner>> anOwners;
if (!aGlobOwner->IsAutoHilight())
{
NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>> aSeq;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
if (aSelIter.Value()->IsSameSelectable(theObj))
{
anOwners.Append(aSelIter.Value());
}
}
}
else
{
anOwners.Append(aGlobOwner);
}
highlightOwners(anOwners, theStyle);
}
//=================================================================================================
void AIS_InteractiveContext::unhighlightSelected(const bool theIsToHilightSubIntensity)
{
unhighlightOwners(mySelection->Objects(), theIsToHilightSubIntensity);
}
//=================================================================================================
void AIS_InteractiveContext::unhighlightOwners(
const NCollection_List<occ::handle<SelectMgr_EntityOwner>>& theOwners,
const bool theIsToHilightSubIntensity)
{
NCollection_IndexedMap<occ::handle<AIS_InteractiveObject>> anObjToClear;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(theOwners);
aSelIter.More();
aSelIter.Next())
{
const occ::handle<SelectMgr_EntityOwner> anOwner = aSelIter.Value();
const occ::handle<AIS_InteractiveObject> anInteractive =
occ::down_cast<AIS_InteractiveObject>(anOwner->Selectable());
occ::handle<AIS_GlobalStatus>* aStatusPtr = myObjects.ChangeSeek(anInteractive);
if (!aStatusPtr)
{
continue;
}
if (anOwner->IsAutoHilight())
{
anOwner->Unhilight(myMainPM);
if (theIsToHilightSubIntensity)
{
if ((*aStatusPtr)->IsSubIntensityOn())
{
const int aHiMode = getHilightMode(anInteractive,
(*aStatusPtr)->HilightStyle(),
(*aStatusPtr)->DisplayMode());
highlightWithSubintensity(anOwner, aHiMode);
}
}
}
else
{
anObjToClear.Add(anInteractive);
}
if (anOwner == anInteractive->GlobalSelOwner())
{
(*aStatusPtr)->SetHilightStatus(false);
}
(*aStatusPtr)->SetHilightStyle(occ::handle<Prs3d_Drawer>());
}
for (NCollection_IndexedMap<occ::handle<AIS_InteractiveObject>>::Iterator anIter(anObjToClear);
anIter.More();
anIter.Next())
{
const occ::handle<AIS_InteractiveObject>& anObj = anIter.Value();
myMainPM->Unhighlight(anObj);
anObj->ClearSelected();
}
}
//=================================================================================================
void AIS_InteractiveContext::unhighlightGlobal(const occ::handle<AIS_InteractiveObject>& theObj)
{
if (theObj.IsNull())
{
return;
}
const occ::handle<SelectMgr_EntityOwner>& aGlobOwner = theObj->GlobalSelOwner();
if (aGlobOwner.IsNull())
{
myMainPM->Unhighlight(theObj);
return;
}
NCollection_List<occ::handle<SelectMgr_EntityOwner>> anOwners;
anOwners.Append(aGlobOwner);
unhighlightOwners(anOwners);
}
//=================================================================================================
void AIS_InteractiveContext::turnOnSubintensity(const occ::handle<AIS_InteractiveObject>& theObject,
const int theDispMode,
const bool theIsDisplayedOnly) const
{
// the only differ with selection highlight is color, so sync transparency values
const occ::handle<Prs3d_Drawer>& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
aSubStyle->SetTransparency(myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
if (theObject.IsNull())
{
for (NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
occ::handle<AIS_GlobalStatus>>::Iterator anObjsIter(myObjects);
anObjsIter.More();
anObjsIter.Next())
{
const occ::handle<AIS_GlobalStatus>& aStatus = anObjsIter.Value();
if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
{
continue;
}
aStatus->SetSubIntensity(true);
myMainPM->Color(anObjsIter.Key(),
aSubStyle,
theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
}
}
else
{
occ::handle<AIS_GlobalStatus> aStatus;
if (!myObjects.Find(theObject, aStatus))
{
return;
}
if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
{
return;
}
aStatus->SetSubIntensity(true);
myMainPM->Color(theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
}
}
//=================================================================================================
void AIS_InteractiveContext::highlightWithSubintensity(
const occ::handle<AIS_InteractiveObject>& theObject,
const int theMode) const
{
// the only differ with selection highlight is color, so
// sync transparency values
myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency(
myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
myMainPM->Color(theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
}
//=================================================================================================
void AIS_InteractiveContext::highlightWithSubintensity(
const occ::handle<SelectMgr_EntityOwner>& theOwner,
const int theMode) const
{
// the only differ with selection highlight is color, so
// sync transparency values
myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency(
myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
theOwner->HilightWithColor(myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
}
//=================================================================================================
bool AIS_InteractiveContext::isSlowHiStyle(const occ::handle<SelectMgr_EntityOwner>& theOwner,
const occ::handle<V3d_Viewer>& theViewer) const
{
if (const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable()))
{
const occ::handle<Prs3d_Drawer>& aHiStyle = getHiStyle(anObj, myLastPicked);
return aHiStyle->ZLayer() == Graphic3d_ZLayerId_UNKNOWN
|| !theViewer->ZLayerSettings(aHiStyle->ZLayer()).IsImmediate();
}
return false;
}
//=================================================================================================
AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const int theXPix,
const int theYPix,
const occ::handle<V3d_View>& theView,
const bool theToRedrawOnUpdate)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError("AIS_InteractiveContext::MoveTo() - invalid argument");
}
MainSelector()->Pick(theXPix, theYPix, theView);
return moveTo(theView, theToRedrawOnUpdate);
}
//=================================================================================================
AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const gp_Ax1& theAxis,
const occ::handle<V3d_View>& theView,
const bool theToRedrawOnUpdate)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError("AIS_InteractiveContext::MoveTo() - invalid argument");
}
MainSelector()->Pick(theAxis, theView);
return moveTo(theView, theToRedrawOnUpdate);
}
//=================================================================================================
AIS_StatusOfDetection AIS_InteractiveContext::moveTo(const occ::handle<V3d_View>& theView,
const bool theToRedrawOnUpdate)
{
myCurDetected = 0;
myCurHighlighted = 0;
myDetectedSeq.Clear();
myLastActiveView = theView.get();
// preliminaries
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
bool toUpdateViewer = false;
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
// (the objects must be AIS_Shapes)
const int aDetectedNb = MainSelector()->NbPicked();
int aNewDetected = 0;
bool toIgnoreDetTop = false;
for (int aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
{
occ::handle<SelectMgr_EntityOwner> anOwner = MainSelector()->Picked(aDetIter);
if (anOwner.IsNull() || !myFilters->IsOk(anOwner))
{
if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
{
toIgnoreDetTop = true;
}
continue;
}
if (aNewDetected < 1 && !toIgnoreDetTop)
{
aNewDetected = aDetIter;
}
myDetectedSeq.Append(aDetIter);
}
if (aNewDetected >= 1)
{
myCurHighlighted = NCollection_Sequence<int>::Lower();
// Does nothing if previously detected object is equal to the current one.
// However in advanced selection modes the owners comparison
// is not effective because in that case only one owner manage the
// selection in current selection mode. It is necessary to check the current detected
// entity and hilight it only if the detected entity is not the same as
// previous detected (IsForcedHilight call)
occ::handle<SelectMgr_EntityOwner> aNewPickedOwner = MainSelector()->Picked(aNewDetected);
if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
{
return myLastPicked->IsSelected() ? AIS_SOD_Selected : AIS_SOD_OnlyOneDetected;
}
// Previously detected object is unhilighted if it is not selected or hilighted
// with selection color if it is selected. Such highlighting with selection color
// is needed only if myToHilightSelected flag is true. In this case previously detected
// object has been already highlighted with myHilightColor during previous MoveTo()
// method call. As result it is necessary to rehighligt it with mySelectionColor.
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
if (isSlowHiStyle(myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
clearDynamicHighlight();
toUpdateViewer = true;
}
// initialize myLastPicked field with currently detected object
myLastPicked = aNewPickedOwner;
// highlight detected object if it is not selected or myToHilightSelected flag is true
if (myLastPicked->HasSelectable())
{
if (myAutoHilight && (!myLastPicked->IsSelected() || myToHilightSelected))
{
if (isSlowHiStyle(myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
highlightWithColor(myLastPicked, theView->Viewer());
toUpdateViewer = true;
}
aStatus = myLastPicked->IsSelected() ? AIS_SOD_Selected : AIS_SOD_OnlyOneDetected;
}
}
else
{
// previously detected object is unhighlighted if it is not selected or highlighted
// with selection color if it is selected
aStatus = AIS_SOD_Nothing;
if (myAutoHilight && !myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
if (isSlowHiStyle(myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
clearDynamicHighlight();
toUpdateViewer = true;
}
myLastPicked.Nullify();
}
if (toUpdateViewer && theToRedrawOnUpdate)
{
if (theView->ComputedMode())
{
theView->Viewer()->Update();
}
else
{
if (theView->IsInvalidated())
{
theView->Viewer()->Redraw();
}
else
{
theView->Viewer()->RedrawImmediate();
}
}
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::AddSelect(
const occ::handle<SelectMgr_EntityOwner>& theObject)
{
mySelection->AddSelect(theObject);
int aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::SelectRectangle(const NCollection_Vec2<int>& thePntMin,
const NCollection_Vec2<int>& thePntMax,
const occ::handle<V3d_View>& theView,
const AIS_SelectionScheme theSelScheme)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError("AIS_InteractiveContext::SelectRectangle() - invalid argument");
}
myLastActiveView = theView.get();
MainSelector()->Pick(thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView);
NCollection_Array1<occ::handle<SelectMgr_EntityOwner>> aPickedOwners;
if (MainSelector()->NbPicked() > 0)
{
aPickedOwners.Resize(1, MainSelector()->NbPicked(), false);
for (int aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter)
{
aPickedOwners.SetValue(aPickIter, MainSelector()->Picked(aPickIter));
}
}
return Select(aPickedOwners, theSelScheme);
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::SelectPolygon(
const NCollection_Array1<gp_Pnt2d>& thePolyline,
const occ::handle<V3d_View>& theView,
const AIS_SelectionScheme theSelScheme)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError("AIS_InteractiveContext::SelectPolygon() - invalid argument");
}
myLastActiveView = theView.get();
MainSelector()->Pick(thePolyline, theView);
NCollection_Array1<occ::handle<SelectMgr_EntityOwner>> aPickedOwners;
if (MainSelector()->NbPicked() > 0)
{
aPickedOwners.Resize(1, MainSelector()->NbPicked(), false);
for (int aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter)
{
aPickedOwners.SetValue(aPickIter, MainSelector()->Picked(aPickIter));
}
}
return Select(aPickedOwners, theSelScheme);
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::SelectPoint(const NCollection_Vec2<int>& thePnt,
const occ::handle<V3d_View>& theView,
const AIS_SelectionScheme theSelScheme)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError("AIS_InteractiveContext::SelectPoint() - invalid argument");
}
myLastActiveView = theView.get();
MainSelector()->Pick(thePnt.x(), thePnt.y(), theView);
NCollection_Array1<occ::handle<SelectMgr_EntityOwner>> aPickedOwners;
if (MainSelector()->NbPicked() > 0)
{
aPickedOwners.Resize(1, MainSelector()->NbPicked(), false);
for (int aPickIter = 1; aPickIter <= MainSelector()->NbPicked(); ++aPickIter)
{
aPickedOwners.SetValue(aPickIter, MainSelector()->Picked(aPickIter));
}
}
return Select(aPickedOwners, theSelScheme);
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::SelectDetected(const AIS_SelectionScheme theSelScheme)
{
// For all selection schemes, allowing to select an object,
// HandleMouseClick is available
if (theSelScheme != AIS_SelectionScheme_Remove && theSelScheme != AIS_SelectionScheme_Clear
&& !myLastPicked.IsNull())
{
NCollection_Vec2<int> aMousePos(-1, -1);
gp_Pnt2d aMouseRealPos = MainSelector()->GetManager().GetMousePosition();
if (!Precision::IsInfinite(aMouseRealPos.X()) && !Precision::IsInfinite(aMouseRealPos.Y()))
{
aMousePos.SetValues((int)aMouseRealPos.X(), (int)aMouseRealPos.Y());
}
if (myLastPicked->HandleMouseClick(aMousePos,
Aspect_VKeyMouse_LeftButton,
Aspect_VKeyFlags_NONE,
false))
{
return AIS_SOP_NothingSelected;
}
}
NCollection_Array1<occ::handle<SelectMgr_EntityOwner>> aPickedOwners(1, 1);
aPickedOwners.SetValue(1, myLastPicked);
return Select(aPickedOwners, theSelScheme);
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select(const int theXPMin,
const int theYPMin,
const int theXPMax,
const int theYPMax,
const occ::handle<V3d_View>& theView,
const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectRectangle(NCollection_Vec2<int>(theXPMin, theYPMin),
NCollection_Vec2<int>(theXPMax, theYPMax),
theView);
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select(const NCollection_Array1<gp_Pnt2d>& thePolyline,
const occ::handle<V3d_View>& theView,
const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectPolygon(thePolyline, theView);
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select(const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectDetected();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectDetected(AIS_SelectionScheme_XOR);
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const int theXPMin,
const int theYPMin,
const int theXPMax,
const int theYPMax,
const occ::handle<V3d_View>& theView,
const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectRectangle(NCollection_Vec2<int>(theXPMin, theYPMin),
NCollection_Vec2<int>(theXPMax, theYPMax),
theView,
AIS_SelectionScheme_XOR);
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(
const NCollection_Array1<gp_Pnt2d>& thePolyline,
const occ::handle<V3d_View>& theView,
const bool theToUpdateViewer)
{
AIS_StatusOfPick aStatus = SelectPolygon(thePolyline, theView, AIS_SelectionScheme_XOR);
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
return aStatus;
}
//=================================================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select(
const NCollection_Array1<occ::handle<SelectMgr_EntityOwner>>& theOwners,
const AIS_SelectionScheme theSelScheme)
{
NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>> aSelOwnerMap(
myAutoHilight ? mySelection->Objects().Length() : 0);
if (myAutoHilight)
{
clearDynamicHighlight();
// collect currently selected owners
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator anOwnerIter(
mySelection->Objects());
anOwnerIter.More();
anOwnerIter.Next())
{
aSelOwnerMap.Add(anOwnerIter.Value());
}
}
mySelection->SelectOwners(theOwners,
theSelScheme,
MainSelector()->GetManager().IsOverlapAllowed(),
myFilters);
if (myAutoHilight)
{
// collect lists of owners to unhighlight (unselected) and to highlight (selected)
NCollection_List<occ::handle<SelectMgr_EntityOwner>> anOwnersToUnhighlight, anOwnersToHighlight;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator anOwnerIter(
mySelection->Objects());
anOwnerIter.More();
anOwnerIter.Next())
{
// add newly selected owners
const occ::handle<SelectMgr_EntityOwner>& anOwner = anOwnerIter.Value();
if (!aSelOwnerMap.RemoveKey(anOwner))
{
// newly selected owner
anOwnersToHighlight.Append(anOwner);
}
else
{
// already selected owner
if (!anOwner->IsAutoHilight() && theSelScheme != AIS_SelectionScheme_XOR
&& theSelScheme != AIS_SelectionScheme_Add)
{
// hack to perform AIS_InteractiveObject::ClearSelected() before highlighting
anOwnersToUnhighlight.Append(anOwner);
anOwnersToHighlight.Append(anOwner);
}
else if (anOwner->IsForcedHilight() || !anOwner->IsAutoHilight())
{
anOwnersToHighlight.Append(anOwner);
}
}
}
for (NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>::Iterator anOwnerIter(
aSelOwnerMap);
anOwnerIter.More();
anOwnerIter.Next())
{
// owners removed from selection
const occ::handle<SelectMgr_EntityOwner>& anOwner = anOwnerIter.Value();
anOwnersToUnhighlight.Append(anOwner);
}
unhighlightOwners(anOwnersToUnhighlight);
highlightOwners(anOwnersToHighlight, occ::handle<Prs3d_Drawer>());
}
int aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
}
//=================================================================================================
void AIS_InteractiveContext::HilightSelected(const bool theToUpdateViewer)
{
// In case of selection without using local context
clearDynamicHighlight();
highlightOwners(mySelection->Objects(), occ::handle<Prs3d_Drawer>());
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::highlightOwners(
const NCollection_List<occ::handle<SelectMgr_EntityOwner>>& theOwners,
const occ::handle<Prs3d_Drawer>& theStyle)
{
NCollection_DataMap<occ::handle<AIS_InteractiveObject>,
NCollection_Handle<NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>>>
anObjOwnerMap;
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(theOwners);
aSelIter.More();
aSelIter.Next())
{
const occ::handle<SelectMgr_EntityOwner> anOwner = aSelIter.Value();
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(anOwner->Selectable());
if (anObj.IsNull())
{
continue;
}
const occ::handle<Prs3d_Drawer>& anObjSelStyle =
!theStyle.IsNull() ? theStyle : getSelStyle(anObj, anOwner);
occ::handle<AIS_GlobalStatus>* aStatusPtr = myObjects.ChangeSeek(anObj);
if (!aStatusPtr)
{
continue;
}
if (anOwner == anObj->GlobalSelOwner())
{
(*aStatusPtr)->SetHilightStatus(true);
(*aStatusPtr)->SetHilightStyle(anObjSelStyle);
}
if (!anOwner->IsAutoHilight())
{
NCollection_Handle<NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>> aSeq;
if (anObjOwnerMap.Find(anObj, aSeq))
{
aSeq->Append(anOwner);
}
else
{
aSeq = new NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>();
aSeq->Append(anOwner);
anObjOwnerMap.Bind(anObj, aSeq);
}
}
else
{
const int aHiMode = getHilightMode(anObj, anObjSelStyle, (*aStatusPtr)->DisplayMode());
anOwner->HilightWithColor(myMainPM, anObjSelStyle, aHiMode);
}
}
if (!anObjOwnerMap.IsEmpty())
{
for (NCollection_DataMap<
occ::handle<AIS_InteractiveObject>,
NCollection_Handle<NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>>>::Iterator
anIter(anObjOwnerMap);
anIter.More();
anIter.Next())
{
anIter.Key()->HilightSelected(myMainPM, *anIter.Value());
}
anObjOwnerMap.Clear();
}
}
//=================================================================================================
void AIS_InteractiveContext::UnhilightSelected(const bool theToUpdateViewer)
{
unhighlightSelected();
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::ClearSelected(const bool theToUpdateViewer)
{
if (NbSelected() == 0)
{
return;
}
if (myAutoHilight)
{
unhighlightSelected();
}
mySelection->Clear();
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
bool AIS_InteractiveContext::isDetected(const occ::handle<AIS_InteractiveObject>& theObject)
{
for (int aDetIter = NCollection_Sequence<int>::Lower(); aDetIter <= myDetectedSeq.Upper();
aDetIter++)
{
occ::handle<SelectMgr_EntityOwner> aPicked = MainSelector()->Picked(myDetectedSeq(aDetIter));
occ::handle<AIS_InteractiveObject> anObj;
if (!aPicked.IsNull())
{
anObj = occ::down_cast<AIS_InteractiveObject>(aPicked->Selectable());
}
if (!anObj.IsNull() && anObj == theObject)
{
return true;
}
}
return false;
}
//=======================================================================
// function : SetSelected
// purpose : Sets the whole object as selected and highlights it with selection color
//=======================================================================
void AIS_InteractiveContext::SetSelected(const occ::handle<AIS_InteractiveObject>& theObject,
const bool theToUpdateViewer)
{
if (theObject.IsNull())
{
return;
}
if (!myObjects.IsBound(theObject))
{
return;
}
occ::handle<SelectMgr_EntityOwner> anOwner = theObject->GlobalSelOwner();
if (anOwner.IsNull())
{
return;
}
const occ::handle<Prs3d_Drawer>& anObjSelStyle = getSelStyle(theObject, anOwner);
if (NbSelected() == 1 && myObjects(theObject)->IsHilighted() && myAutoHilight)
{
occ::handle<Prs3d_Drawer> aCustomStyle;
if (HighlightStyle(theObject, aCustomStyle))
{
if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
HilightWithColor(theObject, anObjSelStyle, theToUpdateViewer);
}
}
return;
}
for (NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator aSelIter(
mySelection->Objects());
aSelIter.More();
aSelIter.Next())
{
const occ::handle<SelectMgr_EntityOwner>& aSelOwner = aSelIter.Value();
if (!myFilters->IsOk(aSelOwner))
{
continue;
}
occ::handle<AIS_InteractiveObject> aSelectable =
occ::down_cast<AIS_InteractiveObject>(aSelOwner->Selectable());
if (myAutoHilight)
{
Unhilight(aSelectable, false);
}
if (aSelOwner == aSelectable->GlobalSelOwner())
{
if (occ::handle<AIS_GlobalStatus>* aStatusPtr = myObjects.ChangeSeek(aSelectable))
{
(*aStatusPtr)->SetHilightStatus(false);
}
}
}
// added to avoid untimely viewer update...
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(anOwner->Selectable());
mySelection->ClearAndSelect(anOwner, myFilters, isDetected(anObj));
if (myAutoHilight)
{
occ::handle<Prs3d_Drawer> aCustomStyle;
if (HighlightStyle(theObject, aCustomStyle))
{
if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
HilightWithColor(theObject, anObjSelStyle, false);
}
}
else
{
HilightWithColor(theObject, anObjSelStyle, false);
}
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=======================================================================
// function : SetSelected
// purpose : Sets the whole object as selected and highlights it with selection color
//=======================================================================
void AIS_InteractiveContext::SetSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner,
const bool theToUpdateViewer)
{
if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk(theOwner))
{
return;
}
const occ::handle<AIS_InteractiveObject> anObject =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
const occ::handle<Prs3d_Drawer>& anObjSelStyle = getSelStyle(anObject, theOwner);
if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
{
occ::handle<Prs3d_Drawer> aCustomStyle;
if (myAutoHilight && HighlightStyle(theOwner, aCustomStyle))
{
if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
{
const int aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
theOwner->HilightWithColor(myMainPM, anObjSelStyle, aHiMode);
}
}
return;
}
if (!myObjects.IsBound(anObject))
{
return;
}
if (myAutoHilight)
{
unhighlightSelected();
}
mySelection->ClearAndSelect(theOwner, myFilters, isDetected(anObject));
if (myAutoHilight)
{
occ::handle<Prs3d_Drawer> aCustomStyle;
if (!HighlightStyle(theOwner, aCustomStyle)
|| (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
{
highlightSelected(theOwner);
}
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
void AIS_InteractiveContext::AddOrRemoveSelected(
const occ::handle<AIS_InteractiveObject>& theObject,
const bool theToUpdateViewer)
{
if (theObject.IsNull() || !myObjects.IsBound(theObject))
{
return;
}
const occ::handle<SelectMgr_EntityOwner> anOwner = theObject->GlobalSelOwner();
if (!anOwner.IsNull() && anOwner->HasSelectable())
{
AddOrRemoveSelected(anOwner, theToUpdateViewer);
}
}
//=======================================================================
// function : AddOrRemoveSelected
// purpose : Allows to highlight or unhighlight the owner given depending on
// its selection status
//=======================================================================
void AIS_InteractiveContext::AddOrRemoveSelected(const occ::handle<SelectMgr_EntityOwner>& theOwner,
const bool theToUpdateViewer)
{
if (theOwner.IsNull() || !theOwner->HasSelectable())
{
return;
}
if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
{
return;
}
AIS_SelectionScheme aSelScheme =
theOwner->IsSelected() ? AIS_SelectionScheme_Remove : AIS_SelectionScheme_Add;
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theOwner->Selectable());
mySelection->Select(theOwner, myFilters, aSelScheme, isDetected(anObj));
if (myAutoHilight)
{
occ::handle<AIS_GlobalStatus>* aStatusPtr = myObjects.ChangeSeek(anObj);
if (!aStatusPtr)
{
return;
}
if (theOwner->IsSelected())
{
highlightSelected(theOwner);
}
else
{
NCollection_List<occ::handle<SelectMgr_EntityOwner>> anOwners;
anOwners.Append(theOwner);
unhighlightOwners(anOwners);
(*aStatusPtr)->SetHilightStyle(occ::handle<Prs3d_Drawer>());
}
}
if (theToUpdateViewer)
{
UpdateCurrentViewer();
}
}
//=================================================================================================
bool AIS_InteractiveContext::SetSelectedState(const occ::handle<SelectMgr_EntityOwner>& theEntity,
const bool theIsSelected)
{
if (theEntity.IsNull())
{
throw Standard_ProgramError(
"Internal error: AIS_InteractiveContext::SetSelectedState() called with NO object");
}
if (!theEntity->HasSelectable() || mySelection->IsSelected(theEntity) == theIsSelected)
{
return false;
}
if (theEntity->IsAutoHilight())
{
AddOrRemoveSelected(theEntity, false);
return true;
}
if (theIsSelected)
{
const AIS_SelectStatus aSelStatus = mySelection->AddSelect(theEntity);
theEntity->SetSelected(true);
return aSelStatus == AIS_SS_Added;
}
else
{
const occ::handle<AIS_InteractiveObject> anObj =
occ::down_cast<AIS_InteractiveObject>(theEntity->Selectable());
const AIS_SelectStatus aSelStatus =
mySelection->Select(theEntity, myFilters, AIS_SelectionScheme_Remove, isDetected(anObj));
theEntity->SetSelected(false);
return aSelStatus == AIS_SS_Removed;
}
}
//=================================================================================================
bool AIS_InteractiveContext::IsSelected(const occ::handle<AIS_InteractiveObject>& theObj) const
{
if (theObj.IsNull())
{
return false;
}
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
if (aStatus == nullptr)
{
return false;
}
const int aGlobalSelMode = theObj->GlobalSelectionMode();
const NCollection_List<int>& anActivatedModes = (*aStatus)->SelectionModes();
for (NCollection_List<int>::Iterator aModeIter(anActivatedModes); aModeIter.More();
aModeIter.Next())
{
if (aModeIter.Value() == aGlobalSelMode)
{
if (occ::handle<SelectMgr_EntityOwner> aGlobOwner = theObj->GlobalSelOwner())
{
return aGlobOwner->IsSelected();
}
return false;
}
}
return false;
}
//=================================================================================================
occ::handle<AIS_InteractiveObject> AIS_InteractiveContext::FirstSelectedObject() const
{
return !mySelection->Objects().IsEmpty()
? occ::down_cast<AIS_InteractiveObject>(mySelection->Objects().First()->Selectable())
: occ::handle<AIS_InteractiveObject>();
}
//=================================================================================================
bool AIS_InteractiveContext::HasSelectedShape() const
{
if (!mySelection->More())
{
return false;
}
const occ::handle<StdSelect_BRepOwner> anOwner =
occ::down_cast<StdSelect_BRepOwner>(mySelection->Value());
return !anOwner.IsNull() && anOwner->HasShape();
}
//=================================================================================================
TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
{
if (!mySelection->More())
{
return TopoDS_Shape();
}
const occ::handle<StdSelect_BRepOwner> anOwner =
occ::down_cast<StdSelect_BRepOwner>(mySelection->Value());
if (anOwner.IsNull() || !anOwner->HasSelectable())
{
return TopoDS_Shape();
}
return anOwner->Shape().Located(anOwner->Location() * anOwner->Shape().Location());
}
//=================================================================================================
void AIS_InteractiveContext::EntityOwners(
occ::handle<NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>&
theOwners,
const occ::handle<AIS_InteractiveObject>& theIObj,
const int theMode) const
{
if (theIObj.IsNull())
{
return;
}
NCollection_List<int> aModes;
if (theMode == -1)
{
ActivatedModes(theIObj, aModes);
}
else
{
aModes.Append(theMode);
}
if (theOwners.IsNull())
{
theOwners =
new NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>();
}
for (NCollection_List<int>::Iterator anItr(aModes); anItr.More(); anItr.Next())
{
const int aMode = anItr.Value();
const occ::handle<SelectMgr_Selection>& aSel = theIObj->Selection(aMode);
if (aSel.IsNull())
{
continue;
}
for (NCollection_DynamicArray<occ::handle<SelectMgr_SensitiveEntity>>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
if (occ::handle<Select3D_SensitiveEntity> aEntity = aSelEntIter.Value()->BaseSensitive())
{
if (const occ::handle<SelectMgr_EntityOwner>& aOwner = aEntity->OwnerId())
{
theOwners->Add(aOwner);
}
}
}
}
}
//=================================================================================================
bool AIS_InteractiveContext::HasDetectedShape() const
{
occ::handle<StdSelect_BRepOwner> anOwner = occ::down_cast<StdSelect_BRepOwner>(myLastPicked);
return !anOwner.IsNull() && anOwner->HasShape();
}
//=================================================================================================
const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const
{
occ::handle<StdSelect_BRepOwner> anOwner = occ::down_cast<StdSelect_BRepOwner>(myLastPicked);
return anOwner->Shape();
}
//=================================================================================================
int AIS_InteractiveContext::HilightNextDetected(const occ::handle<V3d_View>& theView,
const bool theToRedrawImmediate)
{
myMainPM->ClearImmediateDraw();
if (myDetectedSeq.IsEmpty())
{
return 0;
}
if (++myCurHighlighted > myDetectedSeq.Upper())
{
myCurHighlighted = NCollection_Sequence<int>::Lower();
}
const occ::handle<SelectMgr_EntityOwner>& anOwner =
MainSelector()->Picked(myDetectedSeq(myCurHighlighted));
if (anOwner.IsNull())
{
return 0;
}
highlightWithColor(anOwner, theView->Viewer());
myLastPicked = anOwner;
if (theToRedrawImmediate)
{
myMainPM->RedrawImmediate(theView->Viewer());
myMainVwr->RedrawImmediate();
}
return myCurHighlighted;
}
//=================================================================================================
int AIS_InteractiveContext::HilightPreviousDetected(const occ::handle<V3d_View>& theView,
const bool theToRedrawImmediate)
{
myMainPM->ClearImmediateDraw();
if (myDetectedSeq.IsEmpty())
{
return 0;
}
if (--myCurHighlighted < NCollection_Sequence<int>::Lower())
{
myCurHighlighted = myDetectedSeq.Upper();
}
const occ::handle<SelectMgr_EntityOwner>& anOwner =
MainSelector()->Picked(myDetectedSeq(myCurHighlighted));
if (anOwner.IsNull())
{
return 0;
}
highlightWithColor(anOwner, theView->Viewer());
myLastPicked = anOwner;
if (theToRedrawImmediate)
{
myMainPM->RedrawImmediate(theView->Viewer());
myMainVwr->RedrawImmediate();
}
return myCurHighlighted;
}
//=================================================================================================
occ::handle<SelectMgr_EntityOwner> AIS_InteractiveContext::DetectedCurrentOwner() const
{
return MoreDetected() ? MainSelector()->Picked(myDetectedSeq(myCurDetected))
: occ::handle<SelectMgr_EntityOwner>();
}
//=================================================================================================
const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
{
static const TopoDS_Shape AIS_InteractiveContext_myDummyShape;
Standard_DISABLE_DEPRECATION_WARNINGS occ::handle<AIS_Shape> aCurrentShape =
occ::down_cast<AIS_Shape>(DetectedCurrentObject());
Standard_ENABLE_DEPRECATION_WARNINGS return !aCurrentShape.IsNull()
? aCurrentShape->Shape()
: AIS_InteractiveContext_myDummyShape;
}
//=================================================================================================
occ::handle<AIS_InteractiveObject> AIS_InteractiveContext::DetectedCurrentObject() const
{
return MoreDetected() ? occ::down_cast<AIS_InteractiveObject>(
MainSelector()->Picked(myDetectedSeq(myCurDetected))->Selectable())
: occ::handle<AIS_InteractiveObject>();
}
//=================================================================================================
void AIS_InteractiveContext::SetSelectionModeActive(
const occ::handle<AIS_InteractiveObject>& theObj,
const int theMode,
const bool theIsActive,
const AIS_SelectionModesConcurrency theActiveFilter,
const bool theIsForce)
{
if (theObj.IsNull())
{
return;
}
const occ::handle<AIS_GlobalStatus>* aStat = myObjects.Seek(theObj);
if (aStat == nullptr)
{
return;
}
if (!theIsActive || (theMode == -1 && theActiveFilter == AIS_SelectionModesConcurrency_Single))
{
if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed || theIsForce)
{
if (theMode == -1)
{
for (NCollection_List<int>::Iterator aModeIter((*aStat)->SelectionModes());
aModeIter.More();
aModeIter.Next())
{
mgrSelector->Deactivate(theObj, aModeIter.Value());
}
}
else
{
mgrSelector->Deactivate(theObj, theMode);
}
}
if (theMode == -1)
{
(*aStat)->ClearSelectionModes();
}
else
{
(*aStat)->RemoveSelectionMode(theMode);
}
return;
}
else if (theMode == -1)
{
return;
}
if ((*aStat)->SelectionModes().Size() == 1 && (*aStat)->SelectionModes().First() == theMode)
{
return;
}
if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed || theIsForce)
{
switch (theActiveFilter)
{
case AIS_SelectionModesConcurrency_Single: {
for (NCollection_List<int>::Iterator aModeIter((*aStat)->SelectionModes());
aModeIter.More();
aModeIter.Next())
{
mgrSelector->Deactivate(theObj, aModeIter.Value());
}
(*aStat)->ClearSelectionModes();
break;
}
case AIS_SelectionModesConcurrency_GlobalOrLocal: {
const int aGlobSelMode = theObj->GlobalSelectionMode();
NCollection_List<int> aRemovedModes;
for (NCollection_List<int>::Iterator aModeIter((*aStat)->SelectionModes());
aModeIter.More();
aModeIter.Next())
{
if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode)
|| (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode))
{
mgrSelector->Deactivate(theObj, aModeIter.Value());
aRemovedModes.Append(aModeIter.Value());
}
}
if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size())
{
(*aStat)->ClearSelectionModes();
}
else
{
for (NCollection_List<int>::Iterator aModeIter(aRemovedModes); aModeIter.More();
aModeIter.Next())
{
(*aStat)->RemoveSelectionMode(aModeIter.Value());
}
}
break;
}
case AIS_SelectionModesConcurrency_Multiple: {
break;
}
}
mgrSelector->Activate(theObj, theMode);
}
(*aStat)->AddSelectionMode(theMode);
}
//=================================================================================================
void AIS_InteractiveContext::Activate(const int theMode, const bool theIsForce)
{
NCollection_List<occ::handle<AIS_InteractiveObject>> aDisplayedObjects;
DisplayedObjects(aDisplayedObjects);
for (NCollection_List<occ::handle<AIS_InteractiveObject>>::Iterator anIter(aDisplayedObjects);
anIter.More();
anIter.Next())
{
Load(anIter.Value(), -1);
Activate(anIter.Value(), theMode, theIsForce);
}
}
//=================================================================================================
void AIS_InteractiveContext::Deactivate(const int theMode)
{
NCollection_List<occ::handle<AIS_InteractiveObject>> aDisplayedObjects;
DisplayedObjects(aDisplayedObjects);
for (NCollection_List<occ::handle<AIS_InteractiveObject>>::Iterator anIter(aDisplayedObjects);
anIter.More();
anIter.Next())
{
Deactivate(anIter.Value(), theMode);
}
}
//=================================================================================================
void AIS_InteractiveContext::Deactivate()
{
NCollection_List<occ::handle<AIS_InteractiveObject>> aDisplayedObjects;
DisplayedObjects(aDisplayedObjects);
for (NCollection_List<occ::handle<AIS_InteractiveObject>>::Iterator anIter(aDisplayedObjects);
anIter.More();
anIter.Next())
{
Deactivate(anIter.Value());
}
}
//=================================================================================================
void AIS_InteractiveContext::ActivatedModes(const occ::handle<AIS_InteractiveObject>& theObj,
NCollection_List<int>& theList) const
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
if (aStatus != nullptr)
{
for (NCollection_List<int>::Iterator aModeIter((*aStatus)->SelectionModes()); aModeIter.More();
aModeIter.Next())
{
theList.Append(aModeIter.Value());
}
}
}
//=================================================================================================
void AIS_InteractiveContext::SubIntensityOn(const occ::handle<AIS_InteractiveObject>& theObj,
const bool theToUpdateViewer)
{
turnOnSubintensity(theObj);
if (theToUpdateViewer)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::SubIntensityOff(const occ::handle<AIS_InteractiveObject>& theObj,
const bool theToUpdateViewer)
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
if (aStatus == nullptr || !(*aStatus)->IsSubIntensityOn())
{
return;
}
(*aStatus)->SetSubIntensity(false);
bool toUpdateMain = false;
if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainPM->Unhighlight(theObj);
toUpdateMain = true;
}
if (IsSelected(theObj))
{
highlightSelected(theObj->GlobalSelOwner());
}
if (theToUpdateViewer && toUpdateMain)
{
myMainVwr->Update();
}
}
//=================================================================================================
void AIS_InteractiveContext::DisplayActiveSensitive(const occ::handle<V3d_View>& theView)
{
MainSelector()->DisplaySensitive(theView);
}
//=================================================================================================
void AIS_InteractiveContext::DisplayActiveSensitive(
const occ::handle<AIS_InteractiveObject>& theObj,
const occ::handle<V3d_View>& theView)
{
const occ::handle<AIS_GlobalStatus>* aStatus = myObjects.Seek(theObj);
if (aStatus == nullptr)
{
return;
}
for (NCollection_List<int>::Iterator aModeIter((*aStatus)->SelectionModes()); aModeIter.More();
aModeIter.Next())
{
const occ::handle<SelectMgr_Selection>& aSel = theObj->Selection(aModeIter.Value());
MainSelector()->DisplaySensitive(aSel, theObj->Transformation(), theView, false);
}
}
//=================================================================================================
void AIS_InteractiveContext::ClearActiveSensitive(const occ::handle<V3d_View>& theView)
{
MainSelector()->ClearSensitive(theView);
}
//=================================================================================================
bool AIS_InteractiveContext::IsImmediateModeOn() const
{
return myMainPM->IsImmediateModeOn();
}
//=================================================================================================
bool AIS_InteractiveContext::BeginImmediateDraw()
{
if (myMainPM->IsImmediateModeOn())
{
myMainPM->BeginImmediateDraw();
return true;
}
return false;
}
//=================================================================================================
bool AIS_InteractiveContext::ImmediateAdd(const occ::handle<AIS_InteractiveObject>& theObj,
const int theMode)
{
if (myMainPM->IsImmediateModeOn())
{
myMainPM->AddToImmediateList(myMainPM->Presentation(theObj, theMode));
return true;
}
return false;
}
//=================================================================================================
bool AIS_InteractiveContext::EndImmediateDraw(const occ::handle<V3d_View>& theView)
{
if (myMainPM->IsImmediateModeOn())
{
myMainPM->EndImmediateDraw(theView->Viewer());
return true;
}
return false;
}
//=================================================================================================
bool AIS_InteractiveContext::EndImmediateDraw()
{
if (myMainPM->IsImmediateModeOn())
{
myMainPM->EndImmediateDraw(myMainVwr);
return true;
}
return false;
}
//=================================================================================================
void AIS_InteractiveContext::SetPolygonOffsets(const occ::handle<AIS_InteractiveObject>& theObj,
const int theMode,
const float theFactor,
const float theUnits,
const bool theToUpdateViewer)
{
if (theObj.IsNull())
{
return;
}
setContextToObject(theObj);
theObj->SetPolygonOffsets(theMode, theFactor, theUnits);
const occ::handle<AIS_GlobalStatus>* aStatus =
theToUpdateViewer ? myObjects.Seek(theObj) : nullptr;
if (aStatus != nullptr && theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
{
myMainVwr->Update();
}
}
//=================================================================================================
bool AIS_InteractiveContext::HasPolygonOffsets(
const occ::handle<AIS_InteractiveObject>& theObj) const
{
return !theObj.IsNull() && theObj->HasPolygonOffsets();
}
//=================================================================================================
void AIS_InteractiveContext::PolygonOffsets(const occ::handle<AIS_InteractiveObject>& theObj,
int& theMode,
float& theFactor,
float& theUnits) const
{
if (HasPolygonOffsets(theObj))
{
theObj->PolygonOffsets(theMode, theFactor, theUnits);
}
}
//=================================================================================================
void AIS_InteractiveContext::DumpJson(Standard_OStream& theOStream, int) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myObjects.Size())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, mgrSelector.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myMainPM.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myMainVwr.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myLastActiveView)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myLastPicked.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myToHilightSelected)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, mySelection.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myFilters.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myDefaultDrawer.get())
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myStyles[Prs3d_TypeOfHighlight_Selected])
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic])
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected])
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic])
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity])
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myDetectedSeq.Size())
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myCurDetected)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myCurHighlighted)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myPickingStrategy)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myAutoHilight)
OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, myIsAutoActivateSelMode)
}