File indexing completed on 2026-12-05 11:14:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _XCAFPrs_DocumentExplorer_HeaderFile
0016 #define _XCAFPrs_DocumentExplorer_HeaderFile
0017
0018 #include <NCollection_DynamicArray.hxx>
0019 #include <XCAFPrs_DocumentNode.hxx>
0020 #include <TDF_Label.hxx>
0021 #include <NCollection_Sequence.hxx>
0022 #include <TopoDS_Shape.hxx>
0023
0024 class TDocStd_Document;
0025 class XCAFDoc_ColorTool;
0026 class XCAFDoc_VisMaterialTool;
0027
0028 typedef int XCAFPrs_DocumentExplorerFlags;
0029
0030
0031 enum
0032 {
0033 XCAFPrs_DocumentExplorerFlags_None = 0x00,
0034 XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes =
0035 0x01,
0036 XCAFPrs_DocumentExplorerFlags_NoStyle = 0x02,
0037 };
0038
0039
0040 class XCAFPrs_DocumentExplorer
0041 {
0042 public:
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 Standard_EXPORT static TCollection_AsciiString DefineChildId(
0054 const TDF_Label& theLabel,
0055 const TCollection_AsciiString& theParentId);
0056
0057
0058
0059
0060 Standard_EXPORT static TDF_Label FindLabelFromPathId(
0061 const occ::handle<TDocStd_Document>& theDocument,
0062 const TCollection_AsciiString& theId,
0063 TopLoc_Location& theParentLocation,
0064 TopLoc_Location& theLocation);
0065
0066
0067
0068
0069 static TDF_Label FindLabelFromPathId(const occ::handle<TDocStd_Document>& theDocument,
0070 const TCollection_AsciiString& theId,
0071 TopLoc_Location& theLocation)
0072 {
0073 TopLoc_Location aDummy;
0074 return FindLabelFromPathId(theDocument, theId, aDummy, theLocation);
0075 }
0076
0077
0078
0079
0080 Standard_EXPORT static TopoDS_Shape FindShapeFromPathId(
0081 const occ::handle<TDocStd_Document>& theDocument,
0082 const TCollection_AsciiString& theId);
0083
0084 public:
0085
0086 Standard_EXPORT XCAFPrs_DocumentExplorer();
0087
0088
0089
0090
0091
0092 Standard_EXPORT XCAFPrs_DocumentExplorer(const occ::handle<TDocStd_Document>& theDocument,
0093 const XCAFPrs_DocumentExplorerFlags theFlags,
0094 const XCAFPrs_Style& theDefStyle = XCAFPrs_Style());
0095
0096
0097
0098
0099
0100
0101 Standard_EXPORT XCAFPrs_DocumentExplorer(const occ::handle<TDocStd_Document>& theDocument,
0102 const NCollection_Sequence<TDF_Label>& theRoots,
0103 const XCAFPrs_DocumentExplorerFlags theFlags,
0104 const XCAFPrs_Style& theDefStyle = XCAFPrs_Style());
0105
0106
0107
0108
0109
0110
0111 Standard_EXPORT void Init(const occ::handle<TDocStd_Document>& theDocument,
0112 const TDF_Label& theRoot,
0113 const XCAFPrs_DocumentExplorerFlags theFlags,
0114 const XCAFPrs_Style& theDefStyle = XCAFPrs_Style());
0115
0116
0117
0118
0119
0120
0121 Standard_EXPORT void Init(const occ::handle<TDocStd_Document>& theDocument,
0122 const NCollection_Sequence<TDF_Label>& theRoots,
0123 const XCAFPrs_DocumentExplorerFlags theFlags,
0124 const XCAFPrs_Style& theDefStyle = XCAFPrs_Style());
0125
0126
0127 bool More() const { return myHasMore; }
0128
0129
0130 const XCAFPrs_DocumentNode& Current() const { return myCurrent; }
0131
0132
0133 XCAFPrs_DocumentNode& ChangeCurrent() { return myCurrent; }
0134
0135
0136 const XCAFPrs_DocumentNode& Current(int theDepth) const
0137 {
0138 const int aCurrDepth = CurrentDepth();
0139 if (theDepth == aCurrDepth)
0140 {
0141 return myCurrent;
0142 }
0143
0144 Standard_OutOfRange_Raise_if(theDepth < 0 || theDepth > myTop,
0145 "XCAFPrs_DocumentExplorer::Current() out of range");
0146 return myNodeStack.Value(theDepth);
0147 }
0148
0149
0150
0151 int CurrentDepth() const { return myCurrent.IsAssembly ? myTop : myTop + 1; }
0152
0153
0154 Standard_EXPORT void Next();
0155
0156
0157 const occ::handle<XCAFDoc_ColorTool>& ColorTool() const { return myColorTool; }
0158
0159
0160 const occ::handle<XCAFDoc_VisMaterialTool>& VisMaterialTool() const { return myVisMatTool; }
0161
0162 protected:
0163
0164 Standard_EXPORT void initRoot();
0165
0166
0167 Standard_EXPORT void initCurrent(bool theIsAssembly);
0168
0169 protected:
0170 occ::handle<XCAFDoc_ColorTool> myColorTool;
0171 occ::handle<XCAFDoc_VisMaterialTool> myVisMatTool;
0172 NCollection_Sequence<TDF_Label> myRoots;
0173 NCollection_Sequence<TDF_Label>::Iterator myRootIter;
0174 NCollection_DynamicArray<XCAFPrs_DocumentNode> myNodeStack;
0175 int myTop;
0176
0177 bool myHasMore;
0178
0179 XCAFPrs_Style myDefStyle;
0180 XCAFPrs_DocumentNode myCurrent;
0181 XCAFPrs_DocumentExplorerFlags myFlags;
0182 };
0183
0184 #endif