Salome HOME
size of image is limited by 7000 pixels
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeBathymetry.cxx
index 35e8362aee08b5aa3b660e2081ecde63a3aad8bc..f211ae56480fbbd0e4e27861ffc0750604c24af5 100644 (file)
@@ -94,7 +94,7 @@ QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() con
 
 void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale)& theColorScale )
 {
-  if (!myCoords)
+  if (!myCoords || getAISObjects().isEmpty())
     return;
 
   for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
@@ -108,7 +108,7 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale
     theColorScale->FindColor( z, aColor );
     myColors->SetValue( i, aColor );
   }
-  Handle(HYDROGUI_BathymetryPrs) aPntCloud = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObject()[0] );
+  Handle(HYDROGUI_BathymetryPrs) aPntCloud = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObjects()[0] );
   aPntCloud->SetPoints( myCoords, myColors );
   getContext()->RecomputePrsOnly( aPntCloud, Standard_True );
   getContext()->RecomputeSelectionOnly( aPntCloud );
@@ -117,6 +117,9 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale
 void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
                                            const bool theIsUpdateViewer )
 {
+  if( getAISObjects().isEmpty() )
+    return;
+
   bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown != theState );
   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
@@ -125,6 +128,9 @@ void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
 
 void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 {
+  if( getAISObjects().isEmpty() )
+    return;
+
   bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
@@ -133,6 +139,9 @@ void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 {
+  if( getAISObjects().isEmpty() )
+    return;
+
   bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::display( theIsUpdateViewer );
@@ -141,6 +150,9 @@ void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
 {
+  if( getAISObjects().isEmpty() )
+    return;
+
   bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown  );
   HYDROGUI_Shape::erase( theIsUpdateViewer );
@@ -233,7 +245,9 @@ void HYDROGUI_ShapeBathymetry::Rescale( double theMin, double theMax )
   myMin = qMin( theMin, theMax );
   myMax = qMax( theMin, theMax );
   setToUpdateColorScale( true );
-  getAISObject()->Redisplay();
+
+  if( !getAISObjects().isEmpty() )
+    getAISObjects()[0]->Redisplay();
 }
 
 void HYDROGUI_ShapeBathymetry::RescaleDefault()
@@ -270,7 +284,10 @@ void HYDROGUI_ShapeBathymetry::Build()
 
 void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn )
 {
-  Handle(HYDROGUI_BathymetryPrs) prs = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObject() );
+  if( getAISObjects().isEmpty() )
+    return;
+
+  Handle(HYDROGUI_BathymetryPrs) prs = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObjects()[0] );
   if( prs.IsNull() )
     return;
 
@@ -280,5 +297,5 @@ void HYDROGUI_ShapeBathymetry::TextLabels( bool isOn )
 
   getContext()->ClearSelected();
   prs->SetTextLabels( selection );
-  getAISObject()->Redisplay();
+  prs->Redisplay();
 }