}
//=======================================================================
-//function : ViewRefPlaneGUID
+//function : ViewRefNoteGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefNoteGUID()
{
- static Standard_GUID ID("C814ACC6-43AC-4812-9B2A-4E9A2A549354");
+ static 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;
}
//! 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();
//! Return GUIDs for GraphNode representing specified types of View
- Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
Standard_EXPORT static Standard_GUID ViewRefAnnotationGUID();
//! Returns GUID for UAttribute identifying lock flag
#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>
ChildLab_BackPlaneDistance,
ChildLab_ViewVolumeSidesClipping,
ChildLab_ClippingExpression,
- ChildLab_GDTPoints
+ ChildLab_GDTPoints,
+ ChildLab_Image,
+ ChildLab_EnabledShapes,
+ ChildLab_NotePoints
};
//=======================================================================
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));
+ }
+ }
}
//=======================================================================
anObj->SetGDTPoint(i, aPoint);
}
}
+ //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;
}
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);
aPlaneGNode = aChGNode->GetFather(1);
aPlaneGNode->UnSetChild(aChGNode);
if (aPlaneGNode->NbChildren() == 0)
- aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID());
+ aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
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 :
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 :
//! 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);
//! 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;
myBackPlaneClipping = Standard_False;
myViewVolumeSidesClipping = Standard_False;
myGDTPoints = NULL;
+ myImage = NULL;
+ myEnabledShapes = NULL;
+ myNotePoints = NULL;
}
//=======================================================================
myBackPlaneDistance = theObj->myBackPlaneDistance;
myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
myGDTPoints = NULL;
+ myImage = theObj->myImage;
+ myEnabledShapes = NULL;
+ myGDTPoints = NULL;
}
#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)
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:
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