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