Salome HOME
17.12.2013. Added Partition algorithm (draft version).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.cxx
index 4ba2ed2dd7422ba0768d12003154d2bfb9796140..597c9db775e82e70464816dee99f4e502f7c7f1c 100644 (file)
 
 #include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
+#include <HYDROData_DummyObject3D.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Obstacle.h>
 #include <HYDROData_PolylineXY.h>
+#include <HYDROData_Polyline3D.h>
 #include <HYDROData_Profile.h>
 #include <HYDROData_Region.h>
 #include <HYDROData_Stream.h>
@@ -114,6 +116,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
   if ( myContext.IsNull() )
     return;
 
+  bool isDeactivateSelection = false;
   // Try to retrieve information from object
   if ( !myObject.IsNull() )
   {
@@ -163,6 +166,32 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
           updateShape( false, false );
         }
       }
+
+      QColor aWireColor = aPolyline->GetWireColor();
+      setBorderColor( aWireColor, false, false );
+    }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
+    {
+      Handle(HYDROData_Polyline3D) aPolyline =
+        Handle(HYDROData_Polyline3D)::DownCast( myObject );
+
+      TopoDS_Shape aPolylineShape = aPolyline->GetShape3D();
+
+      if ( !aPolylineShape.IsNull() ) {
+        if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+          TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
+          setWire( aPolylineWire, false, false );  
+        } else {
+          myTopoShape = aPolylineShape;
+          myDisplayMode = AIS_WireFrame;
+
+          buildShape();
+          updateShape( false, false );
+        }
+      }
+
+      QColor aWireColor = aPolyline->GetBorderColor();
+      setBorderColor( aWireColor, false, false );
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
     {
@@ -267,26 +296,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
 
       setTextureFileName( aTextureFileName, false, false );
       setFace( aWire, false, false );
-    }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
-    {
-      Handle(HYDROData_Obstacle) anObstacle =
-        Handle(HYDROData_Obstacle)::DownCast( myObject );
-
-      //TODO BEGIN of the block of code to be reimplemented
-      //TODO GetTopShape() to be used in future
-      myTopoShape = anObstacle->GetShape3D();
-      myDisplayMode = AIS_Shaded;
-
-      QColor aFillingColor = anObstacle->GetFillingColor();
-      QColor aBorderColor = anObstacle->GetBorderColor();
-
-      setFillingColor( aFillingColor, false, false );
-      setBorderColor( aBorderColor, false, false );
-
-      buildShape();
-      updateShape( false, false );
-      //TODO END of the block of code to be reimplemented
+      isDeactivateSelection = true;
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
     {
@@ -305,33 +315,37 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       }
 
       setWire( aProfileWire, false, false );  
+
+      QColor aWireColor = aProfile->GetBorderColor();
+      setBorderColor( aWireColor, false, false );
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) )
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) ||
+              myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ||
+              myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
     {
-      Handle(HYDROData_Stream) aStream =
-        Handle(HYDROData_Stream)::DownCast( myObject );
+      Handle(HYDROData_Object) aGeomObject =
+        Handle(HYDROData_Object)::DownCast( myObject );
 
-      TopoDS_Shell aStreamShape = TopoDS::Shell( aStream->GetTopShape() );
+      TopoDS_Shape anObjShape = aGeomObject->GetTopShape();
 
-      setShape( aStreamShape, false, false );
+      setShape( anObjShape, false, false );
 
-      QColor aFillingColor = aStream->GetFillingColor();
-      QColor aBorderColor = aStream->GetBorderColor();
+      QColor aFillingColor = aGeomObject->GetFillingColor();
+      QColor aBorderColor = aGeomObject->GetBorderColor();
 
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) )
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_DummyObject3D) ) )
     {
-      Handle(HYDROData_Channel) aChannel =
-        Handle(HYDROData_Channel)::DownCast( myObject );
+      Handle(HYDROData_DummyObject3D) anObject3D =
+        Handle(HYDROData_DummyObject3D)::DownCast( myObject );
+      TopoDS_Shape aShape3D = anObject3D->GetShape();
 
-      TopoDS_Face aChannelShape = TopoDS::Face( aChannel->GetTopShape() );
+      setShape( aShape3D, false, false );
 
-      setShape( aChannelShape, false, false );
-
-      QColor aFillingColor = aChannel->GetFillingColor();
-      QColor aBorderColor = aChannel->GetBorderColor();
+      QColor aFillingColor = anObject3D->GetFillingColor();
+      QColor aBorderColor = anObject3D->GetBorderColor();
 
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
@@ -342,6 +356,8 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
     return;
 
   myContext->Display( myShape, theIsUpdateViewer );
+  if (isDeactivateSelection)
+    myContext->Deactivate(myShape);
 }
 
 void HYDROGUI_Shape::setVisible( const bool theState,
@@ -361,7 +377,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;
@@ -372,7 +388,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight )
     return;
 
   colorShapeBorder( getActiveColor() );
-  myContext->Display( myShape );
+  myContext->Display( myShape, isUpdateViewer );
 }
 
 bool HYDROGUI_Shape::isHighlighted() const
@@ -655,7 +671,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 )