From a34b423a7b1c26957b15dcb6b82f6e81e57235f5 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 21 Nov 2013 07:19:46 +0000 Subject: [PATCH] Remove functionality by popup menu and the keyboard button "Delete". --- src/HYDROGUI/HYDROGUI_Module.cxx | 9 +++++++++ src/HYDROGUI/HYDROGUI_Module.h | 2 ++ src/HYDROGUI/HYDROGUI_Operations.cxx | 13 ++++++++++++- src/HYDROGUI/HYDROGUI_PolylineDlg.cxx | 16 ++++++++++++++++ src/HYDROGUI/HYDROGUI_PolylineDlg.h | 3 +++ src/HYDROGUI/HYDROGUI_PolylineOp.cxx | 18 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_PolylineOp.h | 3 +++ 7 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 28fc93e7..3b45b680 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -38,6 +38,7 @@ #include "HYDROGUI_VTKPrs.h" #include "HYDROGUI_VTKPrsDisplayer.h" #include "HYDROGUI_AbstractDisplayer.h" +#include "HYDROGUI_PolylineOp.h" #include #include @@ -418,6 +419,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } } + if ( anIsOCCView ) + { + SUIT_Operation* anOp = application()->activeStudy()->activeOperation(); + HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast( anOp ); + if ( aPolylineOp && aPolylineOp->deleteEnabled() ) + theMenu->addAction( action( DeleteId ) ); + } + if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView ) { theMenu->addAction( action( ShowAllId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 0aaf8f0b..384e5e71 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -162,6 +162,8 @@ protected: protected slots: void onOperation(); + void onDelete(); + bool onUndo( int theNumActions ); bool onRedo( int theNumActions ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index d32802e9..87515c4d 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -127,7 +127,8 @@ void HYDROGUI_Module::createActions() createAction( SplitImageId, "SPLIT_IMAGE" ); createAction( EditSplittedImageId, "EDIT_SPLITTED_IMAGE" ); - createAction( DeleteId, "DELETE", "", Qt::Key_Delete ); + createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false, + SLOT( onDelete() ) ); createAction( SetColorId, "COLOR" ); @@ -232,6 +233,16 @@ void HYDROGUI_Module::onOperation() startOperation( anId ); } +void HYDROGUI_Module::onDelete() +{ + SUIT_Operation* anOp = application()->activeStudy()->activeOperation(); + HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast( anOp ); + if ( aPolylineOp && aPolylineOp->deleteEnabled() ) + aPolylineOp->deleteSelected(); + else + startOperation( DeleteId ); +} + bool HYDROGUI_Module::onUndo( int theNumActions ) { QApplication::setOverrideCursor( Qt::WaitCursor ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index 88f11469..de14235f 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -120,3 +120,19 @@ QList< QPair< int, int > > HYDROGUI_PolylineDlg::getSelectedPoints() { return myEditorWidget->getSelectedPoints(); } + +/** + * Redirect the delete action to editor widget + */ +void HYDROGUI_PolylineDlg::deleteSelected() +{ + myEditorWidget->removeSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_PolylineDlg::deleteEnabled() +{ + return myEditorWidget->removeEnabled(); +} diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.h b/src/HYDROGUI/HYDROGUI_PolylineDlg.h index 69c4b6cb..866527c1 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.h +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.h @@ -51,6 +51,9 @@ public: QList getSelectedSections(); QList< QPair< int, int > > getSelectedPoints(); + void deleteSelected(); + bool deleteEnabled(); + protected slots: void processStartedSubOperation( QWidget* ); void processFinishedSubOperation( QWidget* ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index cbefd532..ae3d5b21 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -56,6 +56,24 @@ HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp() erasePreview(); } +/** + * Redirect the delete action to input panel + */ +void HYDROGUI_PolylineOp::deleteSelected() +{ + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); + aPanel->deleteSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_PolylineOp::deleteEnabled() +{ + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); + return aPanel->deleteEnabled(); +} + void HYDROGUI_PolylineOp::startOperation() { if( myCurve ) diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index 78c97a5b..c7fbe658 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -39,6 +39,9 @@ public: HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool isEdit ); virtual ~HYDROGUI_PolylineOp(); + void deleteSelected(); + bool deleteEnabled(); + protected: virtual void startOperation(); virtual void abortOperation(); -- 2.39.2