From 5f1c089db35b75a592625b708921df2320563363 Mon Sep 17 00:00:00 2001 From: mtn Date: Fri, 9 Aug 2013 13:46:06 +0000 Subject: [PATCH] Edit polyline operation was added --- src/HYDROGUI/HYDROGUI_DataModel.cxx | 2 +- src/HYDROGUI/HYDROGUI_Module.cxx | 10 +++++ src/HYDROGUI/HYDROGUI_Operations.cxx | 10 +++-- src/HYDROGUI/HYDROGUI_Operations.h | 3 +- src/HYDROGUI/HYDROGUI_PolylineDlg.cxx | 4 ++ src/HYDROGUI/HYDROGUI_PolylineDlg.h | 1 + src/HYDROGUI/HYDROGUI_PolylineOp.cxx | 55 ++++++++++++++++++++--- src/HYDROGUI/HYDROGUI_PolylineOp.h | 9 +++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 47 ++++++++++++++----- 9 files changed, 117 insertions(+), 24 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 461b493c..71fe1237 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -202,7 +202,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) for( ; aPolyIterator.More(); aPolyIterator.Next() ) { Handle(HYDROData_Polyline) aPolylineObj = - Handle(HYDROData_Polyline)::DownCast( anIterator.Current() ); + Handle(HYDROData_Polyline)::DownCast( aPolyIterator.Current() ); if( !aPolylineObj.IsNull() ) createObject( aPolylineRootObj, aPolylineObj ); } diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 9a377428..3a87b374 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -142,6 +142,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsHiddenInSelection = false; bool anIsImage = false; + bool anIsPolyline = false; foreach( SUIT_DataOwner* aSUITOwner, anOwners ) { @@ -158,6 +159,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, if( anObject->GetKind() == KIND_IMAGE ) anIsImage = true; + + if( anObject->GetKind() == KIND_POLYLINE ) + anIsPolyline = true; } } } @@ -168,6 +172,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addSeparator(); } + if( anOwners.count() == 1 && anIsPolyline ) + { + theMenu->addAction( action( EditPolylineId ) ); + theMenu->addSeparator(); + } + if( anIsSelection ) { theMenu->addAction( action( DeleteId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index ba62ab22..e921a532 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -64,7 +64,8 @@ void HYDROGUI_Module::createActions() { createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); createAction( EditImageId, "EDIT_IMAGE" ); - createAction( PolylineId, "POLYLINE" ); + createAction( CreatePolylineId, "CREATE_POLYLINE" ); + createAction( EditPolylineId, "EDIT_POLYLINE" ); createAction( FuseId, "FUSE_IMAGES" ); createAction( CutId, "CUT_IMAGES" ); @@ -87,7 +88,7 @@ void HYDROGUI_Module::createMenus() int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu ); createMenu( ImportImageId, aHydroId, -1, -1 ); - createMenu( PolylineId, aHydroId, -1, -1 ); + createMenu( CreatePolylineId, aHydroId, -1, -1 ); createMenu( FuseId, aHydroId, -1, -1 ); createMenu( CutId, aHydroId, -1, -1 ); } @@ -206,8 +207,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditImageId: anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId ); break; - case PolylineId: - anOp = new HYDROGUI_PolylineOp( aModule ); + case CreatePolylineId: + case EditPolylineId: + anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId ); break; case FuseId: anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 22eca2ed..116d7a30 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -30,7 +30,8 @@ enum OperationId RedoId, ImportImageId, EditImageId, - PolylineId, + CreatePolylineId, + EditPolylineId, FuseId, CutId, DeleteId, diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index 894bc23a..ef39f2af 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -42,3 +42,7 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QS HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg() { } + +void HYDROGUI_PolylineDlg::reset() +{ +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.h b/src/HYDROGUI/HYDROGUI_PolylineDlg.h index 54c4ae25..2204c684 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.h +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.h @@ -34,6 +34,7 @@ public: HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_PolylineDlg(); + void reset(); protected slots: signals: diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index cfe2c922..774f3c36 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -19,17 +19,22 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - +#include "HYDROGUI_Module.h" #include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_PolylineDlg.h" +#include "HYDROGUI_Tool.h" -#include "HYDROGUI_Module.h" +#include +#include + +#include +#include -HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule ) -: HYDROGUI_Operation( theModule ) +HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit ) +: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit) { - setName( tr("POLYLINE") ); + setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) ); } HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp() @@ -43,5 +48,45 @@ HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags ) { + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); + + int aStudyId = module()->getStudyId(); + bool aHasDoc = HYDROData_Document::HasDocument(aStudyId); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + if( aDocument.IsNull() ) + return false; + + Handle(HYDROData_Polyline) aPolylineObj; + if( myIsEdit ){ + aPolylineObj = myEditedObject; + } + else{ + aPolylineObj = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) ); + } + + if( aPolylineObj.IsNull() ) + return false; + + if( !myIsEdit ){ + static int PolylineId = 0; + aPolylineObj->SetName( QString( "Polyline_%1" ).arg( QString::number( ++PolylineId ) ) ); + } + + aPolylineObj->SetVisibility( true ); + + theUpdateFlags = UF_Model | UF_Viewer; return true; } + +void HYDROGUI_PolylineOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); + aPanel->reset(); + + myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !myEditedObject.IsNull() ) + { + } +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index be473d97..d3377603 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -25,12 +25,14 @@ #include "HYDROGUI_Operation.h" +#include + class HYDROGUI_PolylineOp : public HYDROGUI_Operation { Q_OBJECT public: - HYDROGUI_PolylineOp( HYDROGUI_Module* theModule ); + HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool isEdit ); virtual ~HYDROGUI_PolylineOp(); protected: @@ -38,6 +40,11 @@ protected: virtual bool processApply( int& theUpdateFlags ); + virtual void startOperation(); + +private: + bool myIsEdit; + Handle(HYDROData_Polyline) myEditedObject; }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 3fe2979d..30f70b53 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -104,6 +104,10 @@ HYDROGUI_Module + + DSK_CREATE_POLYLINE + Create polyline + DSK_CUT_IMAGES Cut images @@ -116,6 +120,10 @@ DSK_EDIT_IMAGE Edit image + + DSK_EDIT_POLYLINE + Edit polyline + DSK_FUSE_IMAGES Fuse images @@ -132,10 +140,6 @@ DSK_IMPORT_IMAGE Import image - - DSK_POLYLINE - Create polyline - DSK_REDO Redo @@ -160,6 +164,10 @@ HYDRO_TOOLBAR HYDRO toolbar + + MEN_CREATE_POLYLINE + Create polyline + MEN_CUT_IMAGES Cut images @@ -176,6 +184,10 @@ MEN_EDIT_IMAGE Edit image + + MEN_EDIT_POLYLINE + Create polyline + MEN_FUSE_IMAGES Fuse images @@ -192,10 +204,6 @@ MEN_IMPORT_IMAGE Import image - - MEN_POLYLINE - Create polyline - MEN_REDO Redo @@ -216,6 +224,10 @@ MEN_UNDO Undo + + STB_CREATE_POLYLINE + Create polyline + STB_CUT_IMAGES Cut images @@ -228,6 +240,10 @@ STB_EDIT_IMAGE Edit image + + STB_EDIT_POLYLINE + Edit polyline + STB_FUSE_IMAGES Fuse images @@ -244,10 +260,6 @@ STB_IMPORT_IMAGE Import image - - STB_POLYLINE - Create polyline - STB_REDO Redo @@ -269,6 +281,17 @@ Undo + + HYDROGUI_PolylineOp + + CREATE_POLYLINE + Create polyline + + + EDIT_POLYLINE + Edit polyline + + HYDROGUI_ShowHideOp -- 2.39.2