]> OCCT Git - occt.git/commitdiff
0028188: Improving layer color storage mechanism for DXF Import/Export
authoranv <anv@opencascade.com>
Thu, 29 Dec 2016 08:48:16 +0000 (11:48 +0300)
committerkgv <kgv@opencascade.com>
Fri, 29 Sep 2017 06:42:12 +0000 (09:42 +0300)
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

16 files changed:
src/IGESCAFControl/IGESCAFControl_Writer.cxx
src/IGESCAFControl/IGESCAFControl_Writer.hxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_ColorTool.cxx
src/XCAFDoc/XCAFDoc_ColorTool.hxx
src/XCAFPrs/FILES
src/XCAFPrs/XCAFPrs.cxx
src/XCAFPrs/XCAFPrs.hxx
src/XCAFPrs/XCAFPrs_AISObject.cxx
src/XCAFPrs/XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle.hxx [deleted file]
src/XCAFPrs/XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx [new file with mode: 0644]
src/XCAFPrs/XCAFPrs_DataMapOfShapeStyle.hxx [deleted file]
src/XCAFPrs/XCAFPrs_IndexedDataMapOfShapeStyle.hxx [new file with mode: 0644]
src/XDEDRAW/XDEDRAW.cxx

index 65aa2b97c06593ec043f54e0a5fc80e2f86466a7..027df6bfd7f636863f71c83ff33f56bfb4b526cf 100644 (file)
@@ -236,7 +236,7 @@ Standard_Boolean IGESCAFControl_Writer::WriteAttributes (const TDF_LabelSequence
     TDF_Label L = labels.Value(i);
 
     // collect color settings
-    XCAFPrs_DataMapOfShapeStyle settings;
+    XCAFPrs_IndexedDataMapOfShapeStyle settings;
     TopLoc_Location loc;
     XCAFPrs::CollectStyleSettings ( L, loc, settings );
     if ( settings.Extent() <=0 ) continue;
@@ -262,7 +262,7 @@ Standard_Boolean IGESCAFControl_Writer::WriteAttributes (const TDF_LabelSequence
 //=======================================================================
 
 void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S, 
-                                       const XCAFPrs_DataMapOfShapeStyle &settings,
+                                       const XCAFPrs_IndexedDataMapOfShapeStyle &settings,
                                        XCAFPrs_DataMapOfStyleTransient &colors,
                                        TopTools_MapOfShape &Map,
                                        const XCAFPrs_Style &inherit) 
@@ -272,8 +272,8 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
   
   // check if shape has its own style (or inherits from ancestor)
   XCAFPrs_Style style = inherit;
-  if ( settings.IsBound(S) ) {
-    XCAFPrs_Style own = settings.Find(S);
+  if ( settings.Contains(S) ) {
+    XCAFPrs_Style own = settings.FindFromKey(S);
     if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
     if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
   }
index ff725bc285f5254bd3488fcbc09a7bb9bd06e93f..a8cdeb915a9d817e2cd0b3f9b4a45400d70d1c4b 100644 (file)
@@ -24,7 +24,7 @@
 #include <IGESControl_Writer.hxx>
 #include <Standard_CString.hxx>
 #include <TDF_LabelSequence.hxx>
-#include <XCAFPrs_DataMapOfShapeStyle.hxx>
+#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
 #include <XCAFPrs_DataMapOfStyleTransient.hxx>
 #include <TopTools_MapOfShape.hxx>
 class XSControl_WorkSession;
@@ -125,7 +125,7 @@ private:
   
   //! Recursively iterates on subshapes and assigns colors
   //! to faces and edges (if set)
-  Standard_EXPORT void MakeColors (const TopoDS_Shape& S, const XCAFPrs_DataMapOfShapeStyle& settings, XCAFPrs_DataMapOfStyleTransient& colors, TopTools_MapOfShape& Map, const XCAFPrs_Style& inherit);
+  Standard_EXPORT void MakeColors (const TopoDS_Shape& S, const XCAFPrs_IndexedDataMapOfShapeStyle& settings, XCAFPrs_DataMapOfStyleTransient& colors, TopTools_MapOfShape& Map, const XCAFPrs_Style& inherit);
 
 
   Standard_Boolean myColorMode;
index 270e98b80705a4f04f54f3d7f9ff7e0ce15b0407..67ac7f2993997bc36b0f7aaae1d6469bb465e888 100644 (file)
 #include <XCAFDoc_Volume.hxx>
 #include <XCAFPrs.hxx>
 #include <XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx>
-#include <XCAFPrs_DataMapOfShapeStyle.hxx>
+#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
 #include <XCAFPrs_DataMapOfStyleShape.hxx>
 #include <XCAFPrs_Style.hxx>
 #include <XSControl_TransferWriter.hxx>
@@ -1031,7 +1031,7 @@ static Standard_Boolean setDefaultInstanceColor (const Handle(StepVisual_StyledI
 //=======================================================================
 static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
                            const TopoDS_Shape &S,
-                           const XCAFPrs_DataMapOfShapeStyle &settings,
+                           const XCAFPrs_IndexedDataMapOfShapeStyle &settings,
                            Handle(StepVisual_StyledItem) &override,
                            TopTools_MapOfShape &Map,
                             const MoniTool_DataMapOfShapeTransient& myMapCompMDGPR,
@@ -1047,8 +1047,8 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
   // check if shape has its own style (r inherits from ancestor)
   XCAFPrs_Style style;
   if ( inherit ) style = *inherit;
-  if ( settings.IsBound(S) ) {
-    XCAFPrs_Style own = settings.Find(S);
+  if ( settings.Contains(S) ) {
+    XCAFPrs_Style own = settings.FindFromKey(S);
     if ( !own.IsVisible() ) style.SetVisibility ( Standard_False );
     if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
     if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
@@ -1199,7 +1199,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
         continue;
     
     // collect settings set on that label
-    XCAFPrs_DataMapOfShapeStyle settings;
+    XCAFPrs_IndexedDataMapOfShapeStyle settings;
     TDF_LabelSequence seq;
     seq.Append ( L );
     XCAFDoc_ShapeTool::GetSubShapes ( L, seq );
@@ -1232,7 +1232,11 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
       if ( ! style.IsSetColorCurv() && ! style.IsSetColorSurf() && isVisible ) continue;
 
       TopoDS_Shape sub = XCAFDoc_ShapeTool::GetShape ( lab );
-      settings.Bind ( sub, style );
+      XCAFPrs_Style* aMapStyle = settings.ChangeSeek (sub);
+      if (aMapStyle == NULL)
+        settings.Add ( sub, style );
+      else
+        *aMapStyle = style;
     }
     
     if ( settings.Extent() <=0 ) continue;
index e92b36227eef527d7e8a413e63461f6d15ed9106..222fb7aa92ab1c2d8d628e582633efaa3c672e16 100644 (file)
@@ -195,6 +195,18 @@ Standard_GUID XCAFDoc::InvisibleGUID ()
 }
 
 
+//=======================================================================
+//function : ColorByLayerGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::ColorByLayerGUID ()
+{
+  static Standard_GUID ID ("279e8c1e-70af-4130-b626-9cc52a537db8");
+  return ID;
+}
+
+
 //=======================================================================
 //function : SHUORefGUID
 //purpose  : 
index 3a6ae88366fc8501b226e835eb66459eebf02d1a..7f09f721ac87a30daec542a11f96723d50c2351e 100644 (file)
@@ -102,6 +102,8 @@ public:
   Standard_EXPORT static Standard_GUID NoteRefGUID();
 
   Standard_EXPORT static Standard_GUID InvisibleGUID();
+
+  Standard_EXPORT static Standard_GUID ColorByLayerGUID();
   
   //! Returns GUID for UAttribute identifying external reference on no-step file
   Standard_EXPORT static Standard_GUID ExternRefGUID();
index 6e6402e707cf31ac20f60bda5637a5c49b7590de..0c98aa410d37346630727bcdfba82e5e6a0f1957 100644 (file)
@@ -558,6 +558,35 @@ void XCAFDoc_ColorTool::SetVisibility (const TDF_Label& L,
   else L.ForgetAttribute( XCAFDoc::InvisibleGUID() );
 }
 
+//=======================================================================
+//function : IsColorByLayer
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean XCAFDoc_ColorTool::IsColorByLayer (const TDF_Label& L) const
+{
+  Handle(TDataStd_UAttribute) aUAttr;
+  return L.FindAttribute(XCAFDoc::ColorByLayerGUID(), aUAttr);
+}
+
+//=======================================================================
+//function : SetColorByLayer
+//purpose  : 
+//=======================================================================
+
+void XCAFDoc_ColorTool::SetColorByLayer (const TDF_Label& L,
+                                         const Standard_Boolean isColorByLayer)
+{
+  Handle(TDataStd_UAttribute) aUAttr;
+  if ( isColorByLayer ) {
+    Handle(XCAFDoc_GraphNode) aSHUO;
+    if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO( L, aSHUO ) )
+      if (!L.FindAttribute(XCAFDoc::ColorByLayerGUID(), aUAttr))
+        aUAttr->Set( L, XCAFDoc::ColorByLayerGUID() );
+  }
+  else L.ForgetAttribute( XCAFDoc::ColorByLayerGUID() );
+}
+
 //=======================================================================
 //function : SetInstanceColor
 //purpose  : 
index 0ef9cee73ed89e29ce161fb16eb0c40a5a736dd8..8a582ed574650547cf293ae0ba676cca54abe2bb 100644 (file)
@@ -198,7 +198,14 @@ public:
   //! Set the visibility of object on label. Do nothing if there no any object.
   //! Set UAttribute with corresponding GUID.
   Standard_EXPORT void SetVisibility (const TDF_Label& shapeLabel, const Standard_Boolean isvisible = Standard_True);
-  
+
+  //! Return TRUE if object color defined by its Layer, FALSE if not.
+  Standard_EXPORT Standard_Boolean IsColorByLayer (const TDF_Label& L) const;
+
+  //! Set the Color defined by Layer flag on label. Do nothing if there no any object.
+  //! Set UAttribute with corresponding GUID.
+  Standard_EXPORT void SetColorByLayer (const TDF_Label& shapeLabel, const Standard_Boolean isColorByLayer = Standard_False);
+
   //! Sets the color of component that styled with SHUO structure
   //! Returns FALSE if no sush component found
   //! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
index fd493ba4904775d1c052fa705db94d8e5752ae58..a0185927e835abd1deb6ac85e93658a52df0b471 100644 (file)
@@ -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
index 151e1b2ff78acdc8920f11a906ecd28d5b07bb4e..762eb4405a88f1aac9bdb0799528b54784e24661 100644 (file)
@@ -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);
-      }
-      if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, aColor))
-      {
-        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_ColorCurv, aColor))
+      else
       {
-        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;
   }
 }
 
