From a590288ca69e3f51cf245ab026fbcbc1cc538a7e Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 2 Nov 2017 09:27:41 +0300 Subject: [PATCH] refs #1330: global option show/hide arrows --- src/HYDROGUI/HYDROGUI_Module.cxx | 11 +++++- src/HYDROGUI/HYDROGUI_Module.h | 3 ++ src/HYDROGUI/HYDROGUI_Operations.cxx | 46 +++++++++++++++++++++-- src/HYDROGUI/HYDROGUI_Operations.h | 2 +- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 16 ++++++-- 5 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 42473a59..57f0f934 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -744,8 +744,6 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool isPoly = anIsPolyline || anIsPolyline3D; if (isPoly && !anIsLandCoverMap) theMenu->addAction( action( ExportToShapeFileID ) ); - if( isPoly ) - theMenu->addAction( action( PolylineStyleId ) ); // Add copy action QAction* aCopyAction = action( CopyId ); @@ -822,6 +820,15 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } } } + + bool isPoly = anIsPolyline || anIsPolyline3D; + if( isPoly ) + { + theMenu->addSeparator(); + QAction* a = action( ShowHideArrows ); + a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) ); + theMenu->addAction( a ); + } } void HYDROGUI_Module::createPreferences() diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index edf520d7..ba0f8ba5 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -258,6 +258,9 @@ public: void enableLCMActions(); + bool arrowsVisible() const; + void setArrowsVisible( bool ); + protected: CAM_DataModel* createDataModel(); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index e9cf6580..eaaebfbc 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -243,7 +243,7 @@ void HYDROGUI_Module::createActions() createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" ); createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" ); - createAction( PolylineStyleId, "POLYLINE_STYLE" ); + createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" ); } void HYDROGUI_Module::createMenus() @@ -454,6 +454,47 @@ void HYDROGUI_Module::onOperation() int anId = actionId( anAction ); if( anId >= 0 ) startOperation( anId ); + + if( anId==ShowHideArrows ) + { + setArrowsVisible( !arrowsVisible() ); + } +} + +bool HYDROGUI_Module::arrowsVisible() const +{ + int aType; + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + if( resMgr ) + { + resMgr->value( "polyline", "arrow_type", aType ); + return aType>0; + } + else + return false; +} + +void HYDROGUI_Module::setArrowsVisible( bool isVisible ) +{ + SUIT_ResourceMgr* resMgr = application()->resourceMgr(); + + int aType=-1; + if( !resMgr ) + return; + + if( isVisible ) + { + if( resMgr->hasValue( "polyline", "prev_arrow_type" ) ) + resMgr->value( "polyline", "prev_arrow_type", aType ); + resMgr->setValue( "polyline", "arrow_type", aType ); + } + else + { + resMgr->value( "polyline", "arrow_type", aType ); + resMgr->setValue( "polyline", "prev_arrow_type", aType ); + resMgr->setValue( "polyline", "arrow_type", 0 ); + } + preferencesChanged( "polyline", "arrow_type" ); } void HYDROGUI_Module::onDelete() @@ -717,9 +758,6 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case LandCoverScalarMapModeOffId: anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId ); break; - case PolylineStyleId: - anOp = new HYDROGUI_PolylineStyleOp( aModule ); - break; } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index a2a18fe6..fdd3048d 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -144,7 +144,7 @@ enum OperationId BathymetryRescaleUserId, BathymetryRescaleDefaultId, - PolylineStyleId, + ShowHideArrows, }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 812f1192..ed690455 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -996,8 +996,8 @@ Would you like to remove all references from the image? Default rescale bathymetry - DSK_POLYLINE_STYLE - Polyline style + DSK_SHOW_HIDE_ARROWS + Show/hide arrows DSK_IMPORT_IMAGE @@ -1369,8 +1369,16 @@ Would you like to remove all references from the image? Default rescale bathymetry - MEN_POLYLINE_STYLE - Polyline style + MEN_SHOW_HIDE_ARROWS + Show/hide arrows + + + HIDE_ARROWS + Hide arrows + + + SHOW_ARROWS + Show arrows MEN_IMPORT_IMAGE -- 2.39.2