#include <QImage>
#include <QPainter>
-#include <QApplication>
+
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
#include <QtxAction.h>
#include <QtxMultiAction.h>
#include <QtxToolBar.h>
+#include <QtxActionToolMgr.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_Tools.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
#include "SVTK_NonIsometricDlg.h"
#include "SVTK_UpdateRateDlg.h"
#include "SVTK_CubeAxesDlg.h"
#include "SVTK_SetRotationPointDlg.h"
-
#include "SVTK_TextRegionDlg.h"
-
#include "SVTK_MainWindow.h"
#include "SVTK_Event.h"
#include "SVTK_Renderer.h"
#include "SVTK_InteractorStyle.h"
#include "SVTK_Selector.h"
-#include <vtkGenericRenderWindowInteractor.h>
-#include <vtkRenderer.h>
-#include <vtkRenderWindow.h>
-
/*!
Constructor
*/
{
setObjectName(theName);
setWindowFlags( windowFlags() & ~Qt::Window );
-
- myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this );
-
- createActions(theResourceMgr);
- createToolBar();
}
/*!
SVTK_MainWindow
::Initialize(SVTK_RenderWindowInteractor* theInteractor)
{
+ myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this );
+
+ createActions( SUIT_Session::session()->activeApplication()->resourceMgr() );
+ createToolBar();
+
myInteractor = theInteractor;
SetEventDispatcher(myInteractor->GetDevice());
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");
- myTextRegionDlg = new SVTK_TextRegionDlg(myActionsMap[TextRegion], this, "SVTK_TextRegionDlg");
-
+ 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" );
+ myTextRegionDlg = new SVTK_TextRegionDlg( action( TextRegion ), this, "SVTK_TextRegionDlg");
}
/*!
{
}
+/*!
+ \return assigned tool manager
+*/
+QtxActionToolMgr* SVTK_MainWindow::toolMgr() const
+{
+ return myViewWindow->toolMgr();
+}
+
/*!
\return used SVTK_RenderWindowInteractor
*/
SVTK_MainWindow
::getToolBar()
{
- return myToolBar;
+ return toolMgr()->toolBar( myToolBar );
}
void
SVTK_MainWindow
::createActions(SUIT_ResourceMgr* theResourceMgr)
{
- if(!myActionsMap.isEmpty())
- return;
-
QtxAction* anAction;
+ QtxActionToolMgr* mgr = toolMgr();
// Dump view
anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
tr( "MNU_DUMP_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), myViewWindow, SLOT(onDumpView()));
- myActionsMap[ DumpId ] = anAction;
+ mgr->registerAction( anAction, DumpId );
// FitAll
anAction = new QtxAction(tr("MNU_FITALL"),
tr( "MNU_FITALL" ), 0, this);
anAction->setStatusTip(tr("DSC_FITALL"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onFitAll()));
- myActionsMap[ FitAllId ] = anAction;
+ mgr->registerAction( anAction, FitAllId );
// FitRect
anAction = new QtxAction(tr("MNU_FITRECT"),
tr( "MNU_FITRECT" ), 0, this);
anAction->setStatusTip(tr("DSC_FITRECT"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(activateWindowFit()));
- myActionsMap[ FitRectId ] = anAction;
+ mgr->registerAction( anAction, FitRectId );
// Zoom
anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
tr( "MNU_ZOOM_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(activateZoom()));
- myActionsMap[ ZoomId ] = anAction;
+ mgr->registerAction( anAction, ZoomId );
// Panning
anAction = new QtxAction(tr("MNU_PAN_VIEW"),
tr( "MNU_PAN_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_PAN_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(activatePanning()));
- myActionsMap[ PanId ] = anAction;
+ mgr->registerAction( anAction, PanId );
// Global Panning
anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(activateGlobalPanning()));
- myActionsMap[ GlobalPanId ] = anAction;
+ mgr->registerAction( anAction, GlobalPanId );
// Change rotation point
anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATION_POINT" ) ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
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"),
tr( "MNU_ROTATE_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(activateRotation()));
- myActionsMap[ RotationId ] = anAction;
+ mgr->registerAction( anAction, RotationId );
// Projections
anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
tr( "MNU_FRONT_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), 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(triggered(bool)), 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(triggered(bool)), 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(triggered(bool)), 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(triggered(bool)), 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(triggered(bool)), this, SLOT(onRightView()));
- myActionsMap[ RightId ] = anAction;
+ mgr->registerAction( anAction, RightId );
// Reset
anAction = new QtxAction(tr("MNU_RESET_VIEW"),
tr( "MNU_RESET_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_RESET_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onResetView()));
- myActionsMap[ ResetId ] = anAction;
+ mgr->registerAction( anAction, ResetId );
// onViewTrihedron: Shows - Hides Trihedron
anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onViewTrihedron()));
- myActionsMap[ ViewTrihedronId ] = anAction;
+ mgr->registerAction( anAction, ViewTrihedronId );
// onNonIsometric: Manage non-isometric params
anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
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"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_GRADUATED_AXES" ) ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
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"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_UPDATE_RATE" ) ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
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 );
// onTextRegion: Create Text Region
anAction = new QtxAction(tr("MNU_SVTK_TEXT_REGION"),
tr( "MNU_SVTK_TEXT_REGION" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_TEXT_REGION"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onTextRegion()));
- myActionsMap[ TextRegion ] = anAction;
+ mgr->registerAction( anAction, TextRegion );
// print view
anAction = new QtxAction(tr("MNU_PRINT_VIEW"),
tr( "MNU_PRINT_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_PRINT_VIEW"));
connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onPrintView()));
- myActionsMap[ PrintId ] = anAction;
+ mgr->registerAction( anAction, PrintId );
}
#if defined(WIN32) && !defined(_DEBUG)
SVTK_MainWindow
::createToolBar()
{
- myToolBar->addAction( myActionsMap[DumpId] );
- myToolBar->addAction( myActionsMap[ViewTrihedronId] );
+ QtxActionToolMgr* mgr = 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] );
- myToolBar->addAction( myActionsMap[TextRegion] );
- myToolBar->addAction( myActionsMap[PrintId] );
+ mgr->append( UpdateRate, myToolBar );
+ mgr->append( NonIsometric, myToolBar );
+ mgr->append( GraduatedAxes, myToolBar );
+ mgr->append( TextRegion, myToolBar );
+ mgr->append( PrintId, myToolBar );
}
/*!
GetRenderer()->OnAdjustCubeAxes();
}
+/*!
+ \brief Called when the "Print view" action is activated.
+*/
+void SVTK_MainWindow::onPrintView()
+{
+ QImage img = dumpView();
+ if ( myViewWindow )
+ myViewWindow->printImage( img, this );
+}
+
/*!
\return QImage, containing all scene rendering in window
*/
}
/*!
- \brief Called when the "Print view" action is activated.
+ \return action by it's id
*/
-void SVTK_MainWindow::onPrintView()
+QtxAction* SVTK_MainWindow::action( int id ) const
{
- QImage img = dumpView();
- if ( myViewWindow )
- myViewWindow->printImage( img, this );
+ return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-