]> OCCT Git - occt-copy.git/commitdiff
refs #1491: Section view is invisible after view restoring
authordbv <dmitry.bobylev@opencascade.com>
Tue, 11 Feb 2020 14:35:58 +0000 (17:35 +0300)
committerdbv <dmitry.bobylev@opencascade.com>
Tue, 11 Feb 2020 14:35:58 +0000 (17:35 +0300)
Store Sections visibility status in views.

src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_ViewTool.cxx
src/XCAFDoc/XCAFDoc_ViewTool.hxx

index e95213cfac2205bdddc3a952eec3aa863ae79ea7..0ebc9086fee331bf066926fe7cdd9c991948afb8 100644 (file)
@@ -262,6 +262,17 @@ const Standard_GUID& XCAFDoc::ViewRefPlaneGUID()
   return ID;
 }
 
+//=======================================================================
+//function : ViewRefSectionGUID
+//purpose  : 
+//=======================================================================
+
+const Standard_GUID& XCAFDoc::ViewRefSectionGUID()
+{
+  static const Standard_GUID ID("25709d87-4b29-49cd-9982-1a71e34e43fa");
+  return ID;
+}
+
 //=======================================================================
 //function : ViewRefNoteGUID
 //purpose  : 
index 6047c411fa7cb95c3683f056bdd6256bdaf20b33..aa46a49f4b31455de158d43692d976800f98812e 100644 (file)
@@ -123,6 +123,9 @@ public:
   //! Return GUIDs for TreeNode representing specified types of View
   Standard_EXPORT static const Standard_GUID& ViewRefPlaneGUID();
 
+  //! Return GUIDs for GraphNode representing Section
+  Standard_EXPORT static const Standard_GUID& ViewRefSectionGUID();
+
   //! Return GUIDs for GraphNode representing specified types of View
   Standard_EXPORT static const Standard_GUID& ViewRefNoteGUID();
 
index eee158000d326d24cc4b3730e4aa733525ca7ad2..331944c48c776eca99237926546c5a0b72496b0b 100644 (file)
@@ -464,6 +464,46 @@ void XCAFDoc_ViewTool::SetClippingPlanes(const TDF_LabelSequence& theClippingPla
     aChGNode->SetFather(aPlaneGNode);
   }
 }
+
+//=======================================================================
+//function : SetSections
+//purpose  : 
+//=======================================================================
+void XCAFDoc_ViewTool::SetSections(const TDF_LabelSequence& theSectionsLabels,
+                                         const TDF_Label& theViewL) const
+{
+  if (!IsView(theViewL))
+    return;
+
+  Handle(XCAFDoc_GraphNode) aChGNode;
+  Handle(XCAFDoc_GraphNode) aSectionGNode;
+
+  if (theViewL.FindAttribute(XCAFDoc::ViewRefSectionGUID(), aChGNode)) {
+    while (aChGNode->NbFathers() > 0) {
+      aSectionGNode = aChGNode->GetFather(1);
+      aSectionGNode->UnSetChild(aChGNode);
+      if (aSectionGNode->NbChildren() == 0)
+        aSectionGNode->ForgetAttribute(XCAFDoc::ViewRefSectionGUID());
+    }
+    theViewL.ForgetAttribute(XCAFDoc::ViewRefSectionGUID());
+  }
+
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefSectionGUID(), aChGNode) && theSectionsLabels.Length() > 0) {
+    aChGNode = new XCAFDoc_GraphNode;
+    aChGNode = XCAFDoc_GraphNode::Set(theViewL);
+    aChGNode->SetGraphID(XCAFDoc::ViewRefSectionGUID());
+  }
+  for (Standard_Integer i = theSectionsLabels.Lower(); i <= theSectionsLabels.Upper(); i++) {
+    if (!theSectionsLabels.Value(i).FindAttribute(XCAFDoc::ViewRefSectionGUID(), aSectionGNode)) {
+      aSectionGNode = new XCAFDoc_GraphNode;
+      aSectionGNode = XCAFDoc_GraphNode::Set(theSectionsLabels.Value(i));
+    }
+    aSectionGNode->SetGraphID(XCAFDoc::ViewRefSectionGUID());
+    aSectionGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aSectionGNode);
+  }
+}
+
 //=======================================================================
 //function : SetEnabledShapes
 //purpose  : 
@@ -657,6 +697,29 @@ Standard_Boolean XCAFDoc_ViewTool::GetRefClippingPlaneLabel(const TDF_Label& the
   return Standard_True;
 }
 
+//=======================================================================
+//function : GetRefSectionsLabels
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFDoc_ViewTool::GetRefSectionsLabels(const TDF_Label& theViewL,
+                                                        TDF_LabelSequence& theSectionsLabels) const
+{
+  theSectionsLabels.Clear();
+  Handle(TDataStd_TreeNode) aNode;
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefGUID(), aNode) || !aNode->HasFather()) {
+    Handle(XCAFDoc_GraphNode) aGNode;
+    if (theViewL.FindAttribute(XCAFDoc::ViewRefSectionGUID(), aGNode) && aGNode->NbFathers() > 0) {
+      for (Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+        theSectionsLabels.Append(aGNode->GetFather(i)->Label());
+      return Standard_True;
+    } else
+      return Standard_False;
+  }
+
+  theSectionsLabels.Append(aNode->Father()->Label());
+  return Standard_True;
+}
+
 //=======================================================================
 //function : GetRefEnabledShapesLabel
 //purpose  : 
index 78c3be2a14942a2ad75deed7b8f029b1ba910c0a..002e554968e85d62a5f1a3bbc495359f844f5904 100644 (file)
@@ -86,6 +86,11 @@ public:
   //! Set Clipping planes to  given View
   Standard_EXPORT void SetClippingPlanes(const TDF_LabelSequence& theClippingPlaneLabels,
                                          const TDF_Label& theViewL) const;
+
+  //! Set Sections to  given View
+  Standard_EXPORT void SetSections(const TDF_LabelSequence& theSectionsLabels,
+                                   const TDF_Label& theViewL) const;
+
   Standard_EXPORT void  SetEnabledShapes(const TDF_LabelSequence& theShapesTransparencyLabels,
                                          const TDF_Label& theViewL) const;
 
@@ -129,6 +134,10 @@ public:
   //! Returns False if the theViewL is not in View table
   Standard_EXPORT Standard_Boolean GetRefClippingPlaneLabel(const TDF_Label& theViewL, TDF_LabelSequence& theClippingPlaneLabels) const;
 
+  //! Returns Sections labels defined for label theViewL
+  //! Returns False if the theViewL is not in View table
+  Standard_EXPORT Standard_Boolean GetRefSectionsLabels(const TDF_Label& theViewL, TDF_LabelSequence& theSectionsLabels) const;
+
   //! Returns shapes transparency labels defined for label theViewL
   //! Returns False if the theViewL is not in View table
   Standard_EXPORT Standard_Boolean GetRefEnabledShapesLabel(const TDF_Label& theViewL, TDF_LabelSequence& theShapesTranspanencyLabels) const;