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