From: rkv Date: Tue, 29 Oct 2013 12:18:29 +0000 (+0000) Subject: - Bathymetry names are shown in the browser in Calculation Case dialog; X-Git-Tag: BR_hydro_v_0_3~73 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0802ce8638b337a7c7f655fd3fc83ccaae1244b6;p=modules%2Fhydro.git - Bathymetry names are shown in the browser in Calculation Case dialog; - Transaction management is changed for the Calculation Case operation, onApply is overriden. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index f2f4b79e..30292fac 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -206,11 +206,6 @@ QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculation) theCase ) { myEditedObject = theCase; - /////////////////// - Handle(HYDROData_Object) anEntity = Handle(HYDROData_Object)::DownCast( - module()->getDataModel()->getDocument()->CreateObject( KIND_IMMERSIBLE_ZONE ) ); - myEditedObject->AddGeometryObject( anEntity ); - //////////////// HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" ); myBrowser->setRoot(anobj); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index aab45580..14570182 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -39,6 +39,9 @@ #include #include +#include +#include + #include HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ) @@ -58,6 +61,9 @@ HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp() void HYDROGUI_CalculationOp::startOperation() { HYDROGUI_Operation::startOperation(); + + // Begin transaction + startDocOperation(); HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -100,6 +106,7 @@ void HYDROGUI_CalculationOp::startOperation() { myEditedObject = Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) ); + myEditedObject->SetName(anObjectName); } aPanel->setObjectName( anObjectName ); @@ -112,14 +119,16 @@ void HYDROGUI_CalculationOp::startOperation() void HYDROGUI_CalculationOp::abortOperation() { closePreview(); - + // Abort transaction + abortDocOperation(); HYDROGUI_Operation::abortOperation(); } void HYDROGUI_CalculationOp::commitOperation() { closePreview(); - + // Commit transaction + commitDocOperation(); HYDROGUI_Operation::commitOperation(); } @@ -140,40 +149,83 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, if ( !aPanel ) return false; - QString anObjectName = aPanel->getObjectName().simplified(); - if ( anObjectName.isEmpty() ) - { - theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); - return false; - } + //QString anObjectName = aPanel->getObjectName().simplified(); + //if ( anObjectName.isEmpty() ) + //{ + // theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); + // return false; + //} + + //// check that there are no other objects with the same name in the document + //if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) + //{ + // Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); + // if ( !anObject.IsNull() ) + // { + // theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); + // return false; + // } + //} + + //Handle(HYDROData_Document) aDocument = doc(); + + //Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject : + // Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) ); + //if ( aCalculObj.IsNull() ) + // return false; + + //aCalculObj->SetName( anObjectName ); + + //QStringList aRefObjectNames = aPanel->getSelectedGeomObjects(); + //HYDROData_SequenceOfObjects aGeomObjects = + // HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames ); - // check that there are no other objects with the same name in the document - if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) - { - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); - if ( !anObject.IsNull() ) - { - theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); - return false; - } - } + theUpdateFlags = UF_Model; - Handle(HYDROData_Document) aDocument = doc(); + return true; +} - Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject : - Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) ); - if ( aCalculObj.IsNull() ) - return false; +void HYDROGUI_CalculationOp::onApply() +{ + QApplication::setOverrideCursor( Qt::WaitCursor ); - aCalculObj->SetName( anObjectName ); + int anUpdateFlags = 0; + QString anErrorMsg; - QStringList aRefObjectNames = aPanel->getSelectedGeomObjects(); - HYDROData_SequenceOfObjects aGeomObjects = - HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames ); - - theUpdateFlags = UF_Model; + bool aResult = false; + + try + { + aResult = processApply( anUpdateFlags, anErrorMsg ); + } + catch ( Standard_Failure ) + { + Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); + anErrorMsg = aFailure->GetMessageString(); + aResult = false; + } + catch ( ... ) + { + aResult = false; + } + + QApplication::restoreOverrideCursor(); - return true; + if ( aResult ) + { + module()->update( anUpdateFlags ); + commit(); + } + else + { + abort(); + QString aMsg = tr( "INPUT_VALID_DATA" ); + if( !anErrorMsg.isEmpty() ) + aMsg.prepend( anErrorMsg + "\n" ); + SUIT_MessageBox::critical( module()->getApp()->desktop(), + tr( "INSUFFICIENT_INPUT_DATA" ), + aMsg ); + } } void HYDROGUI_CalculationOp::onSplitZones() diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 394afcd9..52ae6935 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -76,6 +76,7 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; + virtual void onApply(); virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); protected slots: diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index 83be9e8f..133a99d3 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -94,12 +95,12 @@ QString HYDROGUI_DataObject::text( const int theColumnId ) const switch ( theColumnId ) { case RefObjectId: + // Get Ref.Object name aRes += aRefGeomObj->GetName() + ", "; break; case BathymetryId: - //TODO: Get bathymetry name - //aRes += aRefGeomObj-> - ; + // Get bathymetry name + aRes += aRefGeomObj->GetBathymetry()->GetName(); } } }