From: nds Date: Fri, 20 Dec 2013 12:39:59 +0000 (+0000) Subject: Refs #156 - cross-dependence of images - check and error or filter X-Git-Tag: BR_hydro_v_0_6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55e2bdba4efe12717a2d49be73046acc1b50c29d;p=modules%2Fhydro.git Refs #156 - cross-dependence of images - check and error or filter --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index f7f0fcf4..06836f63 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -399,6 +400,9 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, if( aRefImageObj.IsNull() ) return false; + else if ( !isReferenceCorrect() ) + aRefImageObj->RemoveAllReferences(); + aTrsfPointA = aRefMap[ HYDROGUI_PrsImage::PointA ].ImagePoint; aTrsfPointB = aRefMap[ HYDROGUI_PrsImage::PointB ].ImagePoint; if ( !anIsByTwoPoints ) @@ -472,6 +476,53 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, return true; } +bool HYDROGUI_ImportImageOp::isReferenceCorrect() const +{ + bool isCorrect = true; + + if( myIsEdit && !myEditedObject.IsNull() ) + { + HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); + Handle(HYDROData_Image) aRefImageObj = Handle(HYDROData_Image)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPanel->getRefImageName(), KIND_IMAGE ) ); + if( !aRefImageObj.IsNull() ) + { + bool isFoundEdited = false; + HYDROData_SequenceOfObjects aRefSeq = aRefImageObj->GetAllReferenceObjects(); + for ( int i = 1, n = aRefSeq.Length(); i <= n && !isFoundEdited; ++i ) + { + Handle(HYDROData_Entity) anObject = aRefSeq.Value( i ); + isFoundEdited = anObject->GetName() == myEditedObject->GetName(); + } + isCorrect = !isFoundEdited; + } + } + return isCorrect; +} + +void HYDROGUI_ImportImageOp::onApply() +{ + HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); + + bool aCanApply = isReferenceCorrect(); + if ( !aCanApply && !myEditedObject.IsNull() ) + { + Handle(HYDROData_Image) aRefImageObj = Handle(HYDROData_Image)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPanel->getRefImageName(), KIND_IMAGE ) ); + if ( !aRefImageObj.IsNull() ) + aCanApply = SUIT_MessageBox::question( module()->getApp()->desktop(), + tr( "CORRECT_INPUT_DATA" ), tr( "CONFIRM_REMOVE_REFERENCE_FROM_IMAGE" ). + arg( aRefImageObj->GetName() ).arg( myEditedObject->GetName() ), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes; + } + if ( aCanApply ) + HYDROGUI_Operation::onApply(); + else { + aPanel->setRefImageName( "" ); + onRefImageActivated( aPanel->getRefImageName() ); + } +} + void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) { HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index e14249d5..5a7e858f 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -50,8 +50,11 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + bool isReferenceCorrect() const; protected slots: + virtual void onApply(); + void onCreatePreview( QImage ); void onActivatePointSelection( int ); void onPointCoordChanged( bool, int, bool, int ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 7b28a038..6b4abbd9 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -544,6 +544,15 @@ file cannot be correctly imported for a Bathymetry definition. TRANSFORMATION_MATRIX_CANNOT_BE_COMPUTED Transformation matrix cannot be computed. + + CORRECT_INPUT_DATA + Correct input data + + + CONFIRM_REMOVE_REFERENCE_FROM_IMAGE + The image "%1" has a reference to the current object. +Would you like to remove all references from the image? +