From: ouv Date: Mon, 2 Sep 2013 10:57:15 +0000 (+0000) Subject: Added methods startDocOperation(), abortDocOperation(), commitDocOperation() for... X-Git-Tag: BR_hydro_v_0_1~81 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=35a75ba275261aff7c8c48c0d16842dafd455007;p=modules%2Fhydro.git Added methods startDocOperation(), abortDocOperation(), commitDocOperation() for HYDROGUI_Operation class. --- diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx index 0e57e372..46eb2fb5 100644 --- a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx +++ b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx @@ -62,12 +62,14 @@ void HYDROGUI_DeleteOp::startOperation() } } + startDocOperation(); for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) { Handle(HYDROData_Object) anObject = aSeq.Value( anIndex ); if( !anObject.IsNull() ) anObject->Remove(); } + commitDocOperation(); module()->update( UF_Model | UF_Viewer ); commit(); diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 1b132b68..3183b3b8 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -122,6 +122,24 @@ void HYDROGUI_Operation::processCancel() { } +void HYDROGUI_Operation::startDocOperation() +{ + // Open transaction in the model document + doc()->StartOperation(); +} + +void HYDROGUI_Operation::abortDocOperation() +{ + // Abort transaction in the model document + doc()->AbortOperation(); +} + +void HYDROGUI_Operation::commitDocOperation() +{ + // Commit transaction in the model document + doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) ); +} + Handle_HYDROData_Document HYDROGUI_Operation::doc() const { return HYDROData_Document::Document( myModule->getStudyId() ); @@ -131,8 +149,7 @@ void HYDROGUI_Operation::onApply() { QApplication::setOverrideCursor( Qt::WaitCursor ); - // Open transaction in the model document - doc()->StartOperation(); + startDocOperation(); int anUpdateFlags = 0; QString anErrorMsg; @@ -159,16 +176,12 @@ void HYDROGUI_Operation::onApply() if ( aResult ) { module()->update( anUpdateFlags ); - - // Commit transaction in the model document - doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) ); + commitDocOperation(); commit(); } else { - // Abort transaction in the model document - doc()->AbortOperation(); - + abortDocOperation(); QString aMsg = tr( "INPUT_VALID_DATA" ); if( !anErrorMsg.isEmpty() ) aMsg.prepend( anErrorMsg + "\n" ); diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 76eab370..c580e3f5 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -56,6 +56,10 @@ protected: virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); virtual void processCancel(); + void startDocOperation(); + void commitDocOperation(); + void abortDocOperation(); + Handle_HYDROData_Document doc() const; protected slots: diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 04e60c72..8d91cde4 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -55,6 +55,8 @@ void HYDROGUI_ShowHideOp::startOperation() { HYDROGUI_Operation::startOperation(); + startDocOperation(); + size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() ); // for all objects @@ -84,6 +86,8 @@ void HYDROGUI_ShowHideOp::startOperation() } } + commitDocOperation(); + module()->update( UF_Viewer ); commit(); } diff --git a/src/HYDROGUI/HYDROGUI_VisualStateOp.cxx b/src/HYDROGUI/HYDROGUI_VisualStateOp.cxx index dd0523aa..37f9c27f 100644 --- a/src/HYDROGUI/HYDROGUI_VisualStateOp.cxx +++ b/src/HYDROGUI/HYDROGUI_VisualStateOp.cxx @@ -59,6 +59,8 @@ void HYDROGUI_VisualStateOp::startOperation() { HYDROGUI_Operation::startOperation(); + startDocOperation(); + bool aResult = false; if( myIsLoad ) aResult = loadVisualState(); @@ -66,9 +68,15 @@ void HYDROGUI_VisualStateOp::startOperation() aResult = saveVisualState(); if( aResult ) + { + commitDocOperation(); commit(); + } else + { + abortDocOperation(); abort(); // do not commit the document command + } } bool HYDROGUI_VisualStateOp::saveVisualState()