// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <SelectMgr_SelectableObject.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Bnd_Box.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_IndexedMapOfOwner.hxx>
-#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SelectionManager.hxx>
#include <Standard_NoSuchObject.hxx>
return ifound;
}
-
-
//==================================================
-// Function:
+// Function: SelectMgr_SelectableObject
// Purpose :
//==================================================
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
- myDrawer (new Prs3d_Drawer()),
- myHilightDrawer (new Prs3d_Drawer()),
myAssemblyOwner (NULL),
myAutoHilight (Standard_True),
myGlobalSelMode (0)
{
- InitDefaultHilightAttributes (myHilightDrawer);
- myHilightDrawer->Link (myDrawer);
+ //
}
//==================================================
mySelectionPrs->Clear();
}
+//=======================================================================
+//function : ClearDynamicHighlight
+//purpose :
+//=======================================================================
+void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr)
+{
+ theMgr->ClearImmediateDraw();
+}
+
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
-void SelectMgr_SelectableObject::HilightOwnerWithColor
- ( const Handle(PrsMgr_PresentationManager3d)&,
- const Quantity_NameOfColor,
- const Handle(SelectMgr_EntityOwner)&)
+void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&,
+ const Handle(Prs3d_Drawer)&,
+ const Handle(SelectMgr_EntityOwner)&)
{
Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightOwnerWithColor");
}
//function : GetHilightPresentation
//purpose :
//=======================================================================
-Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
+Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
- if( myHilightPrs.IsNull() && !TheMgr.IsNull() )
- {
- myHilightPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
- myHilightPrs->SetTransformPersistence( GetTransformPersistenceMode(),
- GetTransformPersistencePoint() );
- }
+ if (myHilightPrs.IsNull() && !theMgr.IsNull())
+ {
+ myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager());
+ myHilightPrs->SetTransformPersistence (TransformPersistence());
+ }
return myHilightPrs;
}
//function : GetSelectPresentation
//purpose :
//=======================================================================
-Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
+Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
- if( mySelectionPrs.IsNull() && !TheMgr.IsNull() ) {
- mySelectionPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
- mySelectionPrs->SetTransformPersistence( GetTransformPersistenceMode(),
- GetTransformPersistencePoint() );
+ if (mySelectionPrs.IsNull() && !theMgr.IsNull())
+ {
+ mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager());
+ mySelectionPrs->SetTransformPersistence (TransformPersistence());
}
+
return mySelectionPrs;
}
}
//=======================================================================
-//function : UpdateSelection
+//function : updateSelection
//purpose : Sets update status FULL to selections of the object. Must be
// used as the only method of UpdateSelection from outer classes
// to prevent BVH structures from being outdated.
//=======================================================================
-void SelectMgr_SelectableObject::UpdateSelection (const Standard_Integer theMode)
+void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode)
{
if (theMode == -1)
{
}
}
-//=======================================================================
-//function : SetAttributes
-//purpose :
-//=======================================================================
-void SelectMgr_SelectableObject::SetAttributes (const Handle(Prs3d_Drawer)& theDrawer)
-{
- myDrawer = theDrawer;
-}
-
-//=======================================================================
-//function : UnsetAttributes
-//purpose :
-//=======================================================================
-void SelectMgr_SelectableObject::UnsetAttributes()
-{
- Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
- if (myDrawer->HasLink())
- {
- aDrawer->Link (myDrawer->Link());
- }
- myDrawer = aDrawer;
-}
-
-//=======================================================================
-//function : SetHilightAttributes
-//purpose :
-//=======================================================================
-void SelectMgr_SelectableObject::SetHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
-{
- myHilightDrawer = theDrawer;
-}
-
-//=======================================================================
-//function : UnsetAttributes
-//purpose :
-//=======================================================================
-void SelectMgr_SelectableObject::UnsetHilightAttributes()
-{
- Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
- InitDefaultHilightAttributes (aDrawer);
- aDrawer->Link (myDrawer);
- myHilightDrawer = aDrawer;
-}
-
-//=======================================================================
-//function : InitDefaultHilightAttributes
-//purpose :
-//=======================================================================
-void SelectMgr_SelectableObject::InitDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
-{
- if (!theDrawer->HasOwnPointAspect())
- {
- theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnLineAspect())
- {
- theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnWireAspect())
- {
- theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnPlaneAspect())
- {
- theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect());
- if (theDrawer->HasLink())
- {
- *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect();
- }
- }
- if (!theDrawer->HasOwnFreeBoundaryAspect())
- {
- theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
- }
- }
- if (!theDrawer->HasOwnUnFreeBoundaryAspect())
- {
- theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- if (theDrawer->HasLink())
- {
- *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
- }
- }
-
- theDrawer->WireAspect()->SetWidth(2.);
- theDrawer->LineAspect()->SetWidth(2.);
- theDrawer->PlaneAspect()->EdgesAspect()->SetWidth(2.);
- theDrawer->FreeBoundaryAspect()->SetWidth(2.);
- theDrawer->UnFreeBoundaryAspect()->SetWidth(2.);
- theDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_POINT);
- theDrawer->PointAspect()->SetScale(2.);
-
- // By default the hilight drawer has absolute type of deflection.
- // It is supposed that absolute deflection is taken from Link().
- // It is necessary to use for all sub-shapes identical coefficient
- // computed in ::Compute() call for whole shape and stored in base drawer.
- theDrawer->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
-}
-
//=======================================================================
//function : SetAssemblyOwner
//purpose : Sets common entity owner for assembly sensitive object entities
//=======================================================================
//function : BndBoxOfSelected
-//purpose : Returns a bounding box of sensitive entities with the owners given
-// if they are a part of activated selection
+//purpose :
//=======================================================================
-Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (Handle(SelectMgr_IndexedMapOfOwner)& theOwners)
+Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners)
{
- Bnd_Box aBnd;
-
if (theOwners->IsEmpty())
- return aBnd;
+ return Bnd_Box();
+ Bnd_Box aBnd;
for (Init(); More(); Next())
{
const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
if (theOwners->Contains (anOwner))
{
Select3D_BndBox3d aBox = aSel->Sensitive()->BaseSensitive()->BoundingBox();
- Bnd_Box aTmpBnd;
- aTmpBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
- aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
- aBnd.Add (aTmpBnd);
-
- Standard_Integer anOwnerIdx = theOwners->FindIndex (anOwner);
- if (theOwners->Size() != anOwnerIdx)
- {
- theOwners->Swap (anOwnerIdx, theOwners->Size());
- }
- theOwners->RemoveLast();
-
- if (theOwners->IsEmpty())
- return aBnd;
+ aBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
+ aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
}
}
}