1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

refs #355: Add possibility to hide clipping plane

This commit is contained in:
ema 2017-05-11 15:28:48 +03:00
parent 7dc7bda859
commit 1e25daebc7
5 changed files with 117 additions and 23 deletions

View File

@ -304,3 +304,23 @@ Standard_GUID XCAFDoc::LockGUID()
static Standard_GUID ID("efd213eb-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : ViewRefEnabledShapesGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ClipPlaneCappingRefGUID()
{
static Standard_GUID ID("50976BC9-A2B0-497C-9A66-443FB8703DAD");
return ID;
}
//=======================================================================
//function : LockGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ClipPlaneVisibleRefGUID()
{
static Standard_GUID ID("279E76D5-4EFF-4F48-81D5-01CA307A5634");
return ID;
}

View File

@ -126,7 +126,13 @@ public:
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefEnabledShapesGUID();
//! Return GUIDs for clipping plane capping
Standard_EXPORT static Standard_GUID ClipPlaneCappingRefGUID();
//! Return GUIDs for clipping plane visibility
Standard_EXPORT static Standard_GUID ClipPlaneVisibleRefGUID();
//! Return GUIDs for GraphNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
Standard_EXPORT static Standard_GUID ViewRefAnnotationGUID();

View File

@ -59,7 +59,7 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::IsClippingPlane(const TDF_Label& the
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& theLabel,
gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping) const
gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const
{
if (theLabel.Father() != Label())
return Standard_False;
@ -74,9 +74,13 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& th
theName = aNameAttribute->Get();
Handle(TDataStd_Integer) aCappingAttribute;
if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute))
if (theLabel.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute))
theCapping = (aCappingAttribute->Get() == 1);
Handle(TDataStd_Integer) aVisibleAttribute;
if (theLabel.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute))
theVisible = (aVisibleAttribute->Get() == 1);
return Standard_True;
}
@ -86,10 +90,10 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& th
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& theLabel,
gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping) const
gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const
{
TCollection_ExtendedString anExtName;
if (!GetClippingPlane(theLabel, thePlane, anExtName, theCapping))
if (!GetClippingPlane(theLabel, thePlane, anExtName, theCapping, theVisible))
return Standard_False;
theName = new TCollection_HAsciiString(anExtName);
return Standard_True;
@ -108,8 +112,8 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
for (Standard_Integer i = 1; i <= aClippingPlanes.Length(); i++) {
gp_Pln aPlane;
TCollection_ExtendedString aName;
Standard_Boolean aCapping;
GetClippingPlane(aClippingPlanes.Value(i), aPlane, aName, aCapping);
Standard_Boolean aCapping, aVisible;
GetClippingPlane(aClippingPlanes.Value(i), aPlane, aName, aCapping, aVisible);
if (!aName.IsEqual(theName))
continue;
if (aPlane.Axis().Angle(thePlane.Axis()) > Precision::Angular())
@ -149,12 +153,14 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
//purpose :
//=======================================================================
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping) const
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const
{
TDF_Label aLabel = AddClippingPlane(thePlane, theName);
Standard_Integer aCappingVal = (theCapping) ? 1 : 0;
TDataStd_Integer::Set(aLabel, aCappingVal);
Standard_Integer aVisibleVal = (theVisible) ? 1 : 0;
TDataStd_Integer::Set(aLabel, aVisibleVal);
return aLabel;
}
@ -163,10 +169,10 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
//purpose :
//=======================================================================
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping) const
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const
{
TCollection_ExtendedString anExtName = TCollection_ExtendedString(theName->String());
return AddClippingPlane(thePlane, anExtName, theCapping);
return AddClippingPlane(thePlane, anExtName, theCapping, theVisible);
}
//=======================================================================
@ -230,9 +236,9 @@ void XCAFDoc_ClippingPlaneTool::SetCapping(const TDF_Label& theClippingPlaneL, c
if (theClippingPlaneL.Father() != Label())
return;
theClippingPlaneL.ForgetAttribute(TDataStd_Integer::GetID());
theClippingPlaneL.ForgetAttribute(XCAFDoc::ClipPlaneCappingRefGUID());
Standard_Integer aCappingVal = (theCapping) ? 1 : 0;
TDataStd_Integer::Set(theClippingPlaneL, aCappingVal);
TDataStd_Integer::Set(theClippingPlaneL, XCAFDoc::ClipPlaneCappingRefGUID(), aCappingVal);
}
//=======================================================================
@ -246,7 +252,7 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClipp
return Standard_False;
Handle(TDataStd_Integer) aCappingAttribute;
if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute))
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute))
return (aCappingAttribute->Get() == 1);
return Standard_False;
@ -263,13 +269,63 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClipp
return Standard_False;
Handle(TDataStd_Integer) aCappingAttribute;
if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute)) {
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute)) {
theCapping = (aCappingAttribute->Get() == 1);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : SetVisible
//purpose :
//=======================================================================
void XCAFDoc_ClippingPlaneTool::SetVisible(const TDF_Label& theClippingPlaneL, const Standard_Boolean theVisible)
{
if (theClippingPlaneL.Father() != Label())
return;
theClippingPlaneL.ForgetAttribute(XCAFDoc::ClipPlaneVisibleRefGUID());
Standard_Integer aVisibleVal = (theVisible) ? 1 : 0;
TDataStd_Integer::Set(theClippingPlaneL, XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleVal);
}
//=======================================================================
//function : GetVisible
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetVisible(const TDF_Label& theClippingPlaneL) const
{
if (theClippingPlaneL.Father() != Label())
return Standard_False;
Handle(TDataStd_Integer) aVisibleAttribute;
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute))
return (aVisibleAttribute->Get() == 1);
return Standard_False;
}
//=======================================================================
//function : GetVisible
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetVisible(const TDF_Label& theClippingPlaneL, Standard_Boolean &theVisible) const
{
if (theClippingPlaneL.Father() != Label())
return Standard_False;
Handle(TDataStd_Integer) aVisibleAttribute;
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute)) {
theVisible = (aVisibleAttribute->Get() == 1);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetID

View File

@ -48,22 +48,22 @@ public:
//! Returns ClippingPlane defined by label lab
//! Returns False if the label is not in ClippingPlane table
//! or does not define a ClippingPlane
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping) const;
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const;
//! Returns ClippingPlane defined by label lab
//! Returns False if the label is not in ClippingPlane table
//! or does not define a ClippingPlane
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping) const;
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
//! is already defined)
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping) const;
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
//! is already defined)
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping) const;
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
@ -97,6 +97,17 @@ public:
//! Get capping value for given clipping plane label
//! Return true if Label is valid abd capping is exist.
Standard_EXPORT Standard_Boolean GetCapping(const TDF_Label& theClippingPlaneL, Standard_Boolean &theCapping) const;
//! Set new value of visible for given clipping plane label
Standard_EXPORT void SetVisible(const TDF_Label& theClippingPlaneL, const Standard_Boolean theCapping);
//! Get visible value for given clipping plane label
//! Return capping value
Standard_EXPORT Standard_Boolean GetVisible(const TDF_Label& theClippingPlaneL) const;
//! Get visible value for given clipping plane label
//! Return true if Label is valid abd capping is exist.
Standard_EXPORT Standard_Boolean GetVisible(const TDF_Label& theClippingPlaneL, Standard_Boolean &theCapping) const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;

