1 // Created on: 1995-05-23
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _SelectMgr_EntityOwner_HeaderFile
18 #define _SelectMgr_EntityOwner_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <SelectMgr_SOPtr.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <SelectBasics_EntityOwner.hxx>
26 #include <Standard_Integer.hxx>
27 #include <PrsMgr_PresentationManager3d.hxx>
28 #include <Quantity_NameOfColor.hxx>
29 #include <Graphic3d_ZLayerId.hxx>
30 class Standard_NoSuchObject;
31 class SelectMgr_SelectableObject;
32 class PrsMgr_PresentationManager;
33 class TopLoc_Location;
37 class SelectMgr_EntityOwner;
38 DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, SelectBasics_EntityOwner)
40 //! A framework to define classes of owners of sensitive primitives.
41 //! The owner is the link between application and
42 //! selection data structures.
43 //! For the application to make its own objects selectable,
44 //! it must define owner classes inheriting this framework.
45 class SelectMgr_EntityOwner : public SelectBasics_EntityOwner
51 //! Initializes the selection priority aPriority.
52 Standard_EXPORT SelectMgr_EntityOwner(const Standard_Integer aPriority = 0);
54 //! Constructs a framework with the selectable object
55 //! anSO being attributed the selection priority aPriority.
56 Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, const Standard_Integer aPriority = 0);
58 //! Constructs a framework from existing one
59 //! anSO being attributed the selection priority aPriority.
60 Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority = 0);
62 //! Returns true if there is a selectable object to serve as an owner.
63 Standard_EXPORT Standard_Boolean HasSelectable() const;
65 //! Returns a selectable object detected in the working context.
66 Standard_EXPORT virtual Handle(SelectMgr_SelectableObject) Selectable() const;
68 //! Sets the selectable object anSO to be used by the
69 //! second constructor above.
70 Standard_EXPORT void Set (const Handle(SelectMgr_SelectableObject)& aSO);
72 //! Provides a framework to highlight any selectable
73 //! object found subsequently which can serve as an
74 //! owner of a sensitive primitive.
75 Standard_EXPORT virtual void Hilight();
77 //! Returns true if the presentation manager aPM
78 //! highlights selections corresponding to the selection mode aMode.
79 Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) const;
81 //! Highlights the owner of a detected selectable object in
82 //! the presentation manager aPM. This object could be
83 //! the owner of a sensitive primitive.
84 //! The display mode for the highlight is aMode; this has
85 //! the default value of 0, that is, wireframe mode.
86 Standard_EXPORT virtual void Hilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0);
88 Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM, const Quantity_NameOfColor aColor, const Standard_Integer aMode = 0);
90 //! Removes highlighting from the owner of a detected
91 //! selectable object in the presentation manager aPM.
92 //! This object could be the owner of a sensitive primitive.
93 //! The display mode for the highlight is aMode; this has
94 //! the default value of 0, that is, wireframe mode.
95 Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0);
97 //! Clears the owners matching the value of the selection
98 //! mode aMode from the presentation manager object aPM.
99 Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0);
101 Standard_EXPORT virtual Standard_Boolean HasLocation() const Standard_OVERRIDE;
103 Standard_EXPORT virtual void SetLocation (const TopLoc_Location& aLoc) Standard_OVERRIDE;
105 Standard_EXPORT virtual void ResetLocation() Standard_OVERRIDE;
107 Standard_EXPORT virtual TopLoc_Location Location() const Standard_OVERRIDE;
109 //! Set the state of the owner.
110 //! @param theIsSelected [in] shows if owner is selected.
111 void SetSelected (const Standard_Boolean theIsSelected);
113 //! @return Standard_True if the owner is selected.
114 Standard_Boolean IsSelected() const;
116 //! Set the state of the owner.
117 //! The method is deprecated. Use SetSelected() instead.
118 void State (const Standard_Integer aStatus);
120 Standard_Integer State() const;
122 //! if owner is not auto hilighted, for group contains many such owners
123 //! will be called one method HilightSelected of SelectableObject
124 Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const;
126 //! if this method returns TRUE the owner will allways call method
127 //! Hilight for SelectableObject when the owner is detected. By default
128 //! it always return FALSE.
129 Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const;
131 //! Set Z layer ID and update all presentations.
132 Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
134 //! Implements immediate application of location transformation of parent object to dynamic highlight structure
135 Standard_EXPORT virtual void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
136 const Handle(PrsMgr_PresentationManager3d)& theManager,
137 const Standard_Integer theDispMode);
140 DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner)
150 SelectMgr_SOPtr mySelectable;
151 Standard_Boolean myIsSelected;
157 #include <SelectMgr_EntityOwner.lxx>
163 #endif // _SelectMgr_EntityOwner_HeaderFile