]> OCCT Git - occt-copy.git/commitdiff
XCAFDoc/View fixes to store in the view: image, parts transparency, notes, notes...
authornds <nds@opencascade.com>
Thu, 27 Sep 2018 14:38:43 +0000 (17:38 +0300)
committerNatalia ERMOLAEVA <nds@nnov.opencascade.com>
Sat, 11 Apr 2020 18:12:48 +0000 (21:12 +0300)
(cherry picked from commit b050e0a15c06403adfa545ad793555491a0b6b9f)
(cherry picked from commit 7099619e5d4f0c04e2c6827247a7c1050fd2711b)
(cherry picked from commit ccd4b101f5ab18ab3518b9779e88d687e2db6ff1)

# Conflicts:
# src/XCAFDoc/XCAFDoc.cxx
# src/XCAFDoc/XCAFDoc.hxx
(cherry picked from commit a22653eb867815de9036e487a33a741dfb465d0b)
(cherry picked from commit 9f130570964d5c0d38a0e3af23c0b83656210bed)
(cherry picked from commit c00bcd15f1dd1c5f7ed28f948b5b172e6068871d)

src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_View.cxx
src/XCAFDoc/XCAFDoc_ViewTool.cxx
src/XCAFDoc/XCAFDoc_ViewTool.hxx
src/XCAFView/XCAFView_Object.cxx
src/XCAFView/XCAFView_Object.hxx

index d00a8d281ac0bfb7d2c219a9a8f4ab944ca0e806..719d675f778c0cbeb77af693d3a77732552262ac 100644 (file)
@@ -272,13 +272,24 @@ const Standard_GUID& XCAFDoc::ViewRefPlaneGUID()
 }
 
 //=======================================================================
-//function : ViewRefPlaneGUID
+//function : ViewRefNoteGUID
 //purpose  : 
 //=======================================================================
 
 const Standard_GUID& XCAFDoc::ViewRefNoteGUID()
 {
-  static const Standard_GUID ID("C814ACC6-43AC-4812-9B2A-4E9A2A549354");
+  static const Standard_GUID ID("efd213e2-6dfd-11d4-b9c8-0060b0ee281b");
+  return ID;
+}
+
+//=======================================================================
+//function : ViewRefEnabledShapesGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
+{
+  static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
   return ID;
 }
 
index c4bc8f29965c3dc51b059418412d3b87dad1f2f5..42d43db4520f84a7b4358062c9608b4ece18ede0 100644 (file)
@@ -128,6 +128,10 @@ public:
 
   //! Return GUIDs for GraphNode representing specified types of View
   Standard_EXPORT static const Standard_GUID& ViewRefNoteGUID();
+
+  //! Return GUIDs for TreeNode representing specified types of View
+  Standard_EXPORT static Standard_GUID ViewRefEnabledShapesGUID();
+
   Standard_EXPORT static const Standard_GUID& ViewRefAnnotationGUID();
 
   //! Returns GUID for UAttribute identifying lock flag
index 9e96db27a61cc148dda60c4f7eaece2c7fc8dd81..2eda98d9ee386aa53f106e2d3518489ff56907f6 100644 (file)
@@ -20,6 +20,7 @@
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Real.hxx>
 #include <TDataStd_RealArray.hxx>
+#include <TDataStd_ByteArray.hxx>
 #include <TDataXtd_Axis.hxx>
 #include <TDataXtd_Geometry.hxx>
 #include <TDataXtd_Plane.hxx>
@@ -45,7 +46,10 @@ enum ChildLab
   ChildLab_BackPlaneDistance,
   ChildLab_ViewVolumeSidesClipping,
   ChildLab_ClippingExpression,
-  ChildLab_GDTPoints
+  ChildLab_GDTPoints,
+  ChildLab_Image,
+  ChildLab_EnabledShapes,
+  ChildLab_NotePoints
 };
 
 //=======================================================================
@@ -149,6 +153,32 @@ void XCAFDoc_View::SetObject (const Handle(XCAFView_Object)& theObject)
       TDataXtd_Point::Set(aPointsLabel.FindChild(i), theObject->GDTPoint(i));
     }
   }
