From: rkv Date: Tue, 3 Dec 2013 12:51:52 +0000 (+0000) Subject: Fix for the bug #135: It is impossible to rename bathymetry: X-Git-Tag: BR_hydro_v_0_4~80 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55bdcf56f6c32a4164dc1bf0191e9a3d7db7c71f;p=modules%2Fhydro.git Fix for the bug #135: It is impossible to rename bathymetry: - "Edit imported bathymetry" operation is added. - Created/edited bathymetry is shown in VTK viewer on apply. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx index f4237339..8fb9c815 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx @@ -32,13 +32,17 @@ #include #include +#include +#include #include -HYDROGUI_ImportBathymetryOp::HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule ) -: HYDROGUI_Operation( theModule ) +HYDROGUI_ImportBathymetryOp::HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule, + const bool theIsEdit ) +: HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ) { - setName( tr( "IMPORT_BATHYMETRY" ) ); + setName( theIsEdit ? tr( "EDIT_IMPORTED_BATHYMETRY" ) : tr( "IMPORT_BATHYMETRY" ) ); } HYDROGUI_ImportBathymetryOp::~HYDROGUI_ImportBathymetryOp() @@ -55,6 +59,18 @@ void HYDROGUI_ImportBathymetryOp::startOperation() return; aPanel->reset(); + + if( myIsEdit ) + { + myEditedObject = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !myEditedObject.IsNull() ) + { + QString aName = myEditedObject->GetName(); + QString aFileName = myEditedObject->GetFilePath(); + aPanel->setObjectName( aName ); + aPanel->setFileName( aFileName ); + } + } } void HYDROGUI_ImportBathymetryOp::abortOperation() @@ -107,14 +123,22 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, // check that there are no other objects with the same name in the document Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); - if ( !anObject.IsNull() ) + if ( ( !myIsEdit ) && ( !anObject.IsNull() ) ) { theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); return false; } - Handle(HYDROData_Bathymetry) aBathymetryObj = - Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) ); + Handle(HYDROData_Bathymetry) aBathymetryObj; + if ( myIsEdit ) + { + aBathymetryObj = myEditedObject; + } + else + { + aBathymetryObj = + Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) ); + } if ( aBathymetryObj.IsNull() ) return false; @@ -126,7 +150,33 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, aBathymetryObj->SetName( anObjectName ); - theUpdateFlags = UF_Model; + // Activate VTK viewer and show the bathymetry + SUIT_ViewManager* aVTKMgr = 0; + SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager(); + // Try to get a VTK viewer as an active or existing one + if ( aViewMgr ) + { + if ( aViewMgr->getType() == SVTK_Viewer::Type() ) + { + aVTKMgr = aViewMgr; + } + else + { + aVTKMgr = module()->getApp()->viewManager( SVTK_Viewer::Type() ); + } + } + // If there is no VTK viewer yet then create a new one + if ( !aVTKMgr ) + { + aVTKMgr = module()->getApp()->createViewManager( SVTK_Viewer::Type() ); + } + // Set the bathymetry visible in the VTK viewer + if ( aVTKMgr ) + { + module()->setObjectVisible( (size_t)aVTKMgr->getViewModel(), aBathymetryObj, true ); + } + + theUpdateFlags = UF_Model | UF_VTKViewer | UF_VTK_Forced; return true; } diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h index 850ef425..cdf6a39b 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h @@ -25,13 +25,15 @@ #include "HYDROGUI_Operation.h" +#include + class HYDROGUI_ImportBathymetryOp : public HYDROGUI_Operation { Q_OBJECT public: - HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule ); + HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule, const bool theIsEdit ); virtual ~HYDROGUI_ImportBathymetryOp(); protected: @@ -48,6 +50,8 @@ protected slots: void onFileSelected(); private: + bool myIsEdit; + Handle(HYDROData_Bathymetry) myEditedObject; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 8c8396d6..000ba16c 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -447,6 +447,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( SplitImageId ) ); theMenu->addSeparator(); } + else if( anIsBathymetry ) + { + theMenu->addAction( action( EditImportedBathymetryId ) ); + theMenu->addSeparator(); + } else if( anIsPolyline ) { theMenu->addAction( action( EditPolylineId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index de2587d5..89e8ab2c 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -122,6 +122,7 @@ void HYDROGUI_Module::createActions() createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT" ); createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B ); + createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY" ); createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE" ); createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE" ); @@ -374,7 +375,8 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ; break; case ImportBathymetryId: - anOp = new HYDROGUI_ImportBathymetryOp( aModule ); + case EditImportedBathymetryId: + anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId ); break; case CreateImmersibleZoneId: case EditImmersibleZoneId: diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index c0538c9d..9911e68a 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -343,6 +343,10 @@ Do you want to continue? HYDROGUI_ImportBathymetryOp + + EDIT_IMPORTED_BATHYMETRY + Edit imported bathymetry + IMPORT_BATHYMETRY Import bathymetry @@ -588,6 +592,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_IMPORT_BATHYMETRY Import bathymetry + + DSK_EDIT_IMPORTED_BATHYMETRY + Edit imported bathymetry + DSK_IMPORT_IMAGE Import image @@ -796,6 +804,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_IMPORT_BATHYMETRY Import bathymetry + + MEN_EDIT_IMPORTED_BATHYMETRY + Edit imported bathymetry + MEN_IMPORT_IMAGE Import image @@ -980,6 +992,10 @@ file cannot be correctly imported for a Bathymetry definition. STB_IMPORT_BATHYMETRY Import bathymetry + + STB_EDIT_IMPORTED_BATHYMETRY + Edit imported bathymetry + STB_IMPORT_IMAGE Import image