X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_CalculationOp.cxx;h=f8311d5a4f90c45bb0ef1dfa8626dd9995559e35;hb=d6e19029f8b41f295db878e9aecf451c2edda4af;hp=8ace99e3218493a22b31b33848d9e366e47780c7;hpb=1687cb2e2e3e31ae16197ba2b0939cacc31f9807;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 8ace99e3..f8311d5a 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -149,25 +149,7 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->includeGeomObjects( aList ); // set rules - HYDROData_ListOfRules aRules; - Handle(HYDROData_Object) anObject1, anObject2; - HYDROData_PriorityType aPriority; - HYDROData_Zone::MergeAltitudesType aMergeType; - for ( int anIndex = 0; ; anIndex++ ) - { - if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType ) ) { - HYDROData_CustomRule aRule; - aRule.Object1 = anObject1; - aRule.Object2 = anObject2; - aRule.Priority = aPriority; - aRule.MergeType = aMergeType; - - aRules << aRule; - } - else - break; - } - aPanel->setRules( aRules ); + setRules( HYDROData_CalculationCase::DataTag_CustomRules ); } } else @@ -783,10 +765,10 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, // For manual mode priority rules are redundant if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) { - myEditedObject->ClearRules( false ); + myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false ); } if ( aPanel->getLandCoverMode() == HYDROData_CalculationCase::MANUAL ) { - myEditedObject->ClearLandCoverRules( false ); + myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, false ); } theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init; @@ -869,13 +851,15 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) QStringList aList; QStringList anEntryList; + HYDROData_SequenceOfObjects aSeq; + + Handle(HYDROData_StricklerTable) aStricklerTableObj; + QString aStricklerTableName; // Get all Strickler table objects to fill in combo-box aList.clear(); anEntryList.clear(); - HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE ); - Handle(HYDROData_StricklerTable) aStricklerTableObj; - QString aStricklerTableName; + HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE ); for ( ; anIter.More(); anIter.Next() ) { aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() ); @@ -891,11 +875,18 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } } aPanel->setStricklerTableNames( aList, anEntryList ); + if ( !aList.isEmpty() ) + aPanel->setStricklerTable( aList.at( 0 ), false ); // Fill in list widget with all available land covers - HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetLandCovers( module() ); + aSeq = HYDROGUI_Tool::GetLandCovers( module() ); getNamesAndEntries( aSeq, aList, anEntryList ); aPanel->setAllLandCovers( aList, anEntryList ); + + // Set list of included land covers + aSeq = myEditedObject->GetLandCovers(); + getNamesAndEntries( aSeq, aList, anEntryList ); + aPanel->includeLandCovers( aList, true ); if ( !myEditedObject.IsNull() ) { @@ -915,6 +906,9 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) // Set mode (Auto or Manual) to defined priority of land covers aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() ); + + // Set rules defined on land covers + setRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules ); } else { @@ -962,12 +956,13 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) // Clear priority rules //@ASL if ( myEditedObject->GetRulesCount() > 0 ) { - myEditedObject->ClearRules( true ); + myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, true ); //@ASL } // Set priority rules foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) { myEditedObject->AddRule( aRule.Object1, aRule.Priority, - aRule.Object2, aRule.MergeType ); + aRule.Object2, aRule.MergeType, + HYDROData_CalculationCase::DataTag_CustomRules ); } } } @@ -987,6 +982,8 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) createPreview(); anIsToUpdateOb = true; + + myEditedObject->SetToUpdate( true ); } else { @@ -997,6 +994,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } } + // Move this code to processing od the last panel (see below) if ( anIsToUpdateOb ) { SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser(); if ( anObjBrowser ) { @@ -1016,8 +1014,6 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) QApplication::setOverrideCursor( Qt::WaitCursor ); - //... - // Set parameters for automatic mode int aMode = aPanel->getLandCoverMode(); if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) @@ -1038,11 +1034,13 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } // Clear priority rules - myEditedObject->ClearLandCoverRules( true ); - // TODO: Set priority rules - //foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) { - // myEditedObject->AddLandCoverRule( aRule.Object1, aRule.Priority, - // aRule.Object2, aRule.MergeType ); + 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->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL ); @@ -1161,6 +1159,39 @@ QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex, return ( aColor.isValid() ? aColor : HYDROData_ImmersibleZone::DefaultFillingColor() ); } +void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag ) +{ + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + HYDROData_ListOfRules aRules; + Handle(HYDROData_Entity) anObject1, anObject2; + HYDROData_PriorityType aPriority; + HYDROData_Zone::MergeAltitudesType aMergeType; + HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules; + for ( int anIndex = 0; ; anIndex++ ) + { + if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType, theDataTag ) ) { + HYDROData_CustomRule aRule; + aRule.Object1 = anObject1; + aRule.Object2 = anObject2; + aRule.Priority = aPriority; + aRule.MergeType = aMergeType; + + aRules << aRule; + } + else + break; + } + + if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules ) + aPanel->setRules( aRules ); + else if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomLandCoverRules ) + aPanel->setLandCoverRules( aRules ); +} + void HYDROGUI_CalculationOp::createPreview() { LightApp_Application* anApp = module()->getApp(); @@ -1437,7 +1468,7 @@ void HYDROGUI_CalculationOp::onAddLandCovers() if ( !anAddedList.isEmpty() ) { - aPanel->includeLandCovers( anAddedList ); + aPanel->includeLandCovers( anAddedList, false ); // TODO: create preview of included land covers //createPreview(); }