Salome HOME
size of image is limited by 7000 pixels
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeBathymetry.cxx
index 75542ee3be2fe53bbf5e461d2e8ac94e1bfb9f2f..f211ae56480fbbd0e4e27861ffc0750604c24af5 100644 (file)
@@ -63,14 +63,16 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate
   HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
 }
 
-Handle(AIS_InteractiveObject) HYDROGUI_ShapeBathymetry::createShape() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() const
 {
+  QList<Handle(AIS_InteractiveObject)> shapes;
+
   Handle(AIS_InteractiveObject) aPntCloud;
 
   Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
   if( !aBath.IsNull() )
   {
-    aPntCloud = new HYDROGUI_BathymetryPrs();
+    aPntCloud = new HYDROGUI_BathymetryPrs( this );
     //aPntCloud->SetHilightMode( AIS_PointCloud::DM_BndBox );
     aPntCloud->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 2.0));
 
@@ -83,14 +85,16 @@ Handle(AIS_InteractiveObject) HYDROGUI_ShapeBathymetry::createShape() const
     aThat->myColors = new Quantity_HArray1OfColor( aLower, anUpper );
     for( int i=aLower; i<=anUpper; i++ )
       aThat->myCoords->SetValue( i, gp_Pnt( aBathPoints[i].X, aBathPoints[i].Y, aBathPoints[i].Z ) );
+
+    shapes.append( aPntCloud );
   }
 
-  return aPntCloud;
+  return shapes;
 }
 
 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++ )
@@ -104,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() );
+  Handle(HYDROGUI_BathymetryPrs) aPntCloud = Handle(HYDROGUI_BathymetryPrs)::DownCast( getAISObjects()[0] );
   aPntCloud->SetPoints( myCoords, myColors );
   getContext()->RecomputePrsOnly( aPntCloud, Standard_True );
   getContext()->RecomputeSelectionOnly( aPntCloud );
@@ -113,7 +117,10 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale
 void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
                                            const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  if( getAISObjects().isEmpty() )
+    return;
+
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown != theState );
   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -121,7 +128,10 @@ void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
 
 void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  if( getAISObjects().isEmpty() )
+    return;
+
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -129,7 +139,10 @@ void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  if( getAISObjects().isEmpty() )
+    return;
+
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::display( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -137,7 +150,10 @@ void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  if( getAISObjects().isEmpty() )
+    return;
+
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown  );
   HYDROGUI_Shape::erase( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -228,7 +244,10 @@ void HYDROGUI_ShapeBathymetry::Rescale( double theMin, double theMax )
   getContext()->ClearSelected();
   myMin = qMin( theMin, theMax );
   myMax = qMax( theMin, theMax );
-  getAISObject()->Redisplay();
+  setToUpdateColorScale( true );
+
+  if( !getAISObjects().isEmpty() )
+    getAISObjects()[0]->Redisplay();
 }
 
 void HYDROGUI_ShapeBathymetry::RescaleDefault()
@@ -265,12 +284,18 @@ 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;
 
-  QList<int> selection = selected();
+  QList<int> selection;
+  if( isOn )
+    selection = selected();
+
   getContext()->ClearSelected();
   prs->SetTextLabels( selection );
-  getAISObject()->Redisplay();
+  prs->Redisplay();
 }