Salome HOME
refs #1327: debug of scaling operations
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.cxx
index 1feb96abd543ce574ea68ea8494ab18cc06b0502..c34f2cc9522f4807a01529c4c8848175aa1fc626 100644 (file)
@@ -19,6 +19,7 @@
 #include <HYDROGUI_Shape.h>
 #include <HYDROGUI_Tool.h>
 #include <HYDROGUI_Polyline.h>
+#include <HYDROGUI_AISShape.h>
 
 #include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Zone.h>
 #include <HYDROData_LandCoverMap.h>
 
-#include <AIS_Shape.hxx>
 #include <BRep_Builder.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
@@ -425,10 +424,11 @@ void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
 
 void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
                                const bool          theToDisplay,
-                               const bool          theIsUpdateViewer )
+                               const bool          theIsUpdateViewer,
+                               const int           theDisplayMode )
 {
   myTopoShape = theShape;
-  myDisplayMode = AIS_Shaded;
+  myDisplayMode = theDisplayMode;
 
   buildShape();
   updateShape( theToDisplay, theIsUpdateViewer );
@@ -480,10 +480,10 @@ void HYDROGUI_Shape::setZLayer( const int theZLayer )
     myContext->SetZLayer( myShape, myZLayer );
 }
 
-Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
+Handle(AIS_InteractiveObject) HYDROGUI_Shape::createShape() const
 {
   if( myTopoShape.IsNull() ) {
-    return Handle_AIS_InteractiveObject();
+    return Handle(AIS_InteractiveObject)();
   }
 
   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
@@ -500,20 +500,20 @@ Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
   if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) {
     return new HYDROGUI_Polyline( myTopoShape );
   } else {
-    return new AIS_Shape( myTopoShape );
+    return new HYDROGUI_AISShape( myTopoShape );
   }
 }
 
 void HYDROGUI_Shape::buildShape()
 {
   // Erase previously created shape
-  erase();
+  erase(false);
 
   myShape = createShape();
   if( myShape.IsNull() )
     return;
 
-  Handle_AIS_Shape anAISShape = Handle_AIS_Shape::DownCast( myShape );
+  Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( myShape );
   if( !anAISShape.IsNull() )
     anAISShape ->SetHLRAngleAndDeviation( 0.001 );
 
@@ -523,9 +523,8 @@ void HYDROGUI_Shape::buildShape()
   if ( !myObject.IsNull() && !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
     myShape->SetTransparency( 0 );
   myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
-  myShape->SetSelectionMode( (Standard_Integer)mySelectionMode );
 
-    // Init default params for shape
+  // Init default params for shape
   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
   if ( !anAttributes.IsNull() )
   {
@@ -562,7 +561,7 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay,
   const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
   if ( !anAttributes.IsNull() )
   {
-    if ( myDisplayMode == AIS_Shaded )
+    if ( myDisplayMode == AIS_Shaded && myFillingColor.isValid() )
     {
       Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
                                     getQuantityColorVal( myFillingColor.green() ),
@@ -577,7 +576,7 @@ void HYDROGUI_Shape::updateShape( const bool theToDisplay,
     }
 
     // Coloring borders
-    colorShapeBorder( getActiveColor() );
+    colorShapeBorder( myBorderColor );
   }
 
   if ( !theToDisplay || !isVisible() || myContext.IsNull() )
@@ -658,27 +657,9 @@ void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
     }
     else if ( myDisplayMode == AIS_Shaded )
     {
-      if ( theColor.alpha() == 0 )
-      {
-        anAttributes->SetFaceBoundaryDraw( false );
-      }
-      else
-      {
-        anAttributes->SetFaceBoundaryDraw( true );
-  
-        Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
-        if ( !aBoundaryAspect.IsNull() )
-        {
-          aBoundaryAspect->SetColor( aBorderColor );
-          anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
-        }
-        Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect();
-        if ( !aWireAspect.IsNull() )
-        {
-          aWireAspect->SetColor( aBorderColor );
-          anAttributes->SetWireAspect( aWireAspect );
-        }
-      }
+      Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( myShape );
+      if( !aShape.IsNull() )
+        aShape->SetBorderColor( aBorderColor );
     }
     else if ( myDisplayMode == AIS_WireFrame )
     {
@@ -695,4 +676,4 @@ void HYDROGUI_Shape::setDisplayMode( int theDisplayMode )
 void HYDROGUI_Shape::setSelectionMode( int theSelectionMode )
 {
   mySelectionMode = theSelectionMode;
-}
\ No newline at end of file
+}