| 1 | // Created on: 1997-01-17 |
| 2 | // Created by: Robert COUBLANC |
| 3 | // Copyright (c) 1997-1999 Matra Datavision |
| 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 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 |
| 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. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | //Modified by ROB : Traque des UpdateConversion intempestifs. |
| 18 | |
| 19 | #include <AIS_LocalContext.ixx> |
| 20 | #include <SelectMgr_OrFilter.hxx> |
| 21 | #include <SelectMgr_CompositionFilter.hxx> |
| 22 | #include <AIS_LocalStatus.hxx> |
| 23 | #include <AIS_Shape.hxx> |
| 24 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
| 25 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
| 26 | #include <AIS_ListOfInteractive.hxx> |
| 27 | #include <AIS_DataMapIteratorOfDataMapOfSelStat.hxx> |
| 28 | #include <TopAbs_ShapeEnum.hxx> |
| 29 | #include <Graphic3d_Structure.hxx> |
| 30 | #include <Prs3d_LineAspect.hxx> |
| 31 | #include <Prs3d_PlaneAspect.hxx> |
| 32 | #include <Prs3d_PointAspect.hxx> |
| 33 | #include <Prs3d_Presentation.hxx> |
| 34 | #include <Aspect_TypeOfMarker.hxx> |
| 35 | #include <StdSelect_ShapeTypeFilter.hxx> |
| 36 | #include <StdSelect_ViewerSelector3d.hxx> |
| 37 | #include <AIS_Selection.hxx> |
| 38 | #include <V3d_Viewer.hxx> |
| 39 | #include <V3d_View.hxx> |
| 40 | #include <Visual3d_View.hxx> |
| 41 | |
| 42 | #include <stdio.h> |
| 43 | |
| 44 | static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, |
| 45 | const Standard_Integer anIndex) |
| 46 | { |
| 47 | // TCollection_AsciiString SelName; |
| 48 | char string[100]; |
| 49 | sprintf(string,"%p_%d", address, anIndex); // works under any system |
| 50 | TCollection_AsciiString SelName(string); |
| 51 | return SelName; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | //======================================================================= |
| 56 | //function : AIS_LocalContext |
| 57 | //purpose : |
| 58 | //======================================================================= |
| 59 | |
| 60 | |
| 61 | AIS_LocalContext::AIS_LocalContext(){} |
| 62 | |
| 63 | AIS_LocalContext::AIS_LocalContext(const Handle(AIS_InteractiveContext)& aCtx, |
| 64 | const Standard_Integer Index, |
| 65 | const Standard_Boolean LoadDisplayed, |
| 66 | const Standard_Boolean AcceptStandardModes, |
| 67 | const Standard_Boolean AcceptEraseOfTemp, |
| 68 | const Standard_Boolean /*BothViewers*/): |
| 69 | myCTX(aCtx), |
| 70 | myLoadDisplayed(LoadDisplayed), |
| 71 | myAcceptStdMode(AcceptStandardModes), |
| 72 | myAcceptErase(AcceptEraseOfTemp), |
| 73 | mySM(aCtx->SelectionManager()), |
| 74 | myMainVS(aCtx->MainSelector()), |
| 75 | myFilters(new SelectMgr_OrFilter()), |
| 76 | myAutoHilight(Standard_True), |
| 77 | mylastindex(0), |
| 78 | mylastgood(0), |
| 79 | myCurDetected(0), |
| 80 | myAISCurDetected(0) |
| 81 | |
| 82 | { |
| 83 | // bind self to AIS_InteractiveContext::myLocalContexts. Further, the |
| 84 | // constructor executes logic that implies that the context is already |
| 85 | // created and mapped. |
| 86 | aCtx->myLocalContexts.Bind (Index, this); |
| 87 | |
| 88 | myMainVS->ResetSelectionActivationStatus(); |
| 89 | myMainPM = aCtx->MainPrsMgr(); |
| 90 | mySelName = AIS_Local_SelName(this, Index); |
| 91 | AIS_Selection::CreateSelection(mySelName.ToCString()); |
| 92 | |
| 93 | mySM->Add(myMainVS); |
| 94 | if(myLoadDisplayed) LoadContextObjects(); |
| 95 | Process(); |
| 96 | |
| 97 | } |
| 98 | |
| 99 | |
| 100 | //======================================================================= |
| 101 | //function : SetContext |
| 102 | //purpose : |
| 103 | //======================================================================= |
| 104 | |
| 105 | void AIS_LocalContext::SetContext(const Handle(AIS_InteractiveContext)& aCtx) |
| 106 | { myCTX = aCtx;} |
| 107 | |
| 108 | //======================================================================= |
| 109 | //function : Display |
| 110 | //purpose : |
| 111 | //======================================================================= |
| 112 | |
| 113 | Standard_Boolean AIS_LocalContext::Display(const Handle(AIS_InteractiveObject)& anInteractive, |
| 114 | const Standard_Integer WhichMode, |
| 115 | const Standard_Boolean AllowShapeDecomposition, |
| 116 | const Standard_Integer ActivationMode) |
| 117 | { |
| 118 | if(myActiveObjects.IsBound(anInteractive)){ |
| 119 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
| 120 | |
| 121 | if(STAT->DisplayMode() == -1){ |
| 122 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
| 123 | myMainPM->Display(anInteractive,WhichMode); |
| 124 | if(STAT->IsTemporary()) |
| 125 | STAT->SetDisplayMode(WhichMode); |
| 126 | } |
| 127 | else if(STAT->DisplayMode()!=WhichMode && STAT->IsTemporary()){ |
| 128 | myMainPM->Erase(anInteractive,STAT->DisplayMode()); |
| 129 | STAT->SetDisplayMode(WhichMode); |
| 130 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
| 131 | myMainPM->Display(anInteractive,WhichMode); |
| 132 | } |
| 133 | |
| 134 | if(ActivationMode!=-1){ |
| 135 | if(!STAT->IsActivated(ActivationMode)){ |
| 136 | STAT->ClearSelectionModes(); |
| 137 | mySM->Load(anInteractive,myMainVS); |
| 138 | STAT->AddSelectionMode(ActivationMode); |
| 139 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | else { |
| 144 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
| 145 | |
| 146 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
| 147 | Att->SetDecomposition(Standard_True); |
| 148 | else |
| 149 | Att->SetDecomposition(Standard_False); |
| 150 | // status temporary or not |
| 151 | if(myCTX->DisplayStatus(anInteractive) == AIS_DS_None || |
| 152 | myCTX->DisplayStatus(anInteractive) == AIS_DS_Temporary) |
| 153 | Att->SetTemporary(Standard_True); |
| 154 | else |
| 155 | Att->SetTemporary(Standard_False); |
| 156 | |
| 157 | |
| 158 | |
| 159 | if(!myCTX->IsDisplayed(anInteractive,WhichMode)){ |
| 160 | |
| 161 | //storing information.... |
| 162 | Att->SetDisplayMode(WhichMode); |
| 163 | if (ActivationMode!=-1) |
| 164 | Att->AddSelectionMode(ActivationMode); |
| 165 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
| 166 | Att->SetHilightMode(HiMod); |
| 167 | |
| 168 | if(!myMainPM->IsDisplayed(anInteractive,WhichMode)) |
| 169 | myMainPM->Display(anInteractive,WhichMode); |
| 170 | |
| 171 | if(ActivationMode!=-1){ |
| 172 | mySM->Load(anInteractive,myMainVS); |
| 173 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
| 174 | } |
| 175 | } |
| 176 | else{ |
| 177 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode(): WhichMode; |
| 178 | Att->SetHilightMode(HiMod); |
| 179 | } |
| 180 | myActiveObjects.Bind(anInteractive,Att); |
| 181 | } |
| 182 | Process(anInteractive); |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | return Standard_True; |
| 188 | } |
| 189 | |
| 190 | //======================================================================= |
| 191 | //function : Load |
| 192 | //purpose : |
| 193 | //======================================================================= |
| 194 | |
| 195 | Standard_Boolean AIS_LocalContext:: |
| 196 | Load(const Handle(AIS_InteractiveObject)& anInteractive, |
| 197 | const Standard_Boolean AllowShapeDecomposition, |
| 198 | const Standard_Integer ActivationMode) |
| 199 | { |
| 200 | if (myActiveObjects.IsBound (anInteractive)) |
| 201 | { |
| 202 | if (anInteractive->HasSelection (ActivationMode)) |
| 203 | { |
| 204 | const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode); |
| 205 | if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) |
| 206 | { |
| 207 | if (!myMainVS->Contains (anInteractive)) |
| 208 | { |
| 209 | mySM->Load (anInteractive, myMainVS); |
| 210 | } |
| 211 | mySM->Activate (anInteractive, ActivationMode, myMainVS); |
| 212 | return Standard_True; |
| 213 | } |
| 214 | } |
| 215 | return Standard_False; |
| 216 | } |
| 217 | |
| 218 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); |
| 219 | |
| 220 | if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition) |
| 221 | Att->SetDecomposition(Standard_True); |
| 222 | else |
| 223 | Att->SetDecomposition(Standard_False); |
| 224 | |
| 225 | if(!myCTX->IsDisplayed(anInteractive)) |
| 226 | Att->SetTemporary(Standard_True); |
| 227 | else |
| 228 | Att->SetTemporary(Standard_False); |
| 229 | Att->SetDisplayMode(-1); |
| 230 | |
| 231 | //storing information.... |
| 232 | if(ActivationMode!=-1) |
| 233 | Att->AddSelectionMode(ActivationMode); |
| 234 | Standard_Integer HiMod = anInteractive->HasHilightMode()? anInteractive->HilightMode():0; |
| 235 | Att->SetHilightMode(HiMod); |
| 236 | //Action |
| 237 | |
| 238 | mySM->Load(anInteractive,myMainVS); |
| 239 | if(ActivationMode != -1){ |
| 240 | mySM->Activate(anInteractive,ActivationMode,myMainVS); |
| 241 | } |
| 242 | myActiveObjects.Bind(anInteractive,Att); |
| 243 | Process(anInteractive); |
| 244 | return Standard_True; |
| 245 | } |
| 246 | |
| 247 | //======================================================================= |
| 248 | //function : ClearPrs |
| 249 | //purpose : |
| 250 | //======================================================================= |
| 251 | |
| 252 | Standard_Boolean AIS_LocalContext:: |
| 253 | ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, |
| 254 | const Standard_Integer aMode) |
| 255 | { |
| 256 | if(!myActiveObjects.IsBound(anInteractive)) |
| 257 | return Standard_False; |
| 258 | |
| 259 | Standard_Boolean jobdone(Standard_False); |
| 260 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
| 261 | |
| 262 | //Display step |
| 263 | if(STAT->IsSubIntensityOn()) { |
| 264 | STAT->SubIntensityOff(); |
| 265 | if(STAT->HilightMode()==aMode) |
| 266 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
| 267 | } |
| 268 | myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 |
| 269 | jobdone = Standard_True; |
| 270 | if(STAT->DisplayMode()==aMode) |
| 271 | STAT->SetDisplayMode(-1); |
| 272 | return jobdone; |
| 273 | } |
| 274 | //======================================================================= |
| 275 | //function : Erase |
| 276 | //purpose : |
| 277 | //======================================================================= |
| 278 | |
| 279 | Standard_Boolean AIS_LocalContext:: |
| 280 | Erase(const Handle(AIS_InteractiveObject)& anInteractive) |
| 281 | { |
| 282 | if(!myActiveObjects.IsBound(anInteractive)) |
| 283 | return Standard_False; |
| 284 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anInteractive); |
| 285 | |
| 286 | //Display step |
| 287 | if(STAT->IsSubIntensityOn()) { |
| 288 | STAT->SubIntensityOff(); |
| 289 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
| 290 | } |
| 291 | |
| 292 | Standard_Boolean status(Standard_False); |
| 293 | |
| 294 | if(STAT->DisplayMode()!=-1) { |
| 295 | if(IsSelected(anInteractive)) |
| 296 | AddOrRemoveSelected(anInteractive); |
| 297 | if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) |
| 298 | myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); |
| 299 | myMainPM->SetVisibility (anInteractive, STAT->DisplayMode(), Standard_False); |
| 300 | STAT->SetDisplayMode(-1); |
| 301 | status = Standard_True; |
| 302 | } |
| 303 | if(STAT->IsTemporary()){ |
| 304 | if(myMainPM->IsDisplayed(anInteractive,STAT->HilightMode())) |
| 305 | myMainPM->SetVisibility (anInteractive, STAT->HilightMode(), Standard_False); |
| 306 | } |
| 307 | |
| 308 | // Deactivate selectable entities of interactive object |
| 309 | if (mySM->Contains (anInteractive)) |
| 310 | { |
| 311 | TColStd_ListIteratorOfListOfInteger aModeIter (STAT->SelectionModes()); |
| 312 | for (; aModeIter.More(); aModeIter.Next()) |
| 313 | { |
| 314 | mySM->Deactivate (anInteractive, aModeIter.Value(), myMainVS); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | ClearOutdatedSelection (anInteractive, Standard_True); |
| 319 | |
| 320 | return status; |
| 321 | } |
| 322 | |
| 323 | |
| 324 | //======================================================================= |
| 325 | //function : SetShapeDecomposition |
| 326 | //purpose : |
| 327 | //======================================================================= |
| 328 | |
| 329 | void AIS_LocalContext::SetShapeDecomposition(const Handle(AIS_InteractiveObject)& aStoredObject, |
| 330 | const Standard_Boolean aStatus) |
| 331 | { |
| 332 | if(!myActiveObjects.IsBound(aStoredObject)) return; |
| 333 | |
| 334 | if(aStatus == myActiveObjects(aStoredObject)->Decomposed()) |
| 335 | return; |
| 336 | |
| 337 | myActiveObjects(aStoredObject)->SetDecomposition(aStatus); |
| 338 | |
| 339 | Process(aStoredObject); |
| 340 | } |
| 341 | |
| 342 | //======================================================================= |
| 343 | //function : Clear |
| 344 | //purpose : |
| 345 | //======================================================================= |
| 346 | |
| 347 | void AIS_LocalContext::Clear(const AIS_ClearMode aType) |
| 348 | { |
| 349 | switch (aType){ |
| 350 | case AIS_CM_All: |
| 351 | { |
| 352 | ClearObjects(); |
| 353 | myFilters->Clear(); |
| 354 | while(!myListOfStandardMode.IsEmpty()) |
| 355 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
| 356 | break; |
| 357 | } |
| 358 | case AIS_CM_Interactive: |
| 359 | ClearObjects(); |
| 360 | break; |
| 361 | case AIS_CM_Filters: |
| 362 | myFilters->Clear(); |
| 363 | break; |
| 364 | case AIS_CM_StandardModes: |
| 365 | { |
| 366 | while(!myListOfStandardMode.IsEmpty()) |
| 367 | DeactivateStandardMode(AIS_Shape::SelectionType(myListOfStandardMode.Last())); |
| 368 | break; |
| 369 | } |
| 370 | case AIS_CM_TemporaryShapePrs: |
| 371 | ClearDetected(); |
| 372 | } |
| 373 | } |
| 374 | //======================================================================= |
| 375 | //function : ActivateMode |
| 376 | //purpose : |
| 377 | //======================================================================= |
| 378 | |
| 379 | void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
| 380 | const Standard_Integer aMode) |
| 381 | { |
| 382 | if(!myActiveObjects.IsBound(aSelectable)) return; |
| 383 | // if(myActiveObjects(aSelectable)->SelectionMode()!=aMode) |
| 384 | // mySM->Deactivate(aSelectable,aMode,myMainVS); |
| 385 | if(aMode != -1){ |
| 386 | myActiveObjects(aSelectable)->AddSelectionMode(aMode); |
| 387 | mySM->Activate(aSelectable,aMode,myMainVS); |
| 388 | } |
| 389 | } |
| 390 | //======================================================================= |
| 391 | //function : ActivateMode |
| 392 | //purpose : |
| 393 | //======================================================================= |
| 394 | |
| 395 | void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSelectable, |
| 396 | const Standard_Integer aMode) |
| 397 | { |
| 398 | if(!myActiveObjects.IsBound(aSelectable)) return; |
| 399 | |
| 400 | if(aMode==-1) return; |
| 401 | |
| 402 | myActiveObjects(aSelectable)->RemoveSelectionMode(aMode); |
| 403 | mySM->Deactivate(aSelectable,aMode,myMainVS); |
| 404 | } |
| 405 | //======================================================================= |
| 406 | //function : ActivateMode |
| 407 | //purpose : |
| 408 | //======================================================================= |
| 409 | |
| 410 | void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectable) |
| 411 | { |
| 412 | if(!myActiveObjects.IsBound(aSelectable)) return; |
| 413 | |
| 414 | mySM->Deactivate(aSelectable, -1, myMainVS); |
| 415 | myActiveObjects(aSelectable)->ClearSelectionModes(); |
| 416 | } |
| 417 | |
| 418 | //======================================================================= |
| 419 | //function : Remove |
| 420 | //purpose : |
| 421 | //======================================================================= |
| 422 | |
| 423 | Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable) |
| 424 | { |
| 425 | if(!myActiveObjects.IsBound (aSelectable)) |
| 426 | { |
| 427 | return Standard_False; |
| 428 | } |
| 429 | |
| 430 | if (IsSelected (aSelectable)) |
| 431 | { |
| 432 | AddOrRemoveSelected (aSelectable, Standard_False); |
| 433 | } |
| 434 | |
| 435 | const Handle(AIS_LocalStatus)& Att = myActiveObjects (aSelectable); |
| 436 | |
| 437 | TColStd_ListIteratorOfListOfInteger It; |
| 438 | |
| 439 | // Deactivate standard modes |
| 440 | if (Att->Decomposed()) |
| 441 | { |
| 442 | for (It.Initialize (myListOfStandardMode); It.More(); It.Next()) |
| 443 | { |
| 444 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | // If object or temporary presentations |
| 449 | if (Att->IsTemporary()) |
| 450 | { |
| 451 | if (Att->IsSubIntensityOn()) |
| 452 | { |
| 453 | myMainPM->Unhighlight (aSelectable, Att->HilightMode()); |
| 454 | } |
| 455 | |
| 456 | myMainPM->Erase (aSelectable, Att->DisplayMode()); |
| 457 | myMainPM->Clear (aSelectable, Att->DisplayMode()); |
| 458 | if (myMainPM->IsDisplayed (aSelectable, Att->HilightMode())) |
| 459 | { |
| 460 | myMainPM->Erase (aSelectable, Att->HilightMode()); |
| 461 | } |
| 462 | } |
| 463 | // If subintensity used |
| 464 | else if (Att->IsSubIntensityOn()) |
| 465 | { |
| 466 | myCTX->SubIntensityOff (aSelectable); |
| 467 | } |
| 468 | |
| 469 | // Deactivate stored selection modes |
| 470 | for (It.Initialize (Att->SelectionModes()); It.More(); It.Next()) |
| 471 | { |
| 472 | mySM->Deactivate (aSelectable, It.Value(), myMainVS); |
| 473 | } |
| 474 | |
| 475 | // Remove the interactive object from selection manager |
| 476 | if (mySM->Contains (aSelectable)) |
| 477 | { |
| 478 | mySM->Remove (aSelectable); |
| 479 | } |
| 480 | ClearOutdatedSelection (aSelectable, Standard_True); |
| 481 | |
| 482 | // This should be done at the very end because most methods use |
| 483 | // myActiveObjects even during clean-up |
| 484 | myActiveObjects.UnBind (aSelectable); |
| 485 | return Standard_True; |
| 486 | } |
| 487 | |
| 488 | //======================================================================= |
| 489 | //function : ActivateStandardMode |
| 490 | //purpose : |
| 491 | //======================================================================= |
| 492 | |
| 493 | void AIS_LocalContext::ActivateStandardMode(const TopAbs_ShapeEnum aType) |
| 494 | { |
| 495 | |
| 496 | //check if it is not in the list |
| 497 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
| 498 | for(;It.More();It.Next()) |
| 499 | if(It.Value()==aType) return; |
| 500 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
| 501 | |
| 502 | |
| 503 | // create a hidden filter answering ok to the type except for : |
| 504 | // if the type is shape... |
| 505 | // if the filters already impact at the type <aType> |
| 506 | if(aType != TopAbs_SHAPE){ |
| 507 | if(myStdFilters[IMode].IsNull()) |
| 508 | myStdFilters[IMode] = new StdSelect_ShapeTypeFilter(aType); |
| 509 | if(!HasFilters(aType)) |
| 510 | myFilters->Add(myStdFilters[IMode]); |
| 511 | } |
| 512 | |
| 513 | // the mode is activated for all objects of type Shape |
| 514 | // accepting the decomposition in standard mode. |
| 515 | myListOfStandardMode.Append(IMode); |
| 516 | |
| 517 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
| 518 | |
| 519 | for(;ItM.More();ItM.Next()){ |
| 520 | if(ItM.Value()->Decomposed()) |
| 521 | myCTX->SelectionManager()->Activate(ItM.Key(), |
| 522 | IMode, |
| 523 | myMainVS); |
| 524 | } |
| 525 | |
| 526 | } |
| 527 | |
| 528 | //======================================================================= |
| 529 | //function : DeActivateStandardMode |
| 530 | //purpose : |
| 531 | //======================================================================= |
| 532 | |
| 533 | void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType) |
| 534 | { |
| 535 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
| 536 | Standard_Integer IMode = AIS_Shape::SelectionMode(aType); |
| 537 | for(;It.More();It.Next()) |
| 538 | if(It.Value()==IMode) { |
| 539 | AIS_DataMapIteratorOfDataMapOfSelStat ItM(myActiveObjects); |
| 540 | |
| 541 | for(;ItM.More();ItM.Next()){ |
| 542 | if(ItM.Value()->Decomposed()){ |
| 543 | myCTX->SelectionManager()->Deactivate(ItM.Key(), |
| 544 | IMode, |
| 545 | myMainVS); |
| 546 | ItM.Value()->RemoveSelectionMode(IMode); |
| 547 | } |
| 548 | } |
| 549 | myListOfStandardMode.Remove(It); |
| 550 | if(myFilters->IsIn(myStdFilters[IMode])) |
| 551 | myFilters->Remove(myStdFilters[IMode]); |
| 552 | return; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | //======================================================================= |
| 557 | //function : AddFilter |
| 558 | //purpose : |
| 559 | //======================================================================= |
| 560 | |
| 561 | void AIS_LocalContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter) |
| 562 | { |
| 563 | // it is checked if the filter impacts at the type of active sub-shape |
| 564 | // for which a filter of type has been already implemented... |
| 565 | |
| 566 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
| 567 | |
| 568 | for(;It.More();It.Next()){ |
| 569 | if(aFilter->ActsOn(AIS_Shape::SelectionType(It.Value()))) |
| 570 | if(myFilters->IsIn(myStdFilters[It.Value()])) |
| 571 | myFilters->Remove(myStdFilters[It.Value()]); |
| 572 | } |
| 573 | myFilters->Add(aFilter); |
| 574 | } |
| 575 | |
| 576 | //======================================================================= |
| 577 | //function : RemoveFilter |
| 578 | //purpose : |
| 579 | //======================================================================= |
| 580 | |
| 581 | void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter) |
| 582 | { |
| 583 | if(myFilters->IsIn(aFilter)) myFilters->Remove(aFilter); |
| 584 | |
| 585 | // it is checked if the filter for type standard is active. |
| 586 | // if yes, it is checked there are still similarities among the |
| 587 | // remaining filters... |
| 588 | // otherwise, the standard filter is restored to |
| 589 | // continu selecting active modes... |
| 590 | TColStd_ListIteratorOfListOfInteger It(myListOfStandardMode); |
| 591 | TopAbs_ShapeEnum SE; |
| 592 | for(;It.More();It.Next()){ |
| 593 | SE = AIS_Shape::SelectionType(It.Value()); |
| 594 | if(aFilter->ActsOn(SE)) |
| 595 | if(!HasFilters(SE)) |
| 596 | myFilters->Add(myStdFilters[It.Value()]); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | //======================================================================= |
| 601 | //function : Terminate |
| 602 | //purpose : |
| 603 | //======================================================================= |
| 604 | |
| 605 | void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) |
| 606 | { |
| 607 | ClearDetected(); |
| 608 | Clear(); |
| 609 | myMapOfOwner.Clear(); |
| 610 | |
| 611 | mylastindex=0; |
| 612 | // clear the selector... |
| 613 | myMainVS->Clear(); |
| 614 | |
| 615 | |
| 616 | AIS_Selection::SetCurrentSelection(mySelName.ToCString()); |
| 617 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
| 618 | Handle(Standard_Transient) Tr; |
| 619 | for(S->Init();S->More();S->Next()){ |
| 620 | Tr = S->Value(); |
| 621 | (*((Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False); |
| 622 | } |
| 623 | |
| 624 | |
| 625 | AIS_Selection::Select(); |
| 626 | AIS_Selection::Remove(mySelName.ToCString()); |
| 627 | |
| 628 | Handle(V3d_Viewer) aViewer = myCTX->CurrentViewer(); |
| 629 | for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) |
| 630 | { |
| 631 | Handle(V3d_View) aView = aViewer->ActiveView(); |
| 632 | aView->View()->ClearImmediate(); |
| 633 | } |
| 634 | |
| 635 | Handle(V3d_View) aDummyView; |
| 636 | myMainVS->ClearSensitive (aDummyView); |
| 637 | |
| 638 | if (theToUpdate) |
| 639 | { |
| 640 | myCTX->UpdateCurrentViewer(); |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | |
| 645 | //======================================================================= |
| 646 | //function : SubIntensity |
| 647 | //purpose : |
| 648 | //======================================================================= |
| 649 | |
| 650 | void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) |
| 651 | { |
| 652 | if(!myActiveObjects.IsBound(anObject)) return; |
| 653 | |
| 654 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
| 655 | |
| 656 | if(Att->IsTemporary()) |
| 657 | myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); |
| 658 | |
| 659 | Att->SubIntensityOn(); |
| 660 | } |
| 661 | //======================================================================= |
| 662 | //function : SubIntensity |
| 663 | //purpose : |
| 664 | //======================================================================= |
| 665 | |
| 666 | void AIS_LocalContext::SubIntensityOff(const Handle(AIS_InteractiveObject)& anObject) |
| 667 | { |
| 668 | if(!myActiveObjects.IsBound(anObject)) return; |
| 669 | |
| 670 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
| 671 | |
| 672 | if(Att->IsTemporary()) |
| 673 | myMainPM->Unhighlight(anObject); |
| 674 | Att->SubIntensityOff(); |
| 675 | } |
| 676 | |
| 677 | |
| 678 | //======================================================================= |
| 679 | //function : Hilight |
| 680 | //purpose : |
| 681 | //======================================================================= |
| 682 | |
| 683 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) |
| 684 | { |
| 685 | if(!myActiveObjects.IsBound(anObject)){ |
| 686 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
| 687 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
| 688 | Standard_False, |
| 689 | -1,-1,HiMod); |
| 690 | myActiveObjects.Bind(anObject,Att); |
| 691 | |
| 692 | } |
| 693 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
| 694 | myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); |
| 695 | Att->SubIntensityOn(); |
| 696 | } |
| 697 | //======================================================================= |
| 698 | //function : Hilight |
| 699 | //purpose : |
| 700 | //======================================================================= |
| 701 | |
| 702 | void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, |
| 703 | const Quantity_NameOfColor Col) |
| 704 | { |
| 705 | if(!myActiveObjects.IsBound(anObject)){ |
| 706 | Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; |
| 707 | Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, |
| 708 | Standard_False, |
| 709 | -1,-1,HiMod); |
| 710 | myActiveObjects.Bind(anObject,Att); |
| 711 | |
| 712 | } |
| 713 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
| 714 | myMainPM->Color(anObject,Col,Att->HilightMode()); |
| 715 | Att->SubIntensityOn(); |
| 716 | Att->SetHilightColor(Col); |
| 717 | } |
| 718 | |
| 719 | //======================================================================= |
| 720 | //function : Unhilight |
| 721 | //purpose : |
| 722 | //======================================================================= |
| 723 | |
| 724 | void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) |
| 725 | { |
| 726 | if(!myActiveObjects.IsBound(anObject)) return; |
| 727 | |
| 728 | // chieck if by hazard the object is somewhere else... |
| 729 | Standard_Integer Indx; |
| 730 | Standard_Boolean IsSomeWhereElse = |
| 731 | myCTX->IsInLocal(anObject,Indx) && Indx != myCTX->IndexOfCurrentLocal(); |
| 732 | |
| 733 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); |
| 734 | myMainPM->Unhighlight(anObject,Att->HilightMode()); |
| 735 | if(Att->IsTemporary() && Att->DisplayMode()==-1) |
| 736 | if(!IsSomeWhereElse) |
| 737 | myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); |
| 738 | |
| 739 | Att->SubIntensityOff(); |
| 740 | Att->SetHilightColor(Quantity_NOC_WHITE); |
| 741 | } |
| 742 | |
| 743 | |
| 744 | //======================================================================= |
| 745 | //function : IsIn |
| 746 | //purpose : |
| 747 | //======================================================================= |
| 748 | |
| 749 | Standard_Boolean AIS_LocalContext:: |
| 750 | IsIn(const Handle(AIS_InteractiveObject)& anObject) const |
| 751 | { |
| 752 | return myActiveObjects.IsBound(anObject); |
| 753 | } |
| 754 | |
| 755 | //======================================================================= |
| 756 | //function : IsHilighted |
| 757 | //purpose : |
| 758 | //======================================================================= |
| 759 | |
| 760 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject) const |
| 761 | { |
| 762 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
| 763 | return myActiveObjects(anObject)->IsSubIntensityOn(); |
| 764 | } |
| 765 | |
| 766 | Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, |
| 767 | Standard_Boolean& WithColor, |
| 768 | Quantity_NameOfColor& HiCol) const |
| 769 | { |
| 770 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
| 771 | if( myActiveObjects(anObject)->IsSubIntensityOn()){ |
| 772 | HiCol = myActiveObjects(anObject)->HilightColor(); |
| 773 | if(HiCol==Quantity_NOC_WHITE) |
| 774 | WithColor = Standard_True; |
| 775 | else |
| 776 | WithColor = Standard_False; |
| 777 | return Standard_True; |
| 778 | } |
| 779 | return Standard_False; |
| 780 | } |
| 781 | |
| 782 | |
| 783 | void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& anObject, |
| 784 | const Standard_Integer Prior) |
| 785 | { |
| 786 | if(!myActiveObjects.IsBound(anObject)) return; |
| 787 | const Handle(AIS_LocalStatus)& STAT = myActiveObjects(anObject); |
| 788 | if(STAT->DisplayMode()==-1) return; |
| 789 | myMainPM->SetDisplayPriority(anObject,STAT->DisplayMode(),Prior); |
| 790 | if(STAT->IsSubIntensityOn()) |
| 791 | myMainPM->SetDisplayPriority(anObject,STAT->HilightMode(),Prior); |
| 792 | |
| 793 | |
| 794 | } |
| 795 | |
| 796 | //======================================================================= |
| 797 | //function : DisplayedObjects |
| 798 | //purpose : |
| 799 | //======================================================================= |
| 800 | Standard_Integer AIS_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const |
| 801 | { |
| 802 | Standard_Integer NbDisp(0); |
| 803 | for(AIS_DataMapIteratorOfDataMapOfSelStat it(myActiveObjects);it.More();it.Next()){ |
| 804 | const Handle(SelectMgr_SelectableObject)& SO = it.Key(); |
| 805 | if(!theMap.Contains(SO)) |
| 806 | if(it.Value()->DisplayMode()!=-1){ |
| 807 | theMap.Add(SO); |
| 808 | NbDisp++; |
| 809 | } |
| 810 | } |
| 811 | return NbDisp; |
| 812 | } |
| 813 | |
| 814 | |
| 815 | //======================================================================= |
| 816 | //function : IsDisplayed |
| 817 | //purpose : |
| 818 | //======================================================================= |
| 819 | |
| 820 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject) const |
| 821 | { |
| 822 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
| 823 | return (myActiveObjects(anObject)->DisplayMode()!=-1); |
| 824 | } |
| 825 | |
| 826 | //======================================================================= |
| 827 | //function : IsDisplayed |
| 828 | //purpose : |
| 829 | //======================================================================= |
| 830 | |
| 831 | Standard_Boolean AIS_LocalContext::IsDisplayed(const Handle(AIS_InteractiveObject)& anObject, |
| 832 | const Standard_Integer aMode) const |
| 833 | { |
| 834 | if(!myActiveObjects.IsBound(anObject)) return Standard_False; |
| 835 | return (myActiveObjects(anObject)->DisplayMode()==aMode); |
| 836 | } |
| 837 | |
| 838 | //======================================================================= |
| 839 | //function : SelectionModes |
| 840 | //purpose : |
| 841 | //======================================================================= |
| 842 | |
| 843 | const TColStd_ListOfInteger& AIS_LocalContext:: |
| 844 | SelectionModes(const Handle(AIS_InteractiveObject)& anObject) const |
| 845 | { |
| 846 | return myActiveObjects(anObject)->SelectionModes(); |
| 847 | } |
| 848 | |
| 849 | //======================================================================= |
| 850 | //function : Status |
| 851 | //purpose : |
| 852 | //======================================================================= |
| 853 | |
| 854 | TCollection_AsciiString AIS_LocalContext::Status() const |
| 855 | { |
| 856 | TCollection_AsciiString t; |
| 857 | return t; |
| 858 | } |
| 859 | |
| 860 | const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_InteractiveObject)& anObject) const |
| 861 | { |
| 862 | return myActiveObjects(anObject); |
| 863 | } |
| 864 | |
| 865 | //======================================================================= |
| 866 | //function : LoadContextObjects |
| 867 | //purpose : |
| 868 | //======================================================================= |
| 869 | |
| 870 | void AIS_LocalContext::LoadContextObjects() |
| 871 | { |
| 872 | AIS_ListIteratorOfListOfInteractive It; |
| 873 | if(myLoadDisplayed) { |
| 874 | AIS_ListOfInteractive LL; |
| 875 | myCTX->DisplayedObjects(LL,Standard_True); |
| 876 | Handle(AIS_LocalStatus) Att; |
| 877 | for (It.Initialize(LL);It.More();It.Next()){ |
| 878 | const Handle(AIS_InteractiveObject)& anObj = It.Value(); |
| 879 | Att= new AIS_LocalStatus(); |
| 880 | Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode)); |
| 881 | Att->SetTemporary(Standard_False); |
| 882 | Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0); |
| 883 | for (anObj->Init(); anObj->More(); anObj->Next()) |
| 884 | { |
| 885 | const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); |
| 886 | aSel->SetSelectionState (SelectMgr_SOS_Deactivated); |
| 887 | } |
| 888 | myActiveObjects.Bind(anObj,Att); |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | void AIS_LocalContext::UnloadContextObjects() |
| 894 | { |
| 895 | AIS_ListIteratorOfListOfInteractive It; |
| 896 | if(myLoadDisplayed) |
| 897 | { |
| 898 | AIS_ListOfInteractive LL; |
| 899 | myCTX->DisplayedObjects(LL,Standard_True); |
| 900 | |
| 901 | for (It.Initialize(LL);It.More();It.Next()) |
| 902 | { |
| 903 | myActiveObjects.UnBind(It.Value()); |
| 904 | } |
| 905 | } |
| 906 | } |
| 907 | //======================================================================= |
| 908 | //function : Process |
| 909 | //purpose : |
| 910 | //======================================================================= |
| 911 | |
| 912 | void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject) |
| 913 | { |
| 914 | if(!myActiveObjects.IsBound(anObject)) return; |
| 915 | if(myActiveObjects(anObject)->Decomposed()) |
| 916 | ActivateStandardModes(anObject); |
| 917 | else |
| 918 | { |
| 919 | TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes()); |
| 920 | for(;It.More();It.Next()) |
| 921 | myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | //======================================================================= |
| 926 | //function : Process |
| 927 | //purpose : |
| 928 | //======================================================================= |
| 929 | |
| 930 | void AIS_LocalContext::Process() |
| 931 | { |
| 932 | |
| 933 | myMainVS->Clear(); |
| 934 | |
| 935 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
| 936 | |
| 937 | for(;It.More();It.Next()){ |
| 938 | myCTX->SelectionManager()->Load(It.Key(),myMainVS); |
| 939 | if(It.Value()->Decomposed()) |
| 940 | ActivateStandardModes(It.Key()); |
| 941 | else if( myCTX->GetAutoActivateSelection() ) |
| 942 | { |
| 943 | It.Value()->AddSelectionMode(0); |
| 944 | myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | } |
| 949 | |
| 950 | //======================================================================= |
| 951 | //function : ActivateModes |
| 952 | //purpose : |
| 953 | //======================================================================= |
| 954 | |
| 955 | void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject) |
| 956 | { |
| 957 | if(!myActiveObjects.IsBound(anObject)) return; |
| 958 | |
| 959 | TColStd_ListIteratorOfListOfInteger itl (myListOfStandardMode); |
| 960 | |
| 961 | const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject); |
| 962 | if(LS->Decomposed()){ |
| 963 | for(;itl.More();itl.Next()){ |
| 964 | myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS); |
| 965 | LS->AddSelectionMode(itl.Value()); |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | |
| 971 | //======================================================================= |
| 972 | //function : ClearObjects |
| 973 | //purpose : |
| 974 | //======================================================================= |
| 975 | |
| 976 | void AIS_LocalContext::ClearObjects() |
| 977 | { |
| 978 | AIS_DataMapIteratorOfDataMapOfSelStat It(myActiveObjects); |
| 979 | for(;It.More();It.Next()) |
| 980 | { |
| 981 | Handle(AIS_InteractiveObject) SO = |
| 982 | Handle(AIS_InteractiveObject)::DownCast(It.Key()); |
| 983 | |
| 984 | const Handle(AIS_LocalStatus)& CurAtt = It.Value(); |
| 985 | //TColStd_ListIteratorOfListOfInteger ItL; |
| 986 | // if object is temporary the presentations managed by myMainPM are removed |
| 987 | AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); |
| 988 | |
| 989 | if(TheDS != AIS_DS_Displayed){ |
| 990 | if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ |
| 991 | if(CurAtt->IsSubIntensityOn()&& |
| 992 | myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) |
| 993 | myMainPM->Unhighlight(SO,CurAtt->HilightMode()); |
| 994 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
| 995 | } |
| 996 | |
| 997 | if(CurAtt->IsTemporary()){ |
| 998 | myMainPM->Erase(SO,CurAtt->DisplayMode());} |
| 999 | // myMainPM->Clear(SO,CurAtt->DisplayMode());} |
| 1000 | } |
| 1001 | else { |
| 1002 | if (CurAtt->IsSubIntensityOn()){ |
| 1003 | myCTX->SubIntensityOff(Handle(AIS_InteractiveObject)::DownCast(SO));} |
| 1004 | Standard_Integer DiMo = SO->HasDisplayMode()? |
| 1005 | SO->DisplayMode():myCTX->DisplayMode(); |
| 1006 | if(CurAtt->DisplayMode()!=-1 && |
| 1007 | CurAtt->DisplayMode()!= DiMo) |
| 1008 | myMainPM->Erase(SO,CurAtt->DisplayMode()); |
| 1009 | } |
| 1010 | |
| 1011 | TColStd_ListIteratorOfListOfInteger aSelModeIter (CurAtt->SelectionModes()); |
| 1012 | for ( ; aSelModeIter.More(); aSelModeIter.Next()) |
| 1013 | { |
| 1014 | Standard_Integer aSelMode = aSelModeIter.Value(); |
| 1015 | mySM->Deactivate (SO, aSelMode, myMainVS); |
| 1016 | } |
| 1017 | |
| 1018 | } |
| 1019 | ClearSelected( Standard_False ); |
| 1020 | myActiveObjects.Clear(); |
| 1021 | // myMainVS->ClearAreas();myMainVS->ClearSensitive(); |
| 1022 | } |
| 1023 | |
| 1024 | |
| 1025 | Standard_Boolean AIS_LocalContext::IsDecompositionOn() const |
| 1026 | {return !myListOfStandardMode.IsEmpty();} |
| 1027 | |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | //======================================================================= |
| 1032 | //function : HasAlreadyFilters |
| 1033 | //purpose : |
| 1034 | //======================================================================= |
| 1035 | |
| 1036 | Standard_Boolean AIS_LocalContext:: |
| 1037 | HasFilters(const TopAbs_ShapeEnum aType) const |
| 1038 | { |
| 1039 | return myFilters->ActsOn(aType); |
| 1040 | } |
| 1041 | |
| 1042 | void AIS_LocalContext::ClearDetected() |
| 1043 | { |
| 1044 | for(Standard_Integer I=1;I<=myMapOfOwner.Extent();I++) |
| 1045 | { |
| 1046 | if(!myMapOfOwner(I).IsNull()) |
| 1047 | { |
| 1048 | if(myMapOfOwner(I)->IsHilighted(myMainPM)) |
| 1049 | myMapOfOwner(I)->Unhilight(myMainPM); |
| 1050 | else |
| 1051 | { |
| 1052 | const Handle(SelectMgr_SelectableObject)& SO = |
| 1053 | myMapOfOwner.FindKey(I)->Selectable(); |
| 1054 | if(myActiveObjects.IsBound(SO)) |
| 1055 | { |
| 1056 | const Handle(AIS_LocalStatus)& Att = myActiveObjects(SO); |
| 1057 | |
| 1058 | if(Att->IsTemporary() && |
| 1059 | Att->DisplayMode()==-1 && |
| 1060 | Att->SelectionModes().IsEmpty()) |
| 1061 | { |
| 1062 | myMapOfOwner(I)->Clear(myMainPM); |
| 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | //======================================================================= |
| 1071 | //function : BeginImmediateDraw |
| 1072 | //purpose : |
| 1073 | //======================================================================= |
| 1074 | Standard_Boolean AIS_LocalContext::BeginImmediateDraw() |
| 1075 | { |
| 1076 | if (myMainPM->IsImmediateModeOn()) |
| 1077 | { |
| 1078 | myMainPM->BeginImmediateDraw(); |
| 1079 | return Standard_True; |
| 1080 | } |
| 1081 | return Standard_False; |
| 1082 | } |
| 1083 | |
| 1084 | //======================================================================= |
| 1085 | //function : ImmediateAdd |
| 1086 | //purpose : |
| 1087 | //======================================================================= |
| 1088 | Standard_Boolean AIS_LocalContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, |
| 1089 | const Standard_Integer theMode) |
| 1090 | { |
| 1091 | if (!myMainPM->IsImmediateModeOn()) |
| 1092 | { |
| 1093 | return Standard_False; |
| 1094 | } |
| 1095 | |
| 1096 | myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode)->Presentation()); |
| 1097 | return Standard_True; |
| 1098 | } |
| 1099 | |
| 1100 | //======================================================================= |
| 1101 | //function : EndImmediateDraw |
| 1102 | //purpose : |
| 1103 | //======================================================================= |
| 1104 | Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_View)& theView) |
| 1105 | { |
| 1106 | if (!myMainPM->IsImmediateModeOn()) |
| 1107 | { |
| 1108 | return Standard_False; |
| 1109 | } |
| 1110 | |
| 1111 | myMainPM->EndImmediateDraw (theView); |
| 1112 | return Standard_True; |
| 1113 | } |
| 1114 | |
| 1115 | // ======================================================================= |
| 1116 | // function : ClearImmediateDraw |
| 1117 | // purpose : |
| 1118 | // ======================================================================= |
| 1119 | void AIS_LocalContext::ClearImmediateDraw() |
| 1120 | { |
| 1121 | myMainPM->ClearImmediateDraw(); |
| 1122 | } |
| 1123 | |
| 1124 | //======================================================================= |
| 1125 | //function : IsImmediateModeOn |
| 1126 | //purpose : |
| 1127 | //======================================================================= |
| 1128 | Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const |
| 1129 | { |
| 1130 | return myMainPM->IsImmediateModeOn(); |
| 1131 | } |
| 1132 | |
| 1133 | void AIS_LocalContext::SetPixelTolerance(const Standard_Real aPrecision) { |
| 1134 | |
| 1135 | myMainVS->SetPixelTolerance(aPrecision); |
| 1136 | } |
| 1137 | |
| 1138 | Standard_Real AIS_LocalContext::PixelTolerance() const { |
| 1139 | |
| 1140 | return myMainVS->PixelTolerance(); |
| 1141 | } |