b311480e |
1 | // Created on: 1997-01-17 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-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. |
b311480e |
16 | |
d94bed0e |
17 | #include <AIS_InteractiveContext.hxx> |
2ec85268 |
18 | |
42cf5bc1 |
19 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
d94bed0e |
20 | #include <AIS_ConnectedInteractive.hxx> |
7fd59977 |
21 | #include <AIS_GlobalStatus.hxx> |
42cf5bc1 |
22 | #include <AIS_InteractiveObject.hxx> |
23 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
7fd59977 |
24 | #include <AIS_MapIteratorOfMapOfInteractive.hxx> |
42cf5bc1 |
25 | #include <AIS_MultipleConnectedInteractive.hxx> |
7fd59977 |
26 | #include <AIS_Shape.hxx> |
42cf5bc1 |
27 | #include <AIS_Trihedron.hxx> |
28 | #include <Geom_Axis2Placement.hxx> |
7fd59977 |
29 | #include <Graphic3d_AspectFillArea3d.hxx> |
30 | #include <HLRBRep.hxx> |
42cf5bc1 |
31 | #include <OSD_Environment.hxx> |
32 | #include <Precision.hxx> |
33 | #include <Prs3d_BasicAspect.hxx> |
7fd59977 |
34 | #include <Prs3d_DatumAspect.hxx> |
42cf5bc1 |
35 | #include <Prs3d_IsoAspect.hxx> |
36 | #include <Prs3d_LineAspect.hxx> |
7fd59977 |
37 | #include <Prs3d_PlaneAspect.hxx> |
f838dac4 |
38 | #include <Prs3d_PointAspect.hxx> |
42cf5bc1 |
39 | #include <Prs3d_ShadingAspect.hxx> |
7fd59977 |
40 | #include <PrsMgr_PresentableObject.hxx> |
42cf5bc1 |
41 | #include <Quantity_Color.hxx> |
42 | #include <SelectMgr_EntityOwner.hxx> |
43 | #include <SelectMgr_Filter.hxx> |
44 | #include <SelectMgr_OrFilter.hxx> |
45 | #include <SelectMgr_SelectionManager.hxx> |
e33e7e78 |
46 | #include <Standard_Atomic.hxx> |
42cf5bc1 |
47 | #include <Standard_Transient.hxx> |
48 | #include <Standard_Type.hxx> |
f751596e |
49 | #include <StdSelect_ViewerSelector3d.hxx> |
42cf5bc1 |
50 | #include <TCollection_AsciiString.hxx> |
51 | #include <TCollection_ExtendedString.hxx> |
52 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
53 | #include <TColStd_MapIteratorOfMapOfTransient.hxx> |
54 | #include <TopLoc_Location.hxx> |
55 | #include <TopoDS_Shape.hxx> |
7fd59977 |
56 | #include <UnitsAPI.hxx> |
42cf5bc1 |
57 | #include <V3d_View.hxx> |
58 | #include <V3d_Viewer.hxx> |
7fd59977 |
59 | |
2ec85268 |
60 | IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient) |
92efcf78 |
61 | |
e33e7e78 |
62 | namespace |
7fd59977 |
63 | { |
b586500b |
64 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners; |
65 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners; |
f838dac4 |
66 | |
67 | //! Initialize default highlighting attributes. |
df8c7e3e |
68 | static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer, |
69 | const Quantity_Color& theColor) |
f838dac4 |
70 | { |
71 | theDrawer->SetMethod (Aspect_TOHM_COLOR); |
72 | theDrawer->SetDisplayMode (0); |
df8c7e3e |
73 | theDrawer->SetColor (theColor); |
f838dac4 |
74 | |
df8c7e3e |
75 | theDrawer->SetupOwnShadingAspect(); |
76 | theDrawer->SetupOwnPointAspect(); |
f838dac4 |
77 | theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
78 | *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect(); |
79 | theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
80 | *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect(); |
81 | theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect()); |
82 | *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect(); |
83 | theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
84 | *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect(); |
85 | theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
86 | *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect(); |
df8c7e3e |
87 | theDrawer->SetDatumAspect (new Prs3d_DatumAspect()); |
88 | |
89 | theDrawer->ShadingAspect()->SetColor (theColor); |
90 | theDrawer->WireAspect()->SetColor (theColor); |
91 | theDrawer->LineAspect()->SetColor (theColor); |
92 | theDrawer->PlaneAspect()->ArrowAspect()->SetColor (theColor); |
93 | theDrawer->PlaneAspect()->IsoAspect()->SetColor (theColor); |
94 | theDrawer->PlaneAspect()->EdgesAspect()->SetColor (theColor); |
95 | theDrawer->FreeBoundaryAspect()->SetColor (theColor); |
96 | theDrawer->UnFreeBoundaryAspect()->SetColor (theColor); |
97 | theDrawer->PointAspect()->SetColor (theColor); |
98 | for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DP_None; ++aPartIter) |
99 | { |
100 | if (Handle(Prs3d_LineAspect) aLineAsp = theDrawer->DatumAspect()->LineAspect ((Prs3d_DatumParts )aPartIter)) |
101 | { |
102 | aLineAsp->SetColor (theColor); |
103 | } |
104 | } |
f838dac4 |
105 | |
106 | theDrawer->WireAspect()->SetWidth (2.0); |
107 | theDrawer->LineAspect()->SetWidth (2.0); |
108 | theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0); |
109 | theDrawer->FreeBoundaryAspect() ->SetWidth (2.0); |
110 | theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0); |
111 | theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT); |
112 | theDrawer->PointAspect()->SetScale (2.0); |
113 | |
114 | // the triangulation should be computed using main presentation attributes, |
115 | // and should not be overridden by highlighting |
116 | theDrawer->SetAutoTriangulation (Standard_False); |
117 | } |
2195ab96 |
118 | } |
7fd59977 |
119 | |
120 | //======================================================================= |
121 | //function : AIS_InteractiveContext |
122 | //purpose : |
123 | //======================================================================= |
124 | |
125 | AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer): |
c357e426 |
126 | myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())), |
7fd59977 |
127 | myMainVwr(MainViewer), |
128 | myMainSel(new StdSelect_ViewerSelector3d()), |
cbff1e55 |
129 | myToHilightSelected(Standard_True), |
f838dac4 |
130 | mySelection(new AIS_Selection()), |
7fd59977 |
131 | myFilters(new SelectMgr_OrFilter()), |
132 | myDefaultDrawer(new Prs3d_Drawer()), |
f0cddd16 |
133 | myCurDetected(0), |
134 | myCurHighlighted(0), |
14c4193d |
135 | myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable), |
68dcee02 |
136 | myAutoHilight(Standard_True), |
016e5959 |
137 | myIsAutoActivateSelMode(Standard_True) |
f838dac4 |
138 | { |
68dcee02 |
139 | mgrSelector = new SelectMgr_SelectionManager (myMainSel); |
140 | |
f838dac4 |
141 | myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer; |
142 | myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer(); |
143 | myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer(); |
144 | myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer(); |
145 | myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer(); |
146 | myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer(); |
147 | |
148 | myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default); |
149 | myDefaultDrawer->SetDisplayMode(0); |
150 | { |
151 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic]; |
152 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
153 | initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1); |
f838dac4 |
154 | aStyle->SetZLayer(Graphic3d_ZLayerId_Top); |
f838dac4 |
155 | } |
156 | { |
157 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic]; |
158 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
159 | initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1); |
f838dac4 |
160 | aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost); |
f838dac4 |
161 | } |
162 | { |
163 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected]; |
164 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
165 | initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80); |
f838dac4 |
166 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
f838dac4 |
167 | } |
168 | { |
169 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected]; |
170 | aStyle->Link (myDefaultDrawer); |
df8c7e3e |
171 | initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80); |
f838dac4 |
172 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
f838dac4 |
173 | } |
174 | { |
175 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; |
176 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
177 | aStyle->SetMethod(Aspect_TOHM_COLOR); |
178 | aStyle->SetColor (Quantity_NOC_GRAY40); |
179 | } |
180 | |
7fd59977 |
181 | InitAttributes(); |
182 | } |
183 | |
2ec85268 |
184 | //======================================================================= |
185 | //function : ~AIS_InteractiveContext |
186 | //purpose : |
187 | //======================================================================= |
188 | AIS_InteractiveContext::~AIS_InteractiveContext() |
7fd59977 |
189 | { |
016e5959 |
190 | // clear the current selection |
02974a19 |
191 | mySelection->Clear(); |
68dcee02 |
192 | mgrSelector.Nullify(); |
2195ab96 |
193 | |
da0e82aa |
194 | Handle(AIS_InteractiveContext) aNullContext; |
2195ab96 |
195 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
da0e82aa |
196 | { |
b5cce1ab |
197 | const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key(); |
2195ab96 |
198 | anObj->SetContext (aNullContext); |
b5cce1ab |
199 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
200 | { |
b5cce1ab |
201 | aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew); |
c3282ec1 |
202 | } |
da0e82aa |
203 | } |
7fd59977 |
204 | } |
205 | |
2108d9a2 |
206 | //======================================================================= |
207 | //function : LastActiveView |
208 | //purpose : |
209 | //======================================================================= |
210 | Handle(V3d_View) AIS_InteractiveContext::LastActiveView() const |
211 | { |
212 | if (myLastActiveView == NULL |
213 | || myMainVwr.IsNull()) |
214 | { |
215 | return Handle(V3d_View)(); |
216 | } |
217 | |
218 | // as a precaution - check that myLastActiveView pointer is a valid active View |
219 | for (V3d_ListOfViewIterator aViewIter = myMainVwr->ActiveViewIterator(); aViewIter.More(); aViewIter.Next()) |
220 | { |
221 | if (aViewIter.Value() == myLastActiveView) |
222 | { |
223 | return aViewIter.Value(); |
224 | } |
225 | } |
226 | return Handle(V3d_View)(); |
227 | } |
228 | |
7fd59977 |
229 | //======================================================================= |
230 | //function : UpdateCurrentViewer |
231 | //purpose : |
232 | //======================================================================= |
233 | |
234 | void AIS_InteractiveContext::UpdateCurrentViewer() |
235 | { |
236 | if (!myMainVwr.IsNull()) |
237 | myMainVwr->Update(); |
238 | } |
239 | |
7fd59977 |
240 | //======================================================================= |
241 | //function : DisplayedObjects |
2195ab96 |
242 | //purpose : |
7fd59977 |
243 | //======================================================================= |
68dcee02 |
244 | void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
245 | { |
2195ab96 |
246 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
247 | { |
248 | if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed) |
249 | { |
68dcee02 |
250 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
251 | } |
2195ab96 |
252 | } |
7fd59977 |
253 | } |
2195ab96 |
254 | |
7fd59977 |
255 | //======================================================================= |
256 | //function : DisplayedObjects |
2195ab96 |
257 | //purpose : |
7fd59977 |
258 | //======================================================================= |
2195ab96 |
259 | void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind, |
260 | const Standard_Integer theSign, |
68dcee02 |
261 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
262 | { |
2195ab96 |
263 | ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO); |
7fd59977 |
264 | } |
265 | |
7fd59977 |
266 | //======================================================================= |
267 | //function : ErasedObjects |
2195ab96 |
268 | //purpose : |
7fd59977 |
269 | //======================================================================= |
2195ab96 |
270 | void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
271 | { |
2195ab96 |
272 | ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO); |
7fd59977 |
273 | } |
274 | |
275 | //======================================================================= |
276 | //function : ErasedObjects |
2195ab96 |
277 | //purpose : |
7fd59977 |
278 | //======================================================================= |
2195ab96 |
279 | void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind, |
280 | const Standard_Integer theSign, |
281 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
282 | { |
2195ab96 |
283 | ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO); |
7fd59977 |
284 | } |
285 | |
286 | //======================================================================= |
287 | //function : ObjectsByDisplayStatus |
2195ab96 |
288 | //purpose : |
7fd59977 |
289 | //======================================================================= |
2195ab96 |
290 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus, |
291 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
292 | { |
2195ab96 |
293 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
294 | { |
295 | if (anObjIter.Value()->GraphicStatus() == theStatus) |
296 | { |
297 | theListOfIO.Append (anObjIter.Key()); |
298 | } |
7fd59977 |
299 | } |
300 | } |
301 | |
302 | //======================================================================= |
303 | //function : ObjectsByDisplayStatus |
2195ab96 |
304 | //purpose : |
7fd59977 |
305 | //======================================================================= |
2195ab96 |
306 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind, |
307 | const Standard_Integer theSign, |
308 | const AIS_DisplayStatus theStatus, |
309 | AIS_ListOfInteractive& theListOfIO) const |
310 | { |
311 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
312 | { |
a1954302 |
313 | if (theStatus != AIS_DS_None |
314 | && anObjIter.Value()->GraphicStatus() != theStatus) |
315 | { |
316 | continue; |
317 | } |
318 | else if (anObjIter.Key()->Type() != theKind) |
2195ab96 |
319 | { |
320 | continue; |
321 | } |
7fd59977 |
322 | |
2195ab96 |
323 | if (theSign == -1 |
324 | || anObjIter.Key()->Signature() == theSign) |
325 | { |
326 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
327 | } |
328 | } |
329 | } |
330 | |
331 | //======================================================================= |
332 | //function : ObjectsInside |
2195ab96 |
333 | //purpose : |
7fd59977 |
334 | //======================================================================= |
2195ab96 |
335 | void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO, |
336 | const AIS_KindOfInteractive theKind, |
337 | const Standard_Integer theSign) const |
7fd59977 |
338 | { |
2195ab96 |
339 | if (theKind == AIS_KOI_None |
340 | && theSign == -1) |
341 | { |
342 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
343 | { |
344 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
345 | } |
2195ab96 |
346 | return; |
7fd59977 |
347 | } |
2195ab96 |
348 | |
349 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
350 | { |
351 | if (anObjIter.Key()->Type() != theKind) |
352 | { |
353 | continue; |
354 | } |
355 | |
356 | if (theSign == -1 |
357 | || anObjIter.Key()->Signature() == theSign) |
358 | { |
359 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
360 | } |
361 | } |
362 | } |
363 | |
a272ed94 |
364 | //======================================================================= |
365 | //function : ObjectsForView |
366 | //purpose : |
367 | //======================================================================= |
368 | void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO, |
369 | const Handle(V3d_View)& theView, |
370 | const Standard_Boolean theIsVisibleInView, |
371 | const AIS_DisplayStatus theStatus) const |
372 | { |
c357e426 |
373 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
374 | const Standard_Integer aViewId = aViewImpl->Identification(); |
a272ed94 |
375 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
376 | { |
377 | if (theStatus != AIS_DS_None |
378 | && anObjIter.Value()->GraphicStatus() != theStatus) |
379 | { |
380 | theListOfIO.Append (anObjIter.Key()); |
381 | continue; |
382 | } |
383 | |
c357e426 |
384 | Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key()); |
a272ed94 |
385 | const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId); |
386 | if (isVisible == theIsVisibleInView) |
387 | { |
388 | theListOfIO.Append (anObjIter.Key()); |
389 | } |
390 | } |
391 | } |
392 | |
7fd59977 |
393 | //======================================================================= |
394 | //function : Display |
2195ab96 |
395 | //purpose : |
7fd59977 |
396 | //======================================================================= |
2195ab96 |
397 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
398 | const Standard_Boolean theToUpdateViewer) |
399 | { |
400 | if (theIObj.IsNull()) |
401 | { |
402 | return; |
403 | } |
404 | |
405 | Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1; |
406 | GetDefModes (theIObj, aDispMode, aHiMod, aSelMode); |
68dcee02 |
407 | Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1, theToUpdateViewer); |
2195ab96 |
408 | } |
7fd59977 |
409 | |
a272ed94 |
410 | //======================================================================= |
411 | //function : SetViewAffinity |
412 | //purpose : |
413 | //======================================================================= |
414 | void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, |
415 | const Handle(V3d_View)& theView, |
416 | const Standard_Boolean theIsVisible) |
417 | { |
418 | if (theIObj.IsNull() |
419 | || !myObjects.IsBound (theIObj)) |
420 | { |
421 | return; |
422 | } |
423 | |
c357e426 |
424 | Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj); |
425 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
426 | anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True); |
a272ed94 |
427 | if (theIsVisible) |
428 | { |
c04c30b3 |
429 | theView->View()->ChangeHiddenObjects()->Remove (theIObj.get()); |
a272ed94 |
430 | } |
431 | else |
432 | { |
c04c30b3 |
433 | theView->View()->ChangeHiddenObjects()->Add (theIObj.get()); |
a272ed94 |
434 | } |
435 | } |
436 | |
2195ab96 |
437 | //======================================================================= |
438 | //function : Display |
439 | //purpose : |
440 | //======================================================================= |
441 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
442 | const Standard_Integer theDispMode, |
443 | const Standard_Integer theSelectionMode, |
444 | const Standard_Boolean theToUpdateViewer, |
a1954302 |
445 | const AIS_DisplayStatus theDispStatus) |
7fd59977 |
446 | { |
2195ab96 |
447 | if (theIObj.IsNull()) |
448 | { |
449 | return; |
450 | } |
7fd59977 |
451 | |
a1954302 |
452 | if (theDispStatus == AIS_DS_Erased) |
453 | { |
454 | Erase (theIObj, theToUpdateViewer); |
68dcee02 |
455 | Load (theIObj, theSelectionMode); |
6194ee76 |
456 | if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theIObj)) |
457 | { |
458 | (*aStatusPtr)->SetDisplayMode (theDispMode); |
459 | } |
a1954302 |
460 | return; |
461 | } |
462 | |
2ec85268 |
463 | setContextToObject (theIObj); |
2195ab96 |
464 | if (!myObjects.IsBound (theIObj)) |
465 | { |
13c556d9 |
466 | setObjectStatus (theIObj, AIS_DS_Displayed, theDispMode, theSelectionMode); |
6194ee76 |
467 | myMainVwr->StructureManager()->RegisterObject (theIObj); |
2195ab96 |
468 | myMainPM->Display(theIObj, theDispMode); |
469 | if (theSelectionMode != -1) |
470 | { |
543a9964 |
471 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
472 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
473 | { |
474 | mgrSelector->Load (theIObj); |
7fd59977 |
475 | } |
68dcee02 |
476 | mgrSelector->Activate (theIObj, theSelectionMode); |
2195ab96 |
477 | } |
7fd59977 |
478 | } |
7fd59977 |
479 | else |
480 | { |
2195ab96 |
481 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
a6964ce6 |
482 | |
f2b63181 |
483 | // Mark the presentation modes hidden of interactive object different from aDispMode. |
2195ab96 |
484 | // Then make sure aDispMode is displayed and maybe highlighted. |
485 | // Finally, activate selection mode <SelMode> if not yet activated. |
3db69e41 |
486 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
487 | if (anOldMode != theDispMode) |
2195ab96 |
488 | { |
3db69e41 |
489 | if(myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
490 | { |
f838dac4 |
491 | unhighlightGlobal (theIObj); |
2195ab96 |
492 | } |
3db69e41 |
493 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
2195ab96 |
494 | } |
7fd59977 |
495 | |
3db69e41 |
496 | aStatus->SetDisplayMode (theDispMode); |
7fd59977 |
497 | |
2195ab96 |
498 | myMainPM->Display (theIObj, theDispMode); |
a1954302 |
499 | aStatus->SetGraphicStatus (AIS_DS_Displayed); |
2195ab96 |
500 | if (aStatus->IsHilighted()) |
501 | { |
f838dac4 |
502 | highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode); |
2195ab96 |
503 | } |
504 | if (theSelectionMode != -1) |
505 | { |
543a9964 |
506 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
507 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
508 | { |
509 | mgrSelector->Load (theIObj); |
7fd59977 |
510 | } |
2195ab96 |
511 | if (!mgrSelector->IsActivated (theIObj, theSelectionMode)) |
512 | { |
0824e32e |
513 | if (!aStatus->IsSModeIn (theSelectionMode)) |
514 | aStatus->AddSelectionMode (theSelectionMode); |
68dcee02 |
515 | mgrSelector->Activate (theIObj, theSelectionMode); |
7fd59977 |
516 | } |
7fd59977 |
517 | } |
518 | } |
7fd59977 |
519 | |
2195ab96 |
520 | if (theToUpdateViewer) |
521 | { |
522 | myMainVwr->Update(); |
523 | } |
524 | } |
7fd59977 |
525 | |
526 | //======================================================================= |
527 | //function : Load |
2195ab96 |
528 | //purpose : |
7fd59977 |
529 | //======================================================================= |
2195ab96 |
530 | void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj, |
68dcee02 |
531 | const Standard_Integer theSelMode) |
7fd59977 |
532 | { |
2195ab96 |
533 | if (theIObj.IsNull()) |
534 | { |
535 | return; |
536 | } |
7fd59977 |
537 | |
2ec85268 |
538 | setContextToObject (theIObj); |
6194ee76 |
539 | if (!myObjects.IsBound (theIObj)) |
2195ab96 |
540 | { |
6194ee76 |
541 | Standard_Integer aDispMode, aHiMod, aSelModeDef; |
542 | GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef); |
13c556d9 |
543 | setObjectStatus (theIObj, AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); |
6194ee76 |
544 | myMainVwr->StructureManager()->RegisterObject (theIObj); |
545 | } |
89cc29b0 |
546 | |
6194ee76 |
547 | // Register theIObj in the selection manager to prepare further activation of selection |
548 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
549 | if (!mgrSelector->Contains (anObj)) |
550 | { |
551 | mgrSelector->Load (theIObj); |
2195ab96 |
552 | } |
553 | } |
7fd59977 |
554 | |
555 | //======================================================================= |
556 | //function : Erase |
2195ab96 |
557 | //purpose : |
7fd59977 |
558 | //======================================================================= |
2195ab96 |
559 | void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj, |
560 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
561 | { |
2195ab96 |
562 | if (theIObj.IsNull()) |
563 | { |
564 | return; |
565 | } |
7fd59977 |
566 | |
2195ab96 |
567 | if (!theIObj->IsAutoHilight()) |
568 | { |
569 | theIObj->ClearSelected(); |
7fd59977 |
570 | } |
2195ab96 |
571 | |
68dcee02 |
572 | EraseGlobal (theIObj, Standard_False); |
2195ab96 |
573 | if (theToUpdateViewer) |
574 | { |
575 | myMainVwr->Update(); |
576 | } |
7fd59977 |
577 | } |
7fd59977 |
578 | |
579 | //======================================================================= |
580 | //function : EraseAll |
2195ab96 |
581 | //purpose : |
7fd59977 |
582 | //======================================================================= |
2195ab96 |
583 | void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
584 | { |
2195ab96 |
585 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
586 | { |
587 | if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
588 | { |
2195ab96 |
589 | Erase (anObjIter.Key(), Standard_False); |
7fd59977 |
590 | } |
591 | } |
2195ab96 |
592 | |
593 | if (theToUpdateViewer) |
594 | { |
595 | myMainVwr->Update(); |
596 | } |
7fd59977 |
597 | } |
598 | |
599 | //======================================================================= |
600 | //function : DisplayAll |
2195ab96 |
601 | //purpose : |
7fd59977 |
602 | //======================================================================= |
2195ab96 |
603 | void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
604 | { |
2195ab96 |
605 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
606 | { |
607 | const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus(); |
608 | if (aStatus == AIS_DS_Erased) |
eb4320f2 |
609 | { |
2195ab96 |
610 | Display (anObjIter.Key(), Standard_False); |
7fd59977 |
611 | } |
612 | } |
2195ab96 |
613 | |
614 | if (theToUpdateViewer) |
615 | { |
616 | myMainVwr->Update(); |
617 | } |
7fd59977 |
618 | } |
619 | |
620 | //======================================================================= |
621 | //function : DisplaySelected |
2195ab96 |
622 | //purpose : |
7fd59977 |
623 | //======================================================================= |
2195ab96 |
624 | void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
625 | { |
b5cce1ab |
626 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
627 | { |
b5cce1ab |
628 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
629 | Display (anObj, Standard_False); |
2195ab96 |
630 | } |
7fd59977 |
631 | |
b5cce1ab |
632 | if (theToUpdateViewer && !mySelection->Objects().IsEmpty()) |
2195ab96 |
633 | { |
634 | myMainVwr->Update(); |
635 | } |
636 | } |
7fd59977 |
637 | |
2195ab96 |
638 | //======================================================================= |
639 | //function : EraseSelected |
640 | //purpose : |
641 | //======================================================================= |
642 | void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
643 | { |
b5cce1ab |
644 | Standard_Boolean isFound = Standard_False; |
645 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects())) |
2195ab96 |
646 | { |
b5cce1ab |
647 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
648 | Erase (anObj, Standard_False); |
649 | isFound = Standard_True; |
650 | } |
651 | |
652 | if (isFound && theToUpdateViewer) |
653 | { |
654 | myMainVwr->Update(); |
7fd59977 |
655 | } |
656 | } |
2195ab96 |
657 | |
7fd59977 |
658 | //======================================================================= |
2195ab96 |
659 | //function : DisplayStatus |
660 | //purpose : |
7fd59977 |
661 | //======================================================================= |
2195ab96 |
662 | AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
663 | { |
2195ab96 |
664 | if (theIObj.IsNull()) |
665 | { |
666 | return AIS_DS_None; |
667 | } |
68dcee02 |
668 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
669 | return aStatus != NULL ? (*aStatus)->GraphicStatus() : AIS_DS_None; |
7fd59977 |
670 | } |
671 | |
7fd59977 |
672 | //======================================================================= |
673 | //function : Remove |
2195ab96 |
674 | //purpose : |
7fd59977 |
675 | //======================================================================= |
2195ab96 |
676 | void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj, |
677 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
678 | { |
2195ab96 |
679 | if (theIObj.IsNull()) |
680 | { |
681 | return; |
7fd59977 |
682 | } |
2195ab96 |
683 | |
2ec85268 |
684 | if (theIObj->HasInteractiveContext()) |
685 | { |
686 | if (theIObj->myCTXPtr != this) |
687 | { |
9775fa61 |
688 | throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!"); |
2ec85268 |
689 | } |
690 | theIObj->SetContext (Handle(AIS_InteractiveContext)()); |
691 | } |
2195ab96 |
692 | ClearGlobal (theIObj, theToUpdateViewer); |
7fd59977 |
693 | } |
694 | |
695 | //======================================================================= |
696 | //function : RemoveAll |
2195ab96 |
697 | //purpose : |
7fd59977 |
698 | //======================================================================= |
2195ab96 |
699 | void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
700 | { |
701 | AIS_ListOfInteractive aList; |
2195ab96 |
702 | ObjectsInside (aList); |
703 | for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next()) |
704 | { |
705 | Remove (aListIterator.Value(), Standard_False); |
7fd59977 |
706 | } |
7fd59977 |
707 | |
2195ab96 |
708 | if (theToUpdateViewer) |
709 | { |
710 | myMainVwr->Update(); |
7fd59977 |
711 | } |
7fd59977 |
712 | } |
713 | |
7fd59977 |
714 | //======================================================================= |
8e5fb5ea |
715 | //function : HilightWithColor |
716 | //purpose : |
7fd59977 |
717 | //======================================================================= |
8e5fb5ea |
718 | void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
719 | const Handle(Prs3d_Drawer)& theStyle, |
8e5fb5ea |
720 | const Standard_Boolean theIsToUpdate) |
7fd59977 |
721 | { |
8e5fb5ea |
722 | if (theObj.IsNull()) |
2195ab96 |
723 | return; |
7fd59977 |
724 | |
2ec85268 |
725 | setContextToObject (theObj); |
68dcee02 |
726 | if (!myObjects.IsBound (theObj)) |
727 | return; |
eb4320f2 |
728 | |
68dcee02 |
729 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj); |
730 | aStatus->SetHilightStatus (Standard_True); |
8e5fb5ea |
731 | |
68dcee02 |
732 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
733 | { |
68dcee02 |
734 | highlightGlobal (theObj, theStyle, aStatus->DisplayMode()); |
735 | aStatus->SetHilightStyle (theStyle); |
eb4320f2 |
736 | } |
737 | |
8e5fb5ea |
738 | if (theIsToUpdate) |
2195ab96 |
739 | myMainVwr->Update(); |
7fd59977 |
740 | } |
741 | |
742 | //======================================================================= |
743 | //function : Unhilight |
744 | //purpose : |
745 | //======================================================================= |
7fd59977 |
746 | void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) |
747 | { |
748 | if(anIObj.IsNull()) return; |
68dcee02 |
749 | if(!myObjects.IsBound(anIObj)) return; |
7fd59977 |
750 | |
68dcee02 |
751 | const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj); |
752 | aStatus->SetHilightStatus (Standard_False); |
753 | aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); |
eb4320f2 |
754 | |
68dcee02 |
755 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
756 | { |
68dcee02 |
757 | unhighlightGlobal (anIObj); |
eb4320f2 |
758 | } |
68dcee02 |
759 | |
7fd59977 |
760 | if(updateviewer) myMainVwr->Update(); |
761 | } |
762 | |
763 | //======================================================================= |
764 | //function : IsHilighted |
8e5fb5ea |
765 | //purpose : Returns true if the objects global status is set to highlighted. |
7fd59977 |
766 | //======================================================================= |
8e5fb5ea |
767 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
768 | { |
68dcee02 |
769 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
770 | return aStatus != NULL |
771 | && (*aStatus)->IsHilighted(); |
7fd59977 |
772 | } |
773 | |
c3282ec1 |
774 | //======================================================================= |
775 | //function : IsHilighted |
8e5fb5ea |
776 | //purpose : Returns true if the owner is highlighted with selection style. |
c3282ec1 |
777 | //======================================================================= |
8e5fb5ea |
778 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const |
c3282ec1 |
779 | { |
780 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
781 | return Standard_False; |
782 | |
783 | const Handle(AIS_InteractiveObject) anObj = |
784 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
785 | |
8e5fb5ea |
786 | if (anObj->GlobalSelOwner() == theOwner) |
787 | { |
788 | if (!myObjects.IsBound (anObj)) |
789 | return Standard_False; |
790 | |
791 | return myObjects (anObj)->IsHilighted(); |
792 | } |
793 | |
8d2c79f4 |
794 | const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner); |
795 | const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1); |
796 | return theOwner->IsHilighted (myMainPM, aHiMode); |
8e5fb5ea |
797 | } |
798 | |
799 | //======================================================================= |
800 | //function : HighlightStyle |
801 | //purpose : |
802 | //======================================================================= |
803 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
804 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
805 | { |
68dcee02 |
806 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
807 | if (aStatus != NULL |
808 | && (*aStatus)->IsHilighted()) |
8e5fb5ea |
809 | { |
68dcee02 |
810 | theStyle = (*aStatus)->HilightStyle(); |
8e5fb5ea |
811 | return Standard_True; |
812 | } |
68dcee02 |
813 | |
814 | theStyle.Nullify(); |
815 | return Standard_False; |
8e5fb5ea |
816 | } |
c3282ec1 |
817 | |
8e5fb5ea |
818 | //======================================================================= |
819 | //function : HighlightStyle |
820 | //purpose : |
821 | //======================================================================= |
822 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, |
f838dac4 |
823 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
824 | { |
825 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
826 | return Standard_False; |
827 | |
828 | if (IsHilighted (theOwner)) |
c3282ec1 |
829 | { |
8e5fb5ea |
830 | const Handle(AIS_InteractiveObject) anObj = |
831 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
832 | if (anObj->GlobalSelOwner() == theOwner) |
c3282ec1 |
833 | { |
8e5fb5ea |
834 | theStyle = myObjects (anObj)->HilightStyle(); |
c3282ec1 |
835 | } |
836 | else |
837 | { |
8e5fb5ea |
838 | // since part selection style is not stored in global status, |
839 | // check if the object has own selection style. If not, it can |
840 | // only be highlighted with default selection style (because |
841 | // sub-intensity does not modify any selection states) |
f838dac4 |
842 | theStyle = getSelStyle (anObj, theOwner); |
c3282ec1 |
843 | } |
c3282ec1 |
844 | return Standard_True; |
845 | } |
8e5fb5ea |
846 | else |
847 | { |
848 | theStyle.Nullify(); |
849 | return Standard_False; |
850 | } |
c3282ec1 |
851 | } |
7fd59977 |
852 | |
853 | //======================================================================= |
854 | //function : IsDisplayed |
855 | //purpose : |
856 | //======================================================================= |
857 | |
68dcee02 |
858 | Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
859 | { |
68dcee02 |
860 | if(theObj.IsNull()) return Standard_False; |
7fd59977 |
861 | |
68dcee02 |
862 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
863 | return aStatus != NULL |
864 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed; |
7fd59977 |
865 | } |
7fd59977 |
866 | |
867 | //======================================================================= |
868 | //function : IsDisplayed |
2195ab96 |
869 | //purpose : |
7fd59977 |
870 | //======================================================================= |
2195ab96 |
871 | Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj, |
872 | const Standard_Integer theMode) const |
7fd59977 |
873 | { |
2195ab96 |
874 | if (theIObj.IsNull()) |
875 | { |
876 | return Standard_False; |
877 | } |
878 | |
68dcee02 |
879 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
880 | return aStatus != NULL |
881 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed |
882 | && (*aStatus)->DisplayMode() == theMode; |
7fd59977 |
883 | } |
884 | |
7fd59977 |
885 | //======================================================================= |
886 | //function : DisplayPriority |
2195ab96 |
887 | //purpose : |
7fd59977 |
888 | //======================================================================= |
2195ab96 |
889 | Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
890 | { |
2195ab96 |
891 | if (theIObj.IsNull()) |
892 | { |
893 | return -1; |
894 | } |
eb4320f2 |
895 | |
68dcee02 |
896 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
897 | if (aStatus != NULL |
898 | && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed |
899 | || (*aStatus)->GraphicStatus() == AIS_DS_Erased)) |
eb4320f2 |
900 | { |
2195ab96 |
901 | Standard_Integer aDispMode = theIObj->HasDisplayMode() |
902 | ? theIObj->DisplayMode() |
f838dac4 |
903 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
904 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
905 | : 0); |
906 | return myMainPM->DisplayPriority (theIObj, aDispMode); |
7fd59977 |
907 | } |
908 | return 0; |
909 | } |
2195ab96 |
910 | |
7fd59977 |
911 | //======================================================================= |
912 | //function : SetDisplayPriority |
2195ab96 |
913 | //purpose : |
7fd59977 |
914 | //======================================================================= |
2195ab96 |
915 | void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, |
916 | const Standard_Integer thePriority) |
7fd59977 |
917 | { |
2195ab96 |
918 | if (theIObj.IsNull()) |
919 | { |
7fd59977 |
920 | return; |
2195ab96 |
921 | } |
922 | |
2ec85268 |
923 | setContextToObject (theIObj); |
68dcee02 |
924 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
925 | if (aStatus != NULL |
926 | && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed |
927 | || (*aStatus)->GraphicStatus() == AIS_DS_Erased)) |
2195ab96 |
928 | { |
68dcee02 |
929 | Standard_Integer aDisplayMode = theIObj->HasDisplayMode() |
930 | ? theIObj->DisplayMode() |
931 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
932 | ? myDefaultDrawer->DisplayMode() |
933 | : 0); |
934 | myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority); |
eb4320f2 |
935 | } |
7fd59977 |
936 | } |
937 | |
938 | //======================================================================= |
939 | //function : Redisplay |
2195ab96 |
940 | //purpose : |
7fd59977 |
941 | //======================================================================= |
2195ab96 |
942 | void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj, |
943 | const Standard_Boolean theToUpdateViewer, |
944 | const Standard_Boolean theAllModes) |
7fd59977 |
945 | { |
2195ab96 |
946 | RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes); |
947 | RecomputeSelectionOnly (theIObj); |
7fd59977 |
948 | } |
949 | |
950 | //======================================================================= |
951 | //function : Redisplay |
2195ab96 |
952 | //purpose : |
7fd59977 |
953 | //======================================================================= |
2195ab96 |
954 | void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI, |
955 | const Standard_Integer /*theSign*/, |
956 | const Standard_Boolean theToUpdateViewer) |
957 | { |
958 | Standard_Boolean isRedisplayed = Standard_False; |
959 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
960 | { |
961 | Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); |
962 | if (anObj->Type() != theKOI) |
963 | { |
964 | continue; |
7fd59977 |
965 | } |
2195ab96 |
966 | |
967 | Redisplay (anObj, Standard_False); |
968 | isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed |
969 | || isRedisplayed; |
7fd59977 |
970 | } |
2195ab96 |
971 | |
972 | if (theToUpdateViewer |
973 | && isRedisplayed) |
eb4320f2 |
974 | { |
975 | myMainVwr->Update(); |
7fd59977 |
976 | } |
977 | } |
978 | |
7fd59977 |
979 | //======================================================================= |
980 | //function : RecomputePrsOnly |
2195ab96 |
981 | //purpose : |
7fd59977 |
982 | //======================================================================= |
2195ab96 |
983 | void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj, |
984 | const Standard_Boolean theToUpdateViewer, |
985 | const Standard_Boolean theAllModes) |
7fd59977 |
986 | { |
2195ab96 |
987 | if (theIObj.IsNull()) |
988 | { |
989 | return; |
990 | } |
eb4320f2 |
991 | |
226fce20 |
992 | theIObj->SetToUpdate(); |
993 | theIObj->UpdatePresentations (theAllModes); |
2195ab96 |
994 | if (!theToUpdateViewer) |
eb4320f2 |
995 | { |
996 | return; |
997 | } |
998 | |
68dcee02 |
999 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
1000 | if (aStatus != NULL |
1001 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
1002 | { |
1003 | myMainVwr->Update(); |
7fd59977 |
1004 | } |
1005 | } |
1006 | //======================================================================= |
1007 | //function : RecomputeSelectionOnly |
1008 | //purpose : |
1009 | //======================================================================= |
bc677575 |
1010 | void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO) |
7fd59977 |
1011 | { |
bc677575 |
1012 | if (theIO.IsNull()) |
1013 | { |
1014 | return; |
1015 | } |
7fd59977 |
1016 | |
bc677575 |
1017 | mgrSelector->RecomputeSelection (theIO); |
0d969553 |
1018 | |
68dcee02 |
1019 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIO); |
1020 | if (aStatus == NULL |
1021 | || (*aStatus)->GraphicStatus() != AIS_DS_Displayed) |
bc677575 |
1022 | { |
1023 | return; |
1024 | } |
1025 | |
1026 | TColStd_ListOfInteger aModes; |
1027 | ActivatedModes (theIO, aModes); |
1028 | TColStd_ListIteratorOfListOfInteger aModesIter (aModes); |
1029 | for (; aModesIter.More(); aModesIter.Next()) |
1030 | { |
68dcee02 |
1031 | mgrSelector->Activate (theIO, aModesIter.Value()); |
7fd59977 |
1032 | } |
1033 | } |
1034 | |
1035 | //======================================================================= |
1036 | //function : Update |
2195ab96 |
1037 | //purpose : |
7fd59977 |
1038 | //======================================================================= |
f3889691 |
1039 | void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj, |
2195ab96 |
1040 | const Standard_Boolean theUpdateViewer) |
7fd59977 |
1041 | { |
f3889691 |
1042 | if (theIObj.IsNull()) |
1043 | { |
1044 | return; |
1045 | } |
7fd59977 |
1046 | |
226fce20 |
1047 | theIObj->UpdatePresentations(); |
f3889691 |
1048 | mgrSelector->Update(theIObj); |
1049 | |
1050 | if (theUpdateViewer) |
1051 | { |
68dcee02 |
1052 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
1053 | if (aStatus != NULL |
1054 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed) |
f3889691 |
1055 | { |
68dcee02 |
1056 | myMainVwr->Update(); |
7fd59977 |
1057 | } |
1058 | } |
1059 | } |
1060 | |
7fd59977 |
1061 | //======================================================================= |
1062 | //function : SetLocation |
2195ab96 |
1063 | //purpose : |
7fd59977 |
1064 | //======================================================================= |
2195ab96 |
1065 | void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj, |
1066 | const TopLoc_Location& theLoc) |
7fd59977 |
1067 | { |
2195ab96 |
1068 | if (theIObj.IsNull()) |
1069 | { |
1070 | return; |
1071 | } |
7fd59977 |
1072 | |
2195ab96 |
1073 | if (theIObj->HasTransformation() |
1074 | && theLoc.IsIdentity()) |
1075 | { |
1076 | theIObj->ResetTransformation(); |
1077 | mgrSelector->Update (theIObj, Standard_False); |
1078 | return; |
1079 | } |
1080 | else if (theLoc.IsIdentity()) |
1081 | { |
7fd59977 |
1082 | return; |
1083 | } |
7fd59977 |
1084 | |
0d969553 |
1085 | // first reset the previous location to properly clean everything... |
2195ab96 |
1086 | if (theIObj->HasTransformation()) |
1087 | { |
1088 | theIObj->ResetTransformation(); |
1089 | } |
7fd59977 |
1090 | |
2195ab96 |
1091 | theIObj->SetLocalTransformation (theLoc.Transformation()); |
7fd59977 |
1092 | |
68dcee02 |
1093 | mgrSelector->Update (theIObj, Standard_False); |
5396886c |
1094 | |
1095 | // if the object or its part is highlighted dynamically, it is necessary to apply location transformation |
1096 | // to its highlight structure immediately |
8e5fb5ea |
1097 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) |
5396886c |
1098 | { |
7bbccb5f |
1099 | const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
5396886c |
1100 | myLastPicked->UpdateHighlightTrsf (myMainVwr, |
1101 | myMainPM, |
7bbccb5f |
1102 | aHiMod); |
5396886c |
1103 | } |
7fd59977 |
1104 | } |
2195ab96 |
1105 | |
7fd59977 |
1106 | //======================================================================= |
1107 | //function : ResetLocation |
2195ab96 |
1108 | //purpose : |
7fd59977 |
1109 | //======================================================================= |
2195ab96 |
1110 | void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj) |
7fd59977 |
1111 | { |
2195ab96 |
1112 | if (theIObj.IsNull()) |
1113 | { |
1114 | return; |
1115 | } |
7fd59977 |
1116 | |
2195ab96 |
1117 | theIObj->ResetTransformation(); |
1118 | mgrSelector->Update (theIObj, Standard_False); |
7fd59977 |
1119 | } |
1120 | |
1121 | //======================================================================= |
1122 | //function : HasLocation |
2195ab96 |
1123 | //purpose : |
7fd59977 |
1124 | //======================================================================= |
2195ab96 |
1125 | Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1126 | { |
2195ab96 |
1127 | return !theIObj.IsNull() |
1128 | && theIObj->HasTransformation(); |
7fd59977 |
1129 | } |
1130 | |
2195ab96 |
1131 | //======================================================================= |
1132 | //function : Location |
1133 | //purpose : |
1134 | //======================================================================= |
1135 | TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1136 | { |
2195ab96 |
1137 | return theIObj->Transformation(); |
7fd59977 |
1138 | } |
1139 | |
1140 | //======================================================================= |
1141 | //function : SetDeviationCoefficient |
2195ab96 |
1142 | //purpose : |
7fd59977 |
1143 | //======================================================================= |
2195ab96 |
1144 | void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient) |
7fd59977 |
1145 | { |
2195ab96 |
1146 | myDefaultDrawer->SetDeviationCoefficient (theCoefficient); |
7fd59977 |
1147 | } |
2195ab96 |
1148 | |
7fd59977 |
1149 | //======================================================================= |
1150 | //function : SetDeviationAngle |
2195ab96 |
1151 | //purpose : |
7fd59977 |
1152 | //======================================================================= |
2195ab96 |
1153 | void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle) |
7fd59977 |
1154 | { |
e19792fa |
1155 | myDefaultDrawer->SetDeviationAngle (theAngle); |
7fd59977 |
1156 | } |
1157 | |
1158 | //======================================================================= |
1159 | //function : DeviationAngle |
1160 | //purpose : Gets deviationAngle |
1161 | //======================================================================= |
7fd59977 |
1162 | Standard_Real AIS_InteractiveContext::DeviationAngle() const |
1163 | { |
2195ab96 |
1164 | return myDefaultDrawer->DeviationAngle(); |
7fd59977 |
1165 | } |
1166 | |
1167 | //======================================================================= |
1168 | //function : DeviationCoefficient |
2195ab96 |
1169 | //purpose : |
7fd59977 |
1170 | //======================================================================= |
2195ab96 |
1171 | Standard_Real AIS_InteractiveContext::DeviationCoefficient() const |
7fd59977 |
1172 | { |
1173 | return myDefaultDrawer->DeviationCoefficient(); |
1174 | } |
2195ab96 |
1175 | |
7fd59977 |
1176 | //======================================================================= |
1177 | //function : SetDisplayMode |
2195ab96 |
1178 | //purpose : |
7fd59977 |
1179 | //======================================================================= |
e5d7e249 |
1180 | void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, |
1181 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1182 | { |
f838dac4 |
1183 | if (theMode == myDefaultDrawer->DisplayMode()) |
2195ab96 |
1184 | { |
1185 | return; |
1186 | } |
7fd59977 |
1187 | |
2195ab96 |
1188 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
1189 | { |
1190 | Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); |
1191 | Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape)) |
1192 | || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive)) |
1193 | || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive)); |
7fd59977 |
1194 | |
2195ab96 |
1195 | if (!toProcess |
1196 | || anObj->HasDisplayMode() |
1197 | || !anObj->AcceptDisplayMode (theMode)) |
1198 | { |
1199 | continue; |
1200 | } |
1201 | |
1202 | Handle(AIS_GlobalStatus) aStatus = anObjIter.Value(); |
3db69e41 |
1203 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1204 | |
2195ab96 |
1205 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
1206 | { |
2195ab96 |
1207 | myMainPM->Display (anObj, theMode); |
8e5fb5ea |
1208 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj)) |
c3282ec1 |
1209 | { |
1210 | myMainPM->BeginImmediateDraw(); |
f838dac4 |
1211 | unhighlightGlobal (anObj); |
c3282ec1 |
1212 | myMainPM->EndImmediateDraw (myMainVwr); |
1213 | } |
2195ab96 |
1214 | if (aStatus->IsSubIntensityOn()) |
7fd59977 |
1215 | { |
8e5fb5ea |
1216 | highlightWithSubintensity (anObj, theMode); |
7fd59977 |
1217 | } |
f838dac4 |
1218 | myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False); |
2195ab96 |
1219 | } |
1220 | } |
1221 | |
f838dac4 |
1222 | myDefaultDrawer->SetDisplayMode (theMode); |
2195ab96 |
1223 | if (theToUpdateViewer) |
1224 | { |
1225 | myMainVwr->Update(); |
1226 | } |
7fd59977 |
1227 | } |
1228 | |
1229 | //======================================================================= |
1230 | //function : SetDisplayMode |
2195ab96 |
1231 | //purpose : |
7fd59977 |
1232 | //======================================================================= |
2195ab96 |
1233 | void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1234 | const Standard_Integer theMode, |
1235 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1236 | { |
2ec85268 |
1237 | setContextToObject (theIObj); |
2195ab96 |
1238 | if (!myObjects.IsBound (theIObj)) |
1239 | { |
1240 | theIObj->SetDisplayMode (theMode); |
1241 | return; |
1242 | } |
1243 | else if (!theIObj->AcceptDisplayMode (theMode)) |
1244 | { |
1245 | return; |
1246 | } |
eb4320f2 |
1247 | |
2195ab96 |
1248 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
1249 | if (aStatus->GraphicStatus() != AIS_DS_Displayed) |
1250 | { |
b2bafb33 |
1251 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1252 | theIObj->SetDisplayMode (theMode); |
1253 | return; |
1254 | } |
a6964ce6 |
1255 | |
2195ab96 |
1256 | // erase presentations for all display modes different from <aMode> |
3db69e41 |
1257 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
1258 | if (anOldMode != theMode) |
2195ab96 |
1259 | { |
3db69e41 |
1260 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
1261 | { |
f838dac4 |
1262 | unhighlightGlobal (theIObj); |
7fd59977 |
1263 | } |
3db69e41 |
1264 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
7fd59977 |
1265 | } |
2195ab96 |
1266 | |
3db69e41 |
1267 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1268 | |
1269 | myMainPM->Display (theIObj, theMode); |
2195ab96 |
1270 | if (aStatus->IsHilighted()) |
1271 | { |
f838dac4 |
1272 | highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode); |
2195ab96 |
1273 | } |
1274 | if (aStatus->IsSubIntensityOn()) |
1275 | { |
8e5fb5ea |
1276 | highlightWithSubintensity (theIObj, theMode); |
2195ab96 |
1277 | } |
1278 | |
1279 | if (theToUpdateViewer) |
1280 | { |
1281 | myMainVwr->Update(); |
1282 | } |
1283 | theIObj->SetDisplayMode (theMode); |
7fd59977 |
1284 | } |
1285 | |
1286 | //======================================================================= |
1287 | //function : UnsetDisplayMode |
2195ab96 |
1288 | //purpose : |
7fd59977 |
1289 | //======================================================================= |
2195ab96 |
1290 | void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1291 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1292 | { |
2195ab96 |
1293 | if (theIObj.IsNull() |
1294 | || !theIObj->HasDisplayMode()) |
1295 | { |
1296 | return; |
1297 | } |
1298 | |
1299 | if (!myObjects.IsBound (theIObj)) |
1300 | { |
1301 | theIObj->UnsetDisplayMode(); |
1302 | return; |
1303 | } |
1304 | |
1305 | const Standard_Integer anOldMode = theIObj->DisplayMode(); |
f838dac4 |
1306 | if (myDefaultDrawer->DisplayMode() == anOldMode) |
2195ab96 |
1307 | { |
1308 | return; |
1309 | } |
1310 | |
1311 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
f838dac4 |
1312 | aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode()); |
2195ab96 |
1313 | |
1314 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
1315 | { |
1316 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
7fd59977 |
1317 | { |
f838dac4 |
1318 | unhighlightGlobal (theIObj); |
2195ab96 |
1319 | } |
1320 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
f838dac4 |
1321 | myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode()); |
2195ab96 |
1322 | if (aStatus->IsHilighted()) |
1323 | { |
8e5fb5ea |
1324 | highlightSelected (theIObj->GlobalSelOwner()); |
2195ab96 |
1325 | } |
1326 | if (aStatus->IsSubIntensityOn()) |
1327 | { |
f838dac4 |
1328 | highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode()); |
7fd59977 |
1329 | } |
2195ab96 |
1330 | |
1331 | if (theToUpdateViewer) |
1332 | { |
1333 | myMainVwr->Update(); |
1334 | } |
1335 | } |
1336 | |
1337 | theIObj->UnsetDisplayMode(); |
7fd59977 |
1338 | } |
1339 | |
1340 | //======================================================================= |
1341 | //function : SetCurrentFacingModel |
2195ab96 |
1342 | //purpose : |
7fd59977 |
1343 | //======================================================================= |
2195ab96 |
1344 | void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj, |
1345 | const Aspect_TypeOfFacingModel theModel) |
b8ddfc2f |
1346 | { |
2195ab96 |
1347 | if (!theIObj.IsNull()) |
1348 | { |
1349 | theIObj->SetCurrentFacingModel (theModel); |
1350 | } |
7fd59977 |
1351 | } |
7fd59977 |
1352 | |
2195ab96 |
1353 | //======================================================================= |
1354 | //function : SetColor |
1355 | //purpose : |
1356 | //======================================================================= |
1357 | void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1358 | const Quantity_Color& theColor, |
1359 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1360 | { |
2195ab96 |
1361 | if (theIObj.IsNull()) |
1362 | { |
1363 | return; |
1364 | } |
7fd59977 |
1365 | |
2ec85268 |
1366 | setContextToObject (theIObj); |
2195ab96 |
1367 | theIObj->SetColor (theColor); |
226fce20 |
1368 | theIObj->UpdatePresentations(); |
1369 | if (theToUpdateViewer) |
1370 | { |
1371 | UpdateCurrentViewer(); |
1372 | } |
2195ab96 |
1373 | } |
7fd59977 |
1374 | |
5ad8c033 |
1375 | //======================================================================= |
1376 | //function : SetIsoOnTriangulation |
1377 | //purpose : |
1378 | //======================================================================= |
1379 | void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled, |
1380 | const Handle(AIS_InteractiveObject)& theObject) |
1381 | { |
1382 | if (theObject.IsNull()) |
1383 | { |
1384 | return; |
1385 | } |
1386 | |
1387 | theObject->SetIsoOnTriangulation (theIsEnabled); |
1388 | } |
1389 | |
2195ab96 |
1390 | //======================================================================= |
1391 | //function : SetDeviationCoefficient |
1392 | //purpose : |
1393 | //======================================================================= |
1394 | void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
1395 | const Standard_Real theCoefficient, |
1396 | const Standard_Boolean theToUpdateViewer) |
1397 | { |
1398 | if (theIObj.IsNull()) |
1399 | { |
1400 | return; |
1401 | } |
7fd59977 |
1402 | |
2195ab96 |
1403 | // to be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1404 | setContextToObject (theIObj); |
2195ab96 |
1405 | if (theIObj->Type() != AIS_KOI_Object |
1406 | && theIObj->Type() != AIS_KOI_Shape) |
1407 | { |
1408 | return; |
1409 | } |
1410 | else if (theIObj->Signature() != 0) |
1411 | { |
1412 | return; |
1413 | } |
1414 | |
1415 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1416 | aShape->SetOwnDeviationCoefficient (theCoefficient); |
226fce20 |
1417 | aShape->UpdatePresentations(); |
1418 | if (theToUpdateViewer) |
1419 | { |
1420 | UpdateCurrentViewer(); |
1421 | } |
7fd59977 |
1422 | } |
1423 | |
7fd59977 |
1424 | //======================================================================= |
1425 | //function : SetDeviationAngle |
2195ab96 |
1426 | //purpose : |
7fd59977 |
1427 | //======================================================================= |
2195ab96 |
1428 | void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
1429 | const Standard_Real theAngle, |
1430 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1431 | { |
2195ab96 |
1432 | if (theIObj.IsNull()) |
1433 | { |
1434 | return; |
1435 | } |
1436 | |
e33e7e78 |
1437 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1438 | setContextToObject (theIObj); |
2195ab96 |
1439 | if (theIObj->Type() != AIS_KOI_Shape) |
1440 | { |
1441 | return; |
1442 | } |
1443 | else if (theIObj->Signature() != 0) |
1444 | { |
1445 | return; |
1446 | } |
7fd59977 |
1447 | |
2195ab96 |
1448 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1449 | aShape->SetOwnDeviationAngle (theAngle); |
226fce20 |
1450 | aShape->UpdatePresentations(); |
1451 | if (theToUpdateViewer) |
1452 | { |
1453 | UpdateCurrentViewer(); |
1454 | } |
7fd59977 |
1455 | } |
2195ab96 |
1456 | |
7fd59977 |
1457 | //======================================================================= |
2195ab96 |
1458 | //function : SetAngleAndDeviation |
1459 | //purpose : |
7fd59977 |
1460 | //======================================================================= |
2195ab96 |
1461 | void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
1462 | const Standard_Real theAngle, |
1463 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1464 | { |
2195ab96 |
1465 | if (theIObj.IsNull()) |
1466 | { |
1467 | return; |
1468 | } |
1469 | |
e33e7e78 |
1470 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1471 | setContextToObject (theIObj); |
2195ab96 |
1472 | if (theIObj->Type() != AIS_KOI_Shape) |
1473 | { |
1474 | return; |
1475 | } |
1476 | if (theIObj->Signature() != 0) |
1477 | { |
1478 | return; |
1479 | } |
7fd59977 |
1480 | |
2195ab96 |
1481 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1482 | aShape->SetAngleAndDeviation (theAngle); |
226fce20 |
1483 | aShape->UpdatePresentations(); |
1484 | if (theToUpdateViewer) |
2195ab96 |
1485 | { |
226fce20 |
1486 | UpdateCurrentViewer(); |
226fce20 |
1487 | } |
7fd59977 |
1488 | } |
1489 | |
1490 | //======================================================================= |
1491 | //function : UnsetColor |
2195ab96 |
1492 | //purpose : |
7fd59977 |
1493 | //======================================================================= |
2195ab96 |
1494 | void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1495 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1496 | { |
2195ab96 |
1497 | if (theIObj.IsNull()) |
1498 | { |
1499 | return; |
1500 | } |
1501 | |
1502 | theIObj->UnsetColor(); |
226fce20 |
1503 | theIObj->UpdatePresentations(); |
1504 | if (theToUpdateViewer) |
1505 | { |
1506 | UpdateCurrentViewer(); |
1507 | } |
7fd59977 |
1508 | } |
1509 | |
1510 | //======================================================================= |
1511 | //function : HasColor |
2195ab96 |
1512 | //purpose : |
7fd59977 |
1513 | //======================================================================= |
2195ab96 |
1514 | Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1515 | { |
2195ab96 |
1516 | return theIObj->HasColor(); |
7fd59977 |
1517 | } |
1518 | |
2195ab96 |
1519 | //======================================================================= |
1520 | //function : Color |
1521 | //purpose : |
1522 | //======================================================================= |
1523 | void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj, |
1524 | Quantity_Color& theColor) const |
7fd59977 |
1525 | { |
2195ab96 |
1526 | theIObj->Color (theColor); |
7fd59977 |
1527 | } |
7fd59977 |
1528 | |
1529 | //======================================================================= |
1530 | //function : Width |
2195ab96 |
1531 | //purpose : |
7fd59977 |
1532 | //======================================================================= |
2195ab96 |
1533 | Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1534 | { |
2195ab96 |
1535 | return theIObj->Width(); |
7fd59977 |
1536 | } |
1537 | |
1538 | //======================================================================= |
1539 | //function : SetWidth |
2195ab96 |
1540 | //purpose : |
7fd59977 |
1541 | //======================================================================= |
2195ab96 |
1542 | void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1543 | const Standard_Real theWidth, |
1544 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1545 | { |
2195ab96 |
1546 | if (theIObj.IsNull()) |
1547 | { |
1548 | return; |
1549 | } |
1550 | |
2ec85268 |
1551 | setContextToObject (theIObj); |
2195ab96 |
1552 | theIObj->SetWidth (theWidth); |
226fce20 |
1553 | theIObj->UpdatePresentations(); |
a9080ef9 |
1554 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) |
c3282ec1 |
1555 | { |
a9080ef9 |
1556 | if (myLastPicked->IsAutoHilight()) |
c3282ec1 |
1557 | { |
f838dac4 |
1558 | const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
a9080ef9 |
1559 | myLastPicked->HilightWithColor (myMainPM, |
1560 | myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked), |
8e5fb5ea |
1561 | aHiMode); |
c3282ec1 |
1562 | } |
1563 | else |
1564 | { |
8e5fb5ea |
1565 | theIObj->HilightOwnerWithColor (myMainPM, |
a9080ef9 |
1566 | myLastPicked->IsSelected() ? getSelStyle (theIObj, myLastPicked) : getHiStyle (theIObj, myLastPicked), |
1567 | myLastPicked); |
c3282ec1 |
1568 | } |
1569 | } |
226fce20 |
1570 | if (theToUpdateViewer) |
1571 | { |
1572 | UpdateCurrentViewer(); |
1573 | } |
7fd59977 |
1574 | } |
1575 | |
1576 | //======================================================================= |
1577 | //function : UnsetWidth |
2195ab96 |
1578 | //purpose : |
7fd59977 |
1579 | //======================================================================= |
2195ab96 |
1580 | void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1581 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1582 | { |
2195ab96 |
1583 | if (theIObj.IsNull()) |
1584 | { |
1585 | return; |
1586 | } |
1587 | |
1588 | theIObj->UnsetWidth(); |
226fce20 |
1589 | theIObj->UpdatePresentations(); |
1590 | if (theToUpdateViewer) |
1591 | { |
1592 | UpdateCurrentViewer(); |
1593 | } |
7fd59977 |
1594 | } |
1595 | |
1596 | //======================================================================= |
1597 | //function : SetMaterial |
2195ab96 |
1598 | //purpose : |
7fd59977 |
1599 | //======================================================================= |
2195ab96 |
1600 | void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
87432b82 |
1601 | const Graphic3d_MaterialAspect& theMaterial, |
2195ab96 |
1602 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1603 | { |
2195ab96 |
1604 | if (theIObj.IsNull()) |
1605 | { |
1606 | return; |
1607 | } |
1608 | |
2ec85268 |
1609 | setContextToObject (theIObj); |
87432b82 |
1610 | theIObj->SetMaterial (theMaterial); |
226fce20 |
1611 | theIObj->UpdatePresentations(); |
1612 | if (theToUpdateViewer) |
1613 | { |
1614 | UpdateCurrentViewer(); |
1615 | } |
7fd59977 |
1616 | } |
1617 | |
1618 | //======================================================================= |
1619 | //function : UnsetMaterial |
2195ab96 |
1620 | //purpose : |
7fd59977 |
1621 | //======================================================================= |
2195ab96 |
1622 | void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
1623 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1624 | { |
2195ab96 |
1625 | if (theIObj.IsNull()) |
1626 | { |
1627 | return; |
1628 | } |
1629 | theIObj->UnsetMaterial(); |
226fce20 |
1630 | theIObj->UpdatePresentations(); |
1631 | if (theToUpdateViewer) |
1632 | { |
1633 | UpdateCurrentViewer(); |
1634 | } |
7fd59977 |
1635 | } |
1636 | |
1637 | //======================================================================= |
1638 | //function : SetTransparency |
2195ab96 |
1639 | //purpose : |
7fd59977 |
1640 | //======================================================================= |
2195ab96 |
1641 | void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1642 | const Standard_Real theValue, |
1643 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1644 | { |
2195ab96 |
1645 | if (theIObj.IsNull()) |
1646 | { |
1647 | return; |
1648 | } |
1649 | |
2ec85268 |
1650 | setContextToObject (theIObj); |
2195ab96 |
1651 | if (!theIObj->IsTransparent() |
f838dac4 |
1652 | && theValue <= 0.005) |
a6964ce6 |
1653 | { |
1654 | return; |
1655 | } |
1656 | |
f838dac4 |
1657 | if (theValue <= 0.005) |
2195ab96 |
1658 | { |
1659 | UnsetTransparency (theIObj, theToUpdateViewer); |
7fd59977 |
1660 | return; |
1661 | } |
a6964ce6 |
1662 | |
2195ab96 |
1663 | theIObj->SetTransparency (theValue); |
226fce20 |
1664 | theIObj->UpdatePresentations(); |
1665 | if (theToUpdateViewer) |
1666 | { |
1667 | UpdateCurrentViewer(); |
1668 | } |
7fd59977 |
1669 | } |
1670 | |
1671 | //======================================================================= |
1672 | //function : UnsetTransparency |
2195ab96 |
1673 | //purpose : |
7fd59977 |
1674 | //======================================================================= |
2195ab96 |
1675 | void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1676 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1677 | { |
2195ab96 |
1678 | if (theIObj.IsNull()) |
1679 | { |
1680 | return; |
1681 | } |
7fd59977 |
1682 | |
2195ab96 |
1683 | theIObj->UnsetTransparency(); |
226fce20 |
1684 | theIObj->UpdatePresentations(); |
1685 | if (theToUpdateViewer) |
1686 | { |
1687 | UpdateCurrentViewer(); |
1688 | } |
7fd59977 |
1689 | } |
1690 | |
2195ab96 |
1691 | //======================================================================= |
1692 | //function : SetSelectedAspect |
1693 | //purpose : |
1694 | //======================================================================= |
1695 | void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect, |
2195ab96 |
1696 | const Standard_Boolean theToUpdateViewer) |
1697 | { |
2b886265 |
1698 | Standard_DISABLE_DEPRECATION_WARNINGS |
2195ab96 |
1699 | Standard_Boolean isFound = Standard_False; |
02974a19 |
1700 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
1701 | { |
1702 | isFound = Standard_True; |
02974a19 |
1703 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2831708b |
1704 | anObj->SetAspect (theAspect); |
2195ab96 |
1705 | } |
2b886265 |
1706 | Standard_ENABLE_DEPRECATION_WARNINGS |
2195ab96 |
1707 | |
016e5959 |
1708 | if (isFound && theToUpdateViewer) |
2195ab96 |
1709 | { |
1710 | myMainVwr->Update(); |
7fd59977 |
1711 | } |
1712 | } |
7fd59977 |
1713 | |
1714 | //======================================================================= |
1715 | //function : SetLocalAttributes |
2195ab96 |
1716 | //purpose : |
7fd59977 |
1717 | //======================================================================= |
2195ab96 |
1718 | void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
6262338c |
1719 | const Handle(Prs3d_Drawer)& theDrawer, |
2195ab96 |
1720 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1721 | { |
2195ab96 |
1722 | if (theIObj.IsNull()) |
1723 | { |
1724 | return; |
1725 | } |
1726 | |
2ec85268 |
1727 | setContextToObject (theIObj); |
2195ab96 |
1728 | theIObj->SetAttributes (theDrawer); |
1729 | Update (theIObj, theToUpdateViewer); |
7fd59977 |
1730 | } |
1731 | |
1732 | //======================================================================= |
1733 | //function : UnsetLocalAttributes |
2195ab96 |
1734 | //purpose : |
7fd59977 |
1735 | //======================================================================= |
2195ab96 |
1736 | void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
1737 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1738 | { |
2195ab96 |
1739 | if (theIObj.IsNull()) |
1740 | { |
1741 | return; |
1742 | } |
7fd59977 |
1743 | |
2ec85268 |
1744 | setContextToObject (theIObj); |
2195ab96 |
1745 | theIObj->UnsetAttributes(); |
1746 | Update (theIObj, theToUpdateViewer); |
1747 | } |
7fd59977 |
1748 | |
1749 | //======================================================================= |
1750 | //function : Status |
2195ab96 |
1751 | //purpose : |
7fd59977 |
1752 | //======================================================================= |
2195ab96 |
1753 | void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj, |
1754 | TCollection_ExtendedString& theStatus) const |
7fd59977 |
1755 | { |
2195ab96 |
1756 | theStatus = ""; |
1757 | if (theIObj.IsNull() |
1758 | || !myObjects.IsBound (theIObj)) |
1759 | { |
1760 | return; |
1761 | } |
7fd59977 |
1762 | |
2195ab96 |
1763 | theStatus += "\t ____________________________________________"; |
1764 | theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:"; |
1765 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
1766 | switch (aStatus->GraphicStatus()) |
1767 | { |
7fd59977 |
1768 | case AIS_DS_Displayed: |
2195ab96 |
1769 | { |
1770 | theStatus += "\t| -->Displayed\n"; |
7fd59977 |
1771 | break; |
1772 | } |
2195ab96 |
1773 | case AIS_DS_Erased: |
1774 | { |
1775 | theStatus += "\t| -->Erased\n"; |
1776 | break; |
7fd59977 |
1777 | } |
2195ab96 |
1778 | default: |
1779 | break; |
1780 | } |
1781 | |
1782 | theStatus += "\t| Active Display Modes in the MainViewer :\n"; |
3db69e41 |
1783 | theStatus += "\t|\t Mode "; |
1784 | theStatus += TCollection_AsciiString (aStatus->DisplayMode()); |
1785 | theStatus += "\n"; |
1786 | |
2195ab96 |
1787 | if (IsSelected(theIObj)) theStatus +="\t| Selected\n"; |
7fd59977 |
1788 | |
2195ab96 |
1789 | theStatus += "\t| Active Selection Modes in the MainViewer :\n"; |
1790 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
1791 | { |
1792 | theStatus += "\t\t Mode "; |
1793 | theStatus += TCollection_AsciiString (aSelModeIter.Value()); |
1794 | theStatus += "\n"; |
1795 | } |
1796 | theStatus += "\t ____________________________________________"; |
1797 | } |
7fd59977 |
1798 | |
1799 | //======================================================================= |
1800 | //function : GetDefModes |
2195ab96 |
1801 | //purpose : |
7fd59977 |
1802 | //======================================================================= |
2195ab96 |
1803 | void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj, |
1804 | Standard_Integer& theDispMode, |
1805 | Standard_Integer& theHiMode, |
1806 | Standard_Integer& theSelMode) const |
7fd59977 |
1807 | { |
2195ab96 |
1808 | if (theIObj.IsNull()) |
1809 | { |
1810 | return; |
1811 | } |
7fd59977 |
1812 | |
2195ab96 |
1813 | theDispMode = theIObj->HasDisplayMode() |
1814 | ? theIObj->DisplayMode() |
f838dac4 |
1815 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
1816 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
1817 | : 0); |
1818 | theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; |
c3282ec1 |
1819 | theSelMode = theIObj->GlobalSelectionMode(); |
2195ab96 |
1820 | } |
7fd59977 |
1821 | |
1822 | //======================================================================= |
1823 | //function : EraseGlobal |
2195ab96 |
1824 | //purpose : |
7fd59977 |
1825 | //======================================================================= |
2195ab96 |
1826 | void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1827 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
1828 | { |
a9080ef9 |
1829 | Handle(AIS_GlobalStatus) aStatus; |
2195ab96 |
1830 | if (theIObj.IsNull() |
a9080ef9 |
1831 | || !myObjects.Find (theIObj, aStatus) |
1832 | || aStatus->GraphicStatus() == AIS_DS_Erased) |
2195ab96 |
1833 | { |
1834 | return; |
1835 | } |
7fd59977 |
1836 | |
a1954302 |
1837 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
741c4f3e |
1838 | unselectOwners (theIObj); |
3db69e41 |
1839 | myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False); |
1840 | |
4f51d9d7 |
1841 | if (!myLastPicked.IsNull() |
8e5fb5ea |
1842 | && myLastPicked->IsSameSelectable (theIObj)) |
4f51d9d7 |
1843 | { |
731c9b5b |
1844 | clearDynamicHighlight(); |
4f51d9d7 |
1845 | } |
1846 | |
905b0e31 |
1847 | // make sure highlighting presentations are properly erased |
1848 | theIObj->ErasePresentations (false); |
1849 | |
c3282ec1 |
1850 | if (IsSelected (theIObj) |
3db69e41 |
1851 | && aStatus->DisplayMode() != aDispMode) |
a1954302 |
1852 | { |
1853 | myMainPM->SetVisibility (theIObj, aDispMode, Standard_False); |
1854 | } |
1855 | |
1856 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
1857 | { |
68dcee02 |
1858 | mgrSelector->Deactivate (theIObj, aSelModeIter.Value()); |
7fd59977 |
1859 | } |
c3282ec1 |
1860 | aStatus->ClearSelectionModes(); |
2195ab96 |
1861 | aStatus->SetGraphicStatus (AIS_DS_Erased); |
a1954302 |
1862 | |
1863 | if (theToUpdateviewer) |
1864 | { |
1865 | myMainVwr->Update(); |
1866 | } |
7fd59977 |
1867 | } |
1868 | |
c3282ec1 |
1869 | //======================================================================= |
741c4f3e |
1870 | //function : unselectOwners |
c3282ec1 |
1871 | //purpose : |
1872 | //======================================================================= |
741c4f3e |
1873 | void AIS_InteractiveContext::unselectOwners (const Handle(AIS_InteractiveObject)& theObject) |
c3282ec1 |
1874 | { |
02974a19 |
1875 | SelectMgr_SequenceOfOwner aSeq; |
1876 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
1877 | { |
a3d4053c |
1878 | if (aSelIter.Value()->IsSameSelectable (theObject)) |
c3282ec1 |
1879 | { |
02974a19 |
1880 | aSeq.Append (aSelIter.Value()); |
c3282ec1 |
1881 | } |
02974a19 |
1882 | } |
1883 | for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next()) |
1884 | { |
1885 | AddOrRemoveSelected (aDelIter.Value(), Standard_False); |
c3282ec1 |
1886 | } |
1887 | } |
1888 | |
7fd59977 |
1889 | //======================================================================= |
1890 | //function : ClearGlobal |
2195ab96 |
1891 | //purpose : |
7fd59977 |
1892 | //======================================================================= |
2195ab96 |
1893 | void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1894 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
1895 | { |
a9080ef9 |
1896 | Handle(AIS_GlobalStatus) aStatus; |
2195ab96 |
1897 | if (theIObj.IsNull() |
a9080ef9 |
1898 | || !myObjects.Find (theIObj, aStatus)) |
2195ab96 |
1899 | { |
f751596e |
1900 | // for cases when reference shape of connected interactives was not displayed |
1901 | // but its selection primitives were calculated |
543a9964 |
1902 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
1903 | mgrSelector->Remove (anObj); |
2195ab96 |
1904 | return; |
1905 | } |
1906 | |
741c4f3e |
1907 | unselectOwners (theIObj); |
7fd59977 |
1908 | |
e2d7642f |
1909 | myMainPM->Erase (theIObj, -1); |
905b0e31 |
1910 | theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased |
4f51d9d7 |
1911 | |
2195ab96 |
1912 | // Object removes from Detected sequence |
404c8936 |
1913 | Standard_DISABLE_DEPRECATION_WARNINGS |
f2a88e54 |
1914 | for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();) |
7fd59977 |
1915 | { |
f2a88e54 |
1916 | Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter)); |
1917 | Handle(AIS_InteractiveObject) anObj; |
1918 | if (!aPicked.IsNull()) |
1919 | { |
1920 | anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable()); |
1921 | } |
1922 | |
2195ab96 |
1923 | if (!anObj.IsNull() |
f2a88e54 |
1924 | && anObj == theIObj) |
2195ab96 |
1925 | { |
f0cddd16 |
1926 | myDetectedSeq.Remove (aDetIter); |
f2a88e54 |
1927 | if (myCurDetected == aDetIter) |
1928 | { |
1929 | myCurDetected = Min (myDetectedSeq.Upper(), aDetIter); |
1930 | } |
1931 | if (myCurHighlighted == aDetIter) |
1932 | { |
1933 | myCurHighlighted = 0; |
1934 | } |
1935 | } |
1936 | else |
1937 | { |
1938 | aDetIter++; |
2195ab96 |
1939 | } |
7fd59977 |
1940 | } |
404c8936 |
1941 | Standard_ENABLE_DEPRECATION_WARNINGS |
7fd59977 |
1942 | |
2195ab96 |
1943 | // remove IO from the selection manager to avoid memory leaks |
543a9964 |
1944 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
1945 | mgrSelector->Remove (anObj); |
7fd59977 |
1946 | |
13c556d9 |
1947 | setObjectStatus (theIObj, AIS_DS_None, -1, -1); |
c357e426 |
1948 | myMainVwr->StructureManager()->UnregisterObject (theIObj); |
6a24c6de |
1949 | |
1950 | for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next()) |
a272ed94 |
1951 | { |
6a24c6de |
1952 | aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get()); |
a272ed94 |
1953 | } |
7fd59977 |
1954 | |
a9080ef9 |
1955 | if (!myLastPicked.IsNull()) |
1beb58d7 |
1956 | { |
a9080ef9 |
1957 | if (myLastPicked->IsSameSelectable (theIObj)) |
1beb58d7 |
1958 | { |
731c9b5b |
1959 | clearDynamicHighlight(); |
f2a88e54 |
1960 | myLastPicked.Nullify(); |
1beb58d7 |
1961 | } |
1962 | } |
c3282ec1 |
1963 | |
1964 | if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
1965 | { |
1966 | myMainVwr->Update(); |
1967 | } |
7fd59977 |
1968 | } |
1969 | |
1970 | //======================================================================= |
1971 | //function : ClearGlobalPrs |
2195ab96 |
1972 | //purpose : |
7fd59977 |
1973 | //======================================================================= |
2195ab96 |
1974 | void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj, |
1975 | const Standard_Integer theMode, |
1976 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1977 | { |
2195ab96 |
1978 | if (theIObj.IsNull() |
1979 | || !myObjects.IsBound (theIObj)) |
1980 | { |
1981 | return; |
1982 | } |
1983 | |
1984 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
3db69e41 |
1985 | if (aStatus->DisplayMode() == theMode) |
2195ab96 |
1986 | { |
1987 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
1988 | if (aDispMode == theMode |
1989 | && myMainPM->IsHighlighted (theIObj, theMode)) |
1990 | { |
f838dac4 |
1991 | unhighlightGlobal (theIObj); |
2195ab96 |
1992 | } |
1993 | |
1994 | myMainPM->Erase (theIObj, theMode); |
7fd59977 |
1995 | } |
eb4320f2 |
1996 | |
2195ab96 |
1997 | if (aStatus->GraphicStatus() == AIS_DS_Displayed |
1998 | && theToUpdateViewer) |
1999 | { |
7fd59977 |
2000 | myMainVwr->Update(); |
2195ab96 |
2001 | } |
7fd59977 |
2002 | } |
2003 | |
8a590580 |
2004 | //======================================================================= |
2005 | //function : ClearDetected |
2006 | //purpose : |
2007 | //======================================================================= |
2008 | Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate) |
2009 | { |
2010 | myCurDetected = 0; |
2011 | myCurHighlighted = 0; |
2012 | myDetectedSeq.Clear(); |
8a590580 |
2013 | Standard_Boolean toUpdate = Standard_False; |
2014 | if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) |
2015 | { |
2016 | toUpdate = Standard_True; |
2017 | clearDynamicHighlight(); |
2018 | } |
8a590580 |
2019 | myLastPicked.Nullify(); |
2020 | myMainSel->ClearPicked(); |
2021 | if (toUpdate && theToRedrawImmediate) |
2022 | { |
2023 | myMainVwr->RedrawImmediate(); |
2024 | } |
2025 | return toUpdate; |
2026 | } |
2027 | |
7fd59977 |
2028 | //======================================================================= |
2029 | //function : DrawHiddenLine |
2195ab96 |
2030 | //purpose : |
7fd59977 |
2031 | //======================================================================= |
2195ab96 |
2032 | Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const |
2033 | { |
7fd59977 |
2034 | return myDefaultDrawer->DrawHiddenLine(); |
2035 | } |
2036 | |
2037 | //======================================================================= |
2038 | //function : EnableDrawHiddenLine |
2195ab96 |
2039 | //purpose : |
7fd59977 |
2040 | //======================================================================= |
2195ab96 |
2041 | void AIS_InteractiveContext::EnableDrawHiddenLine() const |
2042 | { |
7fd59977 |
2043 | myDefaultDrawer->EnableDrawHiddenLine(); |
2044 | } |
2045 | |
2046 | //======================================================================= |
2047 | //function : DisableDrawHiddenLine |
2195ab96 |
2048 | //purpose : |
7fd59977 |
2049 | //======================================================================= |
2195ab96 |
2050 | void AIS_InteractiveContext::DisableDrawHiddenLine() const |
2051 | { |
7fd59977 |
2052 | myDefaultDrawer->DisableDrawHiddenLine(); |
2053 | } |
2054 | |
2055 | //======================================================================= |
2056 | //function : HiddenLineAspect |
2195ab96 |
2057 | //purpose : |
7fd59977 |
2058 | //======================================================================= |
2195ab96 |
2059 | Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const |
2060 | { |
7fd59977 |
2061 | return myDefaultDrawer->HiddenLineAspect(); |
2062 | } |
2063 | |
2064 | //======================================================================= |
2065 | //function : SetHiddenLineAspect |
2195ab96 |
2066 | //purpose : |
7fd59977 |
2067 | //======================================================================= |
2195ab96 |
2068 | void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const |
2069 | { |
2070 | myDefaultDrawer->SetHiddenLineAspect (theAspect); |
7fd59977 |
2071 | } |
2072 | |
2073 | //======================================================================= |
2074 | //function : SetIsoNumber |
2195ab96 |
2075 | //purpose : |
7fd59977 |
2076 | //======================================================================= |
2195ab96 |
2077 | void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb, |
2078 | const AIS_TypeOfIso theType) |
7fd59977 |
2079 | { |
2195ab96 |
2080 | switch (theType) |
2081 | { |
2082 | case AIS_TOI_IsoU: |
2083 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
2084 | break; |
2085 | case AIS_TOI_IsoV: |
2086 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
2087 | break; |
2088 | case AIS_TOI_Both: |
2089 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
2090 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
2091 | break; |
7fd59977 |
2092 | } |
2093 | } |
2195ab96 |
2094 | |
7fd59977 |
2095 | //======================================================================= |
2096 | //function : IsoNumber |
2195ab96 |
2097 | //purpose : |
7fd59977 |
2098 | //======================================================================= |
2195ab96 |
2099 | Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType) |
7fd59977 |
2100 | { |
2195ab96 |
2101 | switch (theType) |
2102 | { |
2103 | case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number(); |
2104 | case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number(); |
2105 | case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number() |
2106 | ? myDefaultDrawer->UIsoAspect()->Number() |
2107 | : -1; |
7fd59977 |
2108 | } |
2109 | return 0; |
2110 | } |
2111 | |
2112 | //======================================================================= |
2113 | //function : IsoOnPlane |
2195ab96 |
2114 | //purpose : |
7fd59977 |
2115 | //======================================================================= |
2195ab96 |
2116 | void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn) |
7fd59977 |
2117 | { |
2195ab96 |
2118 | myDefaultDrawer->SetIsoOnPlane (theToSwitchOn); |
7fd59977 |
2119 | } |
2120 | |
2121 | //======================================================================= |
2122 | //function : IsoOnPlane |
2195ab96 |
2123 | //purpose : |
7fd59977 |
2124 | //======================================================================= |
2195ab96 |
2125 | Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const |
7fd59977 |
2126 | { |
2127 | return myDefaultDrawer->IsoOnPlane(); |
2128 | } |
2129 | |
3c982548 |
2130 | //======================================================================= |
5ad8c033 |
2131 | //function : IsoOnTriangulation |
2132 | //purpose : |
2133 | //======================================================================= |
2134 | void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theToSwitchOn) |
2135 | { |
2136 | myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn); |
2137 | } |
2138 | |
2139 | //======================================================================= |
2140 | //function : IsoOnTriangulation |
2141 | //purpose : |
2142 | //======================================================================= |
2143 | Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const |
2144 | { |
2145 | return myDefaultDrawer->IsoOnTriangulation(); |
2146 | } |
2147 | |
51004f1c |
2148 | //======================================================================= |
3c982548 |
2149 | //function : SetPixelTolerance |
51004f1c |
2150 | //purpose : |
3c982548 |
2151 | //======================================================================= |
3bf9a45f |
2152 | void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision) |
2195ab96 |
2153 | { |
68dcee02 |
2154 | myMainSel->SetPixelTolerance (thePrecision); |
7fd59977 |
2155 | } |
3c982548 |
2156 | |
2157 | //======================================================================= |
2158 | //function : PixelTolerance |
2195ab96 |
2159 | //purpose : |
3c982548 |
2160 | //======================================================================= |
3bf9a45f |
2161 | Standard_Integer AIS_InteractiveContext::PixelTolerance() const |
2195ab96 |
2162 | { |
68dcee02 |
2163 | return myMainSel->PixelTolerance(); |
3c982548 |
2164 | } |
7fd59977 |
2165 | |
8a1170ad |
2166 | //======================================================================= |
2167 | //function : SetSelectionSensitivity |
2168 | //purpose : Allows to manage sensitivity of a particular selection of interactive object theObject |
2169 | //======================================================================= |
2170 | void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject, |
2171 | const Standard_Integer theMode, |
2172 | const Standard_Integer theNewSensitivity) |
2173 | { |
8a1170ad |
2174 | mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity); |
2175 | } |
2176 | |
7fd59977 |
2177 | //======================================================================= |
2178 | //function : InitAttributes |
2195ab96 |
2179 | //purpose : |
7fd59977 |
2180 | //======================================================================= |
7fd59977 |
2181 | void AIS_InteractiveContext::InitAttributes() |
2182 | { |
2195ab96 |
2183 | Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); |
2184 | myDefaultDrawer->ShadingAspect()->SetMaterial (aMat); |
7fd59977 |
2185 | |
2186 | // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70); |
2195ab96 |
2187 | Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect(); |
2188 | aLineAspect->SetColor (Quantity_NOC_GRAY20); |
2189 | aLineAspect->SetWidth (1.0); |
2190 | aLineAspect->SetTypeOfLine (Aspect_TOL_DASH); |
7fd59977 |
2191 | |
28ee613b |
2192 | // tolerance to 2 pixels... |
3bf9a45f |
2193 | SetPixelTolerance (2); |
7fd59977 |
2194 | |
2195 | // Customizing the drawer for trihedrons and planes... |
2195ab96 |
2196 | Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect(); |
2197 | const Standard_Real aLength = 100.0; |
2198 | aTrihAspect->SetAxisLength (aLength, aLength, aLength); |
87432b82 |
2199 | const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4; |
bc001a40 |
2200 | aTrihAspect->LineAspect(Prs3d_DP_XAxis)->SetColor (aColor); |
2201 | aTrihAspect->LineAspect(Prs3d_DP_YAxis)->SetColor (aColor); |
2202 | aTrihAspect->LineAspect(Prs3d_DP_ZAxis)->SetColor (aColor); |
7fd59977 |
2203 | |
2195ab96 |
2204 | Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect(); |
2205 | const Standard_Real aPlaneLength = 200.0; |
2206 | aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength); |
2207 | aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE); |
7fd59977 |
2208 | } |
2209 | |
7fd59977 |
2210 | //======================================================================= |
2211 | //function : TrihedronSize |
2195ab96 |
2212 | //purpose : |
7fd59977 |
2213 | //======================================================================= |
2214 | Standard_Real AIS_InteractiveContext::TrihedronSize() const |
2215 | { |
bc001a40 |
2216 | return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis); |
7fd59977 |
2217 | } |
2195ab96 |
2218 | |
7fd59977 |
2219 | //======================================================================= |
2220 | //function : SetTrihedronSize |
2195ab96 |
2221 | //purpose : |
7fd59977 |
2222 | //======================================================================= |
2195ab96 |
2223 | void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal, |
2224 | const Standard_Boolean /*updateviewer*/) |
7fd59977 |
2225 | { |
2195ab96 |
2226 | myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal); |
2227 | Redisplay (AIS_KOI_Datum, 3, Standard_False); |
2228 | Redisplay (AIS_KOI_Datum, 4, Standard_True); |
7fd59977 |
2229 | } |
2230 | |
7fd59977 |
2231 | //======================================================================= |
2232 | //function : SetPlaneSize |
2195ab96 |
2233 | //purpose : |
7fd59977 |
2234 | //======================================================================= |
2195ab96 |
2235 | void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX, |
2236 | const Standard_Real theValY, |
0577ae8c |
2237 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2238 | { |
2195ab96 |
2239 | myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY); |
0577ae8c |
2240 | Redisplay (AIS_KOI_Datum, 7, theToUpdateViewer); |
7fd59977 |
2241 | } |
2242 | |
2243 | //======================================================================= |
2244 | //function : SetPlaneSize |
2195ab96 |
2245 | //purpose : |
7fd59977 |
2246 | //======================================================================= |
2195ab96 |
2247 | void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal, |
2248 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2249 | { |
2195ab96 |
2250 | SetPlaneSize (theVal, theVal, theToUpdateViewer); |
7fd59977 |
2251 | } |
2252 | |
2253 | //======================================================================= |
2254 | //function : PlaneSize |
2195ab96 |
2255 | //purpose : |
7fd59977 |
2256 | //======================================================================= |
2195ab96 |
2257 | Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX, |
2258 | Standard_Real& theY) const |
7fd59977 |
2259 | { |
2195ab96 |
2260 | theX = myDefaultDrawer->PlaneAspect()->PlaneXLength(); |
2261 | theY = myDefaultDrawer->PlaneAspect()->PlaneYLength(); |
2262 | return (Abs (theX - theY) <= Precision::Confusion()); |
7fd59977 |
2263 | } |
2264 | |
59f45b7c |
2265 | //======================================================================= |
2266 | //function : SetZLayer |
2195ab96 |
2267 | //purpose : |
59f45b7c |
2268 | //======================================================================= |
59f45b7c |
2269 | void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
8f138407 |
2270 | const Graphic3d_ZLayerId theLayerId) |
59f45b7c |
2271 | { |
2195ab96 |
2272 | if (theIObj.IsNull()) |
59f45b7c |
2273 | return; |
2274 | |
a1954302 |
2275 | theIObj->SetZLayer (theLayerId); |
59f45b7c |
2276 | } |
2277 | |
2278 | //======================================================================= |
2279 | //function : GetZLayer |
2195ab96 |
2280 | //purpose : |
59f45b7c |
2281 | //======================================================================= |
8f138407 |
2282 | Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
59f45b7c |
2283 | { |
a1954302 |
2284 | return !theIObj.IsNull() |
2285 | ? theIObj->ZLayer() |
2286 | : Graphic3d_ZLayerId_UNKNOWN; |
59f45b7c |
2287 | } |
f751596e |
2288 | |
2289 | //======================================================================= |
2290 | //function : RebuildSelectionStructs |
2291 | //purpose : Rebuilds 1st level of BVH selection forcibly |
2292 | //======================================================================= |
2293 | void AIS_InteractiveContext::RebuildSelectionStructs() |
2294 | { |
2295 | myMainSel->RebuildObjectsTree (Standard_True); |
2296 | } |
2297 | |
2298 | //======================================================================= |
2299 | //function : Disconnect |
2300 | //purpose : Disconnects selectable object from an assembly and updates selection structures |
2301 | //======================================================================= |
2302 | void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, |
2303 | const Handle(AIS_InteractiveObject)& theObjToDisconnect) |
2304 | { |
2305 | if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive")) |
2306 | { |
c5f3a425 |
2307 | Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2308 | theObj->Disconnect (theObjToDisconnect); |
7dd7c146 |
2309 | if (!myObjects.IsBound (theObjToDisconnect)) |
2310 | { |
2311 | // connected presentation might contain displayed presentations |
2312 | myMainPM->Erase (theObjToDisconnect, -1); |
2313 | theObjToDisconnect->ErasePresentations (true); |
2314 | } |
2315 | |
543a9964 |
2316 | const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity |
2317 | mgrSelector->Remove (anObj); |
f751596e |
2318 | } |
c04c30b3 |
2319 | else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull()) |
f751596e |
2320 | { |
c5f3a425 |
2321 | Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2322 | theObj->Disconnect(); |
543a9964 |
2323 | const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity |
2324 | mgrSelector->Remove (anObj); |
f751596e |
2325 | } |
2326 | else |
2327 | return; |
2328 | } |
b586500b |
2329 | |
0577ae8c |
2330 | //======================================================================= |
2331 | //function : FitSelected |
2332 | //purpose : Fits the view corresponding to the bounds of selected objects |
2333 | //======================================================================= |
2334 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView) |
2335 | { |
2336 | FitSelected (theView, 0.01, Standard_True); |
2337 | } |
2338 | |
b586500b |
2339 | //======================================================================= |
2108d9a2 |
2340 | //function : BoundingBoxOfSelection |
2341 | //purpose : |
b586500b |
2342 | //======================================================================= |
2108d9a2 |
2343 | Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const |
b586500b |
2344 | { |
b586500b |
2345 | Bnd_Box aBndSelected; |
b586500b |
2346 | AIS_MapOfObjectOwners anObjectOwnerMap; |
68dcee02 |
2347 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
b586500b |
2348 | { |
b5cce1ab |
2349 | const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value(); |
02974a19 |
2350 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); |
2351 | if (anObj->IsInfinite()) |
b586500b |
2352 | { |
02974a19 |
2353 | continue; |
2354 | } |
b586500b |
2355 | |
02974a19 |
2356 | if (anOwner == anObj->GlobalSelOwner()) |
2357 | { |
b586500b |
2358 | Bnd_Box aTmpBnd; |
2359 | anObj->BoundingBox (aTmpBnd); |
2360 | aBndSelected.Add (aTmpBnd); |
2361 | } |
2362 | else |
2363 | { |
b586500b |
2364 | Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap; |
2365 | if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap)) |
2366 | { |
2367 | anOwnerMap = new SelectMgr_IndexedMapOfOwner(); |
2368 | anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap); |
2369 | } |
2370 | |
2371 | anOwnerMap->Add (anOwner); |
2372 | } |
2373 | } |
2374 | |
2375 | for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next()) |
2376 | { |
2377 | const Handle(SelectMgr_SelectableObject) anObject = anIter.Key(); |
2378 | Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue()); |
2379 | aBndSelected.Add (aTmpBox); |
2380 | } |
2381 | |
2108d9a2 |
2382 | return aBndSelected; |
2383 | } |
b586500b |
2384 | |
2108d9a2 |
2385 | //======================================================================= |
2386 | //function : FitSelected |
2387 | //purpose : Fits the view corresponding to the bounds of selected objects |
2388 | //======================================================================= |
2389 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView, |
2390 | const Standard_Real theMargin, |
2391 | const Standard_Boolean theToUpdate) |
2392 | { |
2393 | Bnd_Box aBndSelected = BoundingBoxOfSelection(); |
2394 | if (!aBndSelected.IsVoid()) |
2395 | { |
2396 | theView->FitAll (aBndSelected, theMargin, theToUpdate); |
2397 | } |
b586500b |
2398 | } |
1d92133e |
2399 | |
2400 | //======================================================================= |
2401 | //function : SetTransformPersistence |
2402 | //purpose : |
2403 | //======================================================================= |
2404 | void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject, |
778cd667 |
2405 | const Handle(Graphic3d_TransformPers)& theTrsfPers) |
1d92133e |
2406 | { |
778cd667 |
2407 | theObject->SetTransformPersistence (theTrsfPers); |
1d92133e |
2408 | if (!myObjects.IsBound (theObject)) |
2409 | { |
2410 | return; |
2411 | } |
2412 | |
2413 | mgrSelector->UpdateSelection (theObject); |
2414 | |
2415 | const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex(); |
2416 | const Handle(V3d_Viewer)& aCurViewer = CurrentViewer(); |
6a24c6de |
2417 | for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next()) |
1d92133e |
2418 | { |
6a24c6de |
2419 | anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId); |
2420 | anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId); |
1d92133e |
2421 | } |
2422 | } |
49582f9d |
2423 | |
2424 | //======================================================================= |
2425 | //function : GravityPoint |
2426 | //purpose : |
2427 | //======================================================================= |
2428 | gp_Pnt AIS_InteractiveContext::GravityPoint (const Handle(V3d_View)& theView) const |
2429 | { |
2430 | return theView->GravityPoint(); |
2431 | } |
13c556d9 |
2432 | //======================================================================= |
2433 | //function : setObjectStatus |
2434 | //purpose : |
2435 | //======================================================================= |
2436 | void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj, |
2437 | const AIS_DisplayStatus theStatus, |
2438 | const Standard_Integer theDispMode, |
2439 | const Standard_Integer theSelectionMode) |
2440 | { |
2441 | if (theStatus != AIS_DS_None) |
2442 | { |
2443 | Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode); |
2444 | myObjects.Bind (theIObj, aStatus); |
2445 | } |
2446 | else |
2447 | myObjects.UnBind (theIObj); |
2448 | |
2449 | for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (theIObj->Children()); aPrsIter.More(); aPrsIter.Next()) |
2450 | { |
2451 | Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value())); |
2452 | if (aChild.IsNull()) |
2453 | continue; |
2454 | |
2455 | setObjectStatus (aChild, theStatus, theDispMode, theSelectionMode); |
2456 | } |
2457 | } |