#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFDoc_VisMaterialTool.hxx>
#include <XCAFPrs_DocumentIdIterator.hxx>
namespace
{
//! Return merged style for the child node.
static XCAFPrs_Style mergedStyle (const Handle(XCAFDoc_ColorTool)& theColorTool,
+ const Handle(XCAFDoc_VisMaterialTool)& theVisMatTool,
const XCAFPrs_Style& theParenStyle,
const TDF_Label& theLabel,
const TDF_Label& theRefLabel)
}
XCAFPrs_Style aStyle = theParenStyle;
+ if (Handle(XCAFDoc_VisMaterial) aVisMat = theVisMatTool->GetShapeMaterial (theRefLabel))
+ {
+ aStyle.SetMaterial (aVisMat);
+ }
Quantity_ColorRGBA aColor;
if (theColorTool->GetColor (theRefLabel, XCAFDoc_ColorGen, aColor))
{
if (theLabel != theRefLabel)
{
// override Reference style with Instance style when defined (bad model?)
+ if (Handle(XCAFDoc_VisMaterial) aVisMat = theVisMatTool->GetShapeMaterial (theLabel))
+ {
+ aStyle.SetMaterial (aVisMat);
+ }
if (theColorTool->GetColor (theLabel, XCAFDoc_ColorGen, aColor))
{
aStyle.SetColorCurv (aColor.GetRGB());
if ((theFlags & XCAFPrs_DocumentExplorerFlags_NoStyle) == 0)
{
myColorTool = XCAFDoc_DocumentTool::ColorTool (theDocument->Main());
+ myVisMatTool = XCAFDoc_DocumentTool::VisMaterialTool (theDocument->Main());
}
else
{
myColorTool.Nullify();
+ myVisMatTool.Nullify();
}
myDefStyle = theDefStyle;
XCAFDoc_ShapeTool::GetReferredShape (myCurrent.Label, myCurrent.RefLabel);
myCurrent.LocalTrsf= XCAFDoc_ShapeTool::GetLocation (myCurrent.Label);
myCurrent.Location = myCurrent.LocalTrsf;
- myCurrent.Style = mergedStyle (myColorTool, myDefStyle, myCurrent.Label, myCurrent.RefLabel);
+ myCurrent.Style = mergedStyle (myColorTool, myVisMatTool, myDefStyle, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Id = DefineChildId (myCurrent.Label, TCollection_AsciiString());
}
else
XCAFDoc_ShapeTool::GetReferredShape (myCurrent.Label, myCurrent.RefLabel);
myCurrent.LocalTrsf= XCAFDoc_ShapeTool::GetLocation (myCurrent.Label);
myCurrent.Location = aTopNodeInStack.Location * myCurrent.LocalTrsf;
- myCurrent.Style = mergedStyle (myColorTool, aTopNodeInStack.Style, myCurrent.Label, myCurrent.RefLabel);
+ myCurrent.Style = mergedStyle (myColorTool, myVisMatTool, aTopNodeInStack.Style, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Id = DefineChildId (myCurrent.Label, aTopNodeInStack.Id);
}
}
aNodeInStack.ChildIter = TDF_ChildIterator (aNodeInStack.RefLabel);
aNodeInStack.LocalTrsf = XCAFDoc_ShapeTool::GetLocation (aNodeInStack.Label);
aNodeInStack.Location = aNodeInStack.LocalTrsf;
- aNodeInStack.Style = mergedStyle (myColorTool, myDefStyle, aNodeInStack.Label, aNodeInStack.RefLabel);
+ aNodeInStack.Style = mergedStyle (myColorTool, myVisMatTool, myDefStyle, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Id = DefineChildId (aNodeInStack.Label, TCollection_AsciiString());
myNodeStack.SetValue (0, aNodeInStack);
if ((myFlags & XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes) == 0)
aNodeInStack.RefLabel = aRefLabel;
aNodeInStack.LocalTrsf = XCAFDoc_ShapeTool::GetLocation (aNodeInStack.Label);
aNodeInStack.Location = aParent.Location * aNodeInStack.LocalTrsf;
- aNodeInStack.Style = mergedStyle (myColorTool, aParent.Style, aNodeInStack.Label, aNodeInStack.RefLabel);
+ aNodeInStack.Style = mergedStyle (myColorTool, myVisMatTool, aParent.Style, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Id = DefineChildId (aNodeInStack.Label, aParent.Id);
aNodeInStack.ChildIter = TDF_ChildIterator (aNodeInStack.RefLabel);
myNodeStack.SetValue (myTop, aNodeInStack);
class TDocStd_Document;
class XCAFDoc_ShapeTool;
class XCAFDoc_ColorTool;
+class XCAFDoc_VisMaterialTool;
typedef Standard_Integer XCAFPrs_DocumentExplorerFlags;
//! Go to the next node.
Standard_EXPORT void Next();
+ //! Return color tool.
+ const Handle(XCAFDoc_ColorTool)& ColorTool() const { return myColorTool; }
+
+ //! Return material tool.
+ const Handle(XCAFDoc_VisMaterialTool)& VisMaterialTool() const { return myVisMatTool; }
+
protected:
//! Initialize root label.
protected:
- Handle(XCAFDoc_ColorTool) myColorTool; //!< color tool
- TDF_LabelSequence myRoots; //!< sequence of root labels
- TDF_LabelSequence::Iterator myRootIter; //!< current root label
+ Handle(XCAFDoc_ColorTool) myColorTool; //!< color tool
+ Handle(XCAFDoc_VisMaterialTool) myVisMatTool; //!< visual material tool
+ TDF_LabelSequence myRoots; //!< sequence of root labels
+ TDF_LabelSequence::Iterator myRootIter; //!< current root label
NCollection_Vector<XCAFPrs_DocumentNode>
- myNodeStack; //!< node stack
- Standard_Integer myTop; //!< top position in the node stack
- Standard_Boolean myHasMore; //!< global flag indicating that iterator points to the label
- XCAFPrs_Style myDefStyle; //!< default style
- XCAFPrs_DocumentNode myCurrent; //!< current label info
- XCAFPrs_DocumentExplorerFlags myFlags; //!< iteration flags
+ myNodeStack; //!< node stack
+ Standard_Integer myTop; //!< top position in the node stack
+ Standard_Boolean myHasMore; //!< global flag indicating that iterator points to the label
+ XCAFPrs_Style myDefStyle; //!< default style
+ XCAFPrs_DocumentNode myCurrent; //!< current label info
+ XCAFPrs_DocumentExplorerFlags myFlags; //!< iteration flags
};