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