mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028188: Improving layer color storage mechanism for DXF Import/Export
Attribute ColorByLayer was added for shapes that should be colored by the color of their layer or, if it's absent, by the parent component's layer color. Fixing inconsistency of iterating through the map of Styles Improving ColorByLayer mechanism Fix for Map/IndexedMad differences. Renaming according to convention of naming collection typedefs
This commit is contained in:
@@ -2,10 +2,10 @@ XCAFPrs.cxx
|
||||
XCAFPrs.hxx
|
||||
XCAFPrs_AISObject.cxx
|
||||
XCAFPrs_AISObject.hxx
|
||||
XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle.hxx
|
||||
XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx
|
||||
XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx
|
||||
XCAFPrs_DataMapIteratorOfDataMapOfStyleTransient.hxx
|
||||
XCAFPrs_DataMapOfShapeStyle.hxx
|
||||
XCAFPrs_IndexedDataMapOfShapeStyle.hxx
|
||||
XCAFPrs_DataMapOfStyleShape.hxx
|
||||
XCAFPrs_DataMapOfStyleTransient.hxx
|
||||
XCAFPrs_Driver.cxx
|
||||
|
@@ -86,16 +86,29 @@ static Standard_Boolean getShapesOfSHUO (TopLoc_IndexedMapOfLocation& theaPrevLo
|
||||
//=======================================================================
|
||||
|
||||
void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
const TopLoc_Location& theLoc,
|
||||
XCAFPrs_DataMapOfShapeStyle& theSettings)
|
||||
const TopLoc_Location& theLoc,
|
||||
XCAFPrs_IndexedDataMapOfShapeStyle& theSettings,
|
||||
const Quantity_ColorRGBA& theLayerColor)
|
||||
{
|
||||
// for references, first collect colors of referred shape
|
||||
{
|
||||
TDF_Label aLabelRef;
|
||||
if (XCAFDoc_ShapeTool::GetReferredShape (theLabel, aLabelRef))
|
||||
{
|
||||
Quantity_ColorRGBA aLayerColor = theLayerColor;
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (theLabel);
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (theLabel, aLayerNames);
|
||||
if (aLayerNames->Length() == 1)
|
||||
{
|
||||
TDF_Label aLayer = aLayerTool->FindLayer (aLayerNames->First());
|
||||
Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool(theLabel);
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLayer, XCAFDoc_ColorGen, aColor))
|
||||
aLayerColor = aColor;
|
||||
}
|
||||
TopLoc_Location aLocSub = theLoc.Multiplied (XCAFDoc_ShapeTool::GetLocation (theLabel));
|
||||
CollectStyleSettings (aLabelRef, aLocSub, theSettings);
|
||||
CollectStyleSettings (aLabelRef, aLocSub, theSettings, aLayerColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +121,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
for (TDF_LabelSequence::Iterator aComponentIter (aComponentLabSeq); aComponentIter.More(); aComponentIter.Next())
|
||||
{
|
||||
const TDF_Label& aComponentLab = aComponentIter.Value();
|
||||
CollectStyleSettings (aComponentLab, theLoc, theSettings);
|
||||
CollectStyleSettings (aComponentLab, theLoc, theSettings, theLayerColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,19 +162,39 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
else
|
||||
{
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorGen, aColor))
|
||||
if (aColorTool->IsColorByLayer(aLabel))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
aStyle.SetColorSurf (aColor);
|
||||
Quantity_ColorRGBA aLayerColor = theLayerColor;
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (aLabel, aLayerNames);
|
||||
if (aLayerNames->Length() == 1)
|
||||
{
|
||||
TDF_Label aLayer = aLayerTool->FindLayer (aLayerNames->First());
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLayer, XCAFDoc_ColorGen, aColor))
|
||||
aLayerColor = aColor;
|
||||
}
|
||||
|
||||
aStyle.SetColorCurv (aLayerColor.GetRGB());
|
||||
aStyle.SetColorSurf (aLayerColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, aColor))
|
||||
else
|
||||
{
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, aColor))
|
||||
{
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +283,11 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
for (TopTools_SequenceOfShape::Iterator aShuoShapeIter (aShuoShapeSeq); aShuoShapeIter.More(); aShuoShapeIter.Next())
|
||||
{
|
||||
const TopoDS_Shape& aShuoShape = aShuoShapeIter.Value();
|
||||
theSettings.Bind (aShuoShape, aShuoStyle);
|
||||
XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek (aShuoShape);
|
||||
if (aMapStyle == NULL)
|
||||
theSettings.Add (aShuoShape, aShuoStyle);
|
||||
else
|
||||
*aMapStyle = aShuoStyle;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -273,7 +310,11 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
aSubshape.Move (theLoc);
|
||||
theSettings.Bind (aSubshape, aStyle);
|
||||
XCAFPrs_Style* aMapStyle = theSettings.ChangeSeek (aSubshape);
|
||||
if (aMapStyle == NULL)
|
||||
theSettings.Add (aSubshape, aStyle);
|
||||
else
|
||||
*aMapStyle = aStyle;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <XCAFPrs_DataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
class TDF_Label;
|
||||
class TopLoc_Location;
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
//! shape - style correspondence
|
||||
//! The location <loc> is for internal use, it
|
||||
//! should be Null location for external call
|
||||
Standard_EXPORT static void CollectStyleSettings (const TDF_Label& L, const TopLoc_Location& loc, XCAFPrs_DataMapOfShapeStyle& settings);
|
||||
Standard_EXPORT static void CollectStyleSettings (const TDF_Label& L, const TopLoc_Location& loc, XCAFPrs_IndexedDataMapOfShapeStyle& settings, const Quantity_ColorRGBA& theLayerColor = Quantity_ColorRGBA(Quantity_NOC_WHITE));
|
||||
|
||||
//! Set ViewNameMode for indicate display names or not.
|
||||
Standard_EXPORT static void SetViewNameMode (const Standard_Boolean viewNameMode);
|
||||
|
@@ -33,8 +33,8 @@
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFPrs.hxx>
|
||||
#include <XCAFPrs_DataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
|
||||
// Collecting information on colored subshapes
|
||||
TopLoc_Location aLoc;
|
||||
XCAFPrs_DataMapOfShapeStyle aSettings;
|
||||
XCAFPrs_IndexedDataMapOfShapeStyle aSettings;
|
||||
XCAFPrs::CollectStyleSettings (myLabel, aLoc, aSettings);
|
||||
|
||||
// Getting default colors
|
||||
@@ -146,12 +146,12 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
|
||||
// collect sub-shapes with the same style into compounds
|
||||
BRep_Builder aBuilder;
|
||||
NCollection_DataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style> aStyleGroups;
|
||||
for (XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle aStyledShapeIter (aSettings);
|
||||
NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style> aStyleGroups;
|
||||
for (XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle aStyledShapeIter (aSettings);
|
||||
aStyledShapeIter.More(); aStyledShapeIter.Next())
|
||||
{
|
||||
TopoDS_Compound aComp;
|
||||
if (aStyleGroups.Find (aStyledShapeIter.Value(), aComp))
|
||||
if (aStyleGroups.FindFromKey (aStyledShapeIter.Value(), aComp))
|
||||
{
|
||||
aBuilder.Add (aComp, aStyledShapeIter.Key());
|
||||
continue;
|
||||
@@ -159,12 +159,16 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
|
||||
aBuilder.MakeCompound (aComp);
|
||||
aBuilder.Add (aComp, aStyledShapeIter.Key());
|
||||
aStyleGroups.Bind (aStyledShapeIter.Value(), aComp);
|
||||
TopoDS_Compound* aMapShape = aStyleGroups.ChangeSeek (aStyledShapeIter.Value());
|
||||
if (aMapShape == NULL)
|
||||
aStyleGroups.Add (aStyledShapeIter.Value(), aComp);
|
||||
else
|
||||
*aMapShape = aComp;
|
||||
}
|
||||
aSettings.Clear();
|
||||
|
||||
// assign custom aspects
|
||||
for (NCollection_DataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style>::Iterator aStyleGroupIter (aStyleGroups);
|
||||
for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style>::Iterator aStyleGroupIter (aStyleGroups);
|
||||
aStyleGroupIter.More(); aStyleGroupIter.Next())
|
||||
{
|
||||
const TopoDS_Compound& aComp = aStyleGroupIter.Value();
|
||||
|
@@ -12,9 +12,9 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle_HeaderFile
|
||||
#define XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle_HeaderFile
|
||||
#ifndef XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle_HeaderFile
|
||||
#define XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle_HeaderFile
|
||||
|
||||
#include <XCAFPrs_DataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
|
||||
|
||||
#endif
|
@@ -13,16 +13,16 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef XCAFPrs_DataMapOfShapeStyle_HeaderFile
|
||||
#define XCAFPrs_DataMapOfShapeStyle_HeaderFile
|
||||
#ifndef XCAFPrs_IndexedDataMapOfShapeStyle_HeaderFile
|
||||
#define XCAFPrs_IndexedDataMapOfShapeStyle_HeaderFile
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
#include <TopTools_ShapeMapHasher.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
typedef NCollection_DataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher> XCAFPrs_DataMapOfShapeStyle;
|
||||
typedef NCollection_DataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle;
|
||||
typedef NCollection_IndexedDataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher> XCAFPrs_IndexedDataMapOfShapeStyle;
|
||||
typedef NCollection_IndexedDataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher>::Iterator XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle;
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user