mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030674: Visualization, AIS_InteractiveObject - fix accessibility of several properties
AIS_InteractiveObject/SelectMgr_SelectableObject/PrsMgr_PresentableObject - added missing getters; - removed redundant private sections; - improved documentation; - AIS_InteractiveObject::Compute() marked as pure interface; - methods within this hierarchy have been moved to the base class, when reasonable. Removed redundant typedefs to pointers (PrsMgr_PresentationPointer, PrsMgr_PresentableObjectPointer).
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
@@ -26,8 +23,7 @@
|
||||
#include <Prs3d_PlaneAspect.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <PrsMgr_PresentableObjectPointer.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <PrsMgr_PresentationManager.hxx>
|
||||
#include <Select3D_SensitiveEntity.hxx>
|
||||
#include <SelectBasics_EntityOwner.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
@@ -36,15 +32,14 @@
|
||||
#include <SelectMgr_SelectionManager.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject)
|
||||
|
||||
namespace
|
||||
{
|
||||
Handle(SelectMgr_Selection) THE_NULL_SELECTION;
|
||||
Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
|
||||
static const Handle(SelectMgr_Selection) THE_NULL_SELECTION;
|
||||
static const Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -54,9 +49,9 @@ namespace
|
||||
|
||||
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
|
||||
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
|
||||
myAutoHilight (Standard_True),
|
||||
myGlobalSelMode (0),
|
||||
mycurrent (0),
|
||||
myGlobalSelMode (0)
|
||||
myAutoHilight (Standard_True)
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -290,7 +285,7 @@ void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_S
|
||||
//function : HilightSelected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&,
|
||||
void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager)&,
|
||||
const SelectMgr_SequenceOfOwner&)
|
||||
{
|
||||
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected");
|
||||
@@ -312,7 +307,7 @@ void SelectMgr_SelectableObject::ClearSelected()
|
||||
//function : ClearDynamicHighlight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr)
|
||||
void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr)
|
||||
{
|
||||
theMgr->ClearImmediateDraw();
|
||||
}
|
||||
@@ -321,36 +316,18 @@ void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_Pres
|
||||
//function : HilightOwnerWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&,
|
||||
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Drawer)&,
|
||||
const Handle(SelectMgr_EntityOwner)&)
|
||||
{
|
||||
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightOwnerWithColor");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsAutoHilight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight() const
|
||||
{
|
||||
return myAutoHilight;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAutoHilight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAutoHilight )
|
||||
{
|
||||
myAutoHilight = newAutoHilight;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetHilightPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
|
||||
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& theMgr)
|
||||
{
|
||||
if (myHilightPrs.IsNull() && !theMgr.IsNull())
|
||||
{
|
||||
@@ -363,12 +340,11 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (c
|
||||
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_PresentationManager)& theMgr)
|
||||
{
|
||||
if (mySelectionPrs.IsNull() && !theMgr.IsNull())
|
||||
{
|
||||
|
@@ -18,8 +18,6 @@
|
||||
#define _SelectMgr_SelectableObject_HeaderFile
|
||||
|
||||
#include <PrsMgr_PresentableObject.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <PrsMgr_TypeOfPresentation3d.hxx>
|
||||
#include <SelectMgr_IndexedMapOfOwner.hxx>
|
||||
#include <SelectMgr_SequenceOfSelection.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
@@ -30,15 +28,20 @@ class Prs3d_Presentation;
|
||||
class Standard_NotImplemented;
|
||||
class SelectMgr_SelectionManager;
|
||||
|
||||
//! A framework to supply the structure of the object to be
|
||||
//! selected. At the first pick, this structure is created by
|
||||
//! calling the appropriate algorithm and retaining this
|
||||
//! framework for further picking.
|
||||
//! This abstract framework is inherited in Application
|
||||
//! Interactive Services (AIS), notably in AIS_InteractiveObject.
|
||||
//! Consequently, 3D selection should be handled by the
|
||||
//! relevant daughter classes and their member functions
|
||||
//! in AIS. This is particularly true in the creation of new interactive objects.
|
||||
//! A framework to supply the structure of the object to be selected.
|
||||
//! At the first pick, this structure is created by calling the appropriate algorithm and retaining this framework for further picking.
|
||||
//! This abstract framework is inherited in Application Interactive Services (AIS), notably in AIS_InteractiveObject.
|
||||
//! Consequently, 3D selection should be handled by the relevant daughter classes and their member functions in AIS.
|
||||
//! This is particularly true in the creation of new interactive objects.
|
||||
//!
|
||||
//! Key interface methods to be implemented by every Selectable Object:
|
||||
//! * Presentable Object (PrsMgr_PresentableObject)
|
||||
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
|
||||
//! - AcceptDisplayMode() accepting display modes implemented by this object;
|
||||
//! - Compute() computing presentation for the given display mode index;
|
||||
//! * Selectable Object (SelectMgr_SelectableObject)
|
||||
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
|
||||
//! - ComputeSelection() computing selectable entities for the given selection mode index.
|
||||
class SelectMgr_SelectableObject : public PrsMgr_PresentableObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
|
||||
@@ -47,17 +50,17 @@ public:
|
||||
|
||||
//! Clears all selections of the object
|
||||
Standard_EXPORT virtual ~SelectMgr_SelectableObject();
|
||||
|
||||
//! Recovers and calculates any sensitive primitive,
|
||||
//! aSelection, available in Shape mode, specified by
|
||||
//! aMode. As a rule, these are sensitive faces.
|
||||
//! This method is defined as virtual. This enables you to
|
||||
//! implement it in the creation of a new class of AIS
|
||||
//! Interactive Object. You need to do this and in so
|
||||
//! doing, redefine this method, if you create a class
|
||||
//! which enriches the list of signatures and types.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) = 0;
|
||||
|
||||
|
||||
//! Computes sensitive primitives for the given selection mode - key interface method of Selectable Object.
|
||||
//! @param theSelection selection to fill
|
||||
//! @param theMode selection mode to create sensitive primitives
|
||||
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode) = 0;
|
||||
|
||||
//! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for dynamic selection.
|
||||
//! The most used Interactive Object is AIS_Shape.
|
||||
virtual Standard_Boolean AcceptShapeDecomposition() const { return Standard_False; }
|
||||
|
||||
//! Re-computes the sensitive primitives for all modes. IMPORTANT: Do not use
|
||||
//! this method to update selection primitives except implementing custom selection manager!
|
||||
//! This method does not take into account necessary BVH updates, but may invalidate the pointers
|
||||
@@ -91,6 +94,84 @@ public:
|
||||
//! Return the sequence of selections.
|
||||
const SelectMgr_SequenceOfSelection& Selections() const { return myselections; }
|
||||
|
||||
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
|
||||
|
||||
//! Recomputes the location of the selection aSelection.
|
||||
Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
|
||||
|
||||
//! Updates locations in all sensitive entities from <aSelection>
|
||||
//! and in corresponding entity owners.
|
||||
Standard_EXPORT virtual void UpdateTransformations (const Handle(SelectMgr_Selection)& aSelection);
|
||||
|
||||
//! Method which draws selected owners ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const SelectMgr_SequenceOfOwner& theSeq);
|
||||
|
||||
//! Method which clear all selected owners belonging
|
||||
//! to this selectable object ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void ClearSelected();
|
||||
|
||||
//! Method that needs to be implemented when the object
|
||||
//! manages selection and dynamic highlighting on its own.
|
||||
//! Clears or invalidates dynamic highlight presentation.
|
||||
//! By default it clears immediate draw of given presentation
|
||||
//! manager.
|
||||
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager)& theMgr);
|
||||
|
||||
//! Method which hilight an owner belonging to
|
||||
//! this selectable object ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner);
|
||||
|
||||
//! If returns True, the old mechanism for highlighting selected objects is used (HilightSelected Method may be empty).
|
||||
//! If returns False, the HilightSelected method will be fully responsible for highlighting selected entity owners belonging to this selectable object.
|
||||
virtual Standard_Boolean IsAutoHilight() const { return myAutoHilight; }
|
||||
|
||||
//! Set AutoHilight property to true or false.
|
||||
virtual void SetAutoHilight (const Standard_Boolean theAutoHilight) { myAutoHilight = theAutoHilight; }
|
||||
|
||||
//! Creates or returns existing presentation for highlighting detected object.
|
||||
//! @param thePrsMgr presentation manager to create new presentation
|
||||
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
|
||||
|
||||
//! Creates or returns existing presentation for highlighting selected object.
|
||||
//! @param thePrsMgr presentation manager to create new presentation
|
||||
//! @return existing or newly created presentation (when thePrsMgr is not NULL)
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr);
|
||||
|
||||
//! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation().
|
||||
Standard_EXPORT virtual void ErasePresentations (Standard_Boolean theToRemove);
|
||||
|
||||
//! Set Z layer ID and update all presentations of the selectable object.
|
||||
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
|
||||
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
|
||||
//! 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 UpdateSelection (const Standard_Integer theMode = -1)
|
||||
{
|
||||
updateSelection (theMode);
|
||||
}
|
||||
|
||||
//! Sets common entity owner for assembly sensitive object entities
|
||||
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
|
||||
|
||||
//! Returns a bounding box of sensitive entities with the owners given if they are a part of activated selection
|
||||
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
|
||||
|
||||
//! Returns the mode for selection of object as a whole; 0 by default.
|
||||
Standard_Integer GlobalSelectionMode() const { return myGlobalSelMode; }
|
||||
|
||||
//! Returns the owner of mode for selection of object as a whole
|
||||
Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const;
|
||||
|
||||
//! Returns common entity owner if the object is an assembly
|
||||
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Begins the iteration scanning for sensitive primitives.
|
||||
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
|
||||
void Init() { mycurrent = 1; }
|
||||
@@ -107,92 +188,12 @@ public:
|
||||
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
|
||||
const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); }
|
||||
|
||||
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
|
||||
|
||||
//! Recomputes the location of the selection aSelection.
|
||||
Standard_EXPORT virtual void UpdateTransformation() Standard_OVERRIDE;
|
||||
|
||||
//! Updates locations in all sensitive entities from <aSelection>
|
||||
//! and in corresponding entity owners.
|
||||
Standard_EXPORT virtual void UpdateTransformations (const Handle(SelectMgr_Selection)& aSelection);
|
||||
|
||||
//! Method which draws selected owners ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Seq);
|
||||
|
||||
//! Method which clear all selected owners belonging
|
||||
//! to this selectable object ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void ClearSelected();
|
||||
|
||||
//! Method that needs to be implemented when the object
|
||||
//! manages selection and dynamic highlighting on its own.
|
||||
//! Clears or invalidates dynamic highlight presentation.
|
||||
//! By default it clears immediate draw of given presentation
|
||||
//! manager.
|
||||
Standard_EXPORT virtual void ClearDynamicHighlight (const Handle(PrsMgr_PresentationManager3d)& theMgr);
|
||||
|
||||
//! Method which hilight an owner belonging to
|
||||
//! this selectable object ( for fast presentation draw )
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner);
|
||||
|
||||
//! If returns True, the old mechanism for highlighting
|
||||
//! selected objects is used (HilightSelected Method may be empty).
|
||||
//! If returns False, the HilightSelected method will be
|
||||
//! fully responsible for highlighting selected entity
|
||||
//! owners belonging to this selectable object.
|
||||
Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const;
|
||||
|
||||
//! Set AutoHilight property to true or false
|
||||
//! Sets up Transform Persistence Mode for this object
|
||||
Standard_EXPORT virtual void SetAutoHilight (const Standard_Boolean newAutoHilight);
|
||||
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& TheMgr);
|
||||
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& TheMgr);
|
||||
|
||||
//! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation().
|
||||
Standard_EXPORT virtual void ErasePresentations (Standard_Boolean theToRemove);
|
||||
|
||||
//! Set Z layer ID and update all presentations of the selectable object.
|
||||
//! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
|
||||
Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
|
||||
//! 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 UpdateSelection (const Standard_Integer theMode = -1)
|
||||
{
|
||||
updateSelection (theMode);
|
||||
}
|
||||
|
||||
//! Returns bounding box of selectable object
|
||||
//! by storing its minimum and maximum 3d coordinates
|
||||
//! to output parameters
|
||||
Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox) = 0;
|
||||
|
||||
//! Sets common entity owner for assembly sensitive object entities
|
||||
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
|
||||
|
||||
//! Returns a bounding box of sensitive entities with the owners given
|
||||
//! if they are a part of activated selection
|
||||
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
|
||||
|
||||
//! Returns the mode for selection of object as a whole
|
||||
Standard_Integer GlobalSelectionMode() const
|
||||
{
|
||||
return myGlobalSelMode;
|
||||
}
|
||||
|
||||
//! Returns the owner of mode for selection of object as a whole
|
||||
Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const;
|
||||
|
||||
//! Returns common entity owner if the object is an assembly
|
||||
Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Protected empty constructor.
|
||||
Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
|
||||
//! Override global selection mode.
|
||||
void setGlobalSelMode (const Standard_Integer theMode)
|
||||
{
|
||||
myGlobalSelMode = theMode > 0 ? theMode : 0;
|
||||
@@ -201,19 +202,18 @@ protected:
|
||||
//! Update clipping planes state.
|
||||
Standard_EXPORT virtual void UpdateClipping() Standard_OVERRIDE;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void updateSelection (const Standard_Integer theMode);
|
||||
|
||||
protected:
|
||||
|
||||
SelectMgr_SequenceOfSelection myselections;
|
||||
Handle(Prs3d_Presentation) mySelectionPrs;
|
||||
Handle(Prs3d_Presentation) myHilightPrs;
|
||||
Standard_Boolean myAutoHilight;
|
||||
|
||||
private:
|
||||
|
||||
Standard_Integer mycurrent;
|
||||
Standard_Integer myGlobalSelMode;
|
||||
SelectMgr_SequenceOfSelection myselections; //!< list of selections
|
||||
Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
|
||||
Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
|
||||
Standard_Integer myGlobalSelMode; //!< global selection mode
|
||||
Standard_Integer mycurrent; //!< [deprecated] iterator value
|
||||
Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user