Salome HOME
patch for install error on Linux
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeBathymetry.cxx
index 9835e1aa37db2db37ac5f565050cd25723a05bf6..e8e7941b670df5490036037941cc70b95161a62b 100644 (file)
@@ -37,7 +37,7 @@ HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer*
 
 HYDROGUI_ShapeBathymetry::~HYDROGUI_ShapeBathymetry()
 {
-  myDisplayer->SetToUpdateColorScale();
+  setToUpdateColorScale( true );
 }
 
 void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivateSelection )
@@ -48,7 +48,7 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate
 
   Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
 
-  if ( !aBath.IsNull() )
+  if ( !aBath.IsNull() && !aBath->GetAltitudePoints().empty())
   {
     buildShape();
     updateShape( false, false );
@@ -104,6 +104,8 @@ void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const
 
 void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(Aspect_ColorScale)& theColorScale )
 {
+  if (!myCoords)
+    return;
   for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
   {
     double z = myCoords->Value( i ).Z();
@@ -122,8 +124,7 @@ void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
   bool isShown = getContext()->IsDisplayed( getAISObject() );
   bool isChanged = ( isShown != theState );
   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
-  if( isChanged )
-    myDisplayer->SetToUpdateColorScale();
+  setToUpdateColorScale( isChanged );
 }
 
 void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
@@ -131,8 +132,7 @@ void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
   bool isShown = getContext()->IsDisplayed( getAISObject() );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
-  if( isChanged )
-    myDisplayer->SetToUpdateColorScale();
+  setToUpdateColorScale( isChanged );
 }
 
 void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
@@ -140,8 +140,7 @@ void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
   bool isShown = getContext()->IsDisplayed( getAISObject() );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::display( theIsUpdateViewer );
-  if( isChanged )
-    myDisplayer->SetToUpdateColorScale();
+  setToUpdateColorScale( isChanged );
 }
 
 void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
@@ -149,6 +148,13 @@ void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
   bool isShown = getContext()->IsDisplayed( getAISObject() );
   bool isChanged = ( isShown  );
   HYDROGUI_Shape::erase( theIsUpdateViewer );
-  if( isChanged )
+  setToUpdateColorScale( isChanged );
+}
+
+void HYDROGUI_ShapeBathymetry::setToUpdateColorScale( bool isChanged )
+{
+#ifndef LIGHT_MODE
+  if( isChanged && myDisplayer )
     myDisplayer->SetToUpdateColorScale();
+#endif
 }