Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-03-08 |
2 | // Created by: Mister rmi | |
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 <StdSelect_BRepOwner.hxx> |
7fd59977 | 18 | |
19 | #include <Graphic3d_StructureManager.hxx> | |
7f917335 | 20 | #include <Prs3d_Drawer.hxx> |
42cf5bc1 | 21 | #include <PrsMgr_PresentationManager.hxx> |
0ef04197 | 22 | #include <SelectMgr_EntityOwner.hxx> |
42cf5bc1 | 23 | #include <SelectMgr_SelectableObject.hxx> |
24 | #include <Standard_Type.hxx> | |
42cf5bc1 | 25 | #include <StdSelect_Shape.hxx> |
26 | #include <TopLoc_Location.hxx> | |
27 | #include <TopoDS_Shape.hxx> | |
7fd59977 | 28 | |
92efcf78 | 29 | IMPLEMENT_STANDARD_RTTIEXT(StdSelect_BRepOwner,SelectMgr_EntityOwner) |
30 | ||
7fd59977 | 31 | //================================================== |
f838dac4 | 32 | // Function: StdSelect_BRepOwner |
7fd59977 | 33 | // Purpose : |
34 | //================================================== | |
f838dac4 | 35 | StdSelect_BRepOwner::StdSelect_BRepOwner (const Standard_Integer thePriority) |
36 | : SelectMgr_EntityOwner (thePriority), | |
37 | myCurMode (0) | |
7fd59977 | 38 | { |
f838dac4 | 39 | // |
7fd59977 | 40 | } |
41 | ||
f838dac4 | 42 | //================================================== |
43 | // Function: StdSelect_BRepOwner | |
44 | // Purpose : | |
45 | //================================================== | |
46 | StdSelect_BRepOwner::StdSelect_BRepOwner (const TopoDS_Shape& theShape, | |
47 | const Standard_Integer thePriority, | |
48 | const Standard_Boolean theComesFromDecomposition) | |
49 | : SelectMgr_EntityOwner (thePriority), | |
50 | myShape (theShape), | |
51 | myCurMode (0) | |
7fd59977 | 52 | { |
f838dac4 | 53 | myFromDecomposition = theComesFromDecomposition; |
7fd59977 | 54 | } |
55 | ||
f838dac4 | 56 | //================================================== |
57 | // Function: StdSelect_BRepOwner | |
58 | // Purpose : | |
59 | //================================================== | |
60 | StdSelect_BRepOwner::StdSelect_BRepOwner (const TopoDS_Shape& theShape, | |
61 | const Handle (SelectMgr_SelectableObject)& theOrigin, | |
62 | const Standard_Integer thePriority, | |
63 | const Standard_Boolean theComesFromDecomposition) | |
64 | : SelectMgr_EntityOwner (theOrigin, thePriority), | |
65 | myShape (theShape), | |
66 | myCurMode (0) | |
7fd59977 | 67 | { |
f838dac4 | 68 | myFromDecomposition = theComesFromDecomposition; |
7fd59977 | 69 | } |
70 | ||
71 | //======================================================================= | |
72 | //function : IsHilighted | |
73 | //purpose : | |
74 | //======================================================================= | |
75 | Standard_Boolean StdSelect_BRepOwner:: | |
76 | IsHilighted(const Handle(PrsMgr_PresentationManager)& PM, | |
77 | const Standard_Integer aMode) const | |
78 | { | |
7fd59977 | 79 | Standard_Integer M = (aMode < 0) ? myCurMode : aMode; |
7fd59977 | 80 | if(myPrsSh.IsNull()) |
81 | return PM->IsHighlighted(Selectable(),M); | |
82 | return PM->IsHighlighted(myPrsSh,M); | |
83 | } | |
84 | ||
85 | //======================================================================= | |
8e5fb5ea | 86 | //function : HilightWithColor |
87 | //purpose : | |
7fd59977 | 88 | //======================================================================= |
8e5fb5ea | 89 | void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
f838dac4 | 90 | const Handle(Prs3d_Drawer)& theStyle, |
8e5fb5ea | 91 | const Standard_Integer theMode) |
7fd59977 | 92 | { |
f838dac4 | 93 | if (!HasSelectable()) |
29d43f9c | 94 | { |
f838dac4 | 95 | return; |
96 | } | |
7f917335 | 97 | |
f838dac4 | 98 | const Standard_Integer aDispMode = (theMode < 0) ? myCurMode : theMode; |
99 | Handle(SelectMgr_SelectableObject) aSel = Selectable(); | |
100 | const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : aSel->ZLayer(); | |
101 | if (!myFromDecomposition) | |
102 | { | |
103 | thePM->Color (aSel, theStyle, aDispMode, NULL, aHiLayer); | |
104 | return; | |
105 | } | |
a1954302 | 106 | |
f838dac4 | 107 | // do the update flag check |
226fce20 | 108 | if (!myPrsSh.IsNull() |
109 | && myPrsSh->ToBeUpdated (true)) | |
f838dac4 | 110 | { |
226fce20 | 111 | myPrsSh.Nullify(); |
7fd59977 | 112 | } |
f838dac4 | 113 | |
114 | // generate new presentable shape | |
115 | if (myPrsSh.IsNull()) | |
59f45b7c | 116 | { |
f838dac4 | 117 | if (HasLocation()) |
a272ed94 | 118 | { |
f838dac4 | 119 | TopLoc_Location lbid = Location() * myShape.Location(); |
120 | TopoDS_Shape ShBis = myShape.Located(lbid); | |
121 | myPrsSh = new StdSelect_Shape (ShBis, theStyle); | |
a272ed94 | 122 | } |
59f45b7c | 123 | else |
a272ed94 | 124 | { |
f838dac4 | 125 | myPrsSh = new StdSelect_Shape (myShape, theStyle); |
a272ed94 | 126 | } |
59f45b7c | 127 | } |
f838dac4 | 128 | |
129 | // initialize presentation attributes of child presentation | |
130 | myPrsSh->SetZLayer (aSel->ZLayer()); | |
131 | myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); | |
132 | myPrsSh->Attributes()->SetLink (theStyle); | |
133 | myPrsSh->Attributes()->SetColor (theStyle->Color()); | |
134 | myPrsSh->Attributes()->SetTransparency (theStyle->Transparency()); | |
135 | myPrsSh->Attributes()->SetBasicFillAreaAspect (theStyle->BasicFillAreaAspect()); | |
136 | ||
137 | // highlight with color and set layer | |
138 | thePM->Color (myPrsSh, theStyle, aDispMode, aSel, aHiLayer); | |
7fd59977 | 139 | } |
140 | ||
f838dac4 | 141 | void StdSelect_BRepOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer ) |
7fd59977 | 142 | { |
f838dac4 | 143 | if (myPrsSh.IsNull() || !myFromDecomposition) |
144 | { | |
145 | thePrsMgr->Unhighlight (Selectable()); | |
146 | } | |
7fd59977 | 147 | else |
f838dac4 | 148 | { |
149 | thePrsMgr->Unhighlight (myPrsSh); | |
150 | } | |
7fd59977 | 151 | } |
152 | ||
153 | void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM, | |
154 | const Standard_Integer aMode) | |
155 | { | |
7fd59977 | 156 | Standard_Integer M = (aMode < 0) ? myCurMode : aMode; |
6153bb63 | 157 | if (!myPrsSh.IsNull()) |
7fd59977 | 158 | PM->Clear(myPrsSh,M); |
159 | myPrsSh.Nullify(); | |
160 | } | |
161 | ||
162 | void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc) | |
163 | { | |
164 | SelectMgr_EntityOwner::SetLocation(aLoc); | |
29d43f9c A |
165 | // we must not nullify the myPrsSh here, because unhilight method |
166 | // will be working with wrong entity in this case, the best is to | |
167 | // set the update flag and then recompute myPrsSh on hilighting | |
168 | if (!myPrsSh.IsNull()) | |
169 | myPrsSh->SetToUpdate(); | |
7fd59977 | 170 | } |
59f45b7c | 171 | |
5396886c | 172 | //======================================================================= |
173 | //function : UpdateHighlightTrsf | |
174 | //purpose : | |
175 | //======================================================================= | |
176 | void StdSelect_BRepOwner::UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer, | |
177 | const Handle(PrsMgr_PresentationManager3d)& theManager, | |
178 | const Standard_Integer theDispMode) | |
179 | { | |
180 | if (myPrsSh.IsNull() && Selectable().IsNull()) | |
181 | return; | |
182 | ||
183 | theManager->UpdateHighlightTrsf (theViewer, Selectable(), theDispMode, myPrsSh); | |
184 | } |