]> OCCT Git - occt-copy.git/commitdiff
Saving notes in the view
authorema <elena.mozokhina@opencascade.com>
Mon, 17 Apr 2017 12:16:47 +0000 (15:16 +0300)
committerema <elena.mozokhina@opencascade.com>
Mon, 17 Apr 2017 12:16:47 +0000 (15:16 +0300)
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_ViewTool.cxx
src/XCAFDoc/XCAFDoc_ViewTool.hxx

index 7e0e91614e039f133c04aea25b1621410bea33a2..51249e0ff9becdce73ca7c64faa9e70065432d37 100644 (file)
@@ -251,7 +251,17 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
 }
 
 //=======================================================================
-//function : ViewRefPlaneGUID
+//function : ViewRefNoteGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::ViewRefNoteGUID()
+{
+  static Standard_GUID ID("efd213e2-6dfd-11d4-b9c8-0060b0ee281b");
+  return ID;
+}
+//=======================================================================
+//function : ViewRefEnabledShapesGUID
 //purpose  : 
 //=======================================================================
 
index 3eb79afe3cfa24b56f216369a83d69392593d4b7..a6c8760408aab08d765126efc472a4dfc15988db 100644 (file)
@@ -120,6 +120,9 @@ public:
   
   //! Return GUIDs for TreeNode representing specified types of View
   Standard_EXPORT static Standard_GUID ViewRefPlaneGUID();
+  
+  //! Return GUIDs for TreeNode representing specified types of View
+  Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
  
   //! Return GUIDs for TreeNode representing specified types of View
   Standard_EXPORT static Standard_GUID ViewRefEnabledShapesGUID();
index 9a5741f93645e3b9caf50947c12aadbcecd16512..819cdff4684175481dacc16b7a6261e7e69f8385 100644 (file)
@@ -157,11 +157,10 @@ void XCAFDoc_ViewTool::SetView(const TDF_LabelSequence& theShapeLabels,
       aPlaneGNode = aChGNode->GetFather(1);
       aPlaneGNode->UnSetChild(aChGNode);
       if (aPlaneGNode->NbChildren() == 0)
-        aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID());
+        aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
     }
     theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
   }
-  
   if (!theViewL.FindAttribute(XCAFDoc::ViewRefShapeGUID(), aChGNode) && theShapeLabels.Length() > 0) {
     aChGNode = new XCAFDoc_GraphNode;
     aChGNode = XCAFDoc_GraphNode::Set(theViewL);
@@ -296,7 +295,7 @@ void XCAFDoc_ViewTool::SetClippingPlanes(const TDF_LabelSequence& theClippingPla
       aPlaneGNode = aChGNode->GetFather(1);
       aPlaneGNode->UnSetChild(aChGNode);
       if (aPlaneGNode->NbChildren() == 0)
-        aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID());
+        aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
     }
     theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
   }
@@ -329,14 +328,14 @@ void XCAFDoc_ViewTool::SetEnabledShapes(const TDF_LabelSequence& theShapesTransp
     return;
 
   Handle(XCAFDoc_GraphNode) aChGNode;
-  Handle(XCAFDoc_GraphNode) aPlaneGNode;
+  Handle(XCAFDoc_GraphNode) aShapeGNode;
 
   if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode)) {
     while (aChGNode->NbFathers() > 0) {
-      aPlaneGNode = aChGNode->GetFather(1);
-      aPlaneGNode->UnSetChild(aChGNode);
-      if (aPlaneGNode->NbChildren() == 0)
-        aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
+      aShapeGNode = aChGNode->GetFather(1);
+      aShapeGNode->UnSetChild(aChGNode);
+      if (aShapeGNode->NbChildren() == 0)
+        aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
     }
     theViewL.ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
   }
@@ -349,16 +348,55 @@ void XCAFDoc_ViewTool::SetEnabledShapes(const TDF_LabelSequence& theShapesTransp
   }
   for (Standard_Integer i = theShapesTransparencyLabels.Lower(); i <= theShapesTransparencyLabels.Upper(); i++)
   {
-    if (!theShapesTransparencyLabels.Value(i).FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aPlaneGNode)) {
-      aPlaneGNode = new XCAFDoc_GraphNode;
-      aPlaneGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
+    if (!theShapesTransparencyLabels.Value(i).FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aShapeGNode)) {
+      aShapeGNode = new XCAFDoc_GraphNode;
+      aShapeGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
     }
-    aPlaneGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
-    aPlaneGNode->SetChild(aChGNode);
-    aChGNode->SetFather(aPlaneGNode);
+    aShapeGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
+    aShapeGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aShapeGNode);
   }
 }
