From: asl Date: Thu, 14 Feb 2008 13:16:51 +0000 (+0000) Subject: support of toolbars with help of tool manager X-Git-Tag: V5_0_0a1~37 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=096990e83039ddf218ddc62af7375628a080d18b;p=modules%2Fgui.git support of toolbars with help of tool manager --- diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index a783cf79b..dd563adb5 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -74,8 +75,6 @@ myVP( 0 ) setBackgroundColor( Qt::white ); layout->addWidget( vp ); - myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this ); - createActions(); createToolBar(); } @@ -92,7 +91,6 @@ GLViewer_ViewFrame::~GLViewer_ViewFrame() */ void GLViewer_ViewFrame::createActions() { - if (!myActionsMap.isEmpty()) return; SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QtxAction* aAction; @@ -101,55 +99,55 @@ void GLViewer_ViewFrame::createActions() tr( "MNU_DUMP_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_DUMP_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump())); - myActionsMap[ DumpId ] = aAction; + toolMgr()->registerAction( aAction, DumpId ); // FitAll aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ), tr( "MNU_FITALL" ), 0, this); aAction->setStatusTip(tr("DSC_FITALL")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll())); - myActionsMap[ FitAllId ] = aAction; + toolMgr()->registerAction( aAction, FitAllId ); // FitRect aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ), tr( "MNU_FITRECT" ), 0, this); aAction->setStatusTip(tr("DSC_FITRECT")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea())); - myActionsMap[ FitRectId ] = aAction; + toolMgr()->registerAction( aAction, FitRectId ); // FitSelect aAction = new QtxAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ), tr( "MNU_FITSELECT" ), 0, this); aAction->setStatusTip(tr("DSC_FITSELECT")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitSelect())); - myActionsMap[ FitSelectId ] = aAction; + toolMgr()->registerAction( aAction, FitSelectId ); // Zoom aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ), tr( "MNU_ZOOM_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_ZOOM_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom())); - myActionsMap[ ZoomId ] = aAction; + toolMgr()->registerAction( aAction, ZoomId ); // Panning aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ), tr( "MNU_PAN_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_PAN_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan())); - myActionsMap[ PanId ] = aAction; + toolMgr()->registerAction( aAction, PanId ); // Global Panning aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ), tr( "MNU_GLOBALPAN_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan())); - myActionsMap[ GlobalPanId ] = aAction; + toolMgr()->registerAction( aAction, GlobalPanId ); aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ), tr( "MNU_RESET_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_RESET_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset())); - myActionsMap[ ResetId ] = aAction; + toolMgr()->registerAction( aAction, ResetId ); } /*! @@ -157,21 +155,22 @@ void GLViewer_ViewFrame::createActions() */ void GLViewer_ViewFrame::createToolBar() { - myToolBar->addAction( myActionsMap[DumpId] ); + int tid = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL") ); + toolMgr()->append( DumpId, tid ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); - aScaleAction->insertAction( myActionsMap[FitAllId] ); - aScaleAction->insertAction( myActionsMap[FitRectId] ); - aScaleAction->insertAction( myActionsMap[FitSelectId] ); - aScaleAction->insertAction( myActionsMap[ZoomId] ); - myToolBar->addAction( aScaleAction ); + aScaleAction->insertAction( toolMgr()->action( FitAllId ) ); + aScaleAction->insertAction( toolMgr()->action( FitRectId ) ); + aScaleAction->insertAction( toolMgr()->action( FitSelectId ) ); + aScaleAction->insertAction( toolMgr()->action( ZoomId ) ); + toolMgr()->append( aScaleAction, tid ); QtxMultiAction* aPanAction = new QtxMultiAction( this ); - aPanAction->insertAction( myActionsMap[PanId] ); - aPanAction->insertAction( myActionsMap[GlobalPanId] ); - myToolBar->addAction( aPanAction ); + aPanAction->insertAction( toolMgr()->action( PanId ) ); + aPanAction->insertAction( toolMgr()->action( GlobalPanId ) ); + toolMgr()->append( aPanAction, tid ); - myToolBar->addAction( myActionsMap[ResetId] ); + toolMgr()->append( toolMgr()->action( ResetId ), tid ); } /*! diff --git a/src/GLViewer/GLViewer_ViewFrame.h b/src/GLViewer/GLViewer_ViewFrame.h index 00b83e334..03a9687e8 100644 --- a/src/GLViewer/GLViewer_ViewFrame.h +++ b/src/GLViewer/GLViewer_ViewFrame.h @@ -50,6 +50,10 @@ class GLVIEWER_API GLViewer_ViewFrame: public SUIT_ViewWindow { Q_OBJECT +public: + //! Actions ID + enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId }; + public: GLViewer_ViewFrame( SUIT_Desktop* , GLViewer_Viewer* ); ~GLViewer_ViewFrame(); @@ -109,15 +113,6 @@ private slots: private: void createActions(); void createToolBar(); - -private: - //! Actions ID - enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId }; - typedef QMap ActionsMap; - -private: - ActionsMap myActionsMap; - QToolBar* myToolBar; }; diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 828634eec..cc6e0ba0e 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -27,6 +27,8 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" +#include "QtxActionToolMgr.h" + #include #include #include @@ -296,8 +298,12 @@ void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup) thePopup->addSeparator(); OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); - if ( aView && !aView->getToolBar()->isVisible() ) - thePopup->addAction( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); + + //Support of several toolbars in the popup menu + QList lst = qFindChildren( aView ); + QList::const_iterator it = lst.begin(), last = lst.end(); + for( ; it!=last; it++ ) + thePopup->addAction( (*it)->toggleViewAction() ); } /*! @@ -328,15 +334,6 @@ void OCCViewer_Viewer::onChangeBgColor() aViewPort3d->setBackgroundColor(selColor); } -/*! - SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window -*/ -void OCCViewer_Viewer::onShowToolbar() { - OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); - if ( aView ) - aView->getToolBar()->show(); -} - /*! Updates OCC 3D viewer */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index b21b1660c..7fdb1e9d4 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -149,7 +149,6 @@ protected slots: void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); void onDumpView(); - void onShowToolbar(); void onChangeBgColor(); private: diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index b372b744f..8faa93be0 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -230,8 +230,6 @@ void OCCViewer_ViewWindow::initLayout() setTransformRequested ( NOTHING ); setTransformInProcess ( false ); - myToolBar = new QtxToolBar( true, tr( "LBL_TOOLBAR_LABEL" ), this ); - createActions(); createToolBar(); } @@ -915,8 +913,9 @@ void OCCViewer_ViewWindow::endDrawRect() */ void OCCViewer_ViewWindow::createActions() { - if (!myActionsMap.isEmpty()) return; - + if( !toolMgr()->isEmpty() ) + return; + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QtxAction* aAction; @@ -926,42 +925,42 @@ void OCCViewer_ViewWindow::createActions() tr( "MNU_DUMP_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_DUMP_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView())); - myActionsMap[ DumpId ] = aAction; + toolMgr()->registerAction( aAction, DumpId ); // FitAll aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ), tr( "MNU_FITALL" ), 0, this); aAction->setStatusTip(tr("DSC_FITALL")); connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll())); - myActionsMap[ FitAllId ] = aAction; + toolMgr()->registerAction( aAction, FitAllId ); // FitRect aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ), tr( "MNU_FITRECT" ), 0, this); aAction->setStatusTip(tr("DSC_FITRECT")); connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit())); - myActionsMap[ FitRectId ] = aAction; - + toolMgr()->registerAction( aAction, FitRectId ); + // Zoom aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ), tr( "MNU_ZOOM_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_ZOOM_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom())); - myActionsMap[ ZoomId ] = aAction; + toolMgr()->registerAction( aAction, ZoomId ); // Panning aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ), tr( "MNU_PAN_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_PAN_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning())); - myActionsMap[ PanId ] = aAction; + toolMgr()->registerAction( aAction, PanId ); // Global Panning aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ), tr( "MNU_GLOBALPAN_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning())); - myActionsMap[ GlobalPanId ] = aAction; + toolMgr()->registerAction( aAction, GlobalPanId ); // Rotation Point mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ), @@ -969,91 +968,91 @@ void OCCViewer_ViewWindow::createActions() mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW")); mySetRotationPointAction->setCheckable( true ); connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool ))); - myActionsMap[ ChangeRotationPointId ] = mySetRotationPointAction; + toolMgr()->registerAction( mySetRotationPointAction, ChangeRotationPointId ); // Rotation aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ), tr( "MNU_ROTATE_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_ROTATE_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation())); - myActionsMap[ RotationId ] = aAction; + toolMgr()->registerAction( aAction, RotationId ); // Projections aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ), tr( "MNU_FRONT_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_FRONT_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView())); - myActionsMap[ FrontId ] = aAction; + toolMgr()->registerAction( aAction, FrontId ); aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ), tr( "MNU_BACK_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_BACK_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onBackView())); - myActionsMap[ BackId ] = aAction; + toolMgr()->registerAction( aAction, BackId ); aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ), tr( "MNU_TOP_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_TOP_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onTopView())); - myActionsMap[ TopId ] = aAction; + toolMgr()->registerAction( aAction, TopId ); aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ), tr( "MNU_BOTTOM_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_BOTTOM_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView())); - myActionsMap[ BottomId ] = aAction; + toolMgr()->registerAction( aAction, BottomId ); aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ), tr( "MNU_LEFT_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_LEFT_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView())); - myActionsMap[ LeftId ] = aAction; + toolMgr()->registerAction( aAction, LeftId ); aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ), tr( "MNU_RIGHT_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_RIGHT_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onRightView())); - myActionsMap[ RightId ] = aAction; + toolMgr()->registerAction( aAction, RightId ); // Reset aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ), tr( "MNU_RESET_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_RESET_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onResetView())); - myActionsMap[ ResetId ] = aAction; + toolMgr()->registerAction( aAction, ResetId ); // Reset aAction = new QtxAction(tr("MNU_CLONE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLONE_VIEW" ) ), tr( "MNU_CLONE_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_CLONE_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onCloneView())); - myActionsMap[ CloneId ] = aAction; + toolMgr()->registerAction( aAction, CloneId ); myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ), tr( "MNU_CLIPPING" ), 0, this); myClippingAction->setStatusTip(tr("DSC_CLIPPING")); myClippingAction->setCheckable( true ); connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool ))); - myActionsMap[ ClippingId ] = myClippingAction; + toolMgr()->registerAction( myClippingAction, CloneId ); aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ), tr( "MNU_SHOOT_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_SHOOT_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onMemorizeView())); - myActionsMap[ MemId ] = aAction; + toolMgr()->registerAction( aAction, MemId ); aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ), tr( "MNU_PRESETS_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_PRESETS_VIEW")); connect(aAction, SIGNAL(activated()), this, SLOT(onRestoreView())); - myActionsMap[ RestoreId ] = aAction; + toolMgr()->registerAction( aAction, RestoreId ); if (myModel->trihedronActivated()) { aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ), tr( "MNU_SHOW_TRIHEDRE" ), 0, this); aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE")); connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow())); - myActionsMap[ TrihedronShowId ] = aAction; + toolMgr()->registerAction( aAction, TrihedronShowId ); } } @@ -1062,46 +1061,47 @@ void OCCViewer_ViewWindow::createActions() */ void OCCViewer_ViewWindow::createToolBar() { - myToolBar->addAction( myActionsMap[DumpId] ); - if ( myModel->trihedronActivated() ) - myToolBar->addAction( myActionsMap[TrihedronShowId] ); + int tid = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + + toolMgr()->append( DumpId, tid ); + if( myModel->trihedronActivated() ) + toolMgr()->append( TrihedronShowId, tid ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); - aScaleAction->insertAction( myActionsMap[FitAllId] ); - aScaleAction->insertAction( myActionsMap[FitRectId] ); - aScaleAction->insertAction( myActionsMap[ZoomId] ); - myToolBar->addAction( aScaleAction ); + aScaleAction->insertAction( toolMgr()->action( FitAllId ) ); + aScaleAction->insertAction( toolMgr()->action( FitRectId ) ); + aScaleAction->insertAction( toolMgr()->action( ZoomId ) ); + toolMgr()->append( aScaleAction, tid ); QtxMultiAction* aPanningAction = new QtxMultiAction( this ); - aPanningAction->insertAction( myActionsMap[PanId] ); - aPanningAction->insertAction( myActionsMap[GlobalPanId] ); - myToolBar->addAction( aPanningAction ); - - myToolBar->addAction( myActionsMap[ChangeRotationPointId] ); + aPanningAction->insertAction( toolMgr()->action( PanId ) ); + aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) ); + toolMgr()->append( aPanningAction, tid ); - myToolBar->addAction( myActionsMap[RotationId] ); + toolMgr()->append( ChangeRotationPointId, tid ); + toolMgr()->append( RotationId, tid ); QtxMultiAction* aViewsAction = new QtxMultiAction( this ); - aViewsAction->insertAction( myActionsMap[FrontId] ); - aViewsAction->insertAction( myActionsMap[BackId] ); - aViewsAction->insertAction( myActionsMap[TopId] ); - aViewsAction->insertAction( myActionsMap[BottomId] ); - aViewsAction->insertAction( myActionsMap[LeftId] ); - aViewsAction->insertAction( myActionsMap[RightId] ); - myToolBar->addAction( aViewsAction ); + aViewsAction->insertAction( toolMgr()->action( FrontId ) ); + aViewsAction->insertAction( toolMgr()->action( BackId ) ); + aViewsAction->insertAction( toolMgr()->action( TopId ) ); + aViewsAction->insertAction( toolMgr()->action( BottomId ) ); + aViewsAction->insertAction( toolMgr()->action( LeftId ) ); + aViewsAction->insertAction( toolMgr()->action( RightId ) ); + toolMgr()->append( aViewsAction, tid ); - myToolBar->addAction( myActionsMap[ResetId] ); + toolMgr()->append( ResetId, tid ); QtxMultiAction* aMemAction = new QtxMultiAction( this ); - aMemAction->insertAction( myActionsMap[MemId] ); - aMemAction->insertAction( myActionsMap[RestoreId] ); - myToolBar->addAction( aMemAction ); - - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[CloneId] ); - - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[ClippingId] ); + aMemAction->insertAction( toolMgr()->action( MemId ) ); + aMemAction->insertAction( toolMgr()->action( RestoreId ) ); + toolMgr()->append( aMemAction, tid ); + + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( CloneId, tid ); + + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( ClippingId, tid ); } /*! @@ -1253,11 +1253,11 @@ void OCCViewer_ViewWindow::onCloneView() void OCCViewer_ViewWindow::onClipping( bool on ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if ( on ) + /*if ( on ) myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" ))); else myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); - + */ if ( on ) { if ( !myClippingDlg ) @@ -1638,3 +1638,23 @@ void OCCViewer_ViewWindow::onSketchingFinished() aViewMgr->getOCCViewer()->performSelectionChanged(); } } + +OCCViewer_ViewPort3d* OCCViewer_ViewWindow::getViewPort() +{ + return myViewPort; +} + +bool OCCViewer_ViewWindow::transformRequested() const +{ + return ( myOperation != NOTHING ); +} + +bool OCCViewer_ViewWindow::transformInProcess() const +{ + return myEventStarted; +} + +void OCCViewer_ViewWindow::setTransformInProcess( bool bOn ) +{ + myEventStarted = bOn; +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 686182020..9d1d1d825 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -19,23 +19,19 @@ #ifndef OCCVIEWER_VIEWWINDOW_H #define OCCVIEWER_VIEWWINDOW_H -#include "OCCViewer_ViewModel.h" - +#include "OCCViewer.h" #include "SUIT_ViewWindow.h" - -#include "QtxAction.h" - -#include -#include +#include class QRubberBand; - class SUIT_Desktop; class OCCViewer_ViewPort3d; class OCCViewer_ViewSketcher; - class OCCViewer_ClippingDlg; class OCCViewer_SetRotationPointDlg; +class OCCViewer_Viewer; +class viewAspect; +class QtxAction; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -46,6 +42,11 @@ class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow Q_OBJECT public: + enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, + ChangeRotationPointId, RotationId, + FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, + TrihedronShowId }; + enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW }; @@ -57,12 +58,10 @@ public: OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); - OCCViewer_ViewPort3d* getViewPort() { return myViewPort; } + OCCViewer_ViewPort3d* getViewPort(); bool eventFilter(QObject* watched, QEvent* e); - QToolBar* getToolBar() { return myToolBar; } - void performRestoring( const viewAspect& ); virtual void initLayout(); @@ -122,22 +121,15 @@ signals: void Hide( QHideEvent * ); protected: - enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, - ChangeRotationPointId, RotationId, - FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId }; - - typedef QMap ActionsMap; - QImage dumpView(); /* Transformation selected but not started yet */ - bool transformRequested() const { return ( myOperation != NOTHING ); } - void setTransformRequested ( OperationType op ); + bool transformRequested() const; + void setTransformRequested ( OperationType ); /* Transformation is selected and already started */ - bool transformInProcess() const { return myEventStarted; } - void setTransformInProcess( bool bOn ) { myEventStarted = bOn; } + bool transformInProcess() const; + void setTransformInProcess( bool ); void vpMousePressEvent(QMouseEvent* theEvent); void vpMouseReleaseEvent(QMouseEvent* theEvent); @@ -190,9 +182,6 @@ protected: QCursor myCursor; - QToolBar* myToolBar; - ActionsMap myActionsMap; - double myCurScale; private: diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 6ecda522b..ff40d12d3 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -59,8 +60,6 @@ Plot2d_ViewWindow::Plot2d_ViewWindow( SUIT_Desktop* theDesktop, Plot2d_Viewer* t myViewFrame = new Plot2d_ViewFrame( this, "plotView" ); setCentralWidget( myViewFrame ); - myToolBar = addToolBar( tr("LBL_TOOLBAR_LABEL") ); - createActions(); createToolBar(); @@ -114,7 +113,7 @@ Plot2d_ViewFrame* Plot2d_ViewWindow::getViewFrame() */ QToolBar* Plot2d_ViewWindow::getToolBar() { - return myToolBar; + return toolMgr()->toolBar( myToolBar ); } /*! @@ -123,28 +122,29 @@ QToolBar* Plot2d_ViewWindow::getToolBar() */ void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup ) { + QtxActionToolMgr* mgr = toolMgr(); // scaling QMenu* scalingPopup = thePopup->addMenu( tr( "SCALING_POPUP" ) ); - scalingPopup->addAction( myActionsMap[ PModeXLinearId ] ); - scalingPopup->addAction( myActionsMap[ PModeXLogarithmicId ] ); + scalingPopup->addAction( mgr->action( PModeXLinearId ) ); + scalingPopup->addAction( mgr->action( PModeXLogarithmicId ) ); scalingPopup->addSeparator(); - scalingPopup->addAction( myActionsMap[ PModeYLinearId ] ); - scalingPopup->addAction( myActionsMap[ PModeYLogarithmicId ] ); + scalingPopup->addAction( mgr->action( PModeYLinearId ) ); + scalingPopup->addAction( mgr->action( PModeYLogarithmicId ) ); // fit data thePopup->addAction( tr( "TOT_PLOT2D_FITDATA" ), myViewFrame, SLOT( onFitData() ) ); // curve type QMenu* curTypePopup = thePopup->addMenu( tr( "CURVE_TYPE_POPUP" ) ); - curTypePopup->addAction( myActionsMap[ CurvPointsId ] ); - curTypePopup->addAction( myActionsMap[ CurvLinesId ] ); - curTypePopup->addAction( myActionsMap[ CurvSplinesId ] ); + curTypePopup->addAction( mgr->action( CurvPointsId ) ); + curTypePopup->addAction( mgr->action( CurvLinesId ) ); + curTypePopup->addAction( mgr->action( CurvSplinesId ) ); // legend - thePopup->addAction( myActionsMap[ LegendId ] ); + thePopup->addAction( mgr->action( LegendId ) ); // settings - thePopup->addAction( myActionsMap[ CurvSettingsId ] ); + thePopup->addAction( mgr->action( CurvSettingsId ) ); } /*! @@ -178,9 +178,7 @@ bool Plot2d_ViewWindow::eventFilter( QObject* watched, QEvent* e ) */ void Plot2d_ViewWindow::createActions() { - if ( !myActionsMap.isEmpty() ) - return; - + QtxActionToolMgr* mgr = toolMgr(); QtxAction* aAction; SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -191,7 +189,7 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_DUMP_VIEW" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onDumpView() ) ); - myActionsMap[ DumpId ] = aAction; + mgr->registerAction( aAction, DumpId ); // 2. Scaling operations @@ -202,7 +200,7 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_FITALL" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onFitAll() ) ); - myActionsMap[ FitAllId ] = aAction; + mgr->registerAction( aAction, FitAllId ); // 2.2. Fit Rect aAction = new QtxAction( tr( "MNU_FITRECT" ), @@ -211,7 +209,7 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_FITRECT" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onFitRect() ) ); - myActionsMap[ FitRectId ] = aAction; + mgr->registerAction( aAction, FitRectId ); // 2.3. Zoom aAction = new QtxAction( tr( "MNU_ZOOM_VIEW" ), @@ -220,14 +218,14 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_ZOOM_VIEW" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onZoom() ) ); - myActionsMap[ ZoomId ] = aAction; + mgr->registerAction( aAction, ZoomId ); // 2.4. Create multi-action for scaling operations QtxMultiAction* aScaleAction = new QtxMultiAction( this ); - aScaleAction->insertAction( myActionsMap[ FitAllId ] ); - aScaleAction->insertAction( myActionsMap[ FitRectId ] ); - aScaleAction->insertAction( myActionsMap[ ZoomId ] ); - myActionsMap[ ScaleOpId ] = aScaleAction; + aScaleAction->insertAction( mgr->action( FitAllId ) ); + aScaleAction->insertAction( mgr->action( FitRectId ) ); + aScaleAction->insertAction( mgr->action( ZoomId ) ); + mgr->registerAction( aAction, ScaleOpId ); // 3. Moving operations @@ -238,7 +236,7 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_PAN_VIEW" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onPanning() ) ); - myActionsMap[ PanId ] = aAction; + mgr->registerAction( aAction, PanId ); // 3.2. Global Panning aAction = new QtxAction( tr( "MNU_GLOBALPAN_VIEW" ), @@ -247,13 +245,13 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_GLOBALPAN_VIEW" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onGlobalPanning() ) ); - myActionsMap[ GlobalPanId ] = aAction; + mgr->registerAction( aAction, GlobalPanId ); // 3.3. Create multi-action for moving operations QtxMultiAction* aPanAction = new QtxMultiAction( this ); - aPanAction->insertAction( myActionsMap[ PanId ] ); - aPanAction->insertAction( myActionsMap[ GlobalPanId ] ); - myActionsMap[ MoveOpId ] = aPanAction; + aPanAction->insertAction( mgr->action( PanId ) ); + aPanAction->insertAction( mgr->action( GlobalPanId ) ); + mgr->registerAction( aAction, MoveOpId ); // 4. Curve type operations @@ -264,7 +262,7 @@ void Plot2d_ViewWindow::createActions() 0, this ); aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_POINTS" ) ); aAction->setCheckable( true ); - myActionsMap[ CurvPointsId ] = aAction; + mgr->registerAction( aAction, CurvPointsId ); // 4.2. Lines aAction = new QtxAction( tr( "TOT_PLOT2D_CURVES_LINES" ), @@ -273,7 +271,7 @@ void Plot2d_ViewWindow::createActions() 0, this ); aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_LINES" ) ); aAction->setCheckable( true ); - myActionsMap[ CurvLinesId ] = aAction; + mgr->registerAction( aAction, CurvLinesId ); // 4.3. Splines aAction = new QtxAction( tr( "TOT_PLOT2D_CURVES_SPLINES" ), @@ -282,13 +280,13 @@ void Plot2d_ViewWindow::createActions() 0, this ); aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_SPLINES" ) ); aAction->setCheckable( true ); - myActionsMap[ CurvSplinesId ] = aAction; + mgr->registerAction( aAction, CurvSplinesId ); // 4.4. Create action group for curve type operations QActionGroup* aCurveGroup = new QActionGroup( this ); - aCurveGroup->addAction( myActionsMap[ CurvPointsId ] ); - aCurveGroup->addAction( myActionsMap[ CurvLinesId ] ); - aCurveGroup->addAction( myActionsMap[ CurvSplinesId ] ); + aCurveGroup->addAction( mgr->action( CurvPointsId ) ); + aCurveGroup->addAction( mgr->action( CurvLinesId ) ); + aCurveGroup->addAction( mgr->action( CurvSplinesId ) ); connect( aCurveGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( onCurves() ) ); // 5. Horizontal scaling mode operations @@ -301,7 +299,7 @@ void Plot2d_ViewWindow::createActions() aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LINEAR_HOR" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewHorMode() ) ); aAction->setCheckable( true ); - myActionsMap[ PModeXLinearId ] = aAction; + mgr->registerAction( aAction, PModeXLinearId ); // 5.2. Logarithmic aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_HOR" ), @@ -311,12 +309,12 @@ void Plot2d_ViewWindow::createActions() aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_HOR" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewHorMode() ) ); aAction->setCheckable( true ); - myActionsMap[ PModeXLogarithmicId ] = aAction; + mgr->registerAction( aAction, PModeXLogarithmicId ); // 5.3. Create action group for horizontal scaling mode operations QActionGroup* aHorGroup = new QActionGroup( this ); - aHorGroup->addAction( myActionsMap[ PModeXLinearId ] ); - aHorGroup->addAction( myActionsMap[ PModeXLogarithmicId ] ); + aHorGroup->addAction( mgr->action( PModeXLinearId ) ); + aHorGroup->addAction( mgr->action( PModeXLogarithmicId ) ); // 6. Vertical scaling mode operations @@ -328,7 +326,7 @@ void Plot2d_ViewWindow::createActions() aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LINEAR_VER" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewVerMode() ) ); aAction->setCheckable( true ); - myActionsMap[ PModeYLinearId ] = aAction; + mgr->registerAction( aAction, PModeYLinearId ); // 6.2. Logarithmic aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_VER" ), @@ -338,12 +336,12 @@ void Plot2d_ViewWindow::createActions() aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_VER" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewVerMode() ) ); aAction->setCheckable( true ); - myActionsMap[ PModeYLogarithmicId ] = aAction; + mgr->registerAction( aAction, PModeYLogarithmicId ); // 6.3. Create action group for vertical scaling mode operations QActionGroup* aVerGroup = new QActionGroup( this ); - aVerGroup->addAction( myActionsMap[ PModeYLinearId ] ); - aVerGroup->addAction( myActionsMap[ PModeYLogarithmicId ] ); + aVerGroup->addAction( mgr->action( PModeYLinearId ) ); + aVerGroup->addAction( mgr->action( PModeYLogarithmicId ) ); // 7. Legend aAction = new QtxAction( tr( "TOT_PLOT2D_SHOW_LEGEND" ), @@ -353,7 +351,7 @@ void Plot2d_ViewWindow::createActions() aAction->setStatusTip( tr( "PRP_PLOT2D_SHOW_LEGEND" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onLegend() ) ); aAction->setCheckable( true ); - myActionsMap[ LegendId ] = aAction; + mgr->registerAction( aAction, LegendId ); // 8. Settings aAction = new QtxAction( tr( "TOT_PLOT2D_SETTINGS" ), @@ -362,7 +360,7 @@ void Plot2d_ViewWindow::createActions() 0, this ); aAction->setStatusTip( tr( "PRP_PLOT2D_SETTINGS" ) ); connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onSettings() ) ); - myActionsMap[ CurvSettingsId ] = aAction; + mgr->registerAction( aAction, CurvSettingsId ); // 9. Clone aAction = new QtxAction( tr( "MNU_CLONE_VIEW" ), @@ -371,7 +369,7 @@ void Plot2d_ViewWindow::createActions() 0, this); aAction->setStatusTip( tr( "DSC_CLONE_VIEW" ) ); connect( aAction, SIGNAL( triggered( bool ) ), this, SIGNAL( cloneView() ) ); - myActionsMap[ CloneId ] = aAction; + mgr->registerAction( aAction, CloneId ); // Set initial values onChangeCurveMode(); @@ -385,23 +383,25 @@ void Plot2d_ViewWindow::createActions() */ void Plot2d_ViewWindow::createToolBar() { - myToolBar->addAction( myActionsMap[ DumpId ] ); - myToolBar->addAction( myActionsMap[ ScaleOpId ] ); - myToolBar->addAction( myActionsMap[ MoveOpId ] ); - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[ CurvPointsId ] ); - myToolBar->addAction( myActionsMap[ CurvLinesId ] ); - myToolBar->addAction( myActionsMap[ CurvSplinesId ] ); - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[ PModeXLinearId ] ); - myToolBar->addAction( myActionsMap[ PModeXLogarithmicId ] ); - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[ PModeYLinearId ] ); - myToolBar->addAction( myActionsMap[ PModeYLogarithmicId ] ); - myToolBar->addSeparator(); - myToolBar->addAction( myActionsMap[ LegendId ] ); - myToolBar->addAction( myActionsMap[ CurvSettingsId ] ); - myToolBar->addAction( myActionsMap[ CloneId ] ); + QtxActionToolMgr* mgr = toolMgr(); + myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) ); + mgr->append( DumpId, myToolBar ); + mgr->append( ScaleOpId, myToolBar ); + mgr->append( MoveOpId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( CurvPointsId, myToolBar ); + mgr->append( CurvLinesId, myToolBar ); + mgr->append( CurvSplinesId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( PModeXLinearId, myToolBar ); + mgr->append( PModeXLogarithmicId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( PModeYLinearId, myToolBar ); + mgr->append( PModeYLogarithmicId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( LegendId, myToolBar ); + mgr->append( CurvSettingsId, myToolBar ); + mgr->append( CloneId, myToolBar ); } /*! @@ -440,11 +440,11 @@ void Plot2d_ViewWindow::onChangeHorMode() bool aVerLinear = myViewFrame->isModeVerLinear(); if ( aHorLinear ) - myActionsMap[ PModeXLinearId ]->setChecked( true ); + toolMgr()->action( PModeXLinearId )->setChecked( true ); else - myActionsMap[ PModeXLogarithmicId ]->setChecked( true ); + toolMgr()->action( PModeXLogarithmicId )->setChecked( true ); - myActionsMap[ GlobalPanId ]->setEnabled( aHorLinear && aVerLinear ); + toolMgr()->action( GlobalPanId )->setEnabled( aHorLinear && aVerLinear ); } /*! @@ -456,11 +456,11 @@ void Plot2d_ViewWindow::onChangeVerMode() bool aVerLinear = myViewFrame->isModeVerLinear(); if ( aVerLinear ) - myActionsMap[ PModeYLinearId ]->setChecked( true ); + toolMgr()->action( PModeYLinearId )->setChecked( true ); else - myActionsMap[ PModeYLogarithmicId ]->setChecked( true ); + toolMgr()->action( PModeYLogarithmicId )->setChecked( true ); - myActionsMap[ GlobalPanId ]->setEnabled( aHorLinear && aVerLinear ); + toolMgr()->action( GlobalPanId )->setEnabled( aHorLinear && aVerLinear ); } /*! @@ -470,13 +470,13 @@ void Plot2d_ViewWindow::onChangeCurveMode() { switch ( myViewFrame->getCurveType() ) { case 0: - myActionsMap[ CurvPointsId ]->setChecked( true ); + toolMgr()->action( CurvPointsId )->setChecked( true ); break; case 1: - myActionsMap[ CurvLinesId ]->setChecked( true ); + toolMgr()->action( CurvLinesId )->setChecked( true ); break; case 2: - myActionsMap[ CurvSplinesId ]->setChecked( true ); + toolMgr()->action( CurvSplinesId )->setChecked( true ); break; default: break; @@ -488,7 +488,7 @@ void Plot2d_ViewWindow::onChangeCurveMode() */ void Plot2d_ViewWindow::onChangeLegendMode() { - myActionsMap[ LegendId ]->setChecked( myViewFrame->isLegendShow() ); + toolMgr()->action( LegendId )->setChecked( myViewFrame->isLegendShow() ); } /*! @@ -536,7 +536,7 @@ void Plot2d_ViewWindow::onGlobalPanning() */ void Plot2d_ViewWindow::onViewHorMode() { - myViewFrame->setHorScaleMode( myActionsMap[ PModeXLinearId ]->isChecked() ? 0 : 1 ); + myViewFrame->setHorScaleMode( toolMgr()->action( PModeXLinearId )->isChecked() ? 0 : 1 ); } /*! @@ -544,7 +544,7 @@ void Plot2d_ViewWindow::onViewHorMode() */ void Plot2d_ViewWindow::onViewVerMode() { - myViewFrame->setVerScaleMode( myActionsMap[ PModeYLinearId ]->isChecked() ? 0 : 1 ); + myViewFrame->setVerScaleMode( toolMgr()->action( PModeYLinearId )->isChecked() ? 0 : 1 ); } /*! @@ -561,11 +561,11 @@ void Plot2d_ViewWindow::onLegend() */ void Plot2d_ViewWindow::onCurves() { - if( myActionsMap[ CurvPointsId ]->isChecked() ) + if( toolMgr()->action( CurvPointsId )->isChecked() ) myViewFrame->setCurveType( 0 ); - else if ( myActionsMap[ CurvLinesId ]->isChecked() ) + else if ( toolMgr()->action( CurvLinesId )->isChecked() ) myViewFrame->setCurveType( 1 ); - else if ( myActionsMap[ CurvSplinesId ]->isChecked() ) + else if ( toolMgr()->action( CurvSplinesId )->isChecked() ) myViewFrame->setCurveType( 2 ); } diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index 06d31f84a..68795cd49 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -44,6 +44,17 @@ class PLOT2D_EXPORT Plot2d_ViewWindow : public SUIT_ViewWindow { Q_OBJECT +public: + enum { DumpId, + ScaleOpId, FitAllId, FitRectId, ZoomId, + MoveOpId, PanId, GlobalPanId, + PModeXLinearId, PModeXLogarithmicId, + PModeYLinearId, PModeYLogarithmicId, + CurvPointsId, CurvLinesId, CurvSplinesId, + LegendId, + CurvSettingsId, + CloneId }; + public: Plot2d_ViewWindow( SUIT_Desktop*, Plot2d_Viewer* ); virtual ~Plot2d_ViewWindow(); @@ -82,20 +93,6 @@ public slots: void onDumpView(); -protected: - enum { DumpId, - ScaleOpId, FitAllId, FitRectId, ZoomId, - MoveOpId, PanId, GlobalPanId, - PModeXLinearId, PModeXLogarithmicId, - PModeYLinearId, PModeYLogarithmicId, - CurvPointsId, CurvLinesId, CurvSplinesId, - LegendId, - CurvSettingsId, - CloneId }; - - typedef QMap ActionsMap; - ActionsMap myActionsMap; - protected: virtual QImage dumpView(); virtual bool dumpViewToFormat( const QImage&, @@ -109,7 +106,7 @@ signals: private: Plot2d_Viewer* myModel; Plot2d_ViewFrame* myViewFrame; - QToolBar* myToolBar; + int myToolBar; QImage myDumpImage; }; diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index ecc4729ef..4685fdfe3 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,7 @@ SVTK_MainWindow setObjectName(theName); setWindowFlags( windowFlags() & ~Qt::Window ); - myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this ); + myToolBar = myViewWindow->toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this ); createActions(theResourceMgr); createToolBar(); @@ -90,10 +91,11 @@ SVTK_MainWindow myInteractor->setFocus(); setFocusProxy(myInteractor); - myUpdateRateDlg = new SVTK_UpdateRateDlg(myActionsMap[UpdateRate],this,"SVTK_UpdateRateDlg"); - myNonIsometricDlg = new SVTK_NonIsometricDlg(myActionsMap[NonIsometric],this,"SVTK_NonIsometricDlg"); - myCubeAxesDlg = new SVTK_CubeAxesDlg(myActionsMap[GraduatedAxes],this,"SVTK_CubeAxesDlg"); - mySetRotationPointDlg = new SVTK_SetRotationPointDlg(myActionsMap[ChangeRotationPointId],this,"SVTK_SetRotationPointDlg"); + myUpdateRateDlg = new SVTK_UpdateRateDlg( action( UpdateRate ), this, "SVTK_UpdateRateDlg" ); + myNonIsometricDlg = new SVTK_NonIsometricDlg( action( NonIsometric ), this, "SVTK_NonIsometricDlg" ); + myCubeAxesDlg = new SVTK_CubeAxesDlg( action( GraduatedAxes ), this, "SVTK_CubeAxesDlg" ); + mySetRotationPointDlg = new SVTK_SetRotationPointDlg + ( action( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" ); } /*! @@ -395,7 +397,7 @@ QToolBar* SVTK_MainWindow ::getToolBar() { - return myToolBar; + return myViewWindow->toolMgr()->toolBar( myToolBar ); } void @@ -416,10 +418,8 @@ void SVTK_MainWindow ::createActions(SUIT_ResourceMgr* theResourceMgr) { - if(!myActionsMap.isEmpty()) - return; - QtxAction* anAction; + QtxActionToolMgr* mgr = myViewWindow->toolMgr(); // Dump view anAction = new QtxAction(tr("MNU_DUMP_VIEW"), @@ -427,7 +427,7 @@ SVTK_MainWindow tr( "MNU_DUMP_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_DUMP_VIEW")); connect(anAction, SIGNAL(activated()), myViewWindow, SLOT(onDumpView())); - myActionsMap[ DumpId ] = anAction; + mgr->registerAction( anAction, DumpId ); // FitAll anAction = new QtxAction(tr("MNU_FITALL"), @@ -435,7 +435,7 @@ SVTK_MainWindow tr( "MNU_FITALL" ), 0, this); anAction->setStatusTip(tr("DSC_FITALL")); connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll())); - myActionsMap[ FitAllId ] = anAction; + mgr->registerAction( anAction, FitAllId ); // FitRect anAction = new QtxAction(tr("MNU_FITRECT"), @@ -443,7 +443,7 @@ SVTK_MainWindow tr( "MNU_FITRECT" ), 0, this); anAction->setStatusTip(tr("DSC_FITRECT")); connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit())); - myActionsMap[ FitRectId ] = anAction; + mgr->registerAction( anAction, FitRectId ); // Zoom anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), @@ -451,7 +451,7 @@ SVTK_MainWindow tr( "MNU_ZOOM_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_ZOOM_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom())); - myActionsMap[ ZoomId ] = anAction; + mgr->registerAction( anAction, ZoomId ); // Panning anAction = new QtxAction(tr("MNU_PAN_VIEW"), @@ -459,7 +459,7 @@ SVTK_MainWindow tr( "MNU_PAN_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_PAN_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning())); - myActionsMap[ PanId ] = anAction; + mgr->registerAction( anAction, PanId ); // Global Panning anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), @@ -467,7 +467,7 @@ SVTK_MainWindow tr( "MNU_GLOBALPAN_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning())); - myActionsMap[ GlobalPanId ] = anAction; + mgr->registerAction( anAction, GlobalPanId ); // Change rotation point anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), @@ -476,7 +476,7 @@ SVTK_MainWindow anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW")); anAction->setCheckable(true); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool))); - myActionsMap[ ChangeRotationPointId ] = anAction; + mgr->registerAction( anAction, ChangeRotationPointId ); // Rotation anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), @@ -484,7 +484,7 @@ SVTK_MainWindow tr( "MNU_ROTATE_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_ROTATE_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation())); - myActionsMap[ RotationId ] = anAction; + mgr->registerAction( anAction, RotationId ); // Projections anAction = new QtxAction(tr("MNU_FRONT_VIEW"), @@ -492,42 +492,42 @@ SVTK_MainWindow tr( "MNU_FRONT_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_FRONT_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView())); - myActionsMap[ FrontId ] = anAction; + mgr->registerAction( anAction, FrontId ); anAction = new QtxAction(tr("MNU_BACK_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ), tr( "MNU_BACK_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_BACK_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onBackView())); - myActionsMap[ BackId ] = anAction; + mgr->registerAction( anAction, BackId ); anAction = new QtxAction(tr("MNU_TOP_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ), tr( "MNU_TOP_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_TOP_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onTopView())); - myActionsMap[ TopId ] = anAction; + mgr->registerAction( anAction, TopId ); anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ), tr( "MNU_BOTTOM_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_BOTTOM_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView())); - myActionsMap[ BottomId ] = anAction; + mgr->registerAction( anAction, BottomId ); anAction = new QtxAction(tr("MNU_LEFT_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ), tr( "MNU_LEFT_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_LEFT_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView())); - myActionsMap[ LeftId ] = anAction; + mgr->registerAction( anAction, LeftId ); anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ), tr( "MNU_RIGHT_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_RIGHT_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onRightView())); - myActionsMap[ RightId ] = anAction; + mgr->registerAction( anAction, RightId ); // Reset anAction = new QtxAction(tr("MNU_RESET_VIEW"), @@ -535,7 +535,7 @@ SVTK_MainWindow tr( "MNU_RESET_VIEW" ), 0, this); anAction->setStatusTip(tr("DSC_RESET_VIEW")); connect(anAction, SIGNAL(activated()), this, SLOT(onResetView())); - myActionsMap[ ResetId ] = anAction; + mgr->registerAction( anAction, ResetId ); // onViewTrihedron: Shows - Hides Trihedron anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), @@ -543,7 +543,7 @@ SVTK_MainWindow tr( "MNU_SHOW_TRIHEDRON" ), 0, this); anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON")); connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron())); - myActionsMap[ ViewTrihedronId ] = anAction; + mgr->registerAction( anAction, ViewTrihedronId ); // onNonIsometric: Manage non-isometric params anAction = new QtxAction(tr("MNU_SVTK_SCALING"), @@ -552,7 +552,7 @@ SVTK_MainWindow anAction->setStatusTip(tr("DSC_SVTK_SCALING")); anAction->setCheckable(true); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool))); - myActionsMap[ NonIsometric ] = anAction; + mgr->registerAction( anAction, NonIsometric ); // onGraduatedAxes: Manage graduated axes params anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), @@ -561,7 +561,7 @@ SVTK_MainWindow anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES")); anAction->setCheckable(true); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool))); - myActionsMap[ GraduatedAxes ] = anAction; + mgr->registerAction( anAction, GraduatedAxes ); // onGraduatedAxes: Manage graduated axes params anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"), @@ -570,7 +570,7 @@ SVTK_MainWindow anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE")); anAction->setCheckable(true); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool))); - myActionsMap[ UpdateRate ] = anAction; + mgr->registerAction( anAction, UpdateRate ); } #if defined(WIN32) && !defined(_DEBUG) @@ -584,38 +584,40 @@ void SVTK_MainWindow ::createToolBar() { - myToolBar->addAction( myActionsMap[DumpId] ); - myToolBar->addAction( myActionsMap[ViewTrihedronId] ); + QtxActionToolMgr* mgr = myViewWindow->toolMgr(); + + mgr->append( DumpId, myToolBar ); + mgr->append( ViewTrihedronId, myToolBar ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); - aScaleAction->insertAction( myActionsMap[FitAllId] ); - aScaleAction->insertAction( myActionsMap[FitRectId] ); - aScaleAction->insertAction( myActionsMap[ZoomId] ); - myToolBar->addAction( aScaleAction ); + aScaleAction->insertAction( action( FitAllId ) ); + aScaleAction->insertAction( action( FitRectId ) ); + aScaleAction->insertAction( action( ZoomId ) ); + mgr->append( aScaleAction, myToolBar ); QtxMultiAction* aPanningAction = new QtxMultiAction( this ); - aPanningAction->insertAction( myActionsMap[PanId] ); - aPanningAction->insertAction( myActionsMap[GlobalPanId] ); - myToolBar->addAction( aPanningAction ); + aPanningAction->insertAction( action( PanId ) ); + aPanningAction->insertAction( action( GlobalPanId ) ); + mgr->append( aPanningAction, myToolBar ); - myToolBar->addAction( myActionsMap[ChangeRotationPointId] ); + mgr->append( ChangeRotationPointId, myToolBar ); - myToolBar->addAction( myActionsMap[RotationId] ); + mgr->append( RotationId, myToolBar ); QtxMultiAction* aViewsAction = new QtxMultiAction( this ); - aViewsAction->insertAction( myActionsMap[FrontId] ); - aViewsAction->insertAction( myActionsMap[BackId] ); - aViewsAction->insertAction( myActionsMap[TopId] ); - aViewsAction->insertAction( myActionsMap[BottomId] ); - aViewsAction->insertAction( myActionsMap[LeftId] ); - aViewsAction->insertAction( myActionsMap[RightId] ); - myToolBar->addAction( aViewsAction ); + aViewsAction->insertAction( action( FrontId ) ); + aViewsAction->insertAction( action( BackId ) ); + aViewsAction->insertAction( action( TopId ) ); + aViewsAction->insertAction( action( BottomId ) ); + aViewsAction->insertAction( action( LeftId ) ); + aViewsAction->insertAction( action( RightId ) ); + mgr->append( aViewsAction, myToolBar ); - myToolBar->addAction( myActionsMap[ResetId] ); + mgr->append( ResetId, myToolBar ); - myToolBar->addAction( myActionsMap[UpdateRate] ); - myToolBar->addAction( myActionsMap[NonIsometric] ); - myToolBar->addAction( myActionsMap[GraduatedAxes] ); + mgr->append( UpdateRate, myToolBar ); + mgr->append( NonIsometric, myToolBar ); + mgr->append( GraduatedAxes, myToolBar ); } /*! @@ -901,3 +903,11 @@ SVTK_MainWindow QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() ); return px.toImage(); } + +/*! + \return action by it's id +*/ +QtxAction* SVTK_MainWindow::action( int id ) const +{ + return dynamic_cast( myViewWindow->toolMgr()->action( id ) ); +} diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index 77157c02c..dbb26f5db 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -26,12 +26,9 @@ #include "SVTK.h" #include "SVTK_Selection.h" -#include - #include -#include -class QtxAction; +#include class vtkObject; class vtkRenderer; @@ -39,6 +36,8 @@ class vtkRenderWindow; class vtkInteractorStyle; class vtkRenderWindowInteractor; +class QtxAction; + class SUIT_ResourceMgr; class SUIT_ViewWindow; @@ -48,13 +47,11 @@ class SVTK_UpdateRateDlg; class SVTK_CubeAxesActor2D; class SVTK_CubeAxesDlg; class SVTK_SetRotationPointDlg; - -class VTKViewer_Trihedron; -class VTKViewer_Actor; - class SVTK_Renderer; class SVTK_Selector; +class VTKViewer_Trihedron; +class VTKViewer_Actor; //! The class is a container for #SVTK_RenderWindowInteractor. /*! @@ -247,11 +244,12 @@ public: void SetEventDispatcher(vtkObject* theDispatcher); + QtxAction* action( int ) const; + enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate}; - typedef QMap TActionsMap; SUIT_ViewWindow* myViewWindow; @@ -261,8 +259,7 @@ public: SVTK_SetRotationPointDlg* mySetRotationPointDlg; vtkSmartPointer myEventDispatcher; - TActionsMap myActionsMap; - QToolBar* myToolBar; + int myToolBar; SVTK_RenderWindowInteractor* myInteractor; };