myPreviewViewManager( NULL ),
myShowGeomObjects( true ),
myShowLandCovers( false ),
- myShowZones( false )
+ myShowZones( false ),
+ myUpdateLandCoverZonesPrs( false )
{
setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
}
connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) );
-
+
+ connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
+ connect( aPanel, SIGNAL( ruleLandCoverChanged( bool& ) ), SLOT( onRuleLandCoverChanged( bool& ) ) );
+
connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
//connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
return isConfirmed;
}
+bool HYDROGUI_CalculationOp::confirmRuleChange() const
+{
+ // Check if the case is already modified or not
+ bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ if ( !isConfirmed )
+ {
+ // If not modified check if the case has already defined regions with zones
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false );
+ if ( aSeq.Length() > 0 )
+ {
+ // If there are already defined zones then ask a user to confirm zones recalculation
+ isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "RULE_CHANGED" ),
+ tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No ) == QMessageBox::Yes );
+ }
+ else
+ {
+ isConfirmed = true; // No regions - no zones - nothing to recalculate
+ }
+ }
+ return isConfirmed;
+}
+
bool HYDROGUI_CalculationOp::confirmModeChange() const
{
// Check if the case is already modified or not
return ( anAnswer == QMessageBox::Yes );
}
+bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const
+{
+ // Check if the case is already modified or not
+ bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ if ( !isConfirmed )
+ {
+ // If not modified check if the case has already defined regions with land cover zones
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true );
+ if ( aSeq.Length() > 0 )
+ {
+ // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation
+ isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "REGIONS_CHANGED" ),
+ tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No ) == QMessageBox::Yes );
+ }
+ else
+ {
+ isConfirmed = true; // No regions - no land cover zones - nothing to recalculate
+ }
+ }
+ return isConfirmed;
+}
+
bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
{
// Check if the case is already modified or not
bool isConfirmed = myEditedObject->IsMustBeUpdated();
if ( !isConfirmed )
{
- // If not modified check if the case has already defined regions with zones
- // TODO: adapt HYDROData_CalculationCase class to process regions constructed for land covers
- /*HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCoverRegions();
+ // If not modified check if the case has already defined regions with land cover zones
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true );
if ( aSeq.Length() > 0 )
- {*/
- // If there are already defined zones then ask a user to confirm zones recalculation
+ {
+ // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation
isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
tr( "MODE_CHANGED" ),
tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No ) == QMessageBox::Yes );
- /*}
+ }
else
{
- isConfirmed = true; // No regions - no zones - nothing to recalculate
- }*/
+ isConfirmed = true; // No regions - no land cover zones - nothing to recalculate
+ }
}
return isConfirmed;
}
bool isConfirmed = myEditedObject->IsMustBeUpdated();
if ( !isConfirmed )
{
- // If not modified check if the case has already defined regions with zones
- // TODO: adapt HYDROData_CalculationCase class to process regions constructed for land covers
- /*HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCoverRegions();
+ // If not modified check if the case has already defined regions with land cover zones
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true );
if ( aSeq.Length() > 0 )
- {*/
- // If there are already defined zones then ask a user to confirm zones recalculation
+ {
+ // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation
isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
tr( "ORDER_CHANGED" ),
tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No ) == QMessageBox::Yes );
- /*}
+ }
else
{
- isConfirmed = true; // No regions - no zones - nothing to recalculate
- }*/
+ isConfirmed = true; // No regions - no land cover zones - nothing to recalculate
+ }
+ }
+ return isConfirmed;
+}
+
+bool HYDROGUI_CalculationOp::confirmLandCoverRuleChange() const
+{
+ // Check if the case is already modified or not
+ bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ if ( !isConfirmed )
+ {
+ // If not modified check if the case has already defined regions with land cover zones
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( true );
+ if ( aSeq.Length() > 0 )
+ {
+ // If there are already defined land cover zones then ask a user to confirm land cover zones recalculation
+ isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "RULE_CHANGED" ),
+ tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_REGIONS" ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No ) == QMessageBox::Yes );
+ }
+ else
+ {
+ isConfirmed = true; // No regions - no land cover zones - nothing to recalculate
+ }
}
return isConfirmed;
}
}
}
aPanel->setStricklerTableNames( aList, anEntryList );
+ bool anUpdateState = myEditedObject->IsMustBeUpdated();
if ( !aList.isEmpty() )
aPanel->setStricklerTable( aList.at( 0 ), false );
+ myEditedObject->SetToUpdate( anUpdateState );
// Fill in list widget with all available land covers
aSeq = HYDROGUI_Tool::GetLandCovers( module() );
// automatic names generation for regions and zones
myEditedObject->SetName( aNewCaseName );
- // Set parameters for automatic mode
+ // Zones: set parameters for automatic mode
int aMode = aPanel->getMode();
if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
{
}
}
aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
+
+ // Land cover zones: set parameters for automatic mode
+ aMode = aPanel->getLandCoverMode();
+ if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
+ {
+ // Set objects in the specified order
+ if( myEditedObject->IsMustBeUpdated() )
+ {
+ myEditedObject->RemoveLandCovers();
+ foreach ( const QString& aName, aPanel->getAllLandCovers() )
+ {
+ Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aName ) );
+ if ( aLandCover.IsNull() )
+ {
+ continue;
+ }
+ myEditedObject->AddLandCover( aLandCover );
+ }
+
+ // Clear priority rules
+ myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, true );
+ // Set priority rules
+ foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) {
+ myEditedObject->AddRule( aRule.Object1, aRule.Priority,
+ aRule.Object2, HYDROData_Zone::Merge_Object,
+ HYDROData_CalculationCase::DataTag_CustomLandCoverRules );
+ }
+ }
+ }
+ aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
if ( myEditedObject->IsMustBeUpdated() )
{
anIsToUpdateOb = true;
- myEditedObject->SetToUpdate( true );
+ myUpdateLandCoverZonesPrs = true;
}
else
{
QApplication::setOverrideCursor( Qt::WaitCursor );
- // Set parameters for automatic mode
- int aMode = aPanel->getLandCoverMode();
- if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
- {
- // Set objects in the specified order
- if( myEditedObject->IsMustBeUpdated() )
- {
- myEditedObject->RemoveLandCovers();
- foreach ( const QString& aName, aPanel->getAllLandCovers() )
- {
- Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aName ) );
- if ( aLandCover.IsNull() )
- {
- continue;
- }
- myEditedObject->AddLandCover( aLandCover );
- }
-
- // Clear priority rules
- myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, true );
- // Set priority rules
- foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) {
- myEditedObject->AddRule( aRule.Object1, aRule.Priority,
- aRule.Object2, HYDROData_Zone::Merge_Object,
- HYDROData_CalculationCase::DataTag_CustomLandCoverRules );
- }
- }
- }
- aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
-
bool anIsToUpdateOb = false;
- bool anIsToUpdate = myEditedObject->IsMustBeUpdated();
- if ( anIsToUpdate )
+ if ( myUpdateLandCoverZonesPrs )
{
myShowZones = true;
- myEditedObject->Update();
AssignDefaultZonesColors( true );
closePreview( false );
createPreview( true );
- if ( !anIsToUpdate )
+ if ( myUpdateLandCoverZonesPrs )
+ myUpdateLandCoverZonesPrs = false;
+ else
{
// Hide zones
setZonesVisible( false, false );
// Add land covers selected in the module browser to the calculation case
QStringList aSelectedList = aPanel->getSelectedAvailableLandCovers();
- if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
+ if ( aSelectedList.isEmpty() || !confirmLandCoverRegionsChange() )
return;
QStringList anAddedList;
return;
QStringList aSelectedList = aPanel->getSelectedLandCovers();
- if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
+ if ( aSelectedList.isEmpty() || !confirmLandCoverRegionsChange() )
return;
for (int i = 0; i < aSelectedList.length(); i++)
if( isConfirmed )
myEditedObject->SetToUpdate( true );
}
+
+void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ isConfirmed = confirmRuleChange();
+ if( isConfirmed )
+ myEditedObject->SetToUpdate( true );
+}
+
+void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ isConfirmed = confirmLandCoverRuleChange();
+ if( isConfirmed )
+ myEditedObject->SetToUpdate( true );
+}