mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027816: Visualization - provide an API for overriding clipping planes list
Graphic3d_SequenceOfHClipPlane now inherits Standard_Transient. PrsMgr_PresentableObject, Graphic3d_Structure, Graphic3d_CStructure, V3d_View, OpenGl_View now manages the plane list by Handle. The getters ::GetClipPlanes() has been removed, setters taking non-handle ::SetClipPlanes() has been marked deprecated. OpenGl_Structure::Render() and SelectMgr_ViewerSelector::checkOverlap() now disable global (view) clipping planes for objects with flags Graphic3d_TMF_TriedronPers and Graphic3d_TMF_2d or with new flag Graphic3d_SequenceOfHClipPlane::ToOverrideGlobal(). OpenGl_Clipping now implements interface for managing clipping planes without copying the sequences. The filtering of duplicates is no more performed by OpenGl_Clipping - application is responsible to not do this. OpenGl_Clipping tries avoiding unnecessary allocations for managing list of active planes. MFC sample has been updated to use V3d_View::ClipPlanes() method.
This commit is contained in:
@@ -167,7 +167,11 @@ public:
|
||||
|
||||
//! Valid for point selection only!
|
||||
//! Computes depth range for global (defined for the whole view) clipping planes.
|
||||
virtual void SetViewClipping (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/) {};
|
||||
virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& /*thePlanes*/) {};
|
||||
|
||||
//! Set if view clipping plane is enabled or not.
|
||||
//! @return previous value of the flag
|
||||
virtual Standard_Boolean SetViewClippingEnabled (const Standard_Boolean /*theToEnable*/) { return Standard_False; }
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
|
||||
|
||||
|
@@ -399,6 +399,7 @@ Handle(SelectMgr_BaseFrustum) SelectMgr_RectangularFrustum::ScaleAndTransform (c
|
||||
cacheVertexProjections (aRes.get());
|
||||
|
||||
aRes->myViewClipRange = myViewClipRange;
|
||||
aRes->myIsViewClipEnabled = myIsViewClipEnabled;
|
||||
aRes->myMousePos = myMousePos;
|
||||
|
||||
return aRes;
|
||||
@@ -716,16 +717,17 @@ Standard_Boolean SelectMgr_RectangularFrustum::IsClipped (const Graphic3d_Sequen
|
||||
// function : SetViewClipping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void SelectMgr_RectangularFrustum::SetViewClipping (const Graphic3d_SequenceOfHClipPlane& thePlanes)
|
||||
void SelectMgr_RectangularFrustum::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
|
||||
{
|
||||
if (thePlanes.Size() == 0)
|
||||
if (thePlanes.IsNull()
|
||||
|| thePlanes->IsEmpty())
|
||||
{
|
||||
myViewClipRange.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Real aMaxDepth, aMinDepth;
|
||||
computeClippingRange (thePlanes, aMinDepth, aMaxDepth);
|
||||
computeClippingRange (*thePlanes, aMinDepth, aMaxDepth);
|
||||
myViewClipRange.Set (aMinDepth, aMaxDepth);
|
||||
}
|
||||
|
||||
@@ -735,8 +737,11 @@ void SelectMgr_RectangularFrustum::SetViewClipping (const Graphic3d_SequenceOfHC
|
||||
// =======================================================================
|
||||
Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_Real theDepth) const
|
||||
{
|
||||
if (!myViewClipRange.IsValid())
|
||||
if (!myViewClipRange.IsValid()
|
||||
|| !myIsViewClipEnabled)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return myViewClipRange.MaxDepth() > theDepth
|
||||
&& myViewClipRange.MinDepth() < theDepth;
|
||||
|
@@ -34,7 +34,7 @@ class SelectMgr_RectangularFrustum : public SelectMgr_Frustum<4>
|
||||
{
|
||||
public:
|
||||
|
||||
SelectMgr_RectangularFrustum() : myScale (1.0) {};
|
||||
SelectMgr_RectangularFrustum() : myScale (1.0), myIsViewClipEnabled (Standard_True) {};
|
||||
|
||||
//! Builds volume according to the point and given pixel tolerance
|
||||
Standard_EXPORT virtual void Build (const gp_Pnt2d& thePoint) Standard_OVERRIDE;
|
||||
@@ -109,7 +109,16 @@ public:
|
||||
|
||||
//! Valid for point selection only!
|
||||
//! Computes depth range for global (defined for the whole view) clipping planes.
|
||||
Standard_EXPORT virtual void SetViewClipping (const Graphic3d_SequenceOfHClipPlane& thePlanes) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE;
|
||||
|
||||
//! Set if view clipping plane is enabled or not.
|
||||
//! @return previous value of the flag
|
||||
virtual Standard_Boolean SetViewClippingEnabled (const Standard_Boolean theToEnable) Standard_OVERRIDE
|
||||
{
|
||||
Standard_Boolean aPrevValue = myIsViewClipEnabled;
|
||||
myIsViewClipEnabled = theToEnable;
|
||||
return aPrevValue;
|
||||
}
|
||||
|
||||
//! A set of helper functions that return rectangular selecting frustum data
|
||||
inline const gp_Pnt* GetVertices() const { return myVertices; }
|
||||
@@ -159,6 +168,8 @@ private:
|
||||
gp_Pnt2d myMousePos; //!< Mouse coordinates
|
||||
Standard_Real myScale; //!< Scale factor of applied transformation, if there was any
|
||||
SelectMgr_ViewClipRange myViewClipRange;
|
||||
Standard_Boolean myIsViewClipEnabled; //!< view clipping enabled state
|
||||
|
||||
};
|
||||
|
||||
#endif // _SelectMgr_RectangularFrustum_HeaderFile
|
||||
|
@@ -465,10 +465,22 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
|
||||
// function : SetViewClipping
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectingVolumeManager::SetViewClipping (const Graphic3d_SequenceOfHClipPlane& thePlanes)
|
||||
void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
|
||||
{
|
||||
if (myActiveSelectionType != Point)
|
||||
return;
|
||||
|
||||
mySelectingVolumes[Frustum]->SetViewClipping (thePlanes);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : SetViewClippingEnabled
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectingVolumeManager::SetViewClippingEnabled (const Standard_Boolean theToEnable)
|
||||
{
|
||||
if (myActiveSelectionType != Point)
|
||||
return Standard_False;
|
||||
|
||||
return mySelectingVolumes[Frustum]->SetViewClippingEnabled (theToEnable);
|
||||
}
|
||||
|
@@ -172,7 +172,11 @@ public:
|
||||
|
||||
//! Valid for point selection only!
|
||||
//! Computes depth range for global (defined for the whole view) clipping planes.
|
||||
Standard_EXPORT void SetViewClipping (const Graphic3d_SequenceOfHClipPlane& thePlanes);
|
||||
Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
|
||||
|
||||
//! Set if view clipping plane is enabled or not.
|
||||
//! @return previous flag value
|
||||
Standard_EXPORT Standard_Boolean SetViewClippingEnabled (const Standard_Boolean theToEnable);
|
||||
|
||||
//! A set of helper functions that return rectangular selecting frustum data
|
||||
Standard_EXPORT const gp_Pnt* GetVertices() const;
|
||||
|
@@ -166,50 +166,69 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
|
||||
SelectMgr_SelectingVolumeManager& theMgr)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anOwner (Handle(SelectMgr_EntityOwner)::DownCast (theEntity->OwnerId()));
|
||||
Handle(SelectMgr_SelectableObject) aSelectable;
|
||||
Standard_Boolean toRestoresViewClipEnabled = Standard_False;
|
||||
if (!anOwner.IsNull())
|
||||
{
|
||||
aSelectable = anOwner->Selectable();
|
||||
if (aSelectable->TransformPersistence().Flags == Graphic3d_TMF_TriedronPers
|
||||
|| aSelectable->TransformPersistence().Flags == Graphic3d_TMF_2d
|
||||
|| (!aSelectable->ClipPlanes().IsNull() && aSelectable->ClipPlanes()->ToOverrideGlobal()))
|
||||
{
|
||||
theMgr.SetViewClippingEnabled (Standard_False);
|
||||
toRestoresViewClipEnabled = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
SelectBasics_PickResult aPickResult;
|
||||
if (theEntity->Matches (theMgr, aPickResult))
|
||||
const Standard_Boolean isMatched = theEntity->Matches(theMgr, aPickResult);
|
||||
if (toRestoresViewClipEnabled)
|
||||
{
|
||||
if (!anOwner.IsNull())
|
||||
theMgr.SetViewClippingEnabled (Standard_True);
|
||||
}
|
||||
|
||||
if (!isMatched
|
||||
|| anOwner.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasDepthClipping (anOwner)
|
||||
&& theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point)
|
||||
{
|
||||
Standard_Boolean isClipped = mySelectingVolumeMgr.IsClipped (*aSelectable->ClipPlanes(),
|
||||
aPickResult.Depth());
|
||||
if (isClipped)
|
||||
return;
|
||||
}
|
||||
|
||||
SelectMgr_SortCriterion aCriterion;
|
||||
myZLayerOrderMap.Find (aSelectable->ZLayer(), aCriterion.ZLayerPosition);
|
||||
aCriterion.Entity = theEntity;
|
||||
aCriterion.Priority = anOwner->Priority();
|
||||
aCriterion.Depth = aPickResult.Depth();
|
||||
aCriterion.MinDist = aPickResult.DistToGeomCenter();
|
||||
aCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0;
|
||||
aCriterion.ToPreferClosest = preferclosest;
|
||||
|
||||
const Standard_Integer aPrevStoredIndex = mystored.FindIndex (anOwner);
|
||||
if (aPrevStoredIndex != 0)
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box)
|
||||
{
|
||||
Handle(SelectMgr_SelectableObject) aSelectable = anOwner->Selectable();
|
||||
if (HasDepthClipping (anOwner) && theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point)
|
||||
{
|
||||
Standard_Boolean isClipped = mySelectingVolumeMgr.IsClipped (aSelectable->GetClipPlanes(),
|
||||
aPickResult.Depth());
|
||||
if (isClipped)
|
||||
return;
|
||||
}
|
||||
|
||||
SelectMgr_SortCriterion aCriterion;
|
||||
myZLayerOrderMap.Find (aSelectable->ZLayer(), aCriterion.ZLayerPosition);
|
||||
aCriterion.Entity = theEntity;
|
||||
aCriterion.Priority = anOwner->Priority();
|
||||
aCriterion.Depth = aPickResult.Depth();
|
||||
aCriterion.MinDist = aPickResult.DistToGeomCenter();
|
||||
aCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0;
|
||||
aCriterion.ToPreferClosest = preferclosest;
|
||||
|
||||
const Standard_Integer aPrevStoredIndex = mystored.FindIndex (anOwner);
|
||||
if (aPrevStoredIndex != 0)
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box)
|
||||
{
|
||||
SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromIndex (aPrevStoredIndex);
|
||||
if (aCriterion > aPrevCriterion)
|
||||
{
|
||||
updatePoint3d (aCriterion, theInversedTrsf, theMgr);
|
||||
aPrevCriterion = aCriterion;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromIndex (aPrevStoredIndex);
|
||||
if (aCriterion > aPrevCriterion)
|
||||
{
|
||||
updatePoint3d (aCriterion, theInversedTrsf, theMgr);
|
||||
mystored.Add (anOwner, aCriterion);
|
||||
aPrevCriterion = aCriterion;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePoint3d (aCriterion, theInversedTrsf, theMgr);
|
||||
mystored.Add (anOwner, aCriterion);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user