Salome HOME
Feature #86: The hierarchy in the Object Browser (T 19).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index 2059057f492970c48311140ab3c68ce7f1cc2222..ecf6b2836e40ca5ef1e841bbde1ffe0f7c62fef8 100644 (file)
@@ -133,9 +133,6 @@ void HYDROGUI_ImmersibleZoneOp::startOperation()
   }
   
   aPanel->setObjectName( anObjectName );
-  
-  aPanel->setFillingColor( aFillingColor );
-  aPanel->setBorderColor( aBorderColor );
 
   aPanel->setPolylineNames( aPolylines );
   aPanel->setBathymetryNames( aBathymetries );
@@ -217,8 +214,10 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
 
   aZoneObj->SetName( anObjectName );
 
-  aZoneObj->SetFillingColor( aPanel->getFillingColor() );
-  aZoneObj->SetBorderColor( aPanel->getBorderColor() );
+  if ( !myIsEdit ) {
+    aZoneObj->SetFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
+    aZoneObj->SetBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
+  }
 
   aZoneObj->SetPolyline( aZonePolyline );
   aZoneObj->SetBathymetry( aZoneBathymetry );
@@ -240,12 +239,16 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
     return;
 
   TopoDS_Wire aWire;
+  TopoDS_Shape aShape;
 
   Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
     HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
   if ( !aPolyline.IsNull() )
   {
-    aWire = TopoDS::Wire( aPolyline->GetTopShape() );
+    aShape = aPolyline->GetTopShape();
+    if ( aShape.ShapeType() == TopAbs_WIRE ) {
+      aWire = TopoDS::Wire( aShape );
+    }
   }
 
   LightApp_Application* anApp = module()->getApp();
@@ -266,9 +269,23 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
   if ( !myViewManager || !myPreviewPrs )
     return;
 
-  myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false );
-  myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false );
-  myPreviewPrs->setFace( aWire );
+  QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor();
+  QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor();
+  if ( !myEditedObject.IsNull() ) {
+    aFillingColor = myEditedObject->GetFillingColor();
+    aBorderColor = myEditedObject->GetBorderColor();
+  }
+
+  myPreviewPrs->setFillingColor( aFillingColor, false, false );
+  myPreviewPrs->setBorderColor( aBorderColor, false, false );
+  if ( !aWire.IsNull() ) {
+    myPreviewPrs->setFace( aWire );
+  } else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND ) {
+    TopoDS_Compound aCompound = TopoDS::Compound( aShape );
+    if ( !aCompound.IsNull() ) {
+      myPreviewPrs->setFaces( aCompound );
+    }
+  }
 }
 
 void HYDROGUI_ImmersibleZoneOp::closePreview()