QString aCalculName = GetObjPyName();
- AssignmentMode aMode = GetAssignmentMode();
+ AssignmentMode aMode = GetAssignmentMode();
QString aModeStr = aMode==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
+ AssignmentMode aModeLC = GetAssignmentLandCoverMode();
+ QString aModeLCStr = aModeLC==MANUAL ? "HYDROData_CalculationCase.MANUAL" : "HYDROData_CalculationCase.AUTOMATIC";
+ aResList << QString( "%0.SetAssignmentLandCoverMode( %1 )" ).arg( aCalculName ).arg( aModeLCStr );
+
HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
for ( ; anIter.More(); anIter.Next() )
if( aMode==AUTOMATIC )
DumpRulesToPython( aCalculName, aResList );
+ if( aModeLC==AUTOMATIC )
+ DumpLandCoverRulesToPython( aCalculName, aResList );
aResList << QString( "" );
aResList << "# Start the algorithm of the partition and assignment";
{
// Now we restore the
// - regions and zones order
- DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( false ) );
+ DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( false ) );
+ }
+
+ if( aModeLC==MANUAL )
+ {
+ // Now we restore the
// - land cover regions and zones order
DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( true ) );
}
switch( GetAssignmentMode() )
{
case MANUAL:
- CreateRegionsDef( aDocument, aZonesList, false );
+ CreateRegionsDef( aDocument, aZonesList, false );
+ break;
+ case AUTOMATIC:
+ CreateRegionsAuto( aDocument, aZonesList, false );
+ break;
+ }
+
+ switch( GetAssignmentLandCoverMode() )
+ {
+ case MANUAL:
CreateRegionsDef( aDocument, aLandCoverZonesList, true );
break;
case AUTOMATIC:
- CreateRegionsAuto( aDocument, aZonesList, false );
CreateRegionsAuto( aDocument, aLandCoverZonesList, true );
break;
}
+
CreateEdgeGroupsDef( aDocument, anEdgesList );
}
return HYDROData_PriorityQueue::DumpRules( aRulesLab );
}
+QString HYDROData_CalculationCase::DumpLandCoverRules() const
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+ return HYDROData_PriorityQueue::DumpRules( aRulesLab );
+}
+
void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
{
TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
}
+void HYDROData_CalculationCase::DumpLandCoverRulesToPython( const QString& theCalcCaseName,
+ QStringList& theScript ) const
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+ HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
+}
+
HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const
{
return myLastWarning;
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;
}
}
}
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() );
if ( anIsToUpdate )
{
myShowZones = true;
- myEditedObject->Update();
+ //myEditedObject->Update();
+ myEditedObject->SetToUpdate( false );
AssignDefaultZonesColors( true );
// 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++)