7714b386bc4d1d4b10258f2f8185b63385a604e5
[occt.git] / src / SelectMgr / SelectMgr_EntityOwner.cxx
1 // Created on: 1995-05-23
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23
24 #include <SelectMgr_EntityOwner.ixx>
25
26
27
28 //==================================================
29 // Function: 
30 // Purpose :
31 //==================================================
32 SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer aPriority):
33 SelectBasics_EntityOwner(aPriority),
34 mySelectable(NULL),
35 mystate(0)
36 {
37 }
38
39 SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO,
40                                              const Standard_Integer aPriority):
41 SelectBasics_EntityOwner(aPriority),
42 mystate(0)
43 {
44   mySelectable = aSO.operator->();
45 }
46
47
48 //=======================================================================
49 //function : About Selectable...
50 //purpose  : 
51 //=======================================================================
52 void SelectMgr_EntityOwner::Set(const Handle(SelectMgr_SelectableObject)& aSO)
53 {
54   mySelectable = aSO.operator->();
55 }
56
57 Standard_Boolean SelectMgr_EntityOwner::HasSelectable() const
58 {  
59   Handle(Standard_Transient) aNull;
60   if(mySelectable != aNull.operator->()){
61     if(!Selectable().IsNull()) return Standard_True;}
62   return Standard_False;
63 }
64
65 Handle(SelectMgr_SelectableObject) SelectMgr_EntityOwner::Selectable() const
66 {  
67   return mySelectable;
68 }
69
70 //=======================================================================
71 //function : about Hilight
72 //purpose  : 
73 //=======================================================================
74 Standard_Boolean SelectMgr_EntityOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& PM,
75                                                     const Standard_Integer aMode) const 
76 {if(HasSelectable())
77    return PM->IsHighlighted(mySelectable,aMode);
78  return Standard_False;
79 }
80 void SelectMgr_EntityOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
81                                     const Standard_Integer aMode)
82 {if(HasSelectable())
83    PM->Highlight(mySelectable,aMode);
84 }
85
86 void SelectMgr_EntityOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM,
87                                              const Quantity_NameOfColor aColor,
88                                              const Standard_Integer aMode)
89 {
90   if( HasSelectable() ) {
91     if( IsAutoHilight() )
92       PM->Color(mySelectable,aColor,aMode);
93     else
94       mySelectable->HilightOwnerWithColor( PM, aColor, this );
95   }
96 }
97
98 void SelectMgr_EntityOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
99         const Standard_Integer aMode)
100 {
101   if(HasSelectable())
102     PM->Unhighlight(mySelectable,aMode);
103 }
104
105 void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)&,
106                                   const Standard_Integer)
107 {
108 // nothing done on the selectable here...
109 }
110
111
112 void SelectMgr_EntityOwner::
113 Hilight(){}
114
115
116
117 //=======================================================================
118 //function : about Location
119 //purpose  : 
120 //=======================================================================
121
122 Standard_Boolean SelectMgr_EntityOwner::HasLocation() const
123 {
124   return (HasSelectable() && mySelectable->HasLocation());
125 }
126
127 void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&)
128 {
129 }
130
131 const TopLoc_Location& SelectMgr_EntityOwner::Location() const
132 {
133   static TopLoc_Location anIdentity;
134   return HasSelectable() ? mySelectable->Location() : anIdentity;
135 }
136
137 void SelectMgr_EntityOwner::ResetLocation()
138 {
139 }
140
141 Standard_Boolean SelectMgr_EntityOwner::IsAutoHilight () const
142 {
143   if ( mySelectable==0 )
144     return Standard_True;
145   else
146     return mySelectable->IsAutoHilight();
147 }
148
149 Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const
150 {
151   return Standard_False;
152 }
153
154 //=======================================================================
155 //function : SetZLayer
156 //purpose  :
157 //=======================================================================
158 void SelectMgr_EntityOwner::SetZLayer 
159   (const Handle(PrsMgr_PresentationManager)&,
160    const Standard_Integer)
161 {
162 }