]> OCCT Git - occt-copy.git/commitdiff
refs #355: Add possibility to hide clipping plane
authornds <nds@opencascade.com>
Thu, 27 Sep 2018 14:43:50 +0000 (17:43 +0300)
committernds <natalia.ermolaeva@opencascade.com>
Fri, 15 May 2020 18:33:50 +0000 (21:33 +0300)
(cherry picked from commit ca1f82f6c6860a2e1995d7d9a66ce8c152e9d3cc)
(cherry picked from commit 61f39b4dc7235bf14d685811a8dc4219f02ea4c9)
(cherry picked from commit 7b08ab936a5f6091651fc0311c5c255bd0dc9cb0)

# Conflicts:
# src/XCAFDoc/XCAFDoc.hxx
(cherry picked from commit 72e4a1055636c461e6b154dbd785c84bc611c665)
(cherry picked from commit 37d575793df9e84e58a9b92bba17c5ae58d473f1)
(cherry picked from commit 6964d28a314f847255d1d1cb015dcbd68b3ec1aa)

src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_ClippingPlaneTool.cxx
src/XCAFDoc/XCAFDoc_ClippingPlaneTool.hxx
src/XDEDRAW/XDEDRAW_Views.cxx

index 719d675f778c0cbeb77af693d3a77732552262ac..e6c123c83efb01f4fae841a94c6935c9c14f82c0 100644 (file)
@@ -314,3 +314,23 @@ const Standard_GUID& XCAFDoc::LockGUID()
   static const 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;
+}
index 42d43db4520f84a7b4358062c9608b4ece18ede0..f0681980548ccaee866f4e3bd9f564397c84a039 100644 (file)
@@ -132,6 +132,12 @@ 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();
+  
   Standard_EXPORT static const Standard_GUID& ViewRefAnnotationGUID();
 
   //! Returns GUID for UAttribute identifying lock flag
index 366f26c60779e0aacc1fb7aa15b1eddb22fb27e3..f3d91cc2f517e591d057ccb9a52a1db4f5339f59 100644 (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
index d0cb8a5a393c403c46f64dda287a96ebdb41c2b1..775fea1d1f737de62c9ee4f1a740eacf23021652 100644 (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;
   
index c1d1f9033c786323befcc7fb4a9e86bd2becafd0..b60eaa38eddf13da8a6e6f8c6c2bd64eb3783b74 100644 (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();