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