+//=======================================================================
+//function : SetNotes
+//purpose  : 
+//=======================================================================
+void XCAFDoc_ViewTool::SetNotes(const TDF_LabelSequence& theNoteLabels,
+                                const TDF_Label& theViewL) const
+{
+  if (!IsView(theViewL))
+    return;
 
+  Handle(XCAFDoc_GraphNode) aChGNode;
+  Handle(XCAFDoc_GraphNode) aNoteGNode;
+
+  if (theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aChGNode)) {
+    while (aChGNode->NbFathers() > 0) {
+      aNoteGNode = aChGNode->GetFather(1);
+      aNoteGNode->UnSetChild(aChGNode);
+      if (aNoteGNode->NbChildren() == 0)
+        aNoteGNode->ForgetAttribute(XCAFDoc::ViewRefNoteGUID());
+    }
+    theViewL.ForgetAttribute(XCAFDoc::ViewRefNoteGUID());
+  }
+
+
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aChGNode) && theNoteLabels.Length() > 0) {
+    aChGNode = new XCAFDoc_GraphNode;
+    aChGNode = XCAFDoc_GraphNode::Set(theViewL);
+    aChGNode->SetGraphID(XCAFDoc::ViewRefNoteGUID());
+  }
+  for (Standard_Integer i = theNoteLabels.Lower(); i <= theNoteLabels.Upper(); i++)
+  {
+    if (!theNoteLabels.Value(i).FindAttribute(XCAFDoc::ViewRefNoteGUID(), aNoteGNode)) {
+      aNoteGNode = new XCAFDoc_GraphNode;
+      aNoteGNode = XCAFDoc_GraphNode::Set(theNoteLabels.Value(i));
+    }
+    aNoteGNode->SetGraphID(XCAFDoc::ViewRefNoteGUID());
+    aNoteGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aNoteGNode);
+  }
+}
 //=======================================================================
 //function : GetRefShapeLabel
 //purpose  : 
@@ -455,6 +493,30 @@ Standard_Boolean XCAFDoc_ViewTool::GetRefEnabledShapesLabel(const TDF_Label& the
   return Standard_True;
 }
 
+//=======================================================================
+//function : GetRefNotesLabel
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFDoc_ViewTool::GetRefNoteLabel(const TDF_Label& theViewL,
+  TDF_LabelSequence& theNoteLabels) const
+{
+  theNoteLabels.Clear();
+  Handle(TDataStd_TreeNode) aNode;
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefGUID(), aNode) || !aNode->HasFather()) {
+    Handle(XCAFDoc_GraphNode) aGNode;
+    if (theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aGNode) && aGNode->NbFathers() > 0) {
+      for (Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+        theNoteLabels.Append(aGNode->GetFather(i)->Label());
+      return Standard_True;
+    }
+    else
+      return Standard_False;
+  }
+
+  theNoteLabels.Append(aNode->Father()->Label());
+  return Standard_True;
+}
+
 //=======================================================================
 //function : GetViewLabelsForShape
 //purpose  : 
@@ -531,6 +593,24 @@ Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForEnabledShapesLabel(const TDF_
   return aResult;
 }
 
+//=======================================================================
+//function : GetViewLabelsForNote
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForNote(const TDF_Label& theNoteL, TDF_LabelSequence& theViews)const
+{
+  Handle(XCAFDoc_GraphNode) aGNode;
+  Standard_Boolean aResult = Standard_False;
+  if (theNoteL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aGNode) && aGNode->NbChildren() > 0) {
+    for (Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
+    {
+      theViews.Append(aGNode->GetChild(i)->Label());
+    }
+    aResult = Standard_True;
+  }
+  return aResult;
+}
+
 //=======================================================================
 //function : IsLocked
 //purpose  : 
index 8e04874dda5544242664a84b459337d66057006a..1ec1708f1eb61a1cf1f6699b1c0d500c68d989ca 100644 (file)
@@ -78,8 +78,12 @@ public:
   //! Set Clipping planes to  given View
   Standard_EXPORT void SetClippingPlanes(const TDF_LabelSequence& theClippingPlaneLabels,
                                          const TDF_Label& theViewL) const;
+  //! Set Enabled shapes to  given View
   Standard_EXPORT void  SetEnabledShapes(const TDF_LabelSequence& theShapesTransparencyLabels,
                                          const TDF_Label& theViewL) const;
+  //! Set Notes to  given View
+  Standard_EXPORT void SetNotes(const TDF_LabelSequence& theNoteLabels,
+                                const TDF_Label& theViewL) const;
   //! Returns all View labels defined for label ShapeL
   Standard_EXPORT Standard_Boolean GetViewLabelsForShape(const TDF_Label& theShapeL, TDF_LabelSequence& theViews) const;
 
@@ -91,6 +95,9 @@ public:
   
   //! Returns all View labels defined for label Shapes transparency
   Standard_EXPORT Standard_Boolean GetViewLabelsForEnabledShapesLabel(const TDF_Label& theShapesTransparencyL, TDF_LabelSequence& theViews) const;
+  
+  //! Returns all View labels defined for label NotesL
+  Standard_EXPORT Standard_Boolean GetViewLabelsForNote(const TDF_Label& theNoteL, TDF_LabelSequence& theViews) const;
 
   //! Adds a view definition to a View table and returns its label
   Standard_EXPORT TDF_Label AddView() ;
@@ -110,6 +117,11 @@ public:
   //! 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;
+
+  //! Returns Note labels defined for label theViewL
+  //! Returns False if the theViewL is not in View table
+  Standard_EXPORT Standard_Boolean GetRefNoteLabel(const TDF_Label& theViewL, TDF_LabelSequence& theNoteLabels) const;
+
   //! Returns true if the given View is marked as locked
   Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;