View File

@ -1175,8 +1175,8 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const
//=======================================================================
static Standard_Integer addClippingPlane(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 5) {
di << "Use: XAddClippingPlane Doc plane name capping[0/1]";
if (argc < 6) {
di << "Use: XAddClippingPlane Doc plane name capping[0/1] visible[0/1]";
return 1;
}
Handle(TDocStd_Document) aDoc;
@ -1195,8 +1195,9 @@ static Standard_Integer addClippingPlane(Draw_Interpretor& di, Standard_Integer
aPlane = aSurf->Pln();
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[3]);
Standard_Boolean aCapping = (argv[4][0] == '1');
Standard_Boolean aVisible = (argv[5][0] == '1');
TDF_Label aCPlaneL = aCPlaneTool->AddClippingPlane(aPlane, aName, aCapping);
TDF_Label aCPlaneL = aCPlaneTool->AddClippingPlane(aPlane, aName, aCapping, aVisible);
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aCPlaneL, anEntry);
di << anEntry << "\n";
@ -1230,8 +1231,8 @@ static Standard_Integer getClippingPlane(Draw_Interpretor& di, Standard_Integer
}
gp_Pln aPlane;
Handle(TCollection_HAsciiString) aName;
Standard_Boolean aCapping;
aClippingPlaneTool->GetClippingPlane(aLabel, aPlane, aName, aCapping);
Standard_Boolean aCapping, aVisible;
aClippingPlaneTool->GetClippingPlane(aLabel, aPlane, aName, aCapping, aVisible);
Handle(Geom_Plane) aCPlane = new Geom_Plane(aPlane);
DrawTrSurf::Set(aName->ToCString(), aCPlane);
di << aName->ToCString();