0025695: Visualization, AIS_InteractiveContext - define default HilightMode
[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
f838dac4 17#include <SelectMgr_EntityOwner.hxx>
7fd59977 18
42cf5bc1 19#include <PrsMgr_PresentationManager.hxx>
42cf5bc1 20#include <Standard_NoSuchObject.hxx>
21#include <Standard_Type.hxx>
22#include <TopLoc_Location.hxx>
7fd59977 23
92efcf78 24IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner)
25
7fd59977 26//==================================================
f838dac4 27// Function: SelectMgr_EntityOwner
7fd59977 28// Purpose :
29//==================================================
f838dac4 30SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Standard_Integer thePriority)
31: SelectBasics_EntityOwner (thePriority),
32 mySelectable (NULL),
33 myIsSelected (Standard_False),
34 myFromDecomposition (Standard_False)
7fd59977 35{
f838dac4 36 //
7fd59977 37}
38
f838dac4 39//==================================================
40// Function: SelectMgr_EntityOwner
41// Purpose :
42//==================================================
43SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_SelectableObject)& theSelObj,
44 const Standard_Integer thePriority)
45: SelectBasics_EntityOwner (thePriority),
46 mySelectable (theSelObj.operator->()),
47 myIsSelected (Standard_False),
48 myFromDecomposition (Standard_False)
7fd59977 49{
f838dac4 50 //
7fd59977 51}
52
f838dac4 53//==================================================
54// Function: SelectMgr_EntityOwner
55// Purpose :
56//==================================================
57SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
58 const Standard_Integer thePriority)
59: SelectBasics_EntityOwner (thePriority),
60 mySelectable (theOwner->mySelectable),
61 myIsSelected (Standard_False),
62 myFromDecomposition (Standard_False)
0717ddc1 63{
f838dac4 64 //
0717ddc1 65}
66
7fd59977 67//=======================================================================
f838dac4 68//function : SetSelectable
69//purpose :
7fd59977 70//=======================================================================
f838dac4 71void SelectMgr_EntityOwner::SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj)
7fd59977 72{
f838dac4 73 mySelectable = theSelObj.operator->();
7fd59977 74}
75
f838dac4 76//=======================================================================
77//function : Selectable
78//purpose :
79//=======================================================================
7fd59977 80Handle(SelectMgr_SelectableObject) SelectMgr_EntityOwner::Selectable() const
81{
82 return mySelectable;
83}
84
85//=======================================================================
f838dac4 86//function : IsHilighted
87//purpose :
7fd59977 88//=======================================================================
f838dac4 89Standard_Boolean SelectMgr_EntityOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
90 const Standard_Integer theMode) const
91{
92 return mySelectable != NULL
93 && thePrsMgr->IsHighlighted (mySelectable, theMode);
7fd59977 94}
7fd59977 95
8e5fb5ea 96void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
f838dac4 97 const Handle(Prs3d_Drawer)& theStyle,
8e5fb5ea 98 const Standard_Integer theMode)
7fd59977 99{
f838dac4 100 if (!HasSelectable())
8e5fb5ea 101 {
f838dac4 102 return;
103 }
104
105 if (IsAutoHilight())
106 {
107 const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : mySelectable->ZLayer();
108 thePM->Color (mySelectable, theStyle, theMode, NULL, aHiLayer);
109 }
110 else
111 {
112 mySelectable->HilightOwnerWithColor (thePM, theStyle, this);
eafb234b 113 }
7fd59977 114}
115
f838dac4 116void SelectMgr_EntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer )
7fd59977 117{
f838dac4 118 if (HasSelectable())
119 {
120 thePrsMgr->Unhighlight (mySelectable);
121 }
7fd59977 122}
123
35e08fe8 124void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)&,
125 const Standard_Integer)
7fd59977 126{
127// nothing done on the selectable here...
128}
129
7fd59977 130//=======================================================================
0717ddc1 131//function : about Transformation
7fd59977 132//purpose :
133//=======================================================================
134
135Standard_Boolean SelectMgr_EntityOwner::HasLocation() const
136{
0717ddc1 137 return (HasSelectable() && mySelectable->HasTransformation());
7fd59977 138}
139
140void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&)
141{
142}
143
0717ddc1 144TopLoc_Location SelectMgr_EntityOwner::Location() const
7fd59977 145{
8a864791 146 return !HasLocation() ? TopLoc_Location() : TopLoc_Location(mySelectable->Transformation());
7fd59977 147}
148
149void SelectMgr_EntityOwner::ResetLocation()
150{
151}
152
153Standard_Boolean SelectMgr_EntityOwner::IsAutoHilight () const
154{
f838dac4 155 return mySelectable == NULL
156 || mySelectable->IsAutoHilight();
7fd59977 157}
158
159Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const
160{
161 return Standard_False;
162}
59f45b7c 163
164//=======================================================================
165//function : SetZLayer
166//purpose :
167//=======================================================================
a1954302 168void SelectMgr_EntityOwner::SetZLayer (const Standard_Integer )
59f45b7c 169{
a1954302 170 //
59f45b7c 171}
5396886c 172
173//=======================================================================
174//function : UpdateHighlightTrsf
175//purpose :
176//=======================================================================
177void SelectMgr_EntityOwner::UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer,
178 const Handle(PrsMgr_PresentationManager3d)& theManager,
179 const Standard_Integer theDispMode)
180{
181 if (mySelectable == NULL)
182 return;
183
184 theManager->UpdateHighlightTrsf (theViewer, mySelectable, theDispMode);
185}