return ID;
}
+//=======================================================================
+//function : ViewRefEnabledShapesGUID
+//purpose :
+//=======================================================================
+
+Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
+{
+ static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
+ return ID;
+}
+
//=======================================================================
//function : ViewRefPlaneGUID
//purpose :
//! 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();
ChildLab_ViewVolumeSidesClipping,
ChildLab_ClippingExpression,
ChildLab_GDTPoints,
- ChildLab_Image
+ ChildLab_Image,
+ ChildLab_EnabledShapes
};
//=======================================================================
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);
+ }
+ }
}
//=======================================================================
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;
}
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
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 :
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 :
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);
//! 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() ;
//! 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;
myViewVolumeSidesClipping = Standard_False;
myGDTPoints = NULL;
myImage = NULL;
+ myEnabledShapes = NULL;
}
//=======================================================================
myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
myGDTPoints = NULL;
myImage = theObj->myImage;
+ myEnabledShapes = NULL;
}
#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)
{
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:
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