From d5890a2bbd3eebf1e256c6a86ee1ff854b46711b Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 7 Sep 2017 09:10:58 +0300 Subject: [PATCH] refs #1333: customization of tool buttons in OCCViewer --- src/OCCViewer/OCCViewer_Utilities.cxx | 3 +++ src/OCCViewer/OCCViewer_ViewWindow.cxx | 13 +++++++++++++ src/OCCViewer/OCCViewer_ViewWindow.h | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/OCCViewer/OCCViewer_Utilities.cxx b/src/OCCViewer/OCCViewer_Utilities.cxx index e88b29182..0330f328a 100755 --- a/src/OCCViewer/OCCViewer_Utilities.cxx +++ b/src/OCCViewer/OCCViewer_Utilities.cxx @@ -116,7 +116,10 @@ OCCViewer_ViewWindow::Mode2dType OCCViewer_Utilities::setViewer2DMode for ( int i = 0, aNb = aNo2dActions.size(); i < aNb; i++ ) { anAction = aToolMgr->action( aNo2dActions[i] ); if ( anAction ) + { anAction->setEnabled( !is2dMode ); + anAction->setVisible( !is2dMode ); + } } QAction* aTop = aToolMgr->action( OCCViewer_ViewWindow::TopId ); QtxMultiAction* aMulti = dynamic_cast( aTop->parent() ); diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 060349844..0908496f1 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -3815,3 +3815,16 @@ void OCCViewer_ViewWindow::onLightSource() aDlg->show(); } } + +bool OCCViewer_ViewWindow::isActionVisible( ActionId theId ) const +{ + QAction* a = toolMgr()->action( theId ); + return a && a->isVisible(); +} + +void OCCViewer_ViewWindow::setActionVisible( ActionId theId, bool isVisible ) +{ + QAction* a = toolMgr()->action( theId ); + if( a ) + a->setVisible( isVisible ); +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index e83fe217e..823d0e51c 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -143,7 +143,7 @@ class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow Q_OBJECT public: - enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId, + enum ActionId { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId, CloneId, ClippingId, MemId, RestoreId, @@ -270,6 +270,9 @@ public: virtual SUIT_CameraProperties cameraProperties(); + bool isActionVisible( ActionId theId ) const; + void setActionVisible( ActionId theId, bool isVisible ); + public slots: virtual void onFrontView(); virtual void onViewFitAll(); -- 2.39.2