index 17591adb1697dd73faa63e46c3d853e2cada63a1..e349689193e3fb60ae566ba01b4c5c10c7f7b173 100644 (file)
@@ -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);
index 44d92c1e19d005d3e99ad65dd26a9c0ae61ebdfa..eb33f41910b0152a83f4ce3e76ad38d0b2018db7 100644 (file)
@@ -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();
diff --git a/src/XCAFPrs/XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle.hxx b/src/XCAFPrs/XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle.hxx
deleted file mode 100644 (file)
index 11c83b4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2015 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#ifndef XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle_HeaderFile
-#define XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle_HeaderFile
-
-#include <XCAFPrs_DataMapOfShapeStyle.hxx>
-
-#endif
diff --git a/src/XCAFPrs/XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx b/src/XCAFPrs/XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx
new file mode 100644 (file)
index 0000000..3dc79b7
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle_HeaderFile
+#define XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle_HeaderFile
+
+#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
+
+#endif
diff --git a/src/XCAFPrs/XCAFPrs_DataMapOfShapeStyle.hxx b/src/XCAFPrs/XCAFPrs_DataMapOfShapeStyle.hxx
deleted file mode 100644 (file)
index 91aef6b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Created on: 2000-08-11
-// Created by: Andrey BETENEV
-// Copyright (c) 2000-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// 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
-
-#include <TopoDS_Shape.hxx>
-#include <XCAFPrs_Style.hxx>
-#include <TopTools_ShapeMapHasher.hxx>
-#include <NCollection_DataMap.hxx>
-
-typedef NCollection_DataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher> XCAFPrs_DataMapOfShapeStyle;
-typedef NCollection_DataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle;
-
-
-#endif
diff --git a/src/XCAFPrs/XCAFPrs_IndexedDataMapOfShapeStyle.hxx b/src/XCAFPrs/XCAFPrs_IndexedDataMapOfShapeStyle.hxx
new file mode 100644 (file)
index 0000000..e3b48a2
--- /dev/null
@@ -0,0 +1,28 @@
+// Created on: 2000-08-11
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef XCAFPrs_IndexedDataMapOfShapeStyle_HeaderFile
+#define XCAFPrs_IndexedDataMapOfShapeStyle_HeaderFile
+
+#include <TopoDS_Shape.hxx>
+#include <XCAFPrs_Style.hxx>
+#include <TopTools_ShapeMapHasher.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+
+typedef NCollection_IndexedDataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher> XCAFPrs_IndexedDataMapOfShapeStyle;
+typedef NCollection_IndexedDataMap<TopoDS_Shape,XCAFPrs_Style,TopTools_ShapeMapHasher>::Iterator XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle;
+
+
+#endif
index 53e003c83b4267c74efeae16809079c8d7c44d97..606a6118c86af237293cbbe8ea7c012744f612da 100644 (file)
@@ -304,21 +304,49 @@ static void StatAssembly(const TDF_Label L,
     NbAreaProp++;
   }
   Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
