Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.cxx
index 2951e5838d5dd4003cb4ab77bac4bb40f461a312..97c826ada354267084d96e259e7a1075079b24fa 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;
 }
 
@@ -629,7 +632,7 @@ void HYDROGUI_CalculationOp::onRemoveObjects()
 bool HYDROGUI_CalculationOp::confirmRegionsChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with zones
@@ -654,7 +657,7 @@ bool HYDROGUI_CalculationOp::confirmRegionsChange() const
 bool HYDROGUI_CalculationOp::confirmOrderChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with zones
@@ -679,7 +682,7 @@ bool HYDROGUI_CalculationOp::confirmOrderChange() const
 bool HYDROGUI_CalculationOp::confirmRuleChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with zones
@@ -704,7 +707,7 @@ bool HYDROGUI_CalculationOp::confirmRuleChange() const
 bool HYDROGUI_CalculationOp::confirmModeChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with zones
@@ -758,7 +761,7 @@ bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning
 bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with land cover zones
@@ -783,7 +786,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const
 bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with land cover zones
@@ -808,7 +811,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
 bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with land cover zones
@@ -833,7 +836,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const
 bool HYDROGUI_CalculationOp::confirmLandCoverRuleChange() const
 {
   // Check if the case is already modified or not
-  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No );
   if ( !isConfirmed )
   {
     // If not modified check if the case has already defined regions with land cover zones
@@ -984,10 +987,10 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
       }
     }
     aPanel->setStricklerTableNames( aList, anEntryList );
-    bool anUpdateState = myEditedObject->IsMustBeUpdated();
+    //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated();
     if ( !aList.isEmpty() )
       aPanel->setStricklerTable( aList.at( 0 ), false );
-    myEditedObject->SetToUpdate( anUpdateState );
+    //@ASL: myEditedObject->SetToUpdate( anUpdateState );
 
     // Fill in list widget with all available land covers
     aSeq = HYDROGUI_Tool::GetLandCovers( module() );
@@ -1057,7 +1060,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
     {
       // Set objects in the specified order
-      if( myEditedObject->IsMustBeUpdated() )
+      if( myEditedObject->IsMustBeUpdated(  HYDROData_Entity::Geom_2d ) )
       {
         myEditedObject->RemoveGeometryObjects();
         foreach ( const QString& aName, aPanel->getAllGeomObjects() )
@@ -1090,7 +1093,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
     {
       // Set objects in the specified order
-      if( myEditedObject->IsMustBeUpdated() )
+      if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
       {
         myEditedObject->RemoveLandCovers();
         foreach ( const QString& aName, aPanel->getAllLandCovers() )
@@ -1116,7 +1119,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     }
     aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
          
-    if ( myEditedObject->IsMustBeUpdated() )
+    if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
     {
       myShowZones = true;
       myEditedObject->Update();
@@ -1329,30 +1332,14 @@ 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.) );
-  return ( aColor.isValid() ? aColor : HYDROData_ImmersibleZone::DefaultFillingColor() );
+  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 : Qt::darkBlue );
 }
 
 void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
@@ -1590,7 +1577,7 @@ void HYDROGUI_CalculationOp::setAvailableGroups()
       aGroupsNames.append( aGroup->GetName() );
     }
   }
-  if( myEditedObject->IsMustBeUpdated() ) {
+  if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
     for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
       Handle(HYDROData_ShapesGroup) aGeomGroup =
         Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
@@ -1603,7 +1590,7 @@ void HYDROGUI_CalculationOp::setAvailableGroups()
   aPanel->setAvailableGroups( aGroupsNames );
   aPanel->includeGroups( aList );
 
-  bool isUpdated = myEditedObject->IsMustBeUpdated();
+  //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
 }
 
 void HYDROGUI_CalculationOp::onAddGroups()
@@ -1760,7 +1747,7 @@ void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
 
   isConfirmed = confirmOrderChange();
   if( isConfirmed )
-    myEditedObject->SetToUpdate( true );
+    myEditedObject->Changed( HYDROData_Entity::Geom_2d );
 }
 
 void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed )
@@ -1772,7 +1759,7 @@ void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed )
 
   isConfirmed = confirmLandCoverOrderChange();
   if( isConfirmed )
-    myEditedObject->SetToUpdate( true );
+    myEditedObject->Changed( HYDROData_Entity::Geom_No );
 }
 
 void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
@@ -1784,7 +1771,7 @@ void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
 
   isConfirmed = confirmRuleChange();
   if( isConfirmed )
-    myEditedObject->SetToUpdate( true );
+    myEditedObject->Changed( HYDROData_Entity::Geom_2d );
 }
 
 void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed )
@@ -1796,5 +1783,13 @@ void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed )
 
   isConfirmed = confirmLandCoverRuleChange();
   if( isConfirmed )
-    myEditedObject->SetToUpdate( true );
+    myEditedObject->Changed( HYDROData_Entity::Geom_No );
+}
+
+void HYDROGUI_CalculationOp::onRegenerateColors()
+{
+  // For geometry zones
+  AssignDefaultZonesColors( false );
+  setZonesVisible( false, false );
+  setZonesVisible( true, false );
 }