---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;
}
}
+//=======================================================================
+//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<const Graphic3d_CView* >(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 :
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<const Graphic3d_CView* >(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 :
{
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)
{
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)
#include <V3d_SpotLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_AmbientLight.hxx>
+#include <Visual3d_View.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <SelectMgr_Selection.hxx>
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
#include <SelectBasics_SensitiveEntity.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
+#include <Visual3d_View.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
#include <SelectMgr_Selection.hxx>
myCurDetected = 0;
myDetectedSeq.Clear();
+ myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
myMainVS->Pick (theXpix, theYpix, theView);
const Standard_Integer aDetectedNb = myMainVS->NbPicked();
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
Graphic3d_Camera.hxx
Graphic3d_Camera_Handle.hxx
Graphic3d_RenderingParams.hxx
+Graphic3d_NMapOfTransient.hxx
imported Vertex;
---Category: Classes
+ imported transient class ViewAffinity;
+ imported MapOfObject;
+ imported transient class NMapOfTransient;
+
imported MapOfStructure;
imported SequenceOfDisplayedStructures;
#include <Graphic3d_SequenceOfGroup.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_TypeOfComposition.hxx>
+#include <Graphic3d_ViewAffinity.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <Standard_Transient.hxx>
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;
--- /dev/null
+// 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 <Graphic3d_ViewAffinity.hxx>
+#include <NCollection_DataMap.hxx>
+
+typedef NCollection_DataMap<const Standard_Transient* , Handle(Graphic3d_ViewAffinity)> Graphic3d_MapOfObject;
+
+#endif // _Graphic3d_MapOfObject
--- /dev/null
+// 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 <Standard_Transient.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_Handle.hxx>
+
+typedef NCollection_Map<const Standard_Transient* > Graphic3d_NMapOfTransient;
+typedef NCollection_Handle<Graphic3d_NMapOfTransient> Handle(Graphic3d_NMapOfTransient);
+
+#endif // _Graphic3d_NMapOfTransient_HeaderFile
AspectText3d from Graphic3d,
Structure from Graphic3d,
MapOfStructure from Graphic3d,
+ MapOfObject from Graphic3d,
+ ViewAffinity from Graphic3d,
SequenceOfStructure from Graphic3d,
GraphicDriver from Graphic3d
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
MyDisplayedStructure : MapOfStructure from Graphic3d
is protected;
+ myRegisteredObjects : MapOfObject from Graphic3d is protected;
+
-- the highlighted structures
MyHighlightedStructure : MapOfStructure from Graphic3d
is protected;
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;
+}
--- /dev/null
+// 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 <Graphic3d_ViewAffinity.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (Graphic3d_ViewAffinity, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ViewAffinity, Standard_Transient)
--- /dev/null
+// 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 <Graphic3d_Structure.hxx>
+
+//! 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
void OpenGl_GraphicDriver::ReleaseContext()
{
Handle(OpenGl_Context) aCtxShared;
- for (NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>::Iterator aWindowIter (myMapOfWS);
+ for (NCollection_Map<Handle(OpenGl_Workspace)>::Iterator aWindowIter (myMapOfWS);
aWindowIter.More(); aWindowIter.Next())
{
const Handle(OpenGl_Workspace)& aWindow = aWindowIter.ChangeValue();
{
aCtxShared->MakeCurrent();
}
- for (NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)>::Iterator aViewIter (myMapOfView);
+ for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIter (myMapOfView);
aViewIter.More(); aViewIter.Next())
{
const Handle(OpenGl_View)& aView = aViewIter.ChangeValue();
myTempText->Release (aCtxShared.operator->());
myDeviceLostFlag = myDeviceLostFlag || !myMapOfStructure.IsEmpty();
- for (NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>::Iterator aWindowIter (myMapOfWS);
+ for (NCollection_Map<Handle(OpenGl_Workspace)>::Iterator aWindowIter (myMapOfWS);
aWindowIter.More(); aWindowIter.Next())
{
const Handle(OpenGl_Workspace)& aWindow = aWindowIter.ChangeValue();
return TheNullGlCtx;
}
- NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>::Iterator anIter (myMapOfWS);
+ NCollection_Map<Handle(OpenGl_Workspace)>::Iterator anIter (myMapOfWS);
return anIter.Value()->GetGlContext();
}
#endif
Handle(OpenGl_Caps) myCaps;
- NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)> myMapOfView;
- NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)> myMapOfWS;
+ NCollection_Map<Handle(OpenGl_View)> myMapOfView;
+ NCollection_Map<Handle(OpenGl_Workspace)> myMapOfWS;
NCollection_DataMap<Standard_Integer, OpenGl_Structure*> myMapOfStructure;
mutable Handle(OpenGl_PrinterContext) myPrintContext;
OpenGl_UserDrawCallback_t myUserDrawCallback;
{
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)
if (aCView)
{
const Handle(OpenGl_View) aDummyView;
- aCView->WS->SetActiveView(aDummyView);
+ aCView->WS->SetActiveView (aDummyView, -1);
}
}
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.
myDeviceLostFlag = !myMapOfStructure.IsEmpty();
}
- OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView;
delete aCView;
((Graphic3d_CView *)&theCView)->ptrView = NULL;
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;
}
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())
{
continue;
}
+ else if (!aStruct->ViewAffinity.IsNull()
+ && !aStruct->ViewAffinity->IsVisible (aViewId))
+ {
+ continue;
+ }
aStruct->Render (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())
{
continue;
}
+ else if (!aStruct->ViewAffinity.IsNull()
+ && !aStruct->ViewAffinity->IsVisible (aViewId))
+ {
+ continue;
+ }
aStruct->Render (theWorkspace);
aStruct->ResetCullingStatus();
//
myRaytraceFilter (new OpenGl_RaytraceFilter()),
myToRedrawGL (Standard_True),
+ myViewId (-1),
myAntiAliasingMode (3),
myTransientDrawToFront (Standard_True),
myBackBufferRestored (Standard_False),
//! 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,
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;
{
continue;
}
+ else if (!aStructure->ViewAffinity.IsNull()
+ && !aStructure->ViewAffinity->IsVisible (myViewId))
+ {
+ continue;
+ }
for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next())
{
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.
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;
// =======================================================================
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)
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);
// =======================================================================
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())
{
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);
-SelectMgr_CompareResults.hxx
\ No newline at end of file
+SelectMgr_CompareResults.hxx
-- 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
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;
#include <SelectMgr_Filter.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+#include <SelectMgr_SelectableObject.hxx>
+
+//=============================================================================
+//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;
}
}
// 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);
+ }
}
}
TColStd,
Graphic3d,
Visual3d,
+ SelectMgr,
MMgt,
TCollection,
Quantity,
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)
{
{
toEraseLocal = Standard_True;
}
+ else if (anArgCase == "-view"
+ || anArgCase == "-inview")
+ {
+ toEraseInView = Standard_True;
+ }
else
{
aNamesOfEraseIO.Append (theArgVec[anArgIter]);
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
{
&& 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);
+ }
}
}
}
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
{
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];
aZLayer = aValue.IntegerValue();
}
+ else if (aNameCase == "-view"
+ || aNameCase == "-inview")
+ {
+ toDisplayInView = Standard_True;
+ }
else if (aNameCase == "-local")
{
aDispStatus = AIS_DS_Temporary;
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;
}
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)))
AsciiString from TCollection,
ExtendedString from TCollection,
CGraduatedTrihedron from Graphic3d,
+ NMapOfTransient from Graphic3d,
TypeOfStructure from Graphic3d,
PixMap from Image,
-- 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
myStructuresUpdated : Boolean from Standard;
+ myHiddenObjects : NMapOfTransient from Graphic3d;
+
friends
class ViewManager from Visual3d
myAutoZFitScaleFactor (1.0),
myStructuresUpdated (Standard_True)
{
+ myHiddenObjects = new Graphic3d_NMapOfTransient();
+
MyCView.ViewId = theMgr->Identification (this);
MyCView.Active = 0;
MyCView.IsDeleted = 0;
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();
{
continue;
}
+ else if (!aStructIter.Value()->CStructure()->ViewAffinity.IsNull()
+ && !aStructIter.Value()->CStructure()->ViewAffinity->IsVisible (aViewId))
+ {
+ continue;
+ }
addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult);
}
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;
+}
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())
{
--- /dev/null
+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