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