+  Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
   Quantity_ColorRGBA col;
   Standard_Boolean IsColor = Standard_False;
+  Standard_Boolean IsByLayer = Standard_False;
   if(CTool->GetColor(L,XCAFDoc_ColorGen,col))
     IsColor = Standard_True;
   else if(CTool->GetColor(L,XCAFDoc_ColorSurf,col))
     IsColor = Standard_True;
   else if(CTool->GetColor(L,XCAFDoc_ColorCurv,col))
     IsColor = Standard_True;
-  if(IsColor) {
-    TCollection_AsciiString Entry1;
-    Entry1 = col.GetRGB().StringName(col.GetRGB().Name());
-    if(PrintStructMode) di<<"Color("<<Entry1.ToCString()<<" "<<col.Alpha()<<") ";
-    NbShapesWithColor++;
+  else if(CTool->IsColorByLayer(L))
+    IsByLayer = Standard_True;
+  if(IsColor || IsByLayer) {
+    if(IsByLayer)
+    {
+      Handle(TColStd_HSequenceOfExtendedString) aLayerS;
+      LTool->GetLayers(L, aLayerS);
+      // Currently for DXF pnly, thus
+      // only 1 Layer should be.
+      if(aLayerS->Length() == 1)
+      {
+        TDF_Label aLayer = LTool->FindLayer (aLayerS->First());
+        Quantity_ColorRGBA aColor;
+        if (CTool->GetColor (aLayer, XCAFDoc_ColorGen, aColor))
+        {
+          TCollection_AsciiString aColorName = aColor.GetRGB().StringName(aColor.GetRGB().Name());
+          di<<"Color(" << aColorName.ToCString() << ") ";
+        }
+        else
+        {
+          di<<"Color(ByLayer) ";
+        }
+      }
+      NbShapesWithColor++;
+    }
+    else
+    {
+      TCollection_AsciiString Entry1;
+      Entry1 = col.GetRGB().StringName(col.GetRGB().Name());
+      if(PrintStructMode) di<<"Color("<<Entry1.ToCString()<<" "<<col.Alpha()<<") ";
+      NbShapesWithColor++;
+    }
   }
-  Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
   Handle(TColStd_HSequenceOfExtendedString) aLayerS;
   LTool->GetLayers(L, aLayerS);
   if(!aLayerS.IsNull() && aLayerS->Length()>0) {