1 // Created on: 2004-01-09
2 // Created by: Sergey KUUL
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _XCAFDoc_DimTolTool_HeaderFile
17 #define _XCAFDoc_DimTolTool_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <TDF_LabelSequence.hxx>
25 #include <Standard_Integer.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 class XCAFDoc_ShapeTool;
30 class TCollection_HAsciiString;
32 class TDF_RelocationTable;
35 class XCAFDoc_DimTolTool;
36 DEFINE_STANDARD_HANDLE(XCAFDoc_DimTolTool, TDF_Attribute)
38 //! Provides tools to store and retrieve attributes (colors)
39 //! of TopoDS_Shape in and from TDocStd_Document
40 //! A Document is intended to hold different
41 //! attributes of ONE shape and it's sub-shapes.
42 //! Attribute containing DimTol section of DECAF document.
43 //! Provide tools for management of DimTol section of document.
44 class XCAFDoc_DimTolTool : public TDF_Attribute
50 Standard_EXPORT XCAFDoc_DimTolTool();
52 //! Creates (if not exist) DimTolTool.
53 Standard_EXPORT static Handle(XCAFDoc_DimTolTool) Set (const TDF_Label& L);
55 Standard_EXPORT static const Standard_GUID& GetID();
57 //! returns the label under which colors are stored
58 Standard_EXPORT TDF_Label BaseLabel() const;
60 //! Returns internal XCAFDoc_ShapeTool tool
61 Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
63 //! Returns True if label belongs to a dimtoltable and
64 //! is a DimTol definition
65 Standard_EXPORT Standard_Boolean IsDimTol (const TDF_Label& lab) const;
67 //! Returns a sequence of D>s currently stored
69 Standard_EXPORT void GetDimTolLabels (TDF_LabelSequence& Labels) const;
71 //! Finds a dimtol definition in a DGTtable and returns
72 //! its label if found
73 //! Returns False if dimtol is not found in DGTtable
74 Standard_EXPORT Standard_Boolean FindDimTol (const Standard_Integer kind, const Handle(TColStd_HArray1OfReal)& aVal, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, TDF_Label& lab) const;
76 //! Finds a dimtol definition in a DGTtable and returns
77 //! its label if found (or Null label else)
78 Standard_EXPORT TDF_Label FindDimTol (const Standard_Integer kind, const Handle(TColStd_HArray1OfReal)& aVal, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription) const;
80 //! Adds a dimtol definition to a DGTtable and returns its label
81 Standard_EXPORT TDF_Label AddDimTol (const Standard_Integer kind, const Handle(TColStd_HArray1OfReal)& aVal, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription) const;
83 //! Sets a link with GUID
84 Standard_EXPORT void SetDimTol (const TDF_Label& L, const TDF_Label& DimTolL) const;
86 //! Sets a link with GUID
87 //! Adds a DimTol as necessary
88 Standard_EXPORT TDF_Label SetDimTol (const TDF_Label& L, const Standard_Integer kind, const Handle(TColStd_HArray1OfReal)& aVal, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription) const;
90 //! Returns ShapeL defined for label DimTolL
91 //! Returns False if the DimTolL is not in DGTtable
92 Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& DimTolL, TDF_Label& ShapeL) const;
94 //! Returns all DimTol labels defined for label ShapeL
95 Standard_EXPORT Standard_Boolean GetRefDGTLabels (const TDF_Label& ShapeL, TDF_LabelSequence& DimTols) const;
97 //! Returns dimtol assigned to <DimTolL>
98 //! Returns False if no such dimtol is assigned
99 Standard_EXPORT Standard_Boolean GetDimTol (const TDF_Label& DimTolL, Standard_Integer& kind, Handle(TColStd_HArray1OfReal)& aVal, Handle(TCollection_HAsciiString)& aName, Handle(TCollection_HAsciiString)& aDescription) const;
101 //! Returns True if label belongs to a dimtoltable and
102 //! is a Datum definition
103 Standard_EXPORT Standard_Boolean IsDatum (const TDF_Label& lab) const;
105 //! Returns a sequence of Datumss currently stored
107 Standard_EXPORT void GetDatumLabels (TDF_LabelSequence& Labels) const;
109 //! Finds a datum and returns its label if found
110 Standard_EXPORT Standard_Boolean FindDatum (const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, const Handle(TCollection_HAsciiString)& anIdentification, TDF_Label& lab) const;
112 //! Adds a datum definition to a DGTtable and returns its label
113 Standard_EXPORT TDF_Label AddDatum (const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, const Handle(TCollection_HAsciiString)& anIdentification) const;
115 //! Sets a link with GUID
116 Standard_EXPORT void SetDatum (const TDF_Label& L, const TDF_Label& DatumL) const;
118 //! Sets a link with GUID for Datum
119 //! Adds a Datum as necessary
120 //! Sets connection between Datum and Tolerance
121 Standard_EXPORT void SetDatum (const TDF_Label& L, const TDF_Label& TolerL, const Handle(TCollection_HAsciiString)& aName, const Handle(TCollection_HAsciiString)& aDescription, const Handle(TCollection_HAsciiString)& anIdentification) const;
123 //! Returns datum assigned to <DatumL>
124 //! Returns False if no such datum is assigned
125 Standard_EXPORT Standard_Boolean GetDatum (const TDF_Label& DatumL, Handle(TCollection_HAsciiString)& aName, Handle(TCollection_HAsciiString)& aDescription, Handle(TCollection_HAsciiString)& anIdentification) const;
127 //! Returns all Datum labels defined for label DimTolL
128 Standard_EXPORT Standard_Boolean GetDatumTolerLabels (const TDF_Label& DimTolL, TDF_LabelSequence& Datums) const;
130 Standard_EXPORT const Standard_GUID& ID() const;
132 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with);
134 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const;
136 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const;
141 DEFINE_STANDARD_RTTI(XCAFDoc_DimTolTool,TDF_Attribute)
151 Handle(XCAFDoc_ShapeTool) myShapeTool;
162 #endif // _XCAFDoc_DimTolTool_HeaderFile