+  //Image
+  if (theObject->HasImage())
+  {
+    Handle(TColStd_HArray1OfByte) image = theObject->Image();
+    Handle(TDataStd_ByteArray) arr = TDataStd_ByteArray::Set(Label().FindChild(ChildLab_Image), image->Lower(), image->Upper());
+    for (Standard_Integer i = image->Lower(); i <= image->Upper(); i++) {
+      arr->SetValue(i, image->Value(i));
+    }
+  }
+  //shapes transparency
+  if (theObject->HasEnabledShapes())
+  {
+    TDF_Label aShapeTranspLabel = Label().FindChild(ChildLab_EnabledShapes);
+    for (Standard_Integer i = 1; i <= theObject->NbEnabledShapes(); i++) {
+      Standard_Integer aValue = theObject->EnabledShape(i) ? 1 : 0;
+      TDataStd_Integer::Set(aShapeTranspLabel.FindChild(i), aValue);
+    }
+  }
+  //note points
+  if (theObject->HasNotePoints())
+  {
+    TDF_Label aPointsLabel = Label().FindChild(ChildLab_NotePoints);
+    for (Standard_Integer i = 1; i <= theObject->NbNotePoints(); i++) {
+      TDataXtd_Point::Set(aPointsLabel.FindChild(i), theObject->NotePoint(i));
+    }
+  }
 }
 
 //=======================================================================
@@ -273,7 +303,37 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject()  const
       }
     }
   }
+  //Image
+  Handle(TDataStd_ByteArray) anArr;
+  if (Label().FindChild(ChildLab_Image).FindAttribute(TDataStd_ByteArray::GetID(), anArr)) {
+    anObj->SetImage(anArr->InternalArray());
+  }
 
+  // Shapes transparency
+  if (!Label().FindChild(ChildLab_EnabledShapes, Standard_False).IsNull()) {
+    TDF_Label aShapesTranspLabel = Label().FindChild(ChildLab_EnabledShapes);
+    anObj->CreateEnabledShapes(aShapesTranspLabel.NbChildren());
+    for (Standard_Integer i = 1; i <= aShapesTranspLabel.NbChildren(); i++) {
+      gp_Pnt aPoint;
+      Handle(TDataStd_Integer) aTranspAttr;
+      aShapesTranspLabel.FindChild(i).FindAttribute(TDataStd_Integer::GetID(), aTranspAttr);
+      Standard_Boolean aValue = (aTranspAttr->Get() == 1);
+      anObj->SetEnabledShape(i, aValue);
+    }
+  }
+
+  // Note Points
+  if (!Label().FindChild(ChildLab_NotePoints, Standard_False).IsNull()) {
+    TDF_Label aPointsLabel = Label().FindChild(ChildLab_NotePoints);
+    anObj->CreateNotePoints(aPointsLabel.NbChildren());
+    for (Standard_Integer i = 1; i <= aPointsLabel.NbChildren(); i++) {
+      gp_Pnt aPoint;
+      Handle(TDataXtd_Point) aPointAttr;
+      aPointsLabel.FindChild(i).FindAttribute(TDataXtd_Point::GetID(), aPointAttr);
+      TDataXtd_Geometry::Point(aPointAttr->Label(), aPoint);
+      anObj->SetNotePoint(i, aPoint);
+    }
+  }
   return anObj;
 }
 
index 8a6269a6f2c8552710f2905be63627f06c6ff724..059bd595771ed8590a753a5c29069ebe5ae6664b 100644 (file)
@@ -305,11 +305,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);
@@ -444,7 +443,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());
   }
@@ -465,7 +464,86 @@ void XCAFDoc_ViewTool::SetClippingPlanes(const TDF_LabelSequence& theClippingPla
     aChGNode->SetFather(aPlaneGNode);
   }
 }
+//=======================================================================
+//function : SetEnabledShapes
+//purpose  : 
+//=======================================================================
+void XCAFDoc_ViewTool::SetEnabledShapes(const TDF_LabelSequence& theShapesTransparencyLabels,
+  const TDF_Label& theViewL) const
+{
+  if (!IsView(theViewL))
+    return;
+
+  Handle(XCAFDoc_GraphNode) aChGNode;
+  Handle(XCAFDoc_GraphNode) aShapeGNode;
+
+  if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode)) {
+    while (aChGNode->NbFathers() > 0) {
+      aShapeGNode = aChGNode->GetFather(1);
+      aShapeGNode->UnSetChild(aChGNode);
+      if (aShapeGNode->NbChildren() == 0)
+        aShapeGNode->ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
+    }
+    theViewL.ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
+  }
+
+
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode) && theShapesTransparencyLabels.Length() > 0) {
+    aChGNode = new XCAFDoc_GraphNode;
+    aChGNode = XCAFDoc_GraphNode::Set(theViewL);
+    aChGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
+  }
+  for (Standard_Integer i = theShapesTransparencyLabels.Lower(); i <= theShapesTransparencyLabels.Upper(); i++)
+  {
+    if (!theShapesTransparencyLabels.Value(i).FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aShapeGNode)) {
+      aShapeGNode = new XCAFDoc_GraphNode;
+      aShapeGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
+    }
+    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 : RemoveView
 //purpose  : 
