From: rkv Date: Tue, 12 Nov 2013 13:12:32 +0000 (+0000) Subject: Fix for the bug #49: Message box on objects list change is absent X-Git-Tag: BR_hydro_v_0_3~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45e0fd1da687182f538f640144c1ceebe9903555;p=modules%2Fhydro.git Fix for the bug #49: Message box on objects list change is absent --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 0433f520..093b78fa 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -209,7 +209,6 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName ) { // Set the selected boundary polyline to the calculation case Handle(HYDROData_Polyline) anObject; - HYDROGUI_Shape* aShape; Handle(AIS_InteractiveContext) aCtx; if ( myPreviewViewManager ) { @@ -410,29 +409,32 @@ void HYDROGUI_CalculationOp::onAddObjects() if ( aPanel ) { // Add geometry objects selected in the module browser to the calculation case - Handle(HYDROData_Object) anObject; - Handle(HYDROData_Entity) anEntity; - QStringList aList; QStringList aSelectedList = aPanel->getSelectedAvailableGeomObjects(); - for (int i = 0; i < aSelectedList.length(); i++) + if ( ( !aSelectedList.isEmpty() ) && ( confirmRegionsChange() ) ) { - anEntity = HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ); - if ( !anEntity.IsNull() ) + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + QStringList aList; + for (int i = 0; i < aSelectedList.length(); i++) { - anObject = Handle(HYDROData_Object)::DownCast( anEntity ); - if ( !anObject.IsNull() ) + anEntity = HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ); + if ( !anEntity.IsNull() ) { - if (myEditedObject->AddGeometryObject( anObject )) + anObject = Handle(HYDROData_Object)::DownCast( anEntity ); + if ( !anObject.IsNull() ) { - aList.append( anObject->GetName() ); + if (myEditedObject->AddGeometryObject( anObject )) + { + aList.append( anObject->GetName() ); + } } } } - } - if ( !aList.isEmpty() ) - { - aPanel->includeGeomObjects( aList ); - createPreview(); + if ( !aList.isEmpty() ) + { + aPanel->includeGeomObjects( aList ); + createPreview(); + } } } } @@ -445,26 +447,50 @@ void HYDROGUI_CalculationOp::onRemoveObjects() if ( aPanel ) { QStringList aList = aPanel->getSelectedGeomObjects(); - Handle(HYDROData_Object) anObject; - Handle(HYDROData_Entity) anEntity; - for (int i = 0; i < aList.length(); i++) + if ( ( !aList.isEmpty() ) && ( confirmRegionsChange() ) ) { - anEntity = HYDROGUI_Tool::FindObjectByName( module(), aList.at(i) ); - if ( !anEntity.IsNull() ) + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + for (int i = 0; i < aList.length(); i++) { - anObject = Handle(HYDROData_Object)::DownCast( anEntity ); - if ( !anObject.IsNull() ) + anEntity = HYDROGUI_Tool::FindObjectByName( module(), aList.at(i) ); + if ( !anEntity.IsNull() ) { - module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject ); - myEditedObject->RemoveGeometryObject( anObject ); + anObject = Handle(HYDROData_Object)::DownCast( anEntity ); + if ( !anObject.IsNull() ) + { + module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject ); + myEditedObject->RemoveGeometryObject( anObject ); + } } } + if ( !aList.isEmpty() ) + { + aPanel->excludeGeomObjects( aList ); + } } - if ( !aList.isEmpty() ) + } +} + +bool HYDROGUI_CalculationOp::confirmRegionsChange() 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(); + if ( aSeq.Length() > 0 ) { - aPanel->excludeGeomObjects( aList ); + // If there are already defined zones then ask a user to confirm zones recalculation + isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(), + tr( "REGIONS_CHANGED" ), + tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION" ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No ) == QMessageBox::Yes ); } } + return isConfirmed; } bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 274f144c..bf449bde 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -105,6 +105,11 @@ private: void setZonesVisible( bool theIsVisible ); void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, QStringList& theNames, QStringList& theEntries ) const; + /** + * Ask user to confirm splitting zones recalculation. + * \return true if confirmed + */ + bool confirmRegionsChange() const; private: bool myIsEdit; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 8a445040..56aa6892 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -180,6 +180,14 @@ does not exist or you have not enough permissions to open it. PREVIEW_CASE_ZONES Preview case zones + + REGIONS_CHANGED + Regions list modification + + + CONFIRM_SPLITTING_ZONES_RECALCULATION + Case splitting zones already exist and will be recalculated after regions list modification. Do you confirm the recalculation? +