0027818: Visualization - provide an interface to define highlight presentation properties
[occt.git] / src / SelectMgr / SelectMgr_EntityOwner.cxx
CommitLineData
b311480e 1// Created on: 1995-05-23
2// Created by: Robert COUBLANC
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <PrsMgr_PresentationManager.hxx>
19#include <SelectMgr_EntityOwner.hxx>
20#include <SelectMgr_SelectableObject.hxx>
21#include <Standard_NoSuchObject.hxx>
22#include <Standard_Type.hxx>
23#include <TopLoc_Location.hxx>
7fd59977 24
92efcf78 25IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner)
26
7fd59977 27//==================================================
28// Function:
29// Purpose :
30//==================================================
31SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer aPriority):
32SelectBasics_EntityOwner(aPriority),
33mySelectable(NULL),
c398b00e 34myIsSelected (Standard_False)
7fd59977 35{
36}
37
38SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO,
39 const Standard_Integer aPriority):
40SelectBasics_EntityOwner(aPriority),
c398b00e 41myIsSelected (Standard_False)
7fd59977 42{
43 mySelectable = aSO.operator->();
44}
45
0717ddc1 46SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority)
47:
48 SelectBasics_EntityOwner(aPriority),
49 mySelectable (theOwner->mySelectable)
50{
51}
52
7fd59977 53
54//=======================================================================
55//function : About Selectable...
56//purpose :
57//=======================================================================
58void SelectMgr_EntityOwner::Set(const Handle(SelectMgr_SelectableObject)& aSO)
59{
60 mySelectable = aSO.operator->();
61}
62
63Standard_Boolean SelectMgr_EntityOwner::HasSelectable() const
f751596e 64{
65 return mySelectable != NULL;
7fd59977 66}
67
68Handle(SelectMgr_SelectableObject) SelectMgr_EntityOwner::Selectable() const
69{
70 return mySelectable;
71}
72
73//=======================================================================
74//function : about Hilight
75//purpose :
76//=======================================================================
77Standard_Boolean SelectMgr_EntityOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& PM,
78 const Standard_Integer aMode) const
79{if(HasSelectable())
80 return PM->IsHighlighted(mySelectable,aMode);
81 return Standard_False;
82}
7fd59977 83
8e5fb5ea 84void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
85 const Handle(Graphic3d_HighlightStyle)& theStyle,
86 const Standard_Integer theMode)
7fd59977 87{
8e5fb5ea 88 if (HasSelectable())
89 {
90 if (IsAutoHilight())
c3282ec1 91 {
92 const Graphic3d_ZLayerId aLayerId = mySelectable->GlobalSelOwner().get() == this ?
93 Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost;
8e5fb5ea 94 thePM->Color (mySelectable, theStyle, theMode, NULL, aLayerId);
c3282ec1 95 }
7fd59977 96 else
8e5fb5ea 97 mySelectable->HilightOwnerWithColor (thePM, theStyle, this);
eafb234b 98 }
7fd59977 99}
100
101void SelectMgr_EntityOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
102 const Standard_Integer aMode)
103{
104 if(HasSelectable())
105 PM->Unhighlight(mySelectable,aMode);
106}
107
35e08fe8 108void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)&,
109 const Standard_Integer)
7fd59977 110{
111// nothing done on the selectable here...
112}
113
7fd59977 114//=======================================================================
0717ddc1 115//function : about Transformation
7fd59977 116//purpose :
117//=======================================================================
118
119Standard_Boolean SelectMgr_EntityOwner::HasLocation() const
120{
0717ddc1 121 return (HasSelectable() && mySelectable->HasTransformation());
7fd59977 122}
123
124void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&)
125{
126}
127
0717ddc1 128TopLoc_Location SelectMgr_EntityOwner::Location() const
7fd59977 129{
8a864791 130 return !HasLocation() ? TopLoc_Location() : TopLoc_Location(mySelectable->Transformation());
7fd59977 131}
132
133void SelectMgr_EntityOwner::ResetLocation()
134{
135}
136
137Standard_Boolean SelectMgr_EntityOwner::IsAutoHilight () const
138{
139 if ( mySelectable==0 )
140 return Standard_True;
141 else
142 return mySelectable->IsAutoHilight();
143}
144
145Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const
146{
147 return Standard_False;
148}
59f45b7c 149
150//=======================================================================
151//function : SetZLayer
152//purpose :
153//=======================================================================
a1954302 154void SelectMgr_EntityOwner::SetZLayer (const Standard_Integer )
59f45b7c 155{
a1954302 156 //
59f45b7c 157}
5396886c 158
159//=======================================================================
160//function : UpdateHighlightTrsf
161//purpose :
162//=======================================================================
163void SelectMgr_EntityOwner::UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
164 const Handle(PrsMgr_PresentationManager3d)& theManager,
165 const Standard_Integer theDispMode)
166{
167 if (mySelectable == NULL)
168 return;
169
170 theManager->UpdateHighlightTrsf (theViewer, mySelectable, theDispMode);
171}