@@ -579,6 +657,30 @@ Standard_Boolean XCAFDoc_ViewTool::GetRefClippingPlaneLabel(const TDF_Label& the
   return Standard_True;
 }
 
+//=======================================================================
+//function : GetRefEnabledShapesLabel
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFDoc_ViewTool::GetRefEnabledShapesLabel(const TDF_Label& theViewL,
+  TDF_LabelSequence& theShapesTranspanencyLabels) const
+{
+  theShapesTranspanencyLabels.Clear();
+  Handle(TDataStd_TreeNode) aNode;
+  if (!theViewL.FindAttribute(XCAFDoc::ViewRefGUID(), aNode) || !aNode->HasFather()) {
+    Handle(XCAFDoc_GraphNode) aGNode;
+    if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aGNode) && aGNode->NbFathers() > 0) {
+      for (Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+        theShapesTranspanencyLabels.Append(aGNode->GetFather(i)->Label());
+      return Standard_True;
+    }
+    else
+      return Standard_False;
+  }
+
+  theShapesTranspanencyLabels.Append(aNode->Father()->Label());
+  return Standard_True;
+}
+
 //=======================================================================
 //function : GetRefNoteLabel
 //purpose  : 
@@ -684,6 +786,25 @@ Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForClippingPlane(const TDF_Label
   return aResult;
 }
 
+//=======================================================================
+//function :GetViewLabelsForEnabledShapesLabel
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForEnabledShapesLabel(const TDF_Label& theShapesTransparencyL,
+  TDF_LabelSequence& theViews) const
+{
+  Handle(XCAFDoc_GraphNode) aGNode;
+  Standard_Boolean aResult = Standard_False;
+  if (theShapesTransparencyL.FindAttribute(XCAFDoc::ViewRefPlaneGUID(), 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 : GetViewLabelsForNote
 //purpose  : 
index ea1a3b04688298c824e0c4bcd55d5e68eef9035b..d24d4f9eb70de6c5624fadecca32172082504435 100644 (file)
@@ -86,6 +86,12 @@ public:
   //! Set Clipping planes to  given View
   Standard_EXPORT void SetClippingPlanes(const TDF_LabelSequence& theClippingPlaneLabels,
                                          const TDF_Label& theViewL) const;
+  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;
 
   //! Remove View
   Standard_EXPORT void RemoveView(const TDF_Label& theViewL);
@@ -105,6 +111,9 @@ public:
   //! Returns all View labels defined for label AnnotationL
   Standard_EXPORT Standard_Boolean GetViewLabelsForAnnotation(const TDF_Label& theAnnotationL, TDF_LabelSequence& theViews) const;
 
+  //! Returns all View labels defined for label Shapes transparency
+  Standard_EXPORT Standard_Boolean GetViewLabelsForEnabledShapesLabel(const TDF_Label& theShapesTransparencyL, TDF_LabelSequence& theViews) const;
+  
   //! Adds a view definition to a View table and returns its label
   Standard_EXPORT TDF_Label AddView() ;
   
@@ -120,6 +129,9 @@ 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 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 Notes 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;
index bc1e06f1debb9f0b7557dc0769098b57199ba0b9..bf86ecbb033d1dd9f3ad46c3ea5203da5d7959b2 100644 (file)
@@ -28,6 +28,9 @@ XCAFView_Object::XCAFView_Object()
   myBackPlaneClipping = Standard_False;
   myViewVolumeSidesClipping = Standard_False;
   myGDTPoints = NULL;
+  myImage = NULL;
+  myEnabledShapes = NULL;
+  myNotePoints = NULL;
 }
 
 //=======================================================================
@@ -50,5 +53,8 @@ XCAFView_Object::XCAFView_Object(const Handle(XCAFView_Object)& theObj)
   myBackPlaneDistance = theObj->myBackPlaneDistance;
   myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
   myGDTPoints = NULL;
+  myImage = theObj->myImage;
+  myEnabledShapes = NULL;
+  myGDTPoints = NULL;
 }
 
index 5085da4f873a093d6c1fc4a025ea77db4d025cd0..9baf129f2ab0844587253ac5463940d14fa50db4 100644 (file)
@@ -26,6 +26,8 @@
 #include <TColgp_HArray1OfPnt.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <XCAFView_ProjectionType.hxx>
+#include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_HArray1OfBoolean.hxx>
 
 class XCAFView_Object;
 DEFINE_STANDARD_HANDLE(XCAFView_Object, Standard_Transient)
@@ -217,7 +219,93 @@ public:
     else
       return gp_Pnt();
   }
