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