42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _SelectMgr_EntityOwner_HeaderFile |
18 | #define _SelectMgr_EntityOwner_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
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> |
8e5fb5ea |
29 | #include <Graphic3d_HighlightStyle.hxx> |
42cf5bc1 |
30 | #include <Graphic3d_ZLayerId.hxx> |
8e5fb5ea |
31 | #include <SelectMgr_SelectableObject.hxx> |
42cf5bc1 |
32 | class Standard_NoSuchObject; |
42cf5bc1 |
33 | class PrsMgr_PresentationManager; |
34 | class TopLoc_Location; |
5396886c |
35 | class V3d_Viewer; |
42cf5bc1 |
36 | |
37 | |
38 | class SelectMgr_EntityOwner; |
39 | DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, SelectBasics_EntityOwner) |
40 | |
41 | //! A framework to define classes of owners of sensitive primitives. |
42 | //! The owner is the link between application and |
43 | //! selection data structures. |
44 | //! For the application to make its own objects selectable, |
45 | //! it must define owner classes inheriting this framework. |
46 | class SelectMgr_EntityOwner : public SelectBasics_EntityOwner |
47 | { |
48 | |
49 | public: |
50 | |
51 | |
52 | //! Initializes the selection priority aPriority. |
53 | Standard_EXPORT SelectMgr_EntityOwner(const Standard_Integer aPriority = 0); |
54 | |
55 | //! Constructs a framework with the selectable object |
56 | //! anSO being attributed the selection priority aPriority. |
57 | Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, const Standard_Integer aPriority = 0); |
58 | |
59 | //! Constructs a framework from existing one |
60 | //! anSO being attributed the selection priority aPriority. |
61 | Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority = 0); |
62 | |
63 | //! Returns true if there is a selectable object to serve as an owner. |
64 | Standard_EXPORT Standard_Boolean HasSelectable() const; |
65 | |
66 | //! Returns a selectable object detected in the working context. |
67 | Standard_EXPORT virtual Handle(SelectMgr_SelectableObject) Selectable() const; |
68 | |
69 | //! Sets the selectable object anSO to be used by the |
70 | //! second constructor above. |
71 | Standard_EXPORT void Set (const Handle(SelectMgr_SelectableObject)& aSO); |
72 | |
42cf5bc1 |
73 | //! Returns true if the presentation manager aPM |
74 | //! highlights selections corresponding to the selection mode aMode. |
75 | Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) const; |
76 | |
8e5fb5ea |
77 | //! Highlights selectable object's presentation with mode theMode in presentation manager |
78 | //! with given highlight style. Also a check for auto-highlight is performed - if |
79 | //! selectable object manages highlighting on its own, execution will be passed to |
80 | //! SelectMgr_SelectableObject::HilightOwnerWithColor method |
81 | Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
82 | const Handle(Graphic3d_HighlightStyle)& theStyle, |
83 | const Standard_Integer theMode = 0); |
42cf5bc1 |
84 | |
85 | //! Removes highlighting from the owner of a detected |
86 | //! selectable object in the presentation manager aPM. |
87 | //! This object could be the owner of a sensitive primitive. |
88 | //! The display mode for the highlight is aMode; this has |
89 | //! the default value of 0, that is, wireframe mode. |
90 | Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0); |
91 | |
92 | //! Clears the owners matching the value of the selection |
93 | //! mode aMode from the presentation manager object aPM. |
94 | Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0); |
95 | |
96 | Standard_EXPORT virtual Standard_Boolean HasLocation() const Standard_OVERRIDE; |
97 | |
98 | Standard_EXPORT virtual void SetLocation (const TopLoc_Location& aLoc) Standard_OVERRIDE; |
99 | |
100 | Standard_EXPORT virtual void ResetLocation() Standard_OVERRIDE; |
101 | |
102 | Standard_EXPORT virtual TopLoc_Location Location() const Standard_OVERRIDE; |
103 | |
104 | //! Set the state of the owner. |
105 | //! @param theIsSelected [in] shows if owner is selected. |
106 | void SetSelected (const Standard_Boolean theIsSelected); |
107 | |
108 | //! @return Standard_True if the owner is selected. |
109 | Standard_Boolean IsSelected() const; |
110 | |
111 | //! Set the state of the owner. |
112 | //! The method is deprecated. Use SetSelected() instead. |
113 | void State (const Standard_Integer aStatus); |
114 | |
115 | Standard_Integer State() const; |
116 | |
117 | //! if owner is not auto hilighted, for group contains many such owners |
118 | //! will be called one method HilightSelected of SelectableObject |
119 | Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const; |
120 | |
121 | //! if this method returns TRUE the owner will allways call method |
122 | //! Hilight for SelectableObject when the owner is detected. By default |
123 | //! it always return FALSE. |
124 | Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const; |
125 | |
126 | //! Set Z layer ID and update all presentations. |
127 | Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId); |
128 | |
5396886c |
129 | //! Implements immediate application of location transformation of parent object to dynamic highlight structure |
130 | Standard_EXPORT virtual void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer, |
131 | const Handle(PrsMgr_PresentationManager3d)& theManager, |
132 | const Standard_Integer theDispMode); |
42cf5bc1 |
133 | |
8e5fb5ea |
134 | //! Returns true if pointer to selectable object of this owner is equal to the given one |
135 | Standard_Boolean IsSameSelectable (const Handle(SelectMgr_SelectableObject)& theOther) const |
136 | { |
137 | return mySelectable == theOther.get(); |
138 | } |
139 | |
42cf5bc1 |
140 | |
92efcf78 |
141 | DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner) |
42cf5bc1 |
142 | |
143 | protected: |
144 | |
145 | |
146 | |
147 | |
148 | private: |
149 | |
150 | |
151 | SelectMgr_SOPtr mySelectable; |
152 | Standard_Boolean myIsSelected; |
153 | |
154 | |
155 | }; |
156 | |
157 | |
158 | #include <SelectMgr_EntityOwner.lxx> |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | #endif // _SelectMgr_EntityOwner_HeaderFile |