-  
+
+  Standard_EXPORT void SetImage(Handle(TColStd_HArray1OfByte) theImage)
+  {
+    myImage = theImage;
+  }
+
+  Standard_EXPORT  Handle(TColStd_HArray1OfByte) Image()
+  {
+    return myImage;
+  }
+
+  Standard_EXPORT Standard_Boolean HasImage()
+  {
+    return (!myImage.IsNull());
+  }
+
+  Standard_EXPORT void CreateEnabledShapes(const Standard_Integer theLenght)
+  {
+    if (theLenght > 0)
+      myEnabledShapes = new TColStd_HArray1OfBoolean(1, theLenght);
+  }
+
+  Standard_EXPORT Standard_Boolean HasEnabledShapes()
+  {
+    return (!myEnabledShapes.IsNull());
+  }
+
+  Standard_EXPORT Standard_Integer NbEnabledShapes()
+  {
+    if (myEnabledShapes.IsNull())
+      return 0;
+    return myEnabledShapes->Length();
+  }
+
+  Standard_EXPORT void SetEnabledShape(const Standard_Integer theIndex, const bool theVal)
+  {
+    if (myEnabledShapes.IsNull())
+      return;
+    if (theIndex > 0 && theIndex <= myEnabledShapes->Length())
+      myEnabledShapes->SetValue(theIndex, theVal);
+  }
+
+  Standard_EXPORT bool EnabledShape(const Standard_Integer theIndex)
+  {
+    if (myEnabledShapes.IsNull())
+      return Standard_False;
+    if (theIndex > 0 && theIndex <= myEnabledShapes->Length())
+      return myEnabledShapes->Value(theIndex);
+    else
+      return Standard_False;
+  }
+  Standard_EXPORT void CreateNotePoints(const Standard_Integer theLenght)
+  {
+    if (theLenght > 0)
+      myNotePoints = new TColgp_HArray1OfPnt(1, theLenght);
+  }
+
+  Standard_EXPORT Standard_Boolean HasNotePoints()
+  {
+    return (!myNotePoints.IsNull());
+  }
+
+  Standard_EXPORT Standard_Integer NbNotePoints()
+  {
+    if (myNotePoints.IsNull())
+      return 0;
+    return myNotePoints->Length();
+  }
+
+  Standard_EXPORT void SetNotePoint(const Standard_Integer theIndex, const gp_Pnt thePoint)
+  {
+    if (myNotePoints.IsNull())
+      return;
+    if (theIndex > 0 && theIndex <= myNotePoints->Length())
+      myNotePoints->SetValue(theIndex, thePoint);
+  }
+
+  Standard_EXPORT gp_Pnt NotePoint(const Standard_Integer theIndex)
+  {
+    if (myNotePoints.IsNull())
+      return gp_Pnt();
+    if (theIndex > 0 && theIndex <= myNotePoints->Length())
+      return myNotePoints->Value(theIndex);
+    else
+      return gp_Pnt();
+  }
+
   DEFINE_STANDARD_RTTIEXT(XCAFView_Object,Standard_Transient)
 
 private:
@@ -237,6 +325,9 @@ private:
   Standard_Real myBackPlaneDistance;
   Standard_Boolean myViewVolumeSidesClipping;
   Handle(TColgp_HArray1OfPnt) myGDTPoints; // Point for each GDT to describe position of GDT frame in View.
+  Handle(TColStd_HArray1OfByte) myImage;
+  Handle(TColStd_HArray1OfBoolean) myEnabledShapes;
+  Handle(TColgp_HArray1OfPnt) myNotePoints;
 };
 
 #endif // _XCAFView_Object_HeaderFile