mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-07 18:30:55 +03:00
0022795: Make possible to display some presentable objects in overlay of others, groupped by display priority
This commit is contained in:
parent
f8b2ed3650
commit
59f45b7cef
@ -406,6 +406,26 @@ is
|
|||||||
---Purpose: Sets the display priority aPriority of the seen parts
|
---Purpose: Sets the display priority aPriority of the seen parts
|
||||||
-- presentation of the entity anIobj.
|
-- presentation of the entity anIobj.
|
||||||
|
|
||||||
|
SetZLayer( me : mutable;
|
||||||
|
theIObj : InteractiveObject from AIS;
|
||||||
|
theLayerId : Integer from Standard );
|
||||||
|
---Purpose: Set Z layer id for interactive object. The layer can be
|
||||||
|
-- specified for displayed object only. The Z layers can be used to display
|
||||||
|
-- temporarily presentations of some object in front of the other objects
|
||||||
|
-- in the scene. The ids for Z layers are generated by V3d_Viewer.
|
||||||
|
-- Note that Z layers differ from under-/overlayer in V3d_View:
|
||||||
|
-- under-/overlayer are intended for specific 2D drawings that appear
|
||||||
|
-- behind/in front of all 3D presentations, while SetZLayer() method
|
||||||
|
-- applies to regular 3D presentations and does not imply any specific
|
||||||
|
-- drawing methods.
|
||||||
|
|
||||||
|
GetZLayer( me;
|
||||||
|
theIObj : InteractiveObject from AIS )
|
||||||
|
returns Integer from Standard;
|
||||||
|
---Purpose: Get Z layer id set for displayed interactive object.
|
||||||
|
-- If the object doesn't exists in context or has no computed presentations,
|
||||||
|
-- the method returns -1.
|
||||||
|
|
||||||
Redisplay(me : mutable;
|
Redisplay(me : mutable;
|
||||||
aniobj : InteractiveObject from AIS;
|
aniobj : InteractiveObject from AIS;
|
||||||
updateviewer : Boolean from Standard = Standard_True;
|
updateviewer : Boolean from Standard = Standard_True;
|
||||||
|
@ -3147,3 +3147,54 @@ Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
|
|||||||
{
|
{
|
||||||
return myIsAutoActivateSelMode;
|
return myIsAutoActivateSelMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (theIObj.IsNull ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (myObjects.IsBound (theIObj))
|
||||||
|
{
|
||||||
|
switch (myObjects (theIObj)->GraphicStatus ())
|
||||||
|
{
|
||||||
|
case AIS_DS_Displayed:
|
||||||
|
{
|
||||||
|
theIObj->SetZLayer (myMainPM, theLayerId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AIS_DS_Erased:
|
||||||
|
{
|
||||||
|
theIObj->SetZLayer (myCollectorPM, theLayerId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (HasOpenedContext ())
|
||||||
|
{
|
||||||
|
myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
|
||||||
|
{
|
||||||
|
if (theIObj.IsNull ())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (myObjects.IsBound (theIObj))
|
||||||
|
return theIObj->GetZLayer (myMainPM);
|
||||||
|
|
||||||
|
return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);
|
||||||
|
}
|
||||||
|
@ -373,6 +373,26 @@ is
|
|||||||
anObject: InteractiveObject from AIS;
|
anObject: InteractiveObject from AIS;
|
||||||
Prior : Integer from Standard);
|
Prior : Integer from Standard);
|
||||||
|
|
||||||
|
SetZLayer( me : mutable;
|
||||||
|
theIObj : InteractiveObject from AIS;
|
||||||
|
theLayerId : Integer from Standard );
|
||||||
|
---Purpose: Set Z layer id for interactive object. The layer can be
|
||||||
|
-- specified for displayed object only. The Z layers can be used to display
|
||||||
|
-- temporarily presentations of some object in front of the other objects
|
||||||
|
-- in the scene. The ids for Z layers are generated by V3d_Viewer.
|
||||||
|
-- Note that Z layers differ from under-/overlayer in V3d_View:
|
||||||
|
-- under-/overlayer are intended for specific 2D drawings that appear
|
||||||
|
-- behind/in front of all 3D presentations, while SetZLayer() method
|
||||||
|
-- applies to regular 3D presentations and does not imply any specific
|
||||||
|
-- drawing methods.
|
||||||
|
|
||||||
|
GetZLayer( me;
|
||||||
|
theIObj : InteractiveObject from AIS )
|
||||||
|
returns Integer from Standard;
|
||||||
|
---Purpose: Get Z layer id set for displayed interactive object.
|
||||||
|
-- If the object doesn't exists in context or has no computed presentations,
|
||||||
|
-- the method returns -1.
|
||||||
|
|
||||||
DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
|
DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
|
||||||
returns Integer from Standard;
|
returns Integer from Standard;
|
||||||
|
|
||||||
|
@ -881,7 +881,6 @@ void AIS_LocalContext::SetDisplayPriority(const Handle(AIS_InteractiveObject)& a
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DisplayedObjects
|
//function : DisplayedObjects
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -1220,3 +1219,34 @@ void AIS_LocalContext::SetSensitivity(const Standard_Integer aPrecision) {
|
|||||||
myMainVS->Set(aPrecision);
|
myMainVS->Set(aPrecision);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_LocalContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!myActiveObjects.IsBound (theIObj))
|
||||||
|
return;
|
||||||
|
|
||||||
|
const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theIObj);
|
||||||
|
if (aStatus->DisplayMode () == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
theIObj->SetZLayer (myMainPM, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer AIS_LocalContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
|
||||||
|
{
|
||||||
|
if (!myActiveObjects.IsBound (theIObj))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return theIObj->GetZLayer (myMainPM);
|
||||||
|
}
|
||||||
|
@ -1287,6 +1287,52 @@ is
|
|||||||
-- <theCGroup>. This method is internal and should be used
|
-- <theCGroup>. This method is internal and should be used
|
||||||
-- by Graphic3d_Group only.
|
-- by Graphic3d_Group only.
|
||||||
|
|
||||||
|
AddZLayer( me : mutable;
|
||||||
|
theCView : CView from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Add a new top-level z layer with ID <theLayerId> for
|
||||||
|
-- the view. Z layers allow drawing structures in higher layers
|
||||||
|
-- in foreground of structures in lower layers. To add a structure
|
||||||
|
-- to desired layer on display it is necessary to set the layer
|
||||||
|
-- ID for the structure.
|
||||||
|
|
||||||
|
RemoveZLayer( me : mutable;
|
||||||
|
theCView : CView from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Remove Z layer from the specified view. All structures
|
||||||
|
-- displayed at the moment in layer will be displayed in default layer
|
||||||
|
-- ( the bottom-level z layer ). To unset layer ID from associated
|
||||||
|
-- structures use method UnsetZLayer (...).
|
||||||
|
|
||||||
|
UnsetZLayer( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Unset Z layer ID for all structures. The structure
|
||||||
|
-- indexes will be set to default layer ( the bottom-level z layer
|
||||||
|
-- with ID = 0 ).
|
||||||
|
|
||||||
|
ChangeZLayer( me : mutable;
|
||||||
|
theCStructure : CStructure from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Change Z layer of a structure. The new z layer ID will
|
||||||
|
-- be used to define the associated layer for structure on display.
|
||||||
|
|
||||||
|
ChangeZLayer( me : mutable;
|
||||||
|
theCStructure : CStructure from Graphic3d;
|
||||||
|
theCView : CView from Graphic3d;
|
||||||
|
theNewLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Change Z layer of a structure already presented in view.
|
||||||
|
|
||||||
|
GetZLayer( me;
|
||||||
|
theCStructure : CStructure from Graphic3d )
|
||||||
|
returns Integer from Standard is deferred;
|
||||||
|
---Purpose: Get Z layer ID of structure. If the structure doesn't
|
||||||
|
-- exists in graphic driver, the method returns -1.
|
||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
-- Category: Class methods
|
-- Category: Class methods
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -242,6 +242,19 @@ is
|
|||||||
-- method erase <me> and display <me> with the
|
-- method erase <me> and display <me> with the
|
||||||
-- previous priority.
|
-- previous priority.
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is static;
|
||||||
|
---Purpose: Set Z layer ID for the structure. The Z layer mechanism
|
||||||
|
-- allows to display structures presented in higher layers in overlay
|
||||||
|
-- of structures in lower layers by switching off z buffer depth
|
||||||
|
-- test between layers
|
||||||
|
|
||||||
|
GetZLayer ( me )
|
||||||
|
returns Integer from Standard is static;
|
||||||
|
---Purpose: Get Z layer ID of displayed structure. The method
|
||||||
|
-- returns -1 if the structure has no ID (deleted from graphic driver).
|
||||||
|
|
||||||
SetPick ( me : mutable;
|
SetPick ( me : mutable;
|
||||||
AValue : Boolean from Standard )
|
AValue : Boolean from Standard )
|
||||||
is static;
|
is static;
|
||||||
|
@ -2553,3 +2553,27 @@ Standard_Address Graphic3d_Structure::CStructure () const {
|
|||||||
return Standard_Address (&MyCStructure);
|
return Standard_Address (&MyCStructure);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Graphic3d_Structure::SetZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
// if the structure is not displayed, unable to change its display layer
|
||||||
|
if (IsDeleted ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MyStructureManager->ChangeZLayer (this, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer Graphic3d_Structure::GetZLayer () const
|
||||||
|
{
|
||||||
|
return MyStructureManager->GetZLayer (this);
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@ deferred class StructureManager from Graphic3d inherits TShared
|
|||||||
uses
|
uses
|
||||||
|
|
||||||
Array2OfReal from TColStd,
|
Array2OfReal from TColStd,
|
||||||
|
SequenceOfInteger from TColStd,
|
||||||
|
|
||||||
GenId from Aspect,
|
GenId from Aspect,
|
||||||
GraphicDevice from Aspect,
|
GraphicDevice from Aspect,
|
||||||
@ -272,6 +273,43 @@ is
|
|||||||
---Purpose: Changes the display priority of the structure <AStructure>.
|
---Purpose: Changes the display priority of the structure <AStructure>.
|
||||||
---Category: Private methods
|
---Category: Private methods
|
||||||
|
|
||||||
|
ChangeZLayer ( me : mutable;
|
||||||
|
theStructure : Structure from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Change Z layer for structure. The z layer mechanism allows
|
||||||
|
-- to display structures in higher layers in overlay of structures in
|
||||||
|
-- lower layers.
|
||||||
|
|
||||||
|
GetZLayer ( me;
|
||||||
|
theStructure : Structure from Graphic3d )
|
||||||
|
returns Integer from Standard is deferred;
|
||||||
|
---Purpose: Get Z layer ID assigned to structure. If the structure
|
||||||
|
-- has no layer ID (deleted from graphic driver), the method returns -1.
|
||||||
|
|
||||||
|
AddZLayer ( me : mutable;
|
||||||
|
theLayerId : in out Integer from Standard )
|
||||||
|
returns Boolean from Standard is deferred;
|
||||||
|
---Purpose: Add a new top-level Z layer and get its ID as
|
||||||
|
-- <theLayerId> value. The method returns Standard_False if the layer
|
||||||
|
-- can not be created. The z layer mechanism allows to display
|
||||||
|
-- structures in higher layers in overlay of structures in lower layers.
|
||||||
|
|
||||||
|
RemoveZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
returns Boolean from Standard is deferred;
|
||||||
|
---Purpose: Remove Z layer with ID <theLayerId>. Method returns
|
||||||
|
-- Standard_False if the layer can not be removed or doesn't exists.
|
||||||
|
-- By default, there is always a default bottom-level layer that can't
|
||||||
|
-- be removed.
|
||||||
|
|
||||||
|
GetAllZLayers ( me;
|
||||||
|
theLayerSeq : out SequenceOfInteger from TColStd )
|
||||||
|
is deferred;
|
||||||
|
---Purpose: Return all Z layer ids in sequence ordered by level
|
||||||
|
-- from lowest layer to highest. The first layer ID in sequence is
|
||||||
|
-- the default layer that can't be removed.
|
||||||
|
|
||||||
CurrentId ( myclass )
|
CurrentId ( myclass )
|
||||||
returns Integer from Standard;
|
returns Integer from Standard;
|
||||||
---Level: Internal
|
---Level: Internal
|
||||||
|
@ -124,3 +124,5 @@ OpenGl_Context.hxx
|
|||||||
OpenGl_Context.cxx
|
OpenGl_Context.cxx
|
||||||
OpenGl_ArbVBO.hxx
|
OpenGl_ArbVBO.hxx
|
||||||
OpenGl_ExtFBO.hxx
|
OpenGl_ExtFBO.hxx
|
||||||
|
OpenGl_LayerList.cxx
|
||||||
|
OpenGl_LayerList.hxx
|
@ -285,6 +285,47 @@ public:
|
|||||||
Standard_EXPORT void FBOChangeViewport(const Graphic3d_CView& view,Graphic3d_PtrFrameBuffer& fboPtr,const Standard_Integer width,const Standard_Integer height);
|
Standard_EXPORT void FBOChangeViewport(const Graphic3d_CView& view,Graphic3d_PtrFrameBuffer& fboPtr,const Standard_Integer width,const Standard_Integer height);
|
||||||
Standard_EXPORT Standard_Boolean Export(const Standard_CString theFileName,const Graphic3d_ExportFormat theFormat,const Graphic3d_SortType theSortType,const Standard_Integer theWidth,const Standard_Integer theHeight,const Graphic3d_CView& theView,const Aspect_CLayer2d& theLayerUnder,const Aspect_CLayer2d& theLayerOver,const Standard_Real thePrecision = 0.005,const Standard_Address theProgressBarFunc = NULL,const Standard_Address theProgressObject = NULL);
|
Standard_EXPORT Standard_Boolean Export(const Standard_CString theFileName,const Graphic3d_ExportFormat theFormat,const Graphic3d_SortType theSortType,const Standard_Integer theWidth,const Standard_Integer theHeight,const Graphic3d_CView& theView,const Aspect_CLayer2d& theLayerUnder,const Aspect_CLayer2d& theLayerOver,const Standard_Real thePrecision = 0.005,const Standard_Address theProgressBarFunc = NULL,const Standard_Address theProgressObject = NULL);
|
||||||
|
|
||||||
|
//! Add a new top-level z layer with ID <theLayerId> for <br>
|
||||||
|
//! the view. Z layers allow drawing structures in higher layers <br>
|
||||||
|
//! in foreground of structures in lower layers. To add a structure <br>
|
||||||
|
//! to desired layer on display it is necessary to set the layer <br>
|
||||||
|
//! index for the structure. <br>
|
||||||
|
Standard_EXPORT void AddZLayer(const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Remove Z layer from the specified view. All structures <br>
|
||||||
|
//! displayed at the moment in layer will be displayed in default layer <br>
|
||||||
|
//! ( the bottom-level z layer ). To unset layer index from associated <br>
|
||||||
|
//! structures use method UnsetZLayer (...). <br>
|
||||||
|
Standard_EXPORT void RemoveZLayer(const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Unset Z layer ID for all structures. The structure <br>
|
||||||
|
//! indexes will be set to default layer ( the bottom-level z layer with <br>
|
||||||
|
//! ID = 0 ). <br>
|
||||||
|
Standard_EXPORT void UnsetZLayer(const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Change Z layer of a structure. The new z layer ID will <br>
|
||||||
|
//! be used to define the associated layer for structure on display. <br>
|
||||||
|
//! It is recommended to take care of redisplaying the structures already <br>
|
||||||
|
//! presented in view with previously set layer index. This is usually <br>
|
||||||
|
//! done by viewer manager. Z layers allow drawing structures in <br>
|
||||||
|
//! higher layers in foreground of structures in lower layers. <br>
|
||||||
|
Standard_EXPORT void ChangeZLayer(const Graphic3d_CStructure& theCStructure,
|
||||||
|
const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Change Z layer of a structure already presented in view. <br>
|
||||||
|
//! It is recommended to update z layer of already <br>
|
||||||
|
//! displayed structures with this method before setting new z layer <br>
|
||||||
|
//! index to the structure. This is usually done by viewer manager. <br>
|
||||||
|
Standard_EXPORT void ChangeZLayer(const Graphic3d_CStructure& theCStructure,
|
||||||
|
const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theNewLayerId);
|
||||||
|
|
||||||
|
//! Get Z layer ID of the structure. If the structure doesn't exists in <br>
|
||||||
|
//! graphic driver, the method returns -1. <br>
|
||||||
|
Standard_EXPORT Standard_Integer GetZLayer(const Graphic3d_CStructure& theCStructure) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Returns true if VBO usage does not forbidden.
|
//! Returns true if VBO usage does not forbidden.
|
||||||
|
@ -115,3 +115,74 @@ void OpenGl_GraphicDriver::Structure (Graphic3d_CStructure& theCStructure)
|
|||||||
OpenGl_GraphicDriver::GetMapOfStructures().Bind (theCStructure.Id, aStructure);
|
OpenGl_GraphicDriver::GetMapOfStructures().Bind (theCStructure.Id, aStructure);
|
||||||
InvalidateAllWorkspaces();
|
InvalidateAllWorkspaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure,
|
||||||
|
const Standard_Integer theLayer)
|
||||||
|
{
|
||||||
|
if (!GetMapOfStructures().IsBound (theCStructure.Id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
OpenGl_Structure* aStructure =
|
||||||
|
OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
|
||||||
|
|
||||||
|
aStructure->SetZLayer (theLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure,
|
||||||
|
const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theNewLayerId)
|
||||||
|
{
|
||||||
|
const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
|
||||||
|
|
||||||
|
if (!GetMapOfStructures().IsBound (theCStructure.Id) || !aCView)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OpenGl_Structure* aStructure =
|
||||||
|
OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
|
||||||
|
|
||||||
|
aCView->View->ChangeZLayer (aStructure, theNewLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer OpenGl_GraphicDriver::GetZLayer (const Graphic3d_CStructure& theCStructure) const
|
||||||
|
{
|
||||||
|
if (!GetMapOfStructures().IsBound (theCStructure.Id))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
OpenGl_Structure* aStructure =
|
||||||
|
OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
|
||||||
|
|
||||||
|
return aStructure->GetZLayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : UnsetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_GraphicDriver::UnsetZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator
|
||||||
|
aStructIt (GetMapOfStructures ());
|
||||||
|
|
||||||
|
for( ; aStructIt.More (); aStructIt.Next ())
|
||||||
|
{
|
||||||
|
OpenGl_Structure* aStruct = aStructIt.ChangeValue ();
|
||||||
|
if (aStruct->GetZLayer () == theLayerId)
|
||||||
|
aStruct->SetZLayer (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -496,3 +496,29 @@ void OpenGl_GraphicDriver::SetBackFacingModel (const Graphic3d_CView& ACView)
|
|||||||
if (aCView)
|
if (aCView)
|
||||||
aCView->View->SetBackfacing(ACView.Backfacing);
|
aCView->View->SetBackfacing(ACView.Backfacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
|
||||||
|
if (aCView)
|
||||||
|
aCView->View->AddZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_GraphicDriver::RemoveZLayer (const Graphic3d_CView& theCView,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
const OpenGl_CView* aCView = (const OpenGl_CView *)theCView.ptrView;
|
||||||
|
if (aCView)
|
||||||
|
aCView->View->RemoveZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
243
src/OpenGl/OpenGl_LayerList.cxx
Normal file
243
src/OpenGl/OpenGl_LayerList.cxx
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
// File: OpenGl_LayerList.hxx
|
||||||
|
// Created: 2 February 2012
|
||||||
|
// Author: Anton POLETAEV
|
||||||
|
// Copyright: OPEN CASCADE 2012
|
||||||
|
|
||||||
|
#include <OpenGl_LayerList.hxx>
|
||||||
|
#include <OpenGl_tgl_all.hxx>
|
||||||
|
#include <OpenGl_Structure.hxx>
|
||||||
|
|
||||||
|
#include <InterfaceGraphic_Graphic3d.hxx>
|
||||||
|
#include <InterfaceGraphic.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : OpenGl_LayerList
|
||||||
|
//purpose : Constructor
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
|
||||||
|
: myNbPriorities (theNbPriorities),
|
||||||
|
myNbStructures (0)
|
||||||
|
{
|
||||||
|
// insert default priority layer
|
||||||
|
myLayers.Append (OpenGl_PriorityList (myNbPriorities));
|
||||||
|
myLayerIds.Bind (0, myLayers.Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ~OpenGl_LayerList
|
||||||
|
//purpose : Destructor
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
OpenGl_LayerList::~OpenGl_LayerList ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : defaultLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
OpenGl_PriorityList& OpenGl_LayerList::defaultLayer()
|
||||||
|
{
|
||||||
|
return myLayers.ChangeValue (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPriorities
|
||||||
|
//purpose : Method returns the number of available priorities
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer OpenGl_LayerList::NbPriorities () const
|
||||||
|
{
|
||||||
|
return myNbPriorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbStructures
|
||||||
|
//purpose : Method returns the number of available structures
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer OpenGl_LayerList::NbStructures () const
|
||||||
|
{
|
||||||
|
return myNbStructures;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::AddLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (HasLayer (theLayerId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// add the new layer
|
||||||
|
myLayers.Append (OpenGl_PriorityList (myNbPriorities));
|
||||||
|
myLayerIds.Bind (theLayerId, myLayers.Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : HasLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean OpenGl_LayerList::HasLayer
|
||||||
|
(const Standard_Integer theLayerId) const
|
||||||
|
{
|
||||||
|
return myLayerIds.IsBound (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::RemoveLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!HasLayer (theLayerId) || theLayerId == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Standard_Integer aRemovePos = myLayerIds.Find (theLayerId);
|
||||||
|
|
||||||
|
// move all displayed structures to first layer
|
||||||
|
const OpenGl_PriorityList& aList = myLayers.Value (aRemovePos);
|
||||||
|
defaultLayer ().Append (aList);
|
||||||
|
|
||||||
|
// remove layer
|
||||||
|
myLayers.Remove (aRemovePos);
|
||||||
|
myLayerIds.UnBind (theLayerId);
|
||||||
|
|
||||||
|
// updated sequence indexes in map
|
||||||
|
OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds);
|
||||||
|
for ( ; aMapIt.More (); aMapIt.Next ())
|
||||||
|
{
|
||||||
|
Standard_Integer& aSeqIdx = aMapIt.ChangeValue ();
|
||||||
|
if (aSeqIdx > aRemovePos)
|
||||||
|
aSeqIdx--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddStructure
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::AddStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theLayerId,
|
||||||
|
const Standard_Integer thePriority)
|
||||||
|
{
|
||||||
|
// add structure to associated layer,
|
||||||
|
// if layer doesn't exists, display structure in default layer
|
||||||
|
OpenGl_PriorityList& aList = !HasLayer (theLayerId) ? defaultLayer () :
|
||||||
|
myLayers.ChangeValue (myLayerIds.Find (theLayerId));
|
||||||
|
|
||||||
|
aList.Add (theStructure, thePriority);
|
||||||
|
myNbStructures++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveStructure
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
Standard_Integer aSeqPos = !HasLayer (theLayerId) ?
|
||||||
|
1 : myLayerIds.Find (theLayerId);
|
||||||
|
|
||||||
|
OpenGl_PriorityList& aList = myLayers.ChangeValue (aSeqPos);
|
||||||
|
|
||||||
|
// remove structure from associated list
|
||||||
|
// if the structure is not found there,
|
||||||
|
// scan through layers and remove it
|
||||||
|
if (aList.Remove (theStructure) >= 0)
|
||||||
|
{
|
||||||
|
myNbStructures--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scan through layers and remove it
|
||||||
|
Standard_Integer aSeqId = 1;
|
||||||
|
OpenGl_SequenceOfLayers::Iterator anIts;
|
||||||
|
for (anIts.Init (myLayers); anIts.More (); anIts.Next (), aSeqId++)
|
||||||
|
{
|
||||||
|
OpenGl_PriorityList& aScanList = anIts.ChangeValue ();
|
||||||
|
if (aSeqPos == aSeqId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (aScanList.Remove (theStructure) >= 0)
|
||||||
|
{
|
||||||
|
myNbStructures--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theOldLayerId,
|
||||||
|
const Standard_Integer theNewLayerId)
|
||||||
|
{
|
||||||
|
Standard_Integer aSeqPos = !HasLayer (theOldLayerId) ?
|
||||||
|
1 : myLayerIds.Find (theOldLayerId);
|
||||||
|
|
||||||
|
OpenGl_PriorityList& aList = myLayers.ChangeValue (aSeqPos);
|
||||||
|
Standard_Integer aPriority;
|
||||||
|
|
||||||
|
// take priority and remove structure from list found by <theOldLayerId>
|
||||||
|
// if the structure is not found there, scan through all other layers
|
||||||
|
if ((aPriority = aList.Remove (theStructure)) >= 0)
|
||||||
|
{
|
||||||
|
myNbStructures--;
|
||||||
|
AddStructure (theStructure, theNewLayerId, aPriority);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// scan through layers and remove it
|
||||||
|
Standard_Integer aSeqId = 1;
|
||||||
|
OpenGl_SequenceOfLayers::Iterator anIts;
|
||||||
|
for (anIts.Init (myLayers); anIts.More (); anIts.Next (), aSeqId++)
|
||||||
|
{
|
||||||
|
OpenGl_PriorityList& aScanList = anIts.ChangeValue ();
|
||||||
|
if (aSeqPos == aSeqId)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// try to remove structure and get priority value from this layer
|
||||||
|
if ((aPriority = aList.Remove (theStructure)) >= 0)
|
||||||
|
{
|
||||||
|
myNbStructures--;
|
||||||
|
AddStructure (theStructure, theNewLayerId, aPriority);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Render
|
||||||
|
//purpose : Render this element
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
|
||||||
|
{
|
||||||
|
OpenGl_SequenceOfLayers::Iterator anIts;
|
||||||
|
for(anIts.Init (myLayers); anIts.More (); anIts.Next ())
|
||||||
|
{
|
||||||
|
const OpenGl_PriorityList& aList = anIts.Value ();
|
||||||
|
if (aList.NbStructures () > 0)
|
||||||
|
{
|
||||||
|
// separate depth buffers
|
||||||
|
glClear (GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
// render priority list
|
||||||
|
aList.Render (theWorkspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
src/OpenGl/OpenGl_LayerList.hxx
Normal file
85
src/OpenGl/OpenGl_LayerList.hxx
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// File: OpenGl_LayerList.hxx
|
||||||
|
// Created: 2 February 2012
|
||||||
|
// Author: Anton POLETAEV
|
||||||
|
// Copyright: OPEN CASCADE 2012
|
||||||
|
|
||||||
|
#ifndef _OpenGl_LayerList_Header
|
||||||
|
#define _OpenGl_LayerList_Header
|
||||||
|
|
||||||
|
#include <OpenGl_PriorityList.hxx>
|
||||||
|
|
||||||
|
#include <InterfaceGraphic_telem.hxx>
|
||||||
|
|
||||||
|
#include <NCollection_Sequence.hxx>
|
||||||
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
|
class OpenGl_Structure;
|
||||||
|
class Handle(OpenGl_Workspace);
|
||||||
|
|
||||||
|
typedef NCollection_Sequence<OpenGl_PriorityList> OpenGl_SequenceOfLayers;
|
||||||
|
typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
|
||||||
|
|
||||||
|
class OpenGl_LayerList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
OpenGl_LayerList (const Standard_Integer theNbPriorities = 11);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~OpenGl_LayerList ();
|
||||||
|
|
||||||
|
//! Method returns the number of available priorities
|
||||||
|
Standard_Integer NbPriorities () const;
|
||||||
|
|
||||||
|
//! Number of displayed structures
|
||||||
|
Standard_Integer NbStructures () const;
|
||||||
|
|
||||||
|
//! Insert a new layer with id.
|
||||||
|
void AddLayer (const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Check whether the layer with given id is already created.
|
||||||
|
Standard_Boolean HasLayer (const Standard_Integer theLayerId) const;
|
||||||
|
|
||||||
|
//! Remove layer by its id.
|
||||||
|
void RemoveLayer (const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Add structure to list with given priority. The structure will be inserted
|
||||||
|
//! to specified layer. If the layer isn't found, the structure will be put
|
||||||
|
//! to default bottom-level layer.
|
||||||
|
void AddStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theLayerId,
|
||||||
|
const Standard_Integer thePriority);
|
||||||
|
|
||||||
|
//! Remove structure from structure list and return its previous priority
|
||||||
|
void RemoveStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theZLayerId);
|
||||||
|
|
||||||
|
//! Change structure z layer
|
||||||
|
//! If the new layer is not presented, the structure will be displayed
|
||||||
|
//! in default z layer
|
||||||
|
void ChangeLayer (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theOldLayerId,
|
||||||
|
const Standard_Integer theNewLayerId);
|
||||||
|
|
||||||
|
//! Render this element
|
||||||
|
void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Get default layer
|
||||||
|
OpenGl_PriorityList& defaultLayer ();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// number of structures temporary put to default layer
|
||||||
|
OpenGl_SequenceOfLayers myLayers;
|
||||||
|
OpenGl_LayerSeqIds myLayerIds;
|
||||||
|
Standard_Integer myNbPriorities;
|
||||||
|
Standard_Integer myNbStructures;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IMPLEMENT_MEMORY_OPERATORS
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_OpenGl_LayerList_Header
|
@ -20,7 +20,7 @@ void OpenGl_PriorityList::Add (const OpenGl_Structure *AStructure,const Standard
|
|||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
void OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
|
Standard_Integer OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
|
||||||
{
|
{
|
||||||
const Standard_Integer aNbPr = myArray.Length();
|
const Standard_Integer aNbPr = myArray.Length();
|
||||||
Standard_Integer i = 0;
|
Standard_Integer i = 0;
|
||||||
@ -34,10 +34,12 @@ void OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
|
|||||||
{
|
{
|
||||||
aSeq.Remove(its);
|
aSeq.Remove(its);
|
||||||
myNbStructures--;
|
myNbStructures--;
|
||||||
return;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
@ -54,4 +56,37 @@ void OpenGl_PriorityList::Render (const Handle(OpenGl_Workspace) &AWorkspace) co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
//=======================================================================
|
||||||
|
//function : Append
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean OpenGl_PriorityList::Append (const OpenGl_PriorityList& theOther)
|
||||||
|
{
|
||||||
|
// the source priority list shouldn't have more priorities
|
||||||
|
const Standard_Integer aNbPriorities = theOther.NbPriorities ();
|
||||||
|
if (aNbPriorities > NbPriorities ())
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
|
// add all structures to destination priority list
|
||||||
|
Standard_Integer aIdx = 0;
|
||||||
|
OpenGl_SequenceOfStructure::Iterator anIts;
|
||||||
|
for (; aIdx < aNbPriorities; aIdx++)
|
||||||
|
{
|
||||||
|
const OpenGl_SequenceOfStructure& aSeq = theOther.myArray (aIdx);
|
||||||
|
for (anIts.Init (aSeq); anIts.More (); anIts.Next ())
|
||||||
|
Add (anIts.Value (), aIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : NbPriorities
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer OpenGl_PriorityList::NbPriorities() const
|
||||||
|
{
|
||||||
|
return myArray.Length();
|
||||||
|
}
|
||||||
|
@ -23,15 +23,26 @@ class OpenGl_PriorityList
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
OpenGl_PriorityList (const Standard_Integer ANbPriorities = 11) : myArray(0,(ANbPriorities-1)), myNbStructures(0) {}
|
OpenGl_PriorityList (const Standard_Integer ANbPriorities = 11) : myArray(0,(ANbPriorities-1)), myNbStructures(0) {}
|
||||||
|
|
||||||
virtual ~OpenGl_PriorityList () {}
|
virtual ~OpenGl_PriorityList () {}
|
||||||
|
|
||||||
void Add (const OpenGl_Structure *AStructure, const Standard_Integer APriority);
|
void Add (const OpenGl_Structure *AStructure, const Standard_Integer APriority);
|
||||||
void Remove (const OpenGl_Structure *AStructure);
|
|
||||||
|
//! Remove structure and returns its priority, if the structure is not found,
|
||||||
|
//! method returns negative value
|
||||||
|
Standard_Integer Remove (const OpenGl_Structure *AStructure);
|
||||||
|
|
||||||
Standard_Integer NbStructures () const { return myNbStructures; }
|
Standard_Integer NbStructures () const { return myNbStructures; }
|
||||||
|
|
||||||
void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
|
void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
|
||||||
|
|
||||||
|
//! Returns the number of available priority levels
|
||||||
|
Standard_Integer NbPriorities() const;
|
||||||
|
|
||||||
|
//! Append priority list of acceptable type (with similar number of priorities
|
||||||
|
//! or less). Returns Standard_False if the list can not be accepted.
|
||||||
|
Standard_Boolean Append (const OpenGl_PriorityList& theOther);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
OpenGl_ArrayOfStructure myArray;
|
OpenGl_ArrayOfStructure myArray;
|
||||||
|
@ -36,7 +36,8 @@ OpenGl_Structure::OpenGl_Structure ()
|
|||||||
myAspectText(NULL),
|
myAspectText(NULL),
|
||||||
myHighlightBox(NULL),
|
myHighlightBox(NULL),
|
||||||
myHighlightColor(NULL),
|
myHighlightColor(NULL),
|
||||||
myNamedStatus(0)
|
myNamedStatus(0),
|
||||||
|
myZLayer(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,4 +446,22 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
|||||||
AWorkspace->NamedStatus = named_status;
|
AWorkspace->NamedStatus = named_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
|
||||||
|
{
|
||||||
|
myZLayer = theLayerIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer OpenGl_Structure::GetZLayer () const
|
||||||
|
{
|
||||||
|
return myZLayer;
|
||||||
|
}
|
||||||
|
@ -52,6 +52,12 @@ class OpenGl_Structure : public OpenGl_Element
|
|||||||
void RemoveGroup (const OpenGl_Group *);
|
void RemoveGroup (const OpenGl_Group *);
|
||||||
void Clear ();
|
void Clear ();
|
||||||
|
|
||||||
|
//! Set z layer ID to display the structure in specified layer
|
||||||
|
void SetZLayer (const Standard_Integer theLayerIndex);
|
||||||
|
|
||||||
|
//! Get z layer ID
|
||||||
|
Standard_Integer GetZLayer () const;
|
||||||
|
|
||||||
virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
|
virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -70,6 +76,7 @@ class OpenGl_Structure : public OpenGl_Element
|
|||||||
//Structure_LABVisibility
|
//Structure_LABVisibility
|
||||||
//Structure_LABPick
|
//Structure_LABPick
|
||||||
int myNamedStatus; //Structure_LABNameSet
|
int myNamedStatus; //Structure_LABNameSet
|
||||||
|
int myZLayer;
|
||||||
|
|
||||||
OpenGl_ListOfStructure myConnected;
|
OpenGl_ListOfStructure myConnected;
|
||||||
|
|
||||||
|
@ -26,9 +26,8 @@
|
|||||||
#include <Visual3d_TypeOfSurfaceDetail.hxx>
|
#include <Visual3d_TypeOfSurfaceDetail.hxx>
|
||||||
|
|
||||||
#include <OpenGl_telem_view.hxx>
|
#include <OpenGl_telem_view.hxx>
|
||||||
|
#include <OpenGl_LayerList.hxx>
|
||||||
#include <OpenGl_Light.hxx>
|
#include <OpenGl_Light.hxx>
|
||||||
#include <OpenGl_PriorityList.hxx>
|
|
||||||
|
|
||||||
#include <Handle_OpenGl_Trihedron.hxx>
|
#include <Handle_OpenGl_Trihedron.hxx>
|
||||||
#include <Handle_OpenGl_GraduatedTrihedron.hxx>
|
#include <Handle_OpenGl_GraduatedTrihedron.hxx>
|
||||||
@ -135,8 +134,27 @@ class OpenGl_View : public MMgt_TShared
|
|||||||
const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
|
const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
|
||||||
void EndTransformPersistence ();
|
void EndTransformPersistence ();
|
||||||
|
|
||||||
void DisplayStructure (const OpenGl_Structure *AStructure, const Standard_Integer APriority) { myStructures.Add(AStructure,APriority); }
|
//! Add structure to display list with specified priority.
|
||||||
void EraseStructure (const OpenGl_Structure *AStructure) { myStructures.Remove(AStructure); }
|
//! The structure will be added to associated with it z layer.
|
||||||
|
//! If the z layer is not presented in the view, the structure will
|
||||||
|
//! be displayed in default bottom-level z layer.
|
||||||
|
void DisplayStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer thePriority);
|
||||||
|
|
||||||
|
//! Erase structure from display list.
|
||||||
|
void EraseStructure (const OpenGl_Structure *theStructure);
|
||||||
|
|
||||||
|
//! Insert a new top-level z layer with ID <theLayerId>
|
||||||
|
void AddZLayer (const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Remove a z layer with ID <theLayerId>
|
||||||
|
void RemoveZLayer (const Standard_Integer theLayerId);
|
||||||
|
|
||||||
|
//! Display structure in z layer with ID <theNewLayerId>
|
||||||
|
//! If the layer with ID <theNewLayerId> is not presented in the view,
|
||||||
|
//! the structure will be displayed in default bottom-level layer.
|
||||||
|
void ChangeZLayer (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theNewLayerId);
|
||||||
|
|
||||||
void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
|
void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
|
||||||
void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
|
void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
|
||||||
@ -197,7 +215,7 @@ class OpenGl_View : public MMgt_TShared
|
|||||||
|
|
||||||
//View_LABDepthCueing - fixed index used
|
//View_LABDepthCueing - fixed index used
|
||||||
|
|
||||||
OpenGl_PriorityList myStructures;
|
OpenGl_LayerList myZLayers;
|
||||||
|
|
||||||
int myAnimationListIndex;
|
int myAnimationListIndex;
|
||||||
Standard_Boolean myAnimationListReady;
|
Standard_Boolean myAnimationListReady;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <OpenGl_Trihedron.hxx>
|
#include <OpenGl_Trihedron.hxx>
|
||||||
#include <OpenGl_GraduatedTrihedron.hxx>
|
#include <OpenGl_GraduatedTrihedron.hxx>
|
||||||
#include <OpenGl_PrinterContext.hxx>
|
#include <OpenGl_PrinterContext.hxx>
|
||||||
|
#include <OpenGl_Structure.hxx>
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
/*
|
/*
|
||||||
@ -1231,7 +1232,8 @@ D = -[Px,Py,Pz] dot |Nx|
|
|||||||
//ExecuteViewDisplay
|
//ExecuteViewDisplay
|
||||||
void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace)
|
void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace)
|
||||||
{
|
{
|
||||||
if ( myStructures.NbStructures() <= 0 ) return;
|
if ( myZLayers.NbStructures() <= 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
glPushAttrib ( GL_DEPTH_BUFFER_BIT );
|
glPushAttrib ( GL_DEPTH_BUFFER_BIT );
|
||||||
|
|
||||||
@ -1261,7 +1263,7 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myStructures.Render(AWorkspace);
|
myZLayers.Render (AWorkspace);
|
||||||
|
|
||||||
//TsmPopAttri(); /* restore previous graphics context; before update lights */
|
//TsmPopAttri(); /* restore previous graphics context; before update lights */
|
||||||
|
|
||||||
@ -1511,4 +1513,57 @@ void OpenGl_View::SetBackgroundGradientType (const Aspect_GradientFillMethod ATy
|
|||||||
myBgGradient.type = AType;
|
myBgGradient.type = AType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
//=======================================================================
|
||||||
|
//function : AddZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_View::AddZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
myZLayers.AddLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_View::RemoveZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
myZLayers.RemoveLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DisplayStructure
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_View::DisplayStructure (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer thePriority)
|
||||||
|
{
|
||||||
|
Standard_Integer aZLayer = theStructure->GetZLayer ();
|
||||||
|
myZLayers.AddStructure (theStructure, aZLayer, thePriority);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : EraseStructure
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_View::EraseStructure (const OpenGl_Structure *theStructure)
|
||||||
|
{
|
||||||
|
Standard_Integer aZLayer = theStructure->GetZLayer ();
|
||||||
|
myZLayers.RemoveStructure (theStructure, aZLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void OpenGl_View::ChangeZLayer (const OpenGl_Structure *theStructure,
|
||||||
|
const Standard_Integer theNewLayerId)
|
||||||
|
{
|
||||||
|
Standard_Integer anOldLayer = theStructure->GetZLayer ();
|
||||||
|
myZLayers.ChangeLayer (theStructure, anOldLayer, theNewLayerId);
|
||||||
|
}
|
||||||
|
@ -234,7 +234,21 @@ is
|
|||||||
|
|
||||||
UpdateLocation(me:mutable;P : mutable Presentation from Prs3d) is virtual;
|
UpdateLocation(me:mutable;P : mutable Presentation from Prs3d) is virtual;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
thePrsMgr : PresentationManager from PrsMgr;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is virtual;
|
||||||
|
---Purpose: Set Z layer ID and update all presentations of
|
||||||
|
-- the presentable object. The layer can be set only for displayed object.
|
||||||
|
-- If all object presentations are removed, the layer ID will be set to
|
||||||
|
-- default value when computing presentation. The layers mechanism allows
|
||||||
|
-- drawing objects in higher layers in overlay of objects in lower layers.
|
||||||
|
|
||||||
|
GetZLayer ( me;
|
||||||
|
thePrsMgr : PresentationManager from PrsMgr )
|
||||||
|
returns Integer from Standard is static;
|
||||||
|
---Purpose: Get ID of Z layer. If no presentations of object is displayed,
|
||||||
|
-- and layer ID is unavailable, the -1 value is returned.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
myPresentations: Presentations from PrsMgr is protected;
|
myPresentations: Presentations from PrsMgr is protected;
|
||||||
|
@ -335,3 +335,28 @@ gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const
|
|||||||
{
|
{
|
||||||
return gp_Pnt( myTransformPersistence.Point.x, myTransformPersistence.Point.y, myTransformPersistence.Point.z );
|
return gp_Pnt( myTransformPersistence.Point.x, myTransformPersistence.Point.y, myTransformPersistence.Point.z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void PrsMgr_PresentableObject::SetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!thePrsMgr.IsNull())
|
||||||
|
thePrsMgr->SetZLayer (this, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer PrsMgr_PresentableObject::GetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentationManager)& thePrsMgr) const
|
||||||
|
{
|
||||||
|
if (!thePrsMgr.IsNull())
|
||||||
|
return thePrsMgr->GetZLayer (this);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -48,6 +48,15 @@ is
|
|||||||
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
||||||
is deferred private;
|
is deferred private;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is deferred private;
|
||||||
|
---Purpose: Set Z layer ID for the presentation
|
||||||
|
|
||||||
|
GetZLayer ( me )
|
||||||
|
returns Integer from Standard is deferred private;
|
||||||
|
---Purpose: Get Z layer ID for the presentation
|
||||||
|
|
||||||
Clear(me: mutable)
|
Clear(me: mutable)
|
||||||
is deferred private;
|
is deferred private;
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ is
|
|||||||
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
||||||
is redefined static private;
|
is redefined static private;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is redefined static private;
|
||||||
|
---Purpose: Set Z layer ID for the presentation
|
||||||
|
|
||||||
|
GetZLayer ( me )
|
||||||
|
returns Integer from Standard is redefined static private;
|
||||||
|
---Purpose: Get Z layer ID for the presentation
|
||||||
|
|
||||||
Clear(me:mutable)
|
Clear(me:mutable)
|
||||||
---Purpose: removes the whole content of the presentation.
|
---Purpose: removes the whole content of the presentation.
|
||||||
|
@ -78,3 +78,22 @@ Standard_Integer PrsMgr_Presentation2d::Offset () const {
|
|||||||
|
|
||||||
void PrsMgr_Presentation2d::Destroy () {
|
void PrsMgr_Presentation2d::Destroy () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void PrsMgr_Presentation2d::SetZLayer (Standard_Integer theLayer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer PrsMgr_Presentation2d::GetZLayer () const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -58,6 +58,15 @@ is
|
|||||||
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
|
||||||
is redefined static private;
|
is redefined static private;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is redefined static private;
|
||||||
|
---Purpose: Set Z layer ID for the presentation
|
||||||
|
|
||||||
|
GetZLayer ( me )
|
||||||
|
returns Integer from Standard is redefined static private;
|
||||||
|
---Purpose: Get Z layer ID for the presentation
|
||||||
|
|
||||||
Clear(me:mutable)
|
Clear(me:mutable)
|
||||||
---Purpose: removes the whole content of the presentation.
|
---Purpose: removes the whole content of the presentation.
|
||||||
-- Does not remove the other connected presentations.
|
-- Does not remove the other connected presentations.
|
||||||
|
@ -308,3 +308,23 @@ void PrsMgr_Presentation3d::Destroy () {
|
|||||||
myStructure->Clear();
|
myStructure->Clear();
|
||||||
myStructure.Nullify();
|
myStructure.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void PrsMgr_Presentation3d::SetZLayer (Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
myStructure->SetZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer PrsMgr_Presentation3d::GetZLayer () const
|
||||||
|
{
|
||||||
|
return myStructure->GetZLayer ();
|
||||||
|
}
|
||||||
|
@ -79,6 +79,19 @@ is
|
|||||||
-- aPresentableObject in this framework with the
|
-- aPresentableObject in this framework with the
|
||||||
-- display mode aMode.
|
-- display mode aMode.
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
thePresentableObject : PresentableObject from PrsMgr;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is static;
|
||||||
|
---Purpose: Set Z layer ID for all presentations of the object.
|
||||||
|
|
||||||
|
GetZLayer ( me;
|
||||||
|
thePresentableObject : PresentableObject from PrsMgr )
|
||||||
|
returns Integer from Standard is static;
|
||||||
|
---Purpose: Get Z layer ID assigned to all presentations of the object.
|
||||||
|
-- Method returns -1 value if object has no presentations and is
|
||||||
|
-- impossible to get layer index.
|
||||||
|
|
||||||
IsDisplayed(me;aPresentableObject: PresentableObject from PrsMgr;
|
IsDisplayed(me;aPresentableObject: PresentableObject from PrsMgr;
|
||||||
aMode: Integer from Standard = 0)
|
aMode: Integer from Standard = 0)
|
||||||
---Purpose: Returns true if the presentation of the presentable
|
---Purpose: Returns true if the presentation of the presentable
|
||||||
|
@ -204,6 +204,12 @@ void PrsMgr_PresentationManager::AddPresentation
|
|||||||
Handle(PrsMgr_Presentation) P = newPresentation(aPresentableObject);
|
Handle(PrsMgr_Presentation) P = newPresentation(aPresentableObject);
|
||||||
aPresentableObject->Presentations().Append(PrsMgr_ModedPresentation(P,aMode));
|
aPresentableObject->Presentations().Append(PrsMgr_ModedPresentation(P,aMode));
|
||||||
aPresentableObject->Fill(this,P,aMode);
|
aPresentableObject->Fill(this,P,aMode);
|
||||||
|
|
||||||
|
// set layer index accordingly to object's presentations
|
||||||
|
Standard_Integer aZLayerId = GetZLayer (aPresentableObject);
|
||||||
|
if (aZLayerId >= 0)
|
||||||
|
P->SetZLayer (aZLayerId);
|
||||||
|
|
||||||
P->SetUpdateStatus(Standard_False);
|
P->SetUpdateStatus(Standard_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,3 +228,39 @@ void PrsMgr_PresentationManager::RemovePresentation(const Handle(PrsMgr_Presenta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void PrsMgr_PresentationManager::SetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentableObject)& thePresentableObject,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
|
||||||
|
for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
|
||||||
|
{
|
||||||
|
Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
|
||||||
|
if (aPrs->PresentationManager () == this)
|
||||||
|
aPrs->SetZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer PrsMgr_PresentationManager::GetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentableObject)& thePresentableObject) const
|
||||||
|
{
|
||||||
|
PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
|
||||||
|
for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
|
||||||
|
{
|
||||||
|
Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
|
||||||
|
if (aPrs->PresentationManager () == this)
|
||||||
|
return aPrs->GetZLayer ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -134,6 +134,12 @@ is
|
|||||||
-- Hilight for SelectableObject when the owner is detected. By default
|
-- Hilight for SelectableObject when the owner is detected. By default
|
||||||
-- it always return FALSE.
|
-- it always return FALSE.
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
thePrsMgr : PresentationManager from PrsMgr;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is virtual;
|
||||||
|
---Purpose: Set Z layer ID and update all presentations.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
mySelectable : SOPtr;
|
mySelectable : SOPtr;
|
||||||
|
@ -134,3 +134,13 @@ Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const
|
|||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void SelectMgr_EntityOwner::SetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ uses
|
|||||||
SequenceOfSelection from SelectMgr,
|
SequenceOfSelection from SelectMgr,
|
||||||
TypeOfPresentation3d from PrsMgr,
|
TypeOfPresentation3d from PrsMgr,
|
||||||
Presentation from Prs3d,
|
Presentation from Prs3d,
|
||||||
|
PresentationManager from PrsMgr,
|
||||||
PresentationManager3d from PrsMgr,
|
PresentationManager3d from PrsMgr,
|
||||||
SequenceOfOwner from SelectMgr,
|
SequenceOfOwner from SelectMgr,
|
||||||
NameOfColor from Quantity,
|
NameOfColor from Quantity,
|
||||||
@ -170,6 +171,16 @@ is
|
|||||||
GetSelectPresentation( me: mutable;
|
GetSelectPresentation( me: mutable;
|
||||||
TheMgr: PresentationManager3d from PrsMgr ) returns Presentation from Prs3d is static;
|
TheMgr: PresentationManager3d from PrsMgr ) returns Presentation from Prs3d is static;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
thePrsMgr : PresentationManager from PrsMgr;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is redefined virtual;
|
||||||
|
---Purpose: Set Z layer ID and update all presentations of
|
||||||
|
-- the selectable object. The layer can be set only for displayed object.
|
||||||
|
-- If all object presentations are removed, the layer ID will be set to
|
||||||
|
-- default value when computing presentation. The layers mechanism allows
|
||||||
|
-- drawing objects in higher layers in overlay of objects in lower layers.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
myselections : SequenceOfSelection is protected;
|
myselections : SequenceOfSelection is protected;
|
||||||
|
@ -307,3 +307,42 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation( co
|
|||||||
return mySelectionPrs;
|
return mySelectionPrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void SelectMgr_SelectableObject::SetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (thePrsMgr.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// update own presentations
|
||||||
|
PrsMgr_PresentableObject::SetZLayer (thePrsMgr, theLayerId);
|
||||||
|
|
||||||
|
// update selection presentations
|
||||||
|
if (!mySelectionPrs.IsNull())
|
||||||
|
mySelectionPrs->SetZLayer (theLayerId);
|
||||||
|
|
||||||
|
if (!myHilightPrs.IsNull())
|
||||||
|
myHilightPrs->SetZLayer (theLayerId);
|
||||||
|
|
||||||
|
// update all entity owner presentations
|
||||||
|
for (Init (); More () ;Next ())
|
||||||
|
{
|
||||||
|
const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
|
||||||
|
for (aSel->Init (); aSel->More (); aSel->Next ())
|
||||||
|
{
|
||||||
|
Handle(Select3D_SensitiveEntity) aEntity =
|
||||||
|
Handle(Select3D_SensitiveEntity)::DownCast (aSel->Sensitive());
|
||||||
|
if (!aEntity.IsNull())
|
||||||
|
{
|
||||||
|
Handle(SelectMgr_EntityOwner) aOwner =
|
||||||
|
Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId());
|
||||||
|
if (!aOwner.IsNull())
|
||||||
|
aOwner->SetZLayer (thePrsMgr, theLayerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -134,6 +134,12 @@ is
|
|||||||
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
|
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
|
||||||
ResetLocation(me:mutable) is redefined;
|
ResetLocation(me:mutable) is redefined;
|
||||||
|
|
||||||
|
SetZLayer ( me : mutable;
|
||||||
|
thePrsMgr : PresentationManager from PrsMgr;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is redefined virtual;
|
||||||
|
---Purpose: Set Z layer ID and update all presentations.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
myPrsSh : Shape from StdSelect;
|
myPrsSh : Shape from StdSelect;
|
||||||
myCurMode : Integer from Standard;
|
myCurMode : Integer from Standard;
|
||||||
|
@ -89,15 +89,28 @@ void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
|
|||||||
myPrsSh.Nullify();
|
myPrsSh.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generate new presentable shape
|
||||||
if(myPrsSh.IsNull())
|
if(myPrsSh.IsNull())
|
||||||
myPrsSh = new StdSelect_Shape (myShape);
|
myPrsSh = new StdSelect_Shape (myShape);
|
||||||
}
|
|
||||||
|
|
||||||
|
// highlight and set layer
|
||||||
|
PM->Highlight (myPrsSh, M);
|
||||||
|
Handle(SelectMgr_SelectableObject) aSel = Selectable();
|
||||||
|
if (!aSel.IsNull())
|
||||||
|
{
|
||||||
|
Standard_Integer aLayer = aSel->GetZLayer (PM);
|
||||||
|
if (aLayer >= 0)
|
||||||
|
PM->SetZLayer (myPrsSh, aLayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(myPrsSh.IsNull())
|
if(myPrsSh.IsNull())
|
||||||
PM->Highlight(Selectable(),M);
|
PM->Highlight(Selectable(),M);
|
||||||
else
|
else
|
||||||
PM->Highlight(myPrsSh,M);
|
PM->Highlight(myPrsSh,M);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StdSelect_BRepOwner::Hilight()
|
void StdSelect_BRepOwner::Hilight()
|
||||||
{}
|
{}
|
||||||
@ -122,8 +135,11 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag
|
|||||||
myPrsSh.Nullify();
|
myPrsSh.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(myPrsSh.IsNull()){
|
// generate new presentable shape
|
||||||
if(HasLocation()){
|
if(myPrsSh.IsNull())
|
||||||
|
{
|
||||||
|
if(HasLocation())
|
||||||
|
{
|
||||||
TopLoc_Location lbid = Location() * myShape.Location();
|
TopLoc_Location lbid = Location() * myShape.Location();
|
||||||
TopoDS_Shape ShBis = myShape.Located(lbid);
|
TopoDS_Shape ShBis = myShape.Located(lbid);
|
||||||
myPrsSh = new StdSelect_Shape(ShBis);
|
myPrsSh = new StdSelect_Shape(ShBis);
|
||||||
@ -131,12 +147,25 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag
|
|||||||
else
|
else
|
||||||
myPrsSh = new StdSelect_Shape(myShape);
|
myPrsSh = new StdSelect_Shape(myShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// highlight with color and set layer
|
||||||
|
PM->Color (myPrsSh, aCol, M);
|
||||||
|
Handle(SelectMgr_SelectableObject) aSel = Selectable();
|
||||||
|
if (!aSel.IsNull())
|
||||||
|
{
|
||||||
|
Standard_Integer aLayer = aSel->GetZLayer (PM);
|
||||||
|
if (aLayer >= 0)
|
||||||
|
PM->SetZLayer (myPrsSh, aLayer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(myPrsSh.IsNull())
|
if(myPrsSh.IsNull())
|
||||||
PM->Color(Selectable(),aCol,M);
|
PM->Color(Selectable(),aCol,M);
|
||||||
else
|
else
|
||||||
PM->Color(myPrsSh,aCol,M);
|
PM->Color(myPrsSh,aCol,M);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
|
void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
|
||||||
const Standard_Integer aMode)
|
const Standard_Integer aMode)
|
||||||
@ -173,8 +202,8 @@ void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc)
|
|||||||
// set the update flag and then recompute myPrsSh on hilighting
|
// set the update flag and then recompute myPrsSh on hilighting
|
||||||
if (!myPrsSh.IsNull())
|
if (!myPrsSh.IsNull())
|
||||||
myPrsSh->SetToUpdate();
|
myPrsSh->SetToUpdate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdSelect_BRepOwner::ResetLocation()
|
void StdSelect_BRepOwner::ResetLocation()
|
||||||
{
|
{
|
||||||
SelectMgr_EntityOwner::ResetLocation();
|
SelectMgr_EntityOwner::ResetLocation();
|
||||||
@ -183,5 +212,16 @@ void StdSelect_BRepOwner::ResetLocation()
|
|||||||
// set the update flag and then recompute myPrsSh on hilighting
|
// set the update flag and then recompute myPrsSh on hilighting
|
||||||
if (!myPrsSh.IsNull())
|
if (!myPrsSh.IsNull())
|
||||||
myPrsSh->SetToUpdate();
|
myPrsSh->SetToUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void StdSelect_BRepOwner::SetZLayer
|
||||||
|
(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!myPrsSh.IsNull())
|
||||||
|
thePrsMgr->SetZLayer (myPrsSh, theLayerId);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ uses
|
|||||||
Plane from V3d,
|
Plane from V3d,
|
||||||
ListOfTransient from V3d,
|
ListOfTransient from V3d,
|
||||||
ListIteratorOfListOfTransient from TColStd,
|
ListIteratorOfListOfTransient from TColStd,
|
||||||
|
SequenceOfInteger from TColStd,
|
||||||
TypeOfView from V3d,
|
TypeOfView from V3d,
|
||||||
Vector from Graphic3d,
|
Vector from Graphic3d,
|
||||||
ViewManager from Visual3d,
|
ViewManager from Visual3d,
|
||||||
@ -656,6 +657,31 @@ is
|
|||||||
---Purpose:
|
---Purpose:
|
||||||
-- Display grid echo at requested point in the view.
|
-- Display grid echo at requested point in the view.
|
||||||
|
|
||||||
|
AddZLayer ( me : mutable;
|
||||||
|
theLayerId : in out Integer from Standard )
|
||||||
|
returns Boolean from Standard is static;
|
||||||
|
---Purpose: Add a new top-level Z layer to all managed views and get
|
||||||
|
-- its ID as <theLayerId> value. The Z layers are controlled entirely
|
||||||
|
-- by viewer, it is not possible to add a layer to a
|
||||||
|
-- particular view. The method returns Standard_False if the layer can
|
||||||
|
-- not be created. The layer mechanism allows to display structures
|
||||||
|
-- in higher layers in overlay of structures in lower layers.
|
||||||
|
|
||||||
|
RemoveZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
returns Boolean from Standard is static;
|
||||||
|
---Purpose: Remove Z layer with ID <theLayerId>. Method returns
|
||||||
|
-- Standard_False if the layer can not be removed or doesn't exists.
|
||||||
|
-- By default, there are always default bottom-level layer that can't
|
||||||
|
-- be removed.
|
||||||
|
|
||||||
|
GetAllZLayers ( me;
|
||||||
|
theLayerSeq : out SequenceOfInteger from TColStd )
|
||||||
|
is static;
|
||||||
|
---Purpose: Return all Z layer ids in sequence ordered by overlay level
|
||||||
|
-- from lowest layer to highest ( foreground ). The first layer ID
|
||||||
|
-- in sequence is the default layer that can't be removed.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
MyViewer: ViewManager from Visual3d ;
|
MyViewer: ViewManager from Visual3d ;
|
||||||
|
@ -366,3 +366,33 @@ void V3d_Viewer::DelPlane( const Handle(V3d_Plane)& ThePlane ) {
|
|||||||
|
|
||||||
MyDefinedPlanes.Remove(ThePlane);
|
MyDefinedPlanes.Remove(ThePlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean V3d_Viewer::AddZLayer (Standard_Integer& theLayerId)
|
||||||
|
{
|
||||||
|
return MyViewer->AddZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean V3d_Viewer::RemoveZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
return MyViewer->RemoveZLayer (theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetAllZLayers
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void V3d_Viewer::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
|
||||||
|
{
|
||||||
|
MyViewer->GetAllZLayers (theLayerSeq);
|
||||||
|
}
|
||||||
|
@ -4198,6 +4198,71 @@ static Standard_Integer VSegment (Draw_Interpretor& di,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : VObjZLayer
|
||||||
|
//purpose : Set or get z layer id for presentable object
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
static Standard_Integer VObjZLayer (Draw_Interpretor& di,
|
||||||
|
Standard_Integer argc,
|
||||||
|
const char ** argv)
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
||||||
|
if (aContext.IsNull())
|
||||||
|
{
|
||||||
|
di << argv[0] << "Call 'vinit' before!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get operation
|
||||||
|
TCollection_AsciiString aOperation;
|
||||||
|
if (argc >= 2)
|
||||||
|
aOperation = TCollection_AsciiString (argv [1]);
|
||||||
|
|
||||||
|
// check for correct arguments
|
||||||
|
if (!(argc == 4 && aOperation.IsEqual ("set")) &&
|
||||||
|
!(argc == 3 && aOperation.IsEqual ("get")))
|
||||||
|
{
|
||||||
|
di << "Usage : " << argv[0] << " set/get object [layerid]\n";
|
||||||
|
di << " set - set layer id for interactive object, layerid - z layer id\n";
|
||||||
|
di << " get - get layer id of interactive object\n";
|
||||||
|
di << " argument layerid should be passed for set operation only\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find object
|
||||||
|
TCollection_AsciiString aName (argv[2]);
|
||||||
|
ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
|
||||||
|
if (!aMap.IsBound2 (aName))
|
||||||
|
{
|
||||||
|
di << "Use 'vdisplay' before" << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find interactive object
|
||||||
|
Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
|
||||||
|
Handle(AIS_InteractiveObject) anInterObj =
|
||||||
|
Handle(AIS_InteractiveObject)::DownCast (anObj);
|
||||||
|
if (anInterObj.IsNull())
|
||||||
|
{
|
||||||
|
di << "Not an AIS interactive object!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// process operation
|
||||||
|
if (aOperation.IsEqual ("set"))
|
||||||
|
{
|
||||||
|
Standard_Integer aLayerId = atoi (argv [3]);
|
||||||
|
aContext->SetZLayer (anInterObj, aLayerId);
|
||||||
|
}
|
||||||
|
else if (aOperation.IsEqual ("get"))
|
||||||
|
{
|
||||||
|
di << "Z layer id: " << aContext->GetZLayer (anInterObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ObjectsCommands
|
//function : ObjectsCommands
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -4302,4 +4367,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("vsegment",
|
theCommands.Add("vsegment",
|
||||||
"vsegment Name PointName PointName",
|
"vsegment Name PointName PointName",
|
||||||
__FILE__, VSegment,group);
|
__FILE__, VSegment,group);
|
||||||
|
|
||||||
|
theCommands.Add("vobjzlayer",
|
||||||
|
"vobjzlayer : set/get object [layerid] - set or get z layer id for the interactive object",
|
||||||
|
__FILE__, VObjZLayer, group);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <Draw_Appli.hxx>
|
#include <Draw_Appli.hxx>
|
||||||
#include <Aspect_PrintAlgo.hxx>
|
#include <Aspect_PrintAlgo.hxx>
|
||||||
#include <Image_PixMap.hxx>
|
#include <Image_PixMap.hxx>
|
||||||
|
#include <TColStd_SequenceOfInteger.hxx>
|
||||||
|
|
||||||
#ifndef WNT
|
#ifndef WNT
|
||||||
#include <Graphic3d_GraphicDevice.hxx>
|
#include <Graphic3d_GraphicDevice.hxx>
|
||||||
@ -2060,6 +2061,86 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
//function : VZLayer
|
||||||
|
//purpose : Test z layer operations for v3d viewer
|
||||||
|
//==============================================================================
|
||||||
|
static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
|
||||||
|
if (aContextAIS.IsNull())
|
||||||
|
{
|
||||||
|
di << "Call vinit before!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (argc < 2)
|
||||||
|
{
|
||||||
|
di << "Use: vzlayer " << argv[0];
|
||||||
|
di << " add/del/get [id]\n";
|
||||||
|
di << " add - add new z layer to viewer and print its id\n";
|
||||||
|
di << " del - del z layer by its id\n";
|
||||||
|
di << " get - print sequence of z layers in increasing order of their overlay level\n";
|
||||||
|
di << "id - the layer identificator value defined when removing z layer\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
|
||||||
|
if (aViewer.IsNull())
|
||||||
|
{
|
||||||
|
di << "No active viewer!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// perform operation
|
||||||
|
TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]);
|
||||||
|
if (anOp == "add")
|
||||||
|
{
|
||||||
|
Standard_Integer aNewId;
|
||||||
|
if (!aViewer->AddZLayer (aNewId))
|
||||||
|
{
|
||||||
|
di << "Impossible to add new z layer!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
di << "New z layer added with index: " << aNewId << "\n";
|
||||||
|
}
|
||||||
|
else if (anOp == "del")
|
||||||
|
{
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
di << "Please also provide as argument id of z layer to remove\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer aDelId = atoi (argv[2]);
|
||||||
|
if (!aViewer->RemoveZLayer (aDelId))
|
||||||
|
{
|
||||||
|
di << "Impossible to remove the z layer or invalid id!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
di << "Z layer " << aDelId << " has been removed\n";
|
||||||
|
}
|
||||||
|
else if (anOp == "get")
|
||||||
|
{
|
||||||
|
TColStd_SequenceOfInteger anIds;
|
||||||
|
aViewer->GetAllZLayers (anIds);
|
||||||
|
for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++)
|
||||||
|
{
|
||||||
|
di << anIds.Value (aSeqIdx) << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
di << "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
di << "Invalid operation, please use { add / del / get }\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ViewerCommands
|
//function : ViewerCommands
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -2140,5 +2221,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("vprintview" ,
|
theCommands.Add("vprintview" ,
|
||||||
"vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
|
"vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
|
||||||
__FILE__,VPrintView,group);
|
__FILE__,VPrintView,group);
|
||||||
|
theCommands.Add("vzlayer",
|
||||||
|
"vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids",
|
||||||
|
__FILE__,VZLayer,group);
|
||||||
}
|
}
|
||||||
|
@ -887,6 +887,27 @@ is
|
|||||||
---Purpose: Changes the display priority of the structure <AStructure>.
|
---Purpose: Changes the display priority of the structure <AStructure>.
|
||||||
---Category: Private methods
|
---Category: Private methods
|
||||||
|
|
||||||
|
AddZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is static private;
|
||||||
|
---Purpose: Add a new top-level Z layer to the view with ID
|
||||||
|
-- <theLayerId>. The z layer mechanism allows to display
|
||||||
|
-- structures in higher layers in overlay of structures in lower layers.
|
||||||
|
-- The layers in a particular view should be managed centrally
|
||||||
|
-- by its view manager so to avoid IDs mismatching and provide correct
|
||||||
|
-- display of graphics in all views.
|
||||||
|
|
||||||
|
RemoveZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is static private;
|
||||||
|
---Purpose: Remove z layer from the view by its ID.
|
||||||
|
|
||||||
|
ChangeZLayer ( me : mutable;
|
||||||
|
theStructure : Structure from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is static private;
|
||||||
|
---Purpose: Change Z layer of already displayed structure in the view.
|
||||||
|
|
||||||
Clear ( me : mutable;
|
Clear ( me : mutable;
|
||||||
AStructure : Structure from Graphic3d;
|
AStructure : Structure from Graphic3d;
|
||||||
WithDestruction : Boolean from Standard )
|
WithDestruction : Boolean from Standard )
|
||||||
|
@ -4311,3 +4311,35 @@ Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName
|
|||||||
aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
|
aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
|
||||||
thePrecision, theProgressBarFunc, theProgressObject);
|
thePrecision, theProgressBarFunc, theProgressObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
MyGraphicDriver->AddZLayer (MyCView, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
MyGraphicDriver->ChangeZLayer (
|
||||||
|
(*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);
|
||||||
|
}
|
||||||
|
@ -18,6 +18,8 @@ class ViewManager from Visual3d inherits StructureManager from Graphic3d
|
|||||||
uses
|
uses
|
||||||
|
|
||||||
Array2OfReal from TColStd,
|
Array2OfReal from TColStd,
|
||||||
|
SequenceOfInteger from TColStd,
|
||||||
|
MapOfInteger from TColStd,
|
||||||
|
|
||||||
GenId from Aspect,
|
GenId from Aspect,
|
||||||
GraphicDevice from Aspect,
|
GraphicDevice from Aspect,
|
||||||
@ -275,6 +277,48 @@ is
|
|||||||
---Purpose: Changes the display priority of the structure <AStructure>.
|
---Purpose: Changes the display priority of the structure <AStructure>.
|
||||||
---Category: Private methods
|
---Category: Private methods
|
||||||
|
|
||||||
|
ChangeZLayer ( me : mutable;
|
||||||
|
theStructure : Structure from Graphic3d;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
is redefined static;
|
||||||
|
---Purpose: Change Z layer for structure. The layer mechanism allows
|
||||||
|
-- to display structures in higher layers in overlay of structures in
|
||||||
|
-- lower layers.
|
||||||
|
|
||||||
|
GetZLayer ( me;
|
||||||
|
theStructure : Structure from Graphic3d )
|
||||||
|
returns Integer from Standard is redefined static;
|
||||||
|
---Purpose: Get Z layer ID assigned for the structure.
|
||||||
|
|
||||||
|
AddZLayer ( me : mutable;
|
||||||
|
theLayerId : in out Integer from Standard )
|
||||||
|
returns Boolean from Standard is redefined static;
|
||||||
|
---Purpose: Add a new top-level Z layer and get its ID as
|
||||||
|
-- <theLayerId> value. The method returns Standard_False if the layer
|
||||||
|
-- can not be created. The layer mechanism allows to display
|
||||||
|
-- structures in higher layers in overlay of structures in lower layers.
|
||||||
|
|
||||||
|
RemoveZLayer ( me : mutable;
|
||||||
|
theLayerId : Integer from Standard )
|
||||||
|
returns Boolean from Standard is redefined static;
|
||||||
|
---Purpose: Remove Z layer with ID <theLayerId>. Method returns
|
||||||
|
-- Standard_False if the layer can not be removed or doesn't exists.
|
||||||
|
-- By default, there are always default bottom-level layer that can't
|
||||||
|
-- be removed.
|
||||||
|
|
||||||
|
GetAllZLayers ( me;
|
||||||
|
theLayerSeq : out SequenceOfInteger from TColStd )
|
||||||
|
is redefined static;
|
||||||
|
---Purpose: Return all Z layer ids in sequence ordered by overlay level
|
||||||
|
-- from lowest layer to highest ( foreground ). The first layer ID
|
||||||
|
-- in sequence is the default layer that can't be removed.
|
||||||
|
|
||||||
|
getZLayerGenId ( myclass )
|
||||||
|
---Purpose: Returns global instance of z layer ids generator.
|
||||||
|
---C++: return &
|
||||||
|
returns GenId from Aspect is protected;
|
||||||
|
|
||||||
|
|
||||||
Clear ( me : mutable;
|
Clear ( me : mutable;
|
||||||
AStructure : Structure from Graphic3d;
|
AStructure : Structure from Graphic3d;
|
||||||
WithDestruction : Boolean from Standard )
|
WithDestruction : Boolean from Standard )
|
||||||
@ -431,7 +475,7 @@ is
|
|||||||
-- is managed automatically.
|
-- is managed automatically.
|
||||||
-- Default Standard_False
|
-- Default Standard_False
|
||||||
---Category: Internal methods
|
---Category: Internal methods
|
||||||
--
|
--
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
@ -460,6 +504,10 @@ fields
|
|||||||
MyZBufferAuto : Boolean from Standard;
|
MyZBufferAuto : Boolean from Standard;
|
||||||
MyTransparency : Boolean from Standard;
|
MyTransparency : Boolean from Standard;
|
||||||
|
|
||||||
|
-- Z layer indexes
|
||||||
|
myLayerIds : MapOfInteger from TColStd;
|
||||||
|
myLayerSeq : SequenceOfInteger from TColStd;
|
||||||
|
|
||||||
friends
|
friends
|
||||||
|
|
||||||
class View from Visual3d,
|
class View from Visual3d,
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <Standard_ErrorHandler.hxx>
|
#include <Standard_ErrorHandler.hxx>
|
||||||
|
|
||||||
#include <Aspect.hxx>
|
#include <Aspect.hxx>
|
||||||
|
#include <Aspect_IdentDefinitionError.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_GraphicDriver.hxx>
|
#include <Graphic3d_GraphicDriver.hxx>
|
||||||
#include <Graphic3d_MapOfStructure.hxx>
|
#include <Graphic3d_MapOfStructure.hxx>
|
||||||
@ -81,11 +82,14 @@ MyViewGenId (View_IDMIN+((View_IDMIN+View_IDMAX)/(Visual3d_ViewManager::Limit ()
|
|||||||
MyZBufferAuto (Standard_False),
|
MyZBufferAuto (Standard_False),
|
||||||
MyTransparency (Standard_False)
|
MyTransparency (Standard_False)
|
||||||
{
|
{
|
||||||
|
// default layer is always presented in display layer sequence
|
||||||
|
// it can not be removed
|
||||||
|
myLayerIds.Add (0);
|
||||||
|
myLayerSeq.Append (0);
|
||||||
|
|
||||||
Handle(Aspect_GraphicDriver) agd = aDevice->GraphicDriver ();
|
Handle(Aspect_GraphicDriver) agd = aDevice->GraphicDriver ();
|
||||||
|
|
||||||
MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
|
MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-Destructors
|
//-Destructors
|
||||||
@ -1339,3 +1343,120 @@ const Handle(Visual3d_Layer)& Visual3d_ViewManager::OverLayer () const {
|
|||||||
return (MyOverLayer);
|
return (MyOverLayer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ChangeZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
|
||||||
|
const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!myLayerIds.Contains (theLayerId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// change display layer for structure in all views
|
||||||
|
if (MyDisplayedStructure.Contains (theStructure))
|
||||||
|
{
|
||||||
|
Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
|
||||||
|
for ( ; aViewIt.More (); aViewIt.Next ())
|
||||||
|
(aViewIt.Value ())->ChangeZLayer (theStructure, theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// tell graphic driver to update the structure's display layer
|
||||||
|
MyGraphicDriver->ChangeZLayer (
|
||||||
|
(*(Graphic3d_CStructure*)theStructure->CStructure ()), theLayerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Integer Visual3d_ViewManager::GetZLayer (const Handle(Graphic3d_Structure)& theStructure) const
|
||||||
|
{
|
||||||
|
Graphic3d_CStructure& aStructure =
|
||||||
|
(*(Graphic3d_CStructure*)theStructure->CStructure ());
|
||||||
|
|
||||||
|
return MyGraphicDriver->GetZLayer (aStructure);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AddZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OCC_CATCH_SIGNALS
|
||||||
|
theLayerId = getZLayerGenId ().Next ();
|
||||||
|
myLayerIds.Add (theLayerId);
|
||||||
|
myLayerSeq.Append (theLayerId);
|
||||||
|
}
|
||||||
|
catch (Aspect_IdentDefinitionError)
|
||||||
|
{
|
||||||
|
// new index can't be generated
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tell all managed views to remove display layers
|
||||||
|
Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
|
||||||
|
for ( ; aViewIt.More (); aViewIt.Next ())
|
||||||
|
(aViewIt.Value ())->AddZLayer (theLayerId);
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : RemoveZLayer
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theLayerId)
|
||||||
|
{
|
||||||
|
if (!myLayerIds.Contains (theLayerId) || theLayerId == 0)
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
|
// tell all managed views to remove display layers
|
||||||
|
Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
|
||||||
|
for ( ; aViewIt.More (); aViewIt.Next ())
|
||||||
|
(aViewIt.Value ())->RemoveZLayer (theLayerId);
|
||||||
|
|
||||||
|
MyGraphicDriver->UnsetZLayer (theLayerId);
|
||||||
|
|
||||||
|
// remove index
|
||||||
|
for (int aIdx = 1; aIdx <= myLayerSeq.Length (); aIdx++)
|
||||||
|
if (myLayerSeq(aIdx) == theLayerId)
|
||||||
|
{
|
||||||
|
myLayerSeq.Remove (aIdx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
myLayerIds.Remove (theLayerId);
|
||||||
|
getZLayerGenId ().Free (theLayerId);
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetAllZLayers
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void Visual3d_ViewManager::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
|
||||||
|
{
|
||||||
|
theLayerSeq.Assign (myLayerSeq);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : getZLayerGenId
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Aspect_GenId& Visual3d_ViewManager::getZLayerGenId ()
|
||||||
|
{
|
||||||
|
static Aspect_GenId aGenId (1, IntegerLast());
|
||||||
|
return aGenId;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user