]> OCCT Git - occt-copy.git/commitdiff
Storage the parts transparency in the view
authorema <elena.mozokhina@opencascade.com>
Tue, 4 Apr 2017 10:39:39 +0000 (13:39 +0300)
committersnn <snn@opencascade.com>
Thu, 23 Aug 2018 09:04:28 +0000 (12:04 +0300)
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 222fb7aa92ab1c2d8d628e582633efaa3c672e16..57e96624100274ba6fc30aa4dd53784ae2636027 100644 (file)
@@ -262,6 +262,17 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
   return ID;
 }
 
+//=======================================================================
+//function : ViewRefEnabledShapesGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
+{
+  static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
+  return ID;
+}
+
 //=======================================================================
 //function : ViewRefPlaneGUID
 //purpose  : 
index 7f09f721ac87a30daec542a11f96723d50c2351e..b9c8944e4aa057f8eaf13e85951e258170a04377 100644 (file)
@@ -122,6 +122,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 ViewRefEnabledShapesGUID();
 
   //! Return GUIDs for GraphNode representing specified types of View
   Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
index dcd06a1d82d2efaa6c03cd53c7c746ddcf5b13e1..b9eea2f9c608140f971910320b19dfa91a20aeb0 100644 (file)
@@ -47,7 +47,8 @@ enum ChildLab
   ChildLab_ViewVolumeSidesClipping,
   ChildLab_ClippingExpression,
   ChildLab_GDTPoints,
-  ChildLab_Image
+  ChildLab_Image,
+  ChildLab_EnabledShapes
 };
 
 //=======================================================================
@@ -160,6 +161,15 @@ void XCAFDoc_View::SetObject (const Handle(XCAFView_Object)& theObject)
       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);
+    }
+  }
 }
 
 //=======================================================================
@@ -275,6 +285,19 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject()  const
   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);
+    }
+  }
   return anObj;
 }
 
index d3ee01db120327ba4fdd1478612d22bf161d76bb..082ac58248f754bd7329f8e5acce3816b115ea15 100644 (file)
@@ -465,6 +465,46 @@ 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) aPlaneGNode;
+
+  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());
+    }
+    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(), aPlaneGNode)) {
+      aPlaneGNode = new XCAFDoc_GraphNode;
+      aPlaneGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
+    }
+    aPlaneGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
+    aPlaneGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aPlaneGNode);
+  }
+}
 
 //=======================================================================
 //function : RemoveView
@@ -579,6 +619,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 +748,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 7fcd681007835e04e8105758875d484be45f16b9..453024dc37b3a4899f5e8f9a6356fe44ea55daba 100644 (file)
@@ -87,6 +87,9 @@ public:
   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;
+
   //! Remove View
   Standard_EXPORT void RemoveView(const TDF_Label& theViewL);
 
@@ -105,6 +108,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 +126,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 3b7ea48f4462a1e7b351b3a4dac05be383f8ac5f..9421d1ace23c5f3cb6896488f59b560ec3c8600b 100644 (file)
@@ -29,6 +29,7 @@ XCAFView_Object::XCAFView_Object()
   myViewVolumeSidesClipping = Standard_False;
   myGDTPoints = NULL;
   myImage = NULL;
+  myEnabledShapes = NULL;
 }
 
 //=======================================================================
@@ -52,5 +53,6 @@ XCAFView_Object::XCAFView_Object(const Handle(XCAFView_Object)& theObj)
   myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
   myGDTPoints = NULL;
   myImage = theObj->myImage;
+  myEnabledShapes = NULL;
 }
 
index 113572dafb65b64420bb70ba47ccf541f0da43c1..96c3c47ef06b2d708711fd8bd5261716564c1786 100644 (file)
@@ -27,6 +27,7 @@
 #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)
@@ -233,6 +234,43 @@ public:
   {
     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;
+  }
+
   DEFINE_STANDARD_RTTIEXT(XCAFView_Object,Standard_Transient)
 
 private:
@@ -253,6 +291,7 @@ private:
   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;
 };
 
 #endif // _XCAFView_Object_HeaderFile