0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / XCAFDoc / XCAFDoc_AssemblyItemRef.hxx
CommitLineData
024d6f77 1// Created on: 2017-02-16
2// Created by: Sergey NIKONOV
3// Copyright (c) 2000-2017 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _XCAFDoc_AssemblyItemRef_HeaderFile
17#define _XCAFDoc_AssemblyItemRef_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Type.hxx>
21#include <Standard_GUID.hxx>
22#include <TDF_Attribute.hxx>
23#include <XCAFDoc_AssemblyItemId.hxx>
24
25class TDF_Data;
26class TDF_RelocationTable;
27
28class XCAFDoc_AssemblyItemRef;
29DEFINE_STANDARD_HANDLE(XCAFDoc_AssemblyItemRef, TDF_Attribute)
30
31//! An attribute that describes a weak reference to an assembly item
32//! or to a subshape or to an assembly label attribute.
33class XCAFDoc_AssemblyItemRef : public TDF_Attribute
34{
35
36public:
37
8c2d3314 38 DEFINE_STANDARD_RTTIEXT(XCAFDoc_AssemblyItemRef, TDF_Attribute)
024d6f77 39
40 Standard_EXPORT static const Standard_GUID& GetID();
41
42 //! Finds a reference attribute on the given label and returns it, if it is found
43 Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Get(const TDF_Label& theLabel);
44
45 //! @name Set reference attribute functions.
46 //! @{
47
48 //! Create (if not exist) a reference to an assembly item.
49 //! \param [in] theLabel - label to add the attribute.
50 //! \param [in] theItemId - assembly item ID.
51 //! \return A handle to the attribute instance.
52 Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Set(const TDF_Label& theLabel,
53 const XCAFDoc_AssemblyItemId& theItemId);
54
55 //! Create (if not exist) a reference to an assembly item's label attribute.
56 //! \param [in] theLabel - label to add the attribute.
57 //! \param [in] theItemId - assembly item ID.
58 //! \param [in] theGUID - assembly item's label attribute ID.
59 //! \return A handle to the attribute instance.
60 Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Set(const TDF_Label& theLabel,
61 const XCAFDoc_AssemblyItemId& theItemId,
62 const Standard_GUID& theGUID);
63
64 //! Create (if not exist) a reference to an assembly item's subshape.
65 //! \param [in] theLabel - label to add the attribute.
66 //! \param [in] theItemId - assembly item ID.
67 //! \param [in] theShapeIndex - assembly item's subshape index.
68 //! \return A handle to the attribute instance.
69 Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Set(const TDF_Label& theLabel,
70 const XCAFDoc_AssemblyItemId& theItemId,
71 const Standard_Integer theShapeIndex);
72
73 //! @}
74
75 //! Creates an empty reference attribute.
76 Standard_EXPORT XCAFDoc_AssemblyItemRef();
77
78 //! Checks if the reference points to a really existing item in XDE document.
79 Standard_EXPORT Standard_Boolean IsOrphan() const;
80
81 //! @name Extra reference functions.
82 //! @{
83
84 //! Checks if the reference points on an item's shapeindex or attribute.
85 Standard_EXPORT Standard_Boolean HasExtraRef() const;
86
87 //! Checks is the reference points to an item's attribute.
88 Standard_EXPORT Standard_Boolean IsGUID() const;
89
90 //! Checks is the reference points to an item's subshape.
91 Standard_EXPORT Standard_Boolean IsSubshapeIndex() const;
92
93 //! Returns the assembly item's attribute that the reference points to.
94 //! If the reference doesn't point to an attribute, returns an empty GUID.
95 Standard_EXPORT Standard_GUID GetGUID() const;
96
97 //! Returns the assembly item's subshape that the reference points to.
98 //! If the reference doesn't point to a subshape, returns 0.
99 Standard_EXPORT Standard_Integer GetSubshapeIndex() const;
100
101 //! @}
102
103 //! Returns the assembly item ID that the reference points to.
104 Standard_EXPORT const XCAFDoc_AssemblyItemId& GetItem() const;
105
106 //! @name Set reference data functions.
107 //! @{
108
109 //! Sets the assembly item ID that the reference points to.
110 //! Extra reference data (if any) will be cleared.
111 Standard_EXPORT void SetItem(const XCAFDoc_AssemblyItemId& theItemId);
112
113 //! Sets the assembly item ID from a list of label entries
114 //! that the reference points to.
115 //! Extra reference data (if any) will be cleared.
116 Standard_EXPORT void SetItem(const TColStd_ListOfAsciiString& thePath);
117
118 //! Sets the assembly item ID from a formatted path
119 //! that the reference points to.
120 //! Extra reference data (if any) will be cleared.
121 Standard_EXPORT void SetItem(const TCollection_AsciiString& theString);
122
123 //! Sets the assembly item's label attribute that the reference points to.
124 //! The base assembly item will not change.
125 Standard_EXPORT void SetGUID(const Standard_GUID& theAttrGUID);
126
127 //! Sets the assembly item's subshape that the reference points to.
128 //! The base assembly item will not change.
129 Standard_EXPORT void SetSubshapeIndex(Standard_Integer theShapeIndex);
130
131 //! @}
132
133 //! Reverts the reference to empty state.
134 Standard_EXPORT void ClearExtraRef();
bc73b006 135
136 //! Dumps the content of me into the stream
137 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
024d6f77 138
139public:
140
141 // Overrides TDF_Attribute pure virtuals
142 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
143 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
144 Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
145 Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theAttrInto,
146 const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
147 Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
148
149private:
150
151 XCAFDoc_AssemblyItemId myItemId; ///< Assembly item ID
152 Standard_Integer myExtraRef; ///< Type of extra reference: subshape or attribute
153 TCollection_AsciiString myExtraId; ///< Extra reference data
154
155};
156
157#endif // _XCAFDoc_AssemblyItemRef_HeaderFile