diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 1cd4cb8f91..8bd2d868c4 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -362,7 +362,7 @@ void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO continue; } - Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key()); + Handle(Graphic3d_ViewAffinity) anAffinity = anObjIter.Key()->ViewAffinity(); const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId); if (isVisible == theIsVisibleInView) { @@ -402,17 +402,9 @@ void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject return; } - Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj); + Handle(Graphic3d_ViewAffinity) anAffinity = theIObj->ViewAffinity(); Handle(Graphic3d_CView) aViewImpl = theView->View(); anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True); - if (theIsVisible) - { - theView->View()->ChangeHiddenObjects()->Remove (theIObj.get()); - } - else - { - theView->View()->ChangeHiddenObjects()->Add (theIObj.get()); - } } //======================================================================= @@ -445,7 +437,8 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO if (!myObjects.IsBound (theIObj)) { setObjectStatus (theIObj, PrsMgr_DisplayStatus_Displayed, theDispMode, theSelectionMode); - myMainVwr->StructureManager()->RegisterObject (theIObj); + theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask + myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity()); myMainPM->Display(theIObj, theDispMode); if (theSelectionMode != -1) { @@ -521,7 +514,8 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj, Standard_Integer aDispMode, aHiMod, aSelModeDef; GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef); setObjectStatus (theIObj, PrsMgr_DisplayStatus_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); - myMainVwr->StructureManager()->RegisterObject (theIObj); + theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask + myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity()); } // Register theIObj in the selection manager to prepare further activation of selection @@ -1900,13 +1894,9 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t mgrSelector->Remove (anObj); setObjectStatus (theIObj, PrsMgr_DisplayStatus_None, -1, -1); + theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask myMainVwr->StructureManager()->UnregisterObject (theIObj); - for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next()) - { - aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get()); - } - if (!myLastPicked.IsNull()) { if (myLastPicked->IsSameSelectable (theIObj)) @@ -2228,7 +2218,7 @@ Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection (const Handle(V3d_View)& continue; } - Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObj); + Handle(Graphic3d_ViewAffinity) anAffinity = anObj->ViewAffinity(); const Standard_Boolean isVisible = aViewId == -1 || anAffinity->IsVisible (aViewId); if (!isVisible) { @@ -2682,12 +2672,10 @@ AIS_StatusOfDetection AIS_InteractiveContext::moveTo (const Handle(V3d_View)& th myDetectedSeq.Clear(); myLastActiveView = theView.get(); - // preliminaires + // preliminaries AIS_StatusOfDetection aStatus = AIS_SOD_Nothing; Standard_Boolean toUpdateViewer = Standard_False; - myFilters->SetDisabledObjects (theView->View()->HiddenObjects()); - // filling of myAISDetectedSeq sequence storing information about detected AIS objects // (the objects must be AIS_Shapes) const Standard_Integer aDetectedNb = MainSelector()->NbPicked(); diff --git a/src/AIS/AIS_Manipulator.cxx b/src/AIS/AIS_Manipulator.cxx index 05aefddb1f..43da955306 100644 --- a/src/AIS/AIS_Manipulator.cxx +++ b/src/AIS/AIS_Manipulator.cxx @@ -1071,7 +1071,7 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan return; } - aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this)); + aPresentation->CStructure()->ViewAffinity = myViewAffinity; if (anOwner->Mode() == AIS_MM_TranslationPlane) { diff --git a/src/AIS/AIS_ViewCube.cxx b/src/AIS/AIS_ViewCube.cxx index d2ec561fc1..25894e1057 100644 --- a/src/AIS/AIS_ViewCube.cxx +++ b/src/AIS/AIS_ViewCube.cxx @@ -1016,7 +1016,7 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation (thePrsMgr); aHiPrs->Clear(); - aHiPrs->CStructure()->ViewAffinity = thePrsMgr->StructureManager()->ObjectAffinity (Handle(Standard_Transient)(this)); + aHiPrs->CStructure()->ViewAffinity = myViewAffinity; aHiPrs->SetTransformPersistence (TransformPersistence()); aHiPrs->SetZLayer (aLayer); diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index c114c66a21..985692f00c 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -36,7 +36,6 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM // myStructureManager (theMgr), myCamera (new Graphic3d_Camera()), - myHiddenObjects (new Graphic3d_NMapOfTransient()), myIsInComputedMode (Standard_False), myIsActive (Standard_False), myIsRemoved (Standard_False), diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index ac687ce8f4..143b50f4c4 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -134,12 +134,6 @@ public: //! Returns number of displayed structures in the view. virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); } - //! Returns map of objects hidden within this specific view (not viewer-wise). - const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const { return myHiddenObjects; } - - //! Returns map of objects hidden within this specific view (not viewer-wise). - Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects() { return myHiddenObjects; } - //! Returns Standard_True in case if the structure with the given is //! in list of structures to be computed and stores computed struct to . Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId, @@ -649,7 +643,6 @@ protected: Graphic3d_SequenceOfStructure myStructsToCompute; Graphic3d_SequenceOfStructure myStructsComputed; Graphic3d_MapOfStructure myStructsDisplayed; - Handle(Graphic3d_NMapOfTransient) myHiddenObjects; Standard_Boolean myIsInComputedMode; Standard_Boolean myIsActive; Standard_Boolean myIsRemoved; diff --git a/src/Graphic3d/Graphic3d_StructureManager.cxx b/src/Graphic3d/Graphic3d_StructureManager.cxx index de8637203c..a4e45a9b01 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cxx +++ b/src/Graphic3d/Graphic3d_StructureManager.cxx @@ -182,29 +182,45 @@ void Graphic3d_StructureManager::RecomputeStructures (const NCollection_Map(), aResult)) + if (myRegisteredObjects.Find (theObject.operator->(), aResult) + && aResult == theAffinity) { - return aResult; + return; } - aResult = new Graphic3d_ViewAffinity(); - myRegisteredObjects.Bind (theObject.operator->(), aResult); - return aResult; + myRegisteredObjects.Bind (theObject.operator->(), theAffinity); } +// ======================================================================== +// function : UnregisterObject +// purpose : +// ======================================================================== void Graphic3d_StructureManager::UnregisterObject (const Handle(Standard_Transient)& theObject) { myRegisteredObjects.UnBind (theObject.operator->()); } -Handle(Graphic3d_ViewAffinity) Graphic3d_StructureManager::ObjectAffinity (const Handle(Standard_Transient)& theObject) const +// ======================================================================== +// function : ObjectAffinity +// purpose : +// ======================================================================== +const Handle(Graphic3d_ViewAffinity)& Graphic3d_StructureManager::ObjectAffinity (const Handle(Standard_Transient)& theObject) const { - Handle(Graphic3d_ViewAffinity) aResult; - myRegisteredObjects.Find (theObject.operator->(), aResult); - return aResult; + const Handle(Graphic3d_ViewAffinity)* aResult = myRegisteredObjects.Seek (theObject.operator->()); + if (aResult == nullptr) + { + static const Handle(Graphic3d_ViewAffinity) aDummy; + return aDummy; + } + return *aResult; } // ======================================================================== diff --git a/src/Graphic3d/Graphic3d_StructureManager.hxx b/src/Graphic3d/Graphic3d_StructureManager.hxx index e1dd1452ac..1a881d1980 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.hxx +++ b/src/Graphic3d/Graphic3d_StructureManager.hxx @@ -151,11 +151,12 @@ public: //! Recomputes all structures from theStructures. Standard_EXPORT void RecomputeStructures (const NCollection_Map& theStructures); - Standard_EXPORT Handle(Graphic3d_ViewAffinity) RegisterObject (const Handle(Standard_Transient)& theObject); + Standard_EXPORT void RegisterObject (const Handle(Standard_Transient)& theObject, + const Handle(Graphic3d_ViewAffinity)& theAffinity); Standard_EXPORT void UnregisterObject (const Handle(Standard_Transient)& theObject); - Standard_EXPORT Handle(Graphic3d_ViewAffinity) ObjectAffinity (const Handle(Standard_Transient)& theObject) const; + Standard_EXPORT const Handle(Graphic3d_ViewAffinity)& ObjectAffinity (const Handle(Standard_Transient)& theObject) const; //! Returns TRUE if Device Lost flag has been set and presentation data should be reuploaded onto graphics driver. Standard_Boolean IsDeviceLost() const { return myDeviceLostFlag; } diff --git a/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx b/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx index f3c124cae6..f12b8723a6 100644 --- a/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx +++ b/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx @@ -114,7 +114,7 @@ void IVtkOCC_ViewerSelector::Pick (const Standard_Integer theXPix, mySelectingVolumeMgr.BuildSelectingVolume(); - TraverseSensitives(); + TraverseSensitives (-1); } //============================================================================ @@ -160,7 +160,7 @@ void IVtkOCC_ViewerSelector::Pick (const Standard_Integer theXMin, mySelectingVolumeMgr.BuildSelectingVolume(); - TraverseSensitives(); + TraverseSensitives (-1); } //============================================================================ @@ -207,7 +207,7 @@ void IVtkOCC_ViewerSelector::Pick (double** thePoly, mySelectingVolumeMgr.BuildSelectingVolume(); - TraverseSensitives(); + TraverseSensitives (-1); } //============================================================================ diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index 835dadb20c..3cb38867de 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -45,6 +45,7 @@ const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf() //======================================================================= PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType) : myParent (NULL), + myViewAffinity (new Graphic3d_ViewAffinity()), myDrawer (new Prs3d_Drawer()), myTypeOfPresentation3d (theType), myDisplayStatus (PrsMgr_DisplayStatus_None), diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index 3002dc5ebf..8e75fbf369 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -74,6 +74,9 @@ public: //! This method should be called before object displaying to take effect. Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable); + //! Return view affinity mask. + const Handle(Graphic3d_ViewAffinity)& ViewAffinity() const { return myViewAffinity; } + //! Returns true if the Interactive Object has display mode setting overriding global setting (within Interactive Context). Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; } @@ -522,6 +525,7 @@ protected: PrsMgr_PresentableObject* myParent; //!< pointer to the parent object PrsMgr_Presentations myPresentations; //!< list of presentations + Handle(Graphic3d_ViewAffinity) myViewAffinity; //!< view affinity mask Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; //!< sequence of object-specific clipping planes Handle(Prs3d_Drawer) myDrawer; //!< main presentation attributes Handle(Prs3d_Drawer) myHilightDrawer; //!< (optional) custom presentation attributes for highlighting selected object diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 915e1b9fd7..766d70ed2a 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -519,7 +519,7 @@ Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Hand Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj, theMode); aPrs->SetZLayer (thePrsObj->ZLayer()); - aPrs->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj); + aPrs->CStructure()->ViewAffinity = !theSelObj.IsNull() ? theSelObj->ViewAffinity() : thePrsObj->ViewAffinity(); thePrsObj->Presentations().Append (aPrs); thePrsObj->Fill (this, aPrs, theMode); diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 8559eaed3a..94a7e75d75 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -626,7 +626,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable // purpose : Traverses BVH containing all added selectable objects and // finds candidates for further search of overlap //======================================================================= -void SelectMgr_ViewerSelector::TraverseSensitives() +void SelectMgr_ViewerSelector::TraverseSensitives (const Standard_Integer theViewId) { SelectMgr_BVHThreadPool::Sentry aSentry (myBVHThreadPool); @@ -750,14 +750,16 @@ void SelectMgr_ViewerSelector::TraverseSensitives() } else { - Standard_Integer aStartIdx = aBVHTree->BegPrimitive (aNode); - Standard_Integer anEndIdx = aBVHTree->EndPrimitive (aNode); + const Standard_Integer aStartIdx = aBVHTree->BegPrimitive (aNode); + const Standard_Integer anEndIdx = aBVHTree->EndPrimitive (aNode); for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx) { - const Handle(SelectMgr_SelectableObject)& aSelectableObject = - mySelectableObjects.GetObjectById (aBVHSubset, anIdx); - - traverseObject (aSelectableObject, aMgr, aCamera, aProjectionMat, aWorldViewMat, aWinSize); + const Handle(SelectMgr_SelectableObject)& aSelObj = mySelectableObjects.GetObjectById (aBVHSubset, anIdx); + const Handle(Graphic3d_ViewAffinity)& aViewAffinity = aSelObj->ViewAffinity(); + if (theViewId == -1 || aViewAffinity->IsVisible (theViewId)) + { + traverseObject (aSelObj, aMgr, aCamera, aProjectionMat, aWorldViewMat, aWinSize); + } } if (aHead < 0) { @@ -1175,7 +1177,7 @@ void SelectMgr_ViewerSelector::Pick (const Standard_Integer theXPix, mySelectingVolumeMgr.BuildSelectingVolume(); mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL); - TraverseSensitives(); + TraverseSensitives (theView->View()->Identification()); } //======================================================================= @@ -1204,7 +1206,7 @@ void SelectMgr_ViewerSelector::Pick (const Standard_Integer theXPMin, mySelectingVolumeMgr.BuildSelectingVolume(); mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL); - TraverseSensitives(); + TraverseSensitives (theView->View()->Identification()); } //======================================================================= @@ -1224,7 +1226,7 @@ void SelectMgr_ViewerSelector::Pick (const TColgp_Array1OfPnt2d& thePolyline, mySelectingVolumeMgr.BuildSelectingVolume(); mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL); - TraverseSensitives(); + TraverseSensitives (theView->View()->Identification()); } //======================================================================= @@ -1240,7 +1242,7 @@ void SelectMgr_ViewerSelector::Pick (const gp_Ax1& theAxis, mySelectingVolumeMgr.BuildSelectingVolume(); mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL); - TraverseSensitives(); + TraverseSensitives (theView->View()->Identification()); } //======================================================================= diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index e46d76a06d..ad684245d1 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -325,7 +325,7 @@ protected: //! Traverses BVH containing all added selectable objects and //! finds candidates for further search of overlap - Standard_EXPORT void TraverseSensitives(); + Standard_EXPORT void TraverseSensitives (const Standard_Integer theViewId = -1); //! Internal function that checks if there is possible overlap between some entity of selectable object theObject and //! current selecting volume. diff --git a/tests/v3d/bugs/bug32978 b/tests/v3d/bugs/bug32978 new file mode 100644 index 0000000000..f532c576a5 --- /dev/null +++ b/tests/v3d/bugs/bug32978 @@ -0,0 +1,34 @@ +puts "============" +puts "0031965: Visualization - AIS_InteractiveContext::HilightWithColor() ignores passed highlight style" +puts "============" +puts "" + +pload MODELING VISUALIZATION +vinit V1/RootView -width 1024 -height 512 -composer 0 +vbackground GRAY20 + +vinit V2/ViewLeft -parent V1/RootView -width 0.5 -height 1.0 +vbackground GRAY30 + +box b 100 200 300 +vdisplay -dispMode 1 b +vaspects b -faceBoundaryDraw 1 +vfit +vviewcube vc + +vinit V2/ViewRight -parent V1/RootView -width 0.5 -height 1.0 -left 0.5 +vbackground GRAY40 +psphere s 300 +vdisplay -dispMode 1 s +vaspects s -material SILVER +vfit +vzbufftrihedron + +vactivate V2/ViewLeft +verase s -view +vcamera -rotationMode pick +vmoveto 100 100 +if { [string match "*Select3D_SensitiveSphere*" [vstate -entities]] } { puts "Error: sphere should NOT be detected" } + +vseldump $::imagedir/${::casename}_sel.png -type entity +vdump $::imagedir/${::casename}_vis.png