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