Salome HOME
land cover object is removed from the data model
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.cxx
index 2951e5838d5dd4003cb4ab77bac4bb40f461a312..edce573b2294e7e2bd3bc4afe9f68df1566c1e42 100644 (file)
@@ -248,6 +248,9 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), 
     SLOT( onStricklerTableSelected( const QString & ) ) );
 
+  connect( aPanel, SIGNAL( regenerateColors() ), this, 
+    SLOT( onRegenerateColors() ) );
+
   return aPanel;
 }
 
@@ -1329,29 +1332,13 @@ QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex,
                                                           float theSaturation/* = 0.5*/,
                                                           float theValue/* = 0.95*/ ) const
 {
-  float aGoldenRatioConjugate = (float)(360./582.);
-  float aHue = (float)(rand()%100);
-  aHue += aGoldenRatioConjugate*theIndex;
-  aHue -= floor(aHue);
-
-  float aR = 0., aG = 0., aB = 0.;
-  int aHueInt = (int)(aHue*6.);
-  float aF = aHue*6. - aHueInt;
-  float aP = theValue * (1. - theSaturation);
-  float aQ = theValue * (1. - aF*theSaturation);
-  float aT = theValue * (1. - (1. - aF) * theSaturation);
-  switch (aHueInt)
-  {
-  case 0: { aR = theValue; aG = aT; aB = aP; break; }
-  case 1: { aR = aQ; aG = theValue; aB = aP; break; }
-  case 2: { aR = aP; aG = theValue; aB = aT; break; }
-  case 3: { aR = aP; aG = aQ; aB = theValue; break; }
-  case 4: { aR = aT; aG = aP; aB = theValue; break; }
-  case 5: { aR = theValue; aG = aP; aB = aQ; break; }
-  default: break;
-  }
-
-  QColor aColor = QColor( (int)(aR*256.), (int)(aG*256.), (int)(aB*256.) );
+  float aHue = ( rand()%1000 ) * 0.001f;
+
+  QColor aColor;
+  aColor.setHsl( (int)(aHue*255.), 128, 128 );
+  int r = aColor.red();
+  int g = aColor.green();
+  int b = aColor.blue();
   return ( aColor.isValid() ? aColor : HYDROData_ImmersibleZone::DefaultFillingColor() );
 }
 
@@ -1798,3 +1785,11 @@ void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed )
   if( isConfirmed )
     myEditedObject->SetToUpdate( true );
 }
+
+void HYDROGUI_CalculationOp::onRegenerateColors()
+{
+  // For geometry zones
+  AssignDefaultZonesColors( false );
+  setZonesVisible( false, false );
+  setZonesVisible( true, false );
+}