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