Salome HOME
lot 3 - coloring of section in OCC view see also refs #1838
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.cxx
index 27568465b9f153e1bde9a5d0b206f4b8f628b01b..691581602fd92b506ca83efd43cb29ee673a4add 100644 (file)
@@ -42,6 +42,7 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
 
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
@@ -185,8 +186,48 @@ void HYDROGUI_Shape::update( bool isUpdateViewer,
         }
       }
 
-      QColor aWireColor = aPolyline->GetWireColor();
-      setBorderColor( aWireColor, false, false );
+      //QColor aWireColor = aPolyline->GetWireColor();
+      std::vector<QColor> aSectColors;
+      //TODO backward comp. with old aWireColor??
+      int nbSec = aPolyline->NbSections();
+      for (int i = 0; i < nbSec; i++)
+      {
+        QColor aColor;
+        aPolyline->GetSectionColor(i, aColor);
+        aSectColors.push_back(aColor);
+      }         
+
+      //
+      //setBorderColor( aWireColor, false, false );
+
+      foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+      {
+        if( !myTopoShape.IsNull() )
+        {
+          Handle(HYDROGUI_Polyline) aPShape = Handle(HYDROGUI_Polyline)::DownCast( aShape );
+          bool WireOrCmp = myTopoShape.ShapeType() == TopAbs_WIRE || myTopoShape.ShapeType() == TopAbs_COMPOUND;
+          if ( !aPShape.IsNull() && WireOrCmp)
+          {
+            TopTools_IndexedMapOfShape MW;
+            TopExp::MapShapes(myTopoShape, TopAbs_WIRE, MW);
+            if (MW.Extent() == nbSec)
+            {
+              for (int i=0;i<nbSec;i++)
+              {
+                const TopoDS_Shape& CW = MW(i+1);
+                Quantity_Color aFColor( getQuantityColorVal( aSectColors[i].red() ), 
+                  getQuantityColorVal( aSectColors[i].green() ),
+                  getQuantityColorVal( aSectColors[i].blue() ),
+                  Quantity_TOC_RGB );
+                aPShape->myShapeToColor.Add(CW, aFColor);
+              }
+            }
+          }
+        }
+      }    
+
+      //if ( theToDisplay && isVisible() && !myContext.IsNull() )  
+      //  displayShape( false );
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
     {