Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.cxx
index 3e73e5757ce3b0ee04bd90ad6a7273818327a4d6..37eaf35001c6050e1f74bab38968ac0aaa59cef9 100644 (file)
@@ -47,6 +47,7 @@
 #include <HYDROData_Polyline3D.h>
 #include <HYDROData_Profile.h>
 #include <HYDROData_Region.h>
+#include <HYDROData_ShapesGroup.h>
 #include <HYDROData_Stream.h>
 #include <HYDROData_Zone.h>
 
@@ -116,6 +117,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
   if ( myContext.IsNull() )
     return;
 
+  bool isDeactivateSelection = false;
   // Try to retrieve information from object
   if ( !myObject.IsNull() )
   {
@@ -295,6 +297,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
 
       setTextureFileName( aTextureFileName, false, false );
       setFace( aWire, false, false );
+      isDeactivateSelection = true;
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
     {
@@ -348,12 +351,36 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
     }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_ShapesGroup) ) )
+    {
+      Handle(HYDROData_ShapesGroup) aShapesGroup =
+        Handle(HYDROData_ShapesGroup)::DownCast( myObject );
+
+      TopTools_SequenceOfShape aShapes;
+      aShapesGroup->GetShapes( aShapes );
+
+      BRepBuilderAPI_MakeWire aMakeWire;
+
+      for ( int i = 1, n = aShapes.Length(); i <= n; ++i )
+      {
+        TopoDS_Edge anEdge = TopoDS::Edge( aShapes.Value( i ) );
+        aMakeWire.Add( anEdge );
+      }
+
+      aMakeWire.Build();
+      TopoDS_Wire aResWire = aMakeWire.Wire();
+
+      setWire( aResWire, false, false );  
+      setBorderColor( Qt::red, false, false );
+    }
   }
  
   if ( myShape.IsNull() || !isVisible() )
     return;
 
   myContext->Display( myShape, theIsUpdateViewer );
+  if (isDeactivateSelection)
+    myContext->Deactivate(myShape);
 }
 
 void HYDROGUI_Shape::setVisible( const bool theState,
@@ -373,7 +400,7 @@ void HYDROGUI_Shape::setVisible( const bool theState,
     myContext->Erase( myShape, theIsUpdateViewer );
 }
 
-void HYDROGUI_Shape::highlight( bool theIsHighlight )
+void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
 {
   if ( myIsHighlight == theIsHighlight )
     return;
@@ -384,7 +411,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight )
     return;
 
   colorShapeBorder( getActiveColor() );
-  myContext->Display( myShape );
+  myContext->Display( myShape, isUpdateViewer );
 }
 
 bool HYDROGUI_Shape::isHighlighted() const
@@ -667,7 +694,10 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
 
       Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
       if ( !aBoundaryAspect.IsNull() )
+      {
         aBoundaryAspect->SetColor( aBorderColor );
+        anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
+      }
     }
   }
   else if ( myDisplayMode == AIS_WireFrame )