From a272ed9466eacd455efc2662431191b6c1d25387 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 5 Mar 2015 13:50:47 +0300 Subject: [PATCH] 0025552: Visualization - provide the way to hide the object in specified view of the viewer Add test case bugs/vis/bug25552 OpenGl_GraphicDriver - do not use View and Workspace identifiers on level of entire Driver --- src/AIS/AIS_InteractiveContext.cdl | 13 +++ src/AIS/AIS_InteractiveContext.cxx | 62 +++++++++++++++ src/AIS/AIS_InteractiveContext_1.cxx | 3 +- src/AIS/AIS_LocalContext_1.cxx | 2 + src/Graphic3d/FILES | 4 + src/Graphic3d/Graphic3d.cdl | 4 + src/Graphic3d/Graphic3d_CStructure.hxx | 3 + src/Graphic3d/Graphic3d_MapOfObject.hxx | 24 ++++++ src/Graphic3d/Graphic3d_NMapOfTransient.hxx | 25 ++++++ src/Graphic3d/Graphic3d_StructureManager.cdl | 17 ++++ src/Graphic3d/Graphic3d_StructureManager.cxx | 25 ++++++ src/Graphic3d/Graphic3d_ViewAffinity.cxx | 19 +++++ src/Graphic3d/Graphic3d_ViewAffinity.hxx | 66 +++++++++++++++ src/OpenGl/OpenGl_GraphicDriver.cxx | 8 +- src/OpenGl/OpenGl_GraphicDriver.hxx | 4 +- src/OpenGl/OpenGl_GraphicDriver_7.cxx | 84 ++++++++++---------- src/OpenGl/OpenGl_Layer.cxx | 12 +++ src/OpenGl/OpenGl_Workspace.cxx | 1 + src/OpenGl/OpenGl_Workspace.hxx | 13 ++- src/OpenGl/OpenGl_Workspace_Raytrace.cxx | 5 ++ src/PrsMgr/PrsMgr_PresentationManager.cdl | 7 +- src/PrsMgr/PrsMgr_PresentationManager.cxx | 9 ++- src/SelectMgr/FILES | 2 +- src/SelectMgr/SelectMgr_OrFilter.cdl | 15 +++- src/SelectMgr/SelectMgr_OrFilter.cxx | 42 ++++++++-- src/StdSelect/StdSelect_BRepOwner.cxx | 12 ++- src/V3d/V3d.cdl | 1 + src/ViewerTest/ViewerTest.cxx | 53 +++++++++++- src/Visual3d/Visual3d_View.cdl | 13 +++ src/Visual3d/Visual3d_View.cxx | 26 ++++++ src/Visual3d/Visual3d_ViewManager.cxx | 2 +- tests/bugs/vis/bug25552 | 68 ++++++++++++++++ 32 files changed, 568 insertions(+), 76 deletions(-) create mode 100644 src/Graphic3d/Graphic3d_MapOfObject.hxx create mode 100644 src/Graphic3d/Graphic3d_NMapOfTransient.hxx create mode 100644 src/Graphic3d/Graphic3d_ViewAffinity.cxx create mode 100644 src/Graphic3d/Graphic3d_ViewAffinity.hxx create mode 100644 tests/bugs/vis/bug25552 diff --git a/src/AIS/AIS_InteractiveContext.cdl b/src/AIS/AIS_InteractiveContext.cdl index a8ae057604..6398d8cb1f 100644 --- a/src/AIS/AIS_InteractiveContext.cdl +++ b/src/AIS/AIS_InteractiveContext.cdl @@ -2010,6 +2010,19 @@ is ---Purpose: returns if possible, -- the first local context where the object is seen + SetViewAffinity (me : mutable; + theIObj : InteractiveObject from AIS; + theView : View from V3d; + theIsVisible : Boolean from Standard) is static; + ---Purpose: setup object visibility in specified view, + -- has no effect if object is not disaplyed in this context. + + ObjectsForView (me; + theListOfIO : in out ListOfInteractive from AIS; + theView : View from V3d; + theIsVisibleInView : Boolean from Standard; + theStatus : DisplayStatus from AIS = AIS_DS_None) is static; + ---Purpose: Query objects visible or hidden in specified view due to affinity mask. InitAttributes(me:mutable) is static private; diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index ac165181bf..d026bceb91 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -322,6 +322,35 @@ void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListO } } +//======================================================================= +//function : ObjectsForView +//purpose : +//======================================================================= +void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO, + const Handle(V3d_View)& theView, + const Standard_Boolean theIsVisibleInView, + const AIS_DisplayStatus theStatus) const +{ + const Graphic3d_CView* aCView = reinterpret_cast(theView->View()->CView()); + const Standard_Integer aViewId = aCView->ViewId; + for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) + { + if (theStatus != AIS_DS_None + && anObjIter.Value()->GraphicStatus() != theStatus) + { + theListOfIO.Append (anObjIter.Key()); + continue; + } + + Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (anObjIter.Key()); + const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId); + if (isVisible == theIsVisibleInView) + { + theListOfIO.Append (anObjIter.Key()); + } + } +} + //======================================================================= //function : Display //purpose : @@ -341,6 +370,33 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO theToUpdateViewer, theIObj->AcceptShapeDecomposition()); } +//======================================================================= +//function : SetViewAffinity +//purpose : +//======================================================================= +void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, + const Handle(V3d_View)& theView, + const Standard_Boolean theIsVisible) +{ + if (theIObj.IsNull() + || !myObjects.IsBound (theIObj)) + { + return; + } + + Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->ObjectAffinity (theIObj); + const Graphic3d_CView* aCView = reinterpret_cast(theView->View()->CView()); + anAffinity->SetVisible (aCView->ViewId, theIsVisible == Standard_True); + if (theIsVisible) + { + theView->View()->ChangeHiddenObjects()->Remove (theIObj); + } + else + { + theView->View()->ChangeHiddenObjects()->Add (theIObj); + } +} + //======================================================================= //function : Display //purpose : @@ -392,6 +448,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO { Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode); myObjects.Bind (theIObj, aStatus); + Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->Viewer()->RegisterObject (theIObj); myMainPM->Display(theIObj, theDispMode); if (theSelectionMode != -1) { @@ -2355,6 +2412,11 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t mgrSelector->Remove (theIObj); myObjects.UnBind (theIObj); + myMainVwr->Viewer()->UnregisterObject (theIObj); + for (myMainVwr->InitDefinedViews(); myMainVwr->MoreDefinedViews(); myMainVwr->NextDefinedViews()) + { + myMainVwr->DefinedView()->View()->ChangeHiddenObjects()->Remove (theIObj); + } if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed) diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 7e22edaf00..b8423a9acd 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -71,7 +72,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th AIS_StatusOfDetection aStatus = AIS_SOD_Nothing; Standard_Boolean toUpdateViewer = Standard_False; - // allonzy + myFilters->SetDisabledObjects (theView->View()->HiddenObjects()); myMainSel->Pick (theXPix, theYPix, theView); // filling of myAISDetectedSeq sequence storing information about detected AIS objects diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 2a8ca1bd25..13042c5004 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer theXpix, myCurDetected = 0; myDetectedSeq.Clear(); + myFilters->SetDisabledObjects (theView->View()->HiddenObjects()); myMainVS->Pick (theXpix, theYpix, theView); const Standard_Integer aDetectedNb = myMainVS->NbPicked(); diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 272a3bd094..47cf7ee261 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -22,6 +22,9 @@ Graphic3d_CLight.hxx Graphic3d_CUserDraw.hxx Graphic3d_CView.hxx Graphic3d_CGraduatedTrihedron.hxx +Graphic3d_ViewAffinity.hxx +Graphic3d_ViewAffinity.cxx +Graphic3d_MapOfObject.hxx Graphic3d_Structure.lxx Graphic3d_Structure.pxx Graphic3d_ShaderObject.hxx @@ -71,3 +74,4 @@ Graphic3d_Camera.cxx Graphic3d_Camera.hxx Graphic3d_Camera_Handle.hxx Graphic3d_RenderingParams.hxx +Graphic3d_NMapOfTransient.hxx diff --git a/src/Graphic3d/Graphic3d.cdl b/src/Graphic3d/Graphic3d.cdl index bbeabd8cac..4dcc3a754d 100644 --- a/src/Graphic3d/Graphic3d.cdl +++ b/src/Graphic3d/Graphic3d.cdl @@ -495,6 +495,10 @@ is imported Vertex; ---Category: Classes + imported transient class ViewAffinity; + imported MapOfObject; + imported transient class NMapOfTransient; + imported MapOfStructure; imported SequenceOfDisplayedStructures; diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index d69510b7da..4eb318fdd3 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,8 @@ public: int ContainsFacet; + Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask + unsigned IsInfinite : 1; unsigned stick : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state) unsigned highlight : 1; diff --git a/src/Graphic3d/Graphic3d_MapOfObject.hxx b/src/Graphic3d/Graphic3d_MapOfObject.hxx new file mode 100644 index 0000000000..c3bf0d2592 --- /dev/null +++ b/src/Graphic3d/Graphic3d_MapOfObject.hxx @@ -0,0 +1,24 @@ +// Created on: 2014-12-18 +// Created by: Kirill Gavrilov +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Graphic3d_MapOfObject +#define _Graphic3d_MapOfObject + +#include +#include + +typedef NCollection_DataMap Graphic3d_MapOfObject; + +#endif // _Graphic3d_MapOfObject diff --git a/src/Graphic3d/Graphic3d_NMapOfTransient.hxx b/src/Graphic3d/Graphic3d_NMapOfTransient.hxx new file mode 100644 index 0000000000..c661e99e8c --- /dev/null +++ b/src/Graphic3d/Graphic3d_NMapOfTransient.hxx @@ -0,0 +1,25 @@ +// Created on: 2014-12-08 +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Graphic3d_NMapOfTransient_HeaderFile +#define _Graphic3d_NMapOfTransient_HeaderFile + +#include +#include +#include + +typedef NCollection_Map Graphic3d_NMapOfTransient; +typedef NCollection_Handle Handle(Graphic3d_NMapOfTransient); + +#endif // _Graphic3d_NMapOfTransient_HeaderFile diff --git a/src/Graphic3d/Graphic3d_StructureManager.cdl b/src/Graphic3d/Graphic3d_StructureManager.cdl index 14516cfe81..5b690b7cc3 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cdl +++ b/src/Graphic3d/Graphic3d_StructureManager.cdl @@ -50,6 +50,8 @@ uses AspectText3d from Graphic3d, Structure from Graphic3d, MapOfStructure from Graphic3d, + MapOfObject from Graphic3d, + ViewAffinity from Graphic3d, SequenceOfStructure from Graphic3d, GraphicDriver from Graphic3d @@ -443,6 +445,19 @@ is theStructures : MapOfStructure from Graphic3d); ---Purpose: Recomputes all structures from theStructures. + RegisterObject (me : mutable; + theObject : Transient from Standard) + returns ViewAffinity from Graphic3d + is static; + + UnregisterObject (me : mutable; + theObject : Transient from Standard) is static; + + ObjectAffinity (me; + theObject : Transient from Standard) + returns ViewAffinity from Graphic3d + is static; + -- fields @@ -474,6 +489,8 @@ fields MyDisplayedStructure : MapOfStructure from Graphic3d is protected; + myRegisteredObjects : MapOfObject from Graphic3d is protected; + -- the highlighted structures MyHighlightedStructure : MapOfStructure from Graphic3d is protected; diff --git a/src/Graphic3d/Graphic3d_StructureManager.cxx b/src/Graphic3d/Graphic3d_StructureManager.cxx index e6bc2258fb..799311d39c 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cxx +++ b/src/Graphic3d/Graphic3d_StructureManager.cxx @@ -289,3 +289,28 @@ void Graphic3d_StructureManager::RecomputeStructures (const Graphic3d_MapOfStruc aStruct->Compute(); } } + +Handle(Graphic3d_ViewAffinity) Graphic3d_StructureManager::RegisterObject (const Handle(Standard_Transient)& theObject) +{ + Handle(Graphic3d_ViewAffinity) aResult; + if (myRegisteredObjects.Find (theObject.operator->(), aResult)) + { + return aResult; + } + + aResult = new Graphic3d_ViewAffinity(); + myRegisteredObjects.Bind (theObject.operator->(), aResult); + return aResult; +} + +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 +{ + Handle(Graphic3d_ViewAffinity) aResult; + myRegisteredObjects.Find (theObject.operator->(), aResult); + return aResult; +} diff --git a/src/Graphic3d/Graphic3d_ViewAffinity.cxx b/src/Graphic3d/Graphic3d_ViewAffinity.cxx new file mode 100644 index 0000000000..c108a76bac --- /dev/null +++ b/src/Graphic3d/Graphic3d_ViewAffinity.cxx @@ -0,0 +1,19 @@ +// Created on: 2014-12-18 +// Created by: Kirill Gavrilov +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +IMPLEMENT_STANDARD_HANDLE (Graphic3d_ViewAffinity, Standard_Transient) +IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ViewAffinity, Standard_Transient) diff --git a/src/Graphic3d/Graphic3d_ViewAffinity.hxx b/src/Graphic3d/Graphic3d_ViewAffinity.hxx new file mode 100644 index 0000000000..f6b0b48ed9 --- /dev/null +++ b/src/Graphic3d/Graphic3d_ViewAffinity.hxx @@ -0,0 +1,66 @@ +// Created on: 2014-12-18 +// Created by: Kirill Gavrilov +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Graphic3d_ViewAffinity_HeaderFile +#define _Graphic3d_ViewAffinity_HeaderFile + +#include + +//! Structure display state. +class Graphic3d_ViewAffinity : public Standard_Transient +{ +public: + + //! Empty constructor. + Graphic3d_ViewAffinity() + { + ::memset (&myMask, 0xFF, sizeof(myMask)); + } + + //! Return visibility flag. + bool IsVisible (const Standard_Integer theViewId) const + { + const unsigned int aBit = 1 << theViewId; + return (myMask & aBit) != 0; + } + + //! Setup visibility flag. + void SetVisible (const Standard_Integer theViewId, + const bool theIsVisible) + { + const unsigned int aBit = 1 << theViewId; + if (theIsVisible) + { + myMask |= aBit; + } + else + { + myMask &= ~aBit; + } + } + +private: + + unsigned int myMask; //!< affinity mask + +public: + + DEFINE_STANDARD_RTTI(Graphic3d_ViewAffinity) + +}; + +DEFINE_STANDARD_HANDLE(Graphic3d_ViewAffinity, Standard_Transient) + +#endif // _Graphic3d_ViewAffinity_HeaderFile diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 82010a1304..6f679451c4 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -110,7 +110,7 @@ OpenGl_GraphicDriver::~OpenGl_GraphicDriver() void OpenGl_GraphicDriver::ReleaseContext() { Handle(OpenGl_Context) aCtxShared; - for (NCollection_DataMap::Iterator aWindowIter (myMapOfWS); + for (NCollection_Map::Iterator aWindowIter (myMapOfWS); aWindowIter.More(); aWindowIter.Next()) { const Handle(OpenGl_Workspace)& aWindow = aWindowIter.ChangeValue(); @@ -126,7 +126,7 @@ void OpenGl_GraphicDriver::ReleaseContext() { aCtxShared->MakeCurrent(); } - for (NCollection_DataMap::Iterator aViewIter (myMapOfView); + for (NCollection_Map::Iterator aViewIter (myMapOfView); aViewIter.More(); aViewIter.Next()) { const Handle(OpenGl_View)& aView = aViewIter.ChangeValue(); @@ -142,7 +142,7 @@ void OpenGl_GraphicDriver::ReleaseContext() myTempText->Release (aCtxShared.operator->()); myDeviceLostFlag = myDeviceLostFlag || !myMapOfStructure.IsEmpty(); - for (NCollection_DataMap::Iterator aWindowIter (myMapOfWS); + for (NCollection_Map::Iterator aWindowIter (myMapOfWS); aWindowIter.More(); aWindowIter.Next()) { const Handle(OpenGl_Workspace)& aWindow = aWindowIter.ChangeValue(); @@ -373,7 +373,7 @@ const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext() const return TheNullGlCtx; } - NCollection_DataMap::Iterator anIter (myMapOfWS); + NCollection_Map::Iterator anIter (myMapOfWS); return anIter.Value()->GetGlContext(); } diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index 6eb10a146b..cb5d482ca9 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -348,8 +348,8 @@ private: #endif Handle(OpenGl_Caps) myCaps; - NCollection_DataMap myMapOfView; - NCollection_DataMap myMapOfWS; + NCollection_Map myMapOfView; + NCollection_Map myMapOfWS; NCollection_DataMap myMapOfStructure; mutable Handle(OpenGl_PrinterContext) myPrintContext; OpenGl_UserDrawCallback_t myUserDrawCallback; diff --git a/src/OpenGl/OpenGl_GraphicDriver_7.cxx b/src/OpenGl/OpenGl_GraphicDriver_7.cxx index 24dae48e52..232eaad4ba 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_7.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_7.cxx @@ -27,7 +27,7 @@ void OpenGl_GraphicDriver::ActivateView (const Graphic3d_CView& ACView) { const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView; if (aCView) - aCView->WS->SetActiveView(aCView->View); + aCView->WS->SetActiveView(aCView->View, ACView.ViewId); } void OpenGl_GraphicDriver::AntiAliasing (const Graphic3d_CView& ACView, const Standard_Boolean AFlag) @@ -77,7 +77,7 @@ void OpenGl_GraphicDriver::DeactivateView (const Graphic3d_CView& ACView) if (aCView) { const Handle(OpenGl_View) aDummyView; - aCView->WS->SetActiveView(aDummyView); + aCView->WS->SetActiveView (aDummyView, -1); } } @@ -390,37 +390,40 @@ Standard_Boolean OpenGl_Workspace::BufferDump (OpenGl_FrameBuffer* theFB void OpenGl_GraphicDriver::RemoveView (const Graphic3d_CView& theCView) { - Handle(OpenGl_Context) aCtx = GetSharedContext(); - Handle(OpenGl_View) aView; - Handle(OpenGl_Workspace) aWindow; - if (myMapOfWS.Find (theCView.WsId, aWindow)) + Handle(OpenGl_Context) aCtx = GetSharedContext(); + OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; + if (aCView == NULL + || aCView->View.IsNull() + || aCView->WS.IsNull()) { - myMapOfWS.UnBind (theCView.WsId); + return; } - if (!aWindow.IsNull()) + + Handle(OpenGl_View) aView = aCView->View; + Handle(OpenGl_Workspace) aWindow = aCView->WS; + if (!myMapOfWS .Remove (aWindow) + || !myMapOfView.Remove (aView)) { - if (aWindow->GetGlContext()->MakeCurrent()) - { - aCtx = aWindow->GetGlContext(); - } - else - { - // try to hijack another context if any - const Handle(OpenGl_Context)& anOtherCtx = GetSharedContext(); - if (!anOtherCtx.IsNull() - && anOtherCtx != aWindow->GetGlContext()) - { - aCtx = anOtherCtx; - aCtx->MakeCurrent(); - } - } + return; } - if (myMapOfView.Find (theCView.ViewId, aView)) + + if (aWindow->GetGlContext()->MakeCurrent()) { - aView->ReleaseGlResources (aCtx); - myMapOfView.UnBind (theCView.ViewId); + aCtx = aWindow->GetGlContext(); + } + else + { + // try to hijack another context if any + const Handle(OpenGl_Context)& anOtherCtx = GetSharedContext(); + if (!anOtherCtx.IsNull() + && anOtherCtx != aWindow->GetGlContext()) + { + aCtx = anOtherCtx; + aCtx->MakeCurrent(); + } } + aView->ReleaseGlResources (aCtx); if (myMapOfWS.IsEmpty()) { // The last view removed but some objects still present. @@ -435,7 +438,6 @@ void OpenGl_GraphicDriver::RemoveView (const Graphic3d_CView& theCView) myDeviceLostFlag = !myMapOfStructure.IsEmpty(); } - OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; delete aCView; ((Graphic3d_CView *)&theCView)->ptrView = NULL; @@ -499,34 +501,30 @@ void OpenGl_GraphicDriver::InvalidateBVHData (Graphic3d_CView& theCView, const S Standard_Boolean OpenGl_GraphicDriver::View (Graphic3d_CView& theCView) { Handle(OpenGl_Context) aShareCtx = GetSharedContext(); - if (myMapOfView.IsBound (theCView.ViewId)) + OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; + if (aCView != NULL + && myMapOfView.Contains (aCView->View)) { - OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; - if (!myMapOfWS.IsBound (theCView.WsId) - || aCView == NULL) - { - return Standard_False; - } - - Handle(OpenGl_Workspace) aWS = new OpenGl_Workspace (this, theCView.DefWindow, theCView.GContext, myCaps, aShareCtx); + Handle(OpenGl_Workspace) anOldWS = aCView->WS; + Handle(OpenGl_Workspace) aWS = new OpenGl_Workspace (this, theCView.DefWindow, theCView.GContext, myCaps, aShareCtx); aCView->WS = aWS; - aWS->SetActiveView (aCView->View); + aWS->SetActiveView (aCView->View, theCView.ViewId); - myMapOfWS.UnBind (theCView.WsId); - myMapOfWS.Bind (theCView.WsId, aWS); + myMapOfWS.Remove (anOldWS); + myMapOfWS.Add (aWS); return Standard_True; } Handle(OpenGl_Workspace) aWS = new OpenGl_Workspace (this, theCView.DefWindow, theCView.GContext, myCaps, aShareCtx); Handle(OpenGl_View) aView = new OpenGl_View (theCView.Context, &myStateCounter); - myMapOfWS .Bind (theCView.WsId, aWS); - myMapOfView.Bind (theCView.ViewId, aView); + myMapOfWS .Add (aWS); + myMapOfView.Add (aView); - OpenGl_CView* aCView = new OpenGl_CView(); + aCView = new OpenGl_CView(); aCView->View = aView; aCView->WS = aWS; theCView.ptrView = aCView; - aWS->SetActiveView (aCView->View); + aWS->SetActiveView (aCView->View, theCView.ViewId); return Standard_True; } diff --git a/src/OpenGl/OpenGl_Layer.cxx b/src/OpenGl/OpenGl_Layer.cxx index 57f81419f0..5ab137cd56 100644 --- a/src/OpenGl/OpenGl_Layer.cxx +++ b/src/OpenGl/OpenGl_Layer.cxx @@ -123,6 +123,7 @@ void OpenGl_Layer::InvalidateBVHData() void OpenGl_Layer::renderAll (const Handle(OpenGl_Workspace)& theWorkspace) const { const Standard_Integer aNbPriorities = myArray.Length(); + const Standard_Integer aViewId = theWorkspace->ActiveViewId(); for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { for (OpenGl_SequenceOfStructure::Iterator aStructIter (myArray (aPriorityIter)); aStructIter.More(); aStructIter.Next()) @@ -132,6 +133,11 @@ void OpenGl_Layer::renderAll (const Handle(OpenGl_Workspace)& theWorkspace) cons { continue; } + else if (!aStruct->ViewAffinity.IsNull() + && !aStruct->ViewAffinity->IsVisible (aViewId)) + { + continue; + } aStruct->Render (theWorkspace); } @@ -154,6 +160,7 @@ void OpenGl_Layer::renderTraverse (const Handle(OpenGl_Workspace)& theWorkspace) traverse (aSelector); const Standard_Integer aNbPriorities = myArray.Length(); + const Standard_Integer aViewId = theWorkspace->ActiveViewId(); for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) { for (OpenGl_SequenceOfStructure::Iterator aStructIter (myArray (aPriorityIter)); aStructIter.More(); aStructIter.Next()) @@ -164,6 +171,11 @@ void OpenGl_Layer::renderTraverse (const Handle(OpenGl_Workspace)& theWorkspace) { continue; } + else if (!aStruct->ViewAffinity.IsNull() + && !aStruct->ViewAffinity->IsVisible (aViewId)) + { + continue; + } aStruct->Render (theWorkspace); aStruct->ResetCullingStatus(); diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index d9f8cca982..88e073d850 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -154,6 +154,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_GraphicDriver)& theDrive // myRaytraceFilter (new OpenGl_RaytraceFilter()), myToRedrawGL (Standard_True), + myViewId (-1), myAntiAliasingMode (3), myTransientDrawToFront (Standard_True), myBackBufferRestored (Standard_False), diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 2c8523f664..4b36fc4d7f 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -140,8 +140,16 @@ public: //! Destructor virtual ~OpenGl_Workspace(); - void SetActiveView (const Handle(OpenGl_View)& theView) { myView = theView; } - const Handle(OpenGl_View)& ActiveView () const { return myView; } + void SetActiveView (const Handle(OpenGl_View)& theView, + const Standard_Integer theViewId) + { + myView = theView; + myViewId = theViewId; + } + + const Handle(OpenGl_View)& ActiveView() const { return myView; } + + Standard_Integer ActiveViewId() const { return myViewId; } //! Redraw the window. void Redraw (const Graphic3d_CView& theCView, @@ -658,6 +666,7 @@ protected: //! @name protected fields Handle(OpenGl_PrinterContext) myPrintContext; Handle(OpenGl_View) myView; Handle(OpenGl_LineAttributes) myLineAttribs; + Standard_Integer myViewId; Standard_Integer myAntiAliasingMode; Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer) Standard_Boolean myBackBufferRestored; diff --git a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx index 2f1118f596..33435e67b8 100644 --- a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx +++ b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx @@ -96,6 +96,11 @@ Standard_Boolean OpenGl_Workspace::UpdateRaytraceGeometry (GeomUpdateMode theMod { continue; } + else if (!aStructure->ViewAffinity.IsNull() + && !aStructure->ViewAffinity->IsVisible (myViewId)) + { + continue; + } for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next()) { diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cdl b/src/PrsMgr/PrsMgr_PresentationManager.cdl index 52dfb9394b..cc0f813a39 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cdl +++ b/src/PrsMgr/PrsMgr_PresentationManager.cdl @@ -169,7 +169,8 @@ is Color (me : mutable; thePrsObject : PresentableObject from PrsMgr; theColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; - theMode : Integer from Standard = 0) + theMode : Integer from Standard = 0; + theSelObj : PresentableObject from PrsMgr = NULL) ---Purpose: Highlights the graphic object thePrsObject in the color theColor. -- thePrsObject has the display mode theMode; -- this has the default value of 0, that is, the wireframe display mode. @@ -235,11 +236,13 @@ is Presentation (me; thePrsObject : PresentableObject from PrsMgr; theMode : Integer from Standard = 0; - theToCreate : Boolean from Standard = Standard_False) + theToCreate : Boolean from Standard = Standard_False; + theSelObj : PresentableObject from PrsMgr = NULL) returns Presentation from PrsMgr is static; ---Purpose: Returns the presentation Presentation of the presentable object thePrsObject in this framework. -- When theToCreate is true - automatically creates presentation for specified mode when not exist. + -- Optional argument theSelObj specifies parent decomposed object to inherit its view affinity. RemovePresentation (me : mutable; thePrsObject : PresentableObject from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 83bb668a39..702faad79a 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -405,7 +405,8 @@ Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMg // ======================================================================= Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Standard_Integer theMode, - const Standard_Boolean theToCreate) const + const Standard_Boolean theToCreate, + const Handle(PrsMgr_PresentableObject)& theSelObj) const { const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) @@ -426,6 +427,7 @@ Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Hand Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation (this, thePrsObj); aPrs->SetZLayer (thePrsObj->ZLayer()); + aPrs->Presentation()->CStructure()->ViewAffinity = myStructureManager->ObjectAffinity (!theSelObj.IsNull() ? theSelObj : thePrsObj); thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode)); thePrsObj->Fill (this, aPrs, theMode); @@ -516,7 +518,8 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec // ======================================================================= void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, const Quantity_NameOfColor theColor, - const Standard_Integer theMode) + const Standard_Integer theMode, + const Handle(PrsMgr_PresentableObject)& theSelObj) { for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) { @@ -527,7 +530,7 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& return; } - Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True, theSelObj); if (aPrs->MustBeUpdated()) { Update (thePrsObj, theMode); diff --git a/src/SelectMgr/FILES b/src/SelectMgr/FILES index e3e59f51e3..076e4ef840 100755 --- a/src/SelectMgr/FILES +++ b/src/SelectMgr/FILES @@ -1 +1 @@ -SelectMgr_CompareResults.hxx \ No newline at end of file +SelectMgr_CompareResults.hxx diff --git a/src/SelectMgr/SelectMgr_OrFilter.cdl b/src/SelectMgr/SelectMgr_OrFilter.cdl index 0daba7fa81..78da7249c4 100644 --- a/src/SelectMgr/SelectMgr_OrFilter.cdl +++ b/src/SelectMgr/SelectMgr_OrFilter.cdl @@ -23,9 +23,10 @@ class OrFilter from SelectMgr inherits CompositionFilter from SelectMgr -- This selects one or another type of sensitive entity. uses - Filter from SelectMgr, - Transient from Standard, - EntityOwner from SelectMgr + Filter from SelectMgr, + Transient from Standard, + EntityOwner from SelectMgr, + NMapOfTransient from Graphic3d is @@ -35,4 +36,12 @@ is IsOk(me; anobj : EntityOwner from SelectMgr) returns Boolean from Standard ; + SetDisabledObjects (me : mutable; + theObjects : NMapOfTransient from Graphic3d) is static; + ---Purpose: Disable selection of specified objects. + +fields + + myDisabledObjects : NMapOfTransient from Graphic3d; + end OrFilter; diff --git a/src/SelectMgr/SelectMgr_OrFilter.cxx b/src/SelectMgr/SelectMgr_OrFilter.cxx index f87fb0cdcd..d1046680e3 100644 --- a/src/SelectMgr/SelectMgr_OrFilter.cxx +++ b/src/SelectMgr/SelectMgr_OrFilter.cxx @@ -16,19 +16,49 @@ #include #include +#include + +//============================================================================= +//function : SelectMgr_OrFilter +//purpose : +//============================================================================= SelectMgr_OrFilter::SelectMgr_OrFilter() { } - -Standard_Boolean SelectMgr_OrFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const +//============================================================================= +//function : SetDisabledObjects +//purpose : +//============================================================================= +void SelectMgr_OrFilter::SetDisabledObjects (const Handle(Graphic3d_NMapOfTransient)& theObjects) { + myDisabledObjects = theObjects; +} - if(myFilters.IsEmpty()) +//============================================================================= +//function : IsOk +//purpose : +//============================================================================= +Standard_Boolean SelectMgr_OrFilter::IsOk (const Handle(SelectMgr_EntityOwner)& theObj) const +{ + const SelectMgr_SelectableObject* aSelectable = theObj->Selectable().operator->(); + if (!myDisabledObjects.IsNull() + && myDisabledObjects->Contains (aSelectable)) + { + return Standard_False; + } + else if (myFilters.IsEmpty()) + { return Standard_True; - SelectMgr_ListIteratorOfListOfFilter it(myFilters); - for ( ; it.More();it.Next()) - if(it.Value()->IsOk(anobj)) + } + + for (SelectMgr_ListIteratorOfListOfFilter aFilterIter (myFilters); aFilterIter.More(); aFilterIter.Next()) + { + if (aFilterIter.Value()->IsOk (theObj)) + { return Standard_True; + } + } + return Standard_False; } diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index a4e3a7ebf0..fb3feffaef 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -149,14 +149,18 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag } // highlight with color and set layer - PM->Color (myPrsSh, aCol, M); + PM->Color (myPrsSh, aCol, M, aSel); } else { - if(myPrsSh.IsNull()) - PM->Color(aSel, aCol, M); + if (!myPrsSh.IsNull()) + { + PM->Color (myPrsSh, aCol, M, aSel); + } else - PM->Color(myPrsSh,aCol,M); + { + PM->Color (aSel, aCol, M); + } } } diff --git a/src/V3d/V3d.cdl b/src/V3d/V3d.cdl index 2346113ea0..7d1f50d931 100644 --- a/src/V3d/V3d.cdl +++ b/src/V3d/V3d.cdl @@ -35,6 +35,7 @@ uses TColStd, Graphic3d, Visual3d, + SelectMgr, MMgt, TCollection, Quantity, diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 60505dc2c8..15008ec52c 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -2513,7 +2513,8 @@ int VErase (Draw_Interpretor& theDI, const Standard_Boolean toEraseAll = TCollection_AsciiString (theArgNb > 0 ? theArgVec[0] : "") == "veraseall"; Standard_Integer anArgIter = 1; - Standard_Boolean toEraseLocal = Standard_False; + Standard_Boolean toEraseLocal = Standard_False; + Standard_Boolean toEraseInView = Standard_False; TColStd_SequenceOfAsciiString aNamesOfEraseIO; for (; anArgIter < theArgNb; ++anArgIter) { @@ -2527,6 +2528,11 @@ int VErase (Draw_Interpretor& theDI, { toEraseLocal = Standard_True; } + else if (anArgCase == "-view" + || anArgCase == "-inview") + { + toEraseInView = Standard_True; + } else { aNamesOfEraseIO.Append (theArgVec[anArgIter]); @@ -2565,7 +2571,14 @@ int VErase (Draw_Interpretor& theDI, theDI << aName.ToCString() << " "; if (!anIO.IsNull()) { - aCtx->Erase (anIO, Standard_False); + if (toEraseInView) + { + aCtx->SetViewAffinity (anIO, aView, Standard_False); + } + else + { + aCtx->Erase (anIO, Standard_False); + } } else { @@ -2588,7 +2601,14 @@ int VErase (Draw_Interpretor& theDI, && aCtx->IsCurrent (anIO)) { theDI << anIter.Key2().ToCString() << " "; - aCtx->Erase (anIO, Standard_False); + if (toEraseInView) + { + aCtx->SetViewAffinity (anIO, aView, Standard_False); + } + else + { + aCtx->Erase (anIO, Standard_False); + } } } } @@ -2601,7 +2621,14 @@ int VErase (Draw_Interpretor& theDI, const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); if (!anIO.IsNull()) { - aCtx->Erase (anIO, Standard_False); + if (toEraseInView) + { + aCtx->SetViewAffinity (anIO, aView, Standard_False); + } + else + { + aCtx->Erase (anIO, Standard_False); + } } else { @@ -3194,6 +3221,7 @@ static int VDisplay2 (Draw_Interpretor& theDI, Standard_Boolean toReDisplay = Standard_False; TColStd_SequenceOfAsciiString aNamesOfDisplayIO; AIS_DisplayStatus aDispStatus = AIS_DS_None; + Standard_Integer toDisplayInView = Standard_False; for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) { const TCollection_AsciiString aName = theArgVec[anArgIter]; @@ -3242,6 +3270,11 @@ static int VDisplay2 (Draw_Interpretor& theDI, aZLayer = aValue.IntegerValue(); } + else if (aNameCase == "-view" + || aNameCase == "-inview") + { + toDisplayInView = Standard_True; + } else if (aNameCase == "-local") { aDispStatus = AIS_DS_Temporary; @@ -3305,6 +3338,14 @@ static int VDisplay2 (Draw_Interpretor& theDI, aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aShape->AcceptShapeDecomposition(), aDispStatus); + if (toDisplayInView) + { + for (aCtx->CurrentViewer()->InitDefinedViews(); aCtx->CurrentViewer()->MoreDefinedViews(); aCtx->CurrentViewer()->NextDefinedViews()) + { + aCtx->SetViewAffinity (aShape, aCtx->CurrentViewer()->DefinedView(), Standard_False); + } + aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); + } } continue; } @@ -3357,6 +3398,10 @@ static int VDisplay2 (Draw_Interpretor& theDI, aCtx->Display (aShape, aDispMode, aSelMode, Standard_False, aShape->AcceptShapeDecomposition(), aDispStatus); + if (toDisplayInView) + { + aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True); + } } } else if (anObj->IsKind (STANDARD_TYPE (NIS_InteractiveObject))) diff --git a/src/Visual3d/Visual3d_View.cdl b/src/Visual3d/Visual3d_View.cdl index ec3d457382..9405974201 100644 --- a/src/Visual3d/Visual3d_View.cdl +++ b/src/Visual3d/Visual3d_View.cdl @@ -105,6 +105,7 @@ uses AsciiString from TCollection, ExtendedString from TCollection, CGraduatedTrihedron from Graphic3d, + NMapOfTransient from Graphic3d, TypeOfStructure from Graphic3d, PixMap from Image, @@ -1152,6 +1153,16 @@ is -- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer). -- Notice however that results may differ a lot and do not contain some elements. + HiddenObjects (me) returns NMapOfTransient from Graphic3d is static; + ---C++: return const & + ---Level: Public + ---Purpose: Returns map of objects hidden within this specific view (not viewer-wise). + + ChangeHiddenObjects (me : mutable) returns NMapOfTransient from Graphic3d is static; + ---C++: return & + ---Level: Public + ---Purpose: Returns map of objects hidden within this specific view (not viewer-wise). + fields -- the ViewManager associated with the view @@ -1193,6 +1204,8 @@ fields myStructuresUpdated : Boolean from Standard; + myHiddenObjects : NMapOfTransient from Graphic3d; + friends class ViewManager from Visual3d diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index a25e99d561..7bfe697c81 100644 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -53,6 +53,8 @@ Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& theMgr) myAutoZFitScaleFactor (1.0), myStructuresUpdated (Standard_True) { + myHiddenObjects = new Graphic3d_NMapOfTransient(); + MyCView.ViewId = theMgr->Identification (this); MyCView.Active = 0; MyCView.IsDeleted = 0; @@ -1735,6 +1737,7 @@ Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet, const Standard_Boolean theToIgnoreInfiniteFlag) const { Bnd_Box aResult; + const Standard_Integer aViewId = MyCView.ViewId; for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next()) { const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key(); @@ -1742,6 +1745,11 @@ Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet, { continue; } + else if (!aStructIter.Value()->CStructure()->ViewAffinity.IsNull() + && !aStructIter.Value()->CStructure()->ViewAffinity->IsVisible (aViewId)) + { + continue; + } addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult); } @@ -2690,3 +2698,21 @@ Standard_Boolean Visual3d_View::Print (const Handle(Visual3d_Layer)& theUnderLay thePrintDC, theToShowBackground, theFilename, thePrintAlgorithm, theScaleFactor); } + +//============================================================================= +//function : HiddenObjects +//purpose : +//============================================================================= +const Handle(Graphic3d_NMapOfTransient)& Visual3d_View::HiddenObjects() const +{ + return myHiddenObjects; +} + +//============================================================================= +//function : HiddenObjects +//purpose : +//============================================================================= +Handle(Graphic3d_NMapOfTransient)& Visual3d_View::ChangeHiddenObjects() +{ + return myHiddenObjects; +} diff --git a/src/Visual3d/Visual3d_ViewManager.cxx b/src/Visual3d/Visual3d_ViewManager.cxx index bb8d59cb3e..acc6cfee52 100644 --- a/src/Visual3d/Visual3d_ViewManager.cxx +++ b/src/Visual3d/Visual3d_ViewManager.cxx @@ -81,7 +81,7 @@ Visual3d_ViewManager::Visual3d_ViewManager (const Handle(Graphic3d_GraphicDriver)& theDriver): Graphic3d_StructureManager (theDriver), MyDefinedView (), -MyViewGenId (View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*(Visual3d_ViewManager::CurrentId ()-1),View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()))*Visual3d_ViewManager::CurrentId ()-1), +MyViewGenId (0, 31), MyZBufferAuto (Standard_False), myZLayerGenId (1, IntegerLast()) { diff --git a/tests/bugs/vis/bug25552 b/tests/bugs/vis/bug25552 new file mode 100644 index 0000000000..1a518e5fff --- /dev/null +++ b/tests/bugs/vis/bug25552 @@ -0,0 +1,68 @@ +puts "============" +puts "CR25552" +puts "Provide the way to hide objects within different Views of the one Viewer" +puts "============" +puts "" + +set aSubShapeTriang $imagedir/${casename}_subshape_triangulation.png +set aShapeTriang $imagedir/${casename}_shape_triangulation.png +set aDiff $imagedir/${casename}_diff.png + +vinit View1 +vclear +vaxo +vsetdispmode 1 + +vinit View2 +vclear +vaxo +vsetdispmode 1 + +box b1 0 0 0 1 2 3 +box b2 3 0 0 2 3 1 +box b3 0 3 0 2 3 1 + +vdisplay b1 b3 +# b2 should be displayed only in View2, but not in View1 +vdisplay -inview b2 +#vdisplay b2 +vaspects -noupdate b1 -setcolor RED +vaspects -noupdate b2 -setcolor GREEN +vfit +# b1 should be displayed only in View1 +verase -inview b1 +vmoveto 250 350 + +set aColorV2B1 [vreadpixel 50 250 rgb name] +if { $aColorV2B1 != "BLACK" } { + puts "Error: box b1 (red) should NOT be visible in View2!" +} + +set aColorV2B2 [vreadpixel 200 350 rgb name] +if { $aColorV2B2 != "GREEN3" } { + puts "Error: box b2 (green) should be visible in View2!" +} + +set aColorV2B3 [vreadpixel 250 200 rgb name] +if { $aColorV2B3 != "DARKGOLDENROD3" } { + puts "Error: box b3 (goldenrod) should be visible in View2!" +} +vdump $imagedir/${casename}_v2.png + +vactivate View1 +vfit +set aColorV1B1 [vreadpixel 50 250 rgb name] +if { $aColorV1B1 != "RED3" } { + puts "Error: box b1 (red) should be visible in View1!" +} + +set aColorV1B2 [vreadpixel 200 350 rgb name] +if { $aColorV1B2 != "BLACK" } { + puts "Error: box b2 (green) should NOT be visible in View1!" +} + +set aColorV1B3 [vreadpixel 250 200 rgb name] +if { $aColorV1B3 != "DARKGOLDENROD3" } { + puts "Error: box b3 (goldenrod) should be visible in View1!" +} +vdump $imagedir/${casename}_v1.png -- 2.39.5