From b605cda410817d4024a6fe8142cde8c5d386d523 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 21 Aug 2008 14:56:06 +0000 Subject: [PATCH] MainWindow removed from using --- src/SVTK/Makefile.am | 4 +- src/SVTK/SALOME_Actor.cxx | 2 +- src/SVTK/SVTK.cxx | 3 +- src/SVTK/SVTK.pro | 2 - src/SVTK/SVTK_CubeAxesDlg.cxx | 4 +- src/SVTK/SVTK_CubeAxesDlg.h | 6 +- src/SVTK/SVTK_View.cxx | 14 +- src/SVTK/SVTK_View.h | 28 +-- src/SVTK/SVTK_ViewParameterDlg.cxx | 4 +- src/SVTK/SVTK_ViewParameterDlg.h | 6 +- src/SVTK/SVTK_ViewWindow.cxx | 262 ++++++++++++++++++++++++++++- src/SVTK/SVTK_ViewWindow.h | 52 +++++- src/SVTK/resources/SVTK_msg_en.ts | 2 +- 13 files changed, 337 insertions(+), 52 deletions(-) diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index aec5af001..2784b5c5c 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -40,7 +40,6 @@ salomeinclude_HEADERS= \ SVTK_ViewManager.h \ SVTK_ViewModel.h \ SVTK_ViewWindow.h \ -# SVTK_MainWindow.h \ SVTK_Renderer.h \ SVTK_InteractorStyle.h \ SVTK_KeyFreeInteractorStyle.h \ @@ -79,7 +78,6 @@ dist_libSVTK_la_SOURCES= \ SVTK_ViewModel.cxx \ SVTK_Renderer.cxx \ SVTK_ViewWindow.cxx \ -# SVTK_MainWindow.cxx \ SVTK_InteractorStyle.cxx \ SVTK_KeyFreeInteractorStyle.cxx \ SVTK_RenderWindowInteractor.cxx \ @@ -95,6 +93,7 @@ dist_libSVTK_la_SOURCES= \ SVTK_ImageWriter.cxx \ SVTK_ImageWriterMgr.cxx + EXTRA_DIST+= SVTK_SelectorDef.h SVTK_Trihedron.h MOC_FILES= \ @@ -108,7 +107,6 @@ MOC_FILES= \ SVTK_ViewModelBase_moc.cxx \ SVTK_ViewManager_moc.cxx \ SVTK_ViewWindow_moc.cxx \ -# SVTK_MainWindow_moc.cxx \ SVTK_ViewModel_moc.cxx \ SVTK_View_moc.cxx \ SVTK_SetRotationPointDlg_moc.cxx \ diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 7f17c2708..12a14ea84 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -419,7 +419,7 @@ SALOME_Actor { if ( !GetPickable() ) return false; - + vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // myPreHighlightActor->SetVisibility( false ); diff --git a/src/SVTK/SVTK.cxx b/src/SVTK/SVTK.cxx index 674714f77..0e3b1af7f 100644 --- a/src/SVTK/SVTK.cxx +++ b/src/SVTK/SVTK.cxx @@ -35,8 +35,7 @@ #include "SVTK_CubeAxesActor2D.h" #include "SVTK_Functor.h" #include "SVTK_View.h" -#include "SVTK_MainWindow.h" -#include "SVTK_MainWindow.h" +//#include "SVTK_MainWindow.h" #include "SVTK_NonIsometricDlg.h" #include "SVTK_CubeAxesDlg.h" #include "SVTK_FontWidget.h" diff --git a/src/SVTK/SVTK.pro b/src/SVTK/SVTK.pro index 5d944e3cc..2713f0d59 100644 --- a/src/SVTK/SVTK.pro +++ b/src/SVTK/SVTK.pro @@ -35,7 +35,6 @@ HEADERS += SVTK_DialogBase.h HEADERS += SVTK_FontWidget.h HEADERS += SVTK_CubeAxesActor2D.h HEADERS += SVTK_Functor.h -HEADERS += SVTK_MainWindow.h HEADERS += SVTK_View.h HEADERS += SVTK_ViewManager.h HEADERS += SVTK_ViewModel.h @@ -68,7 +67,6 @@ SOURCES += SVTK_CubeAxesDlg.cxx SOURCES += SVTK_DialogBase.cxx SOURCES += SVTK_FontWidget.cxx SOURCES += SVTK_Trihedron.cxx -SOURCES += SVTK_MainWindow.cxx SOURCES += SVTK_View.cxx SOURCES += SVTK_ViewManager.cxx SOURCES += SVTK_ViewModel.cxx diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx index 1258e98ed..ffbff8e5d 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.cxx +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -27,7 +27,7 @@ #include "SVTK_CubeAxesDlg.h" -#include "SVTK_MainWindow.h" +#include "SVTK_ViewWindow.h" #include "SVTK_FontWidget.h" #include "SVTK_CubeAxesActor2D.h" @@ -390,7 +390,7 @@ bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor) Constructor */ SVTK_CubeAxesDlg::SVTK_CubeAxesDlg(QtxAction* theAction, - SVTK_MainWindow* theParent, + SVTK_ViewWindow* theParent, const char* theName): SVTK_DialogBase(theAction, theParent, diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h index 1428dad9d..fc214b727 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.h +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -46,7 +46,7 @@ class SVTK_CubeAxesActor2D; class SVTK_FontWidget; class SVTK_AxisWidget; -class SVTK_MainWindow; +class SVTK_ViewWindow; /*! * Class : SVTK_CubeAxesDlg @@ -58,7 +58,7 @@ class SVTK_CubeAxesDlg : public SVTK_DialogBase public: SVTK_CubeAxesDlg(QtxAction* theAction, - SVTK_MainWindow* theParent, + SVTK_ViewWindow* theParent, const char* theName); virtual ~SVTK_CubeAxesDlg(); @@ -75,7 +75,7 @@ private: bool isValid() const; private: - SVTK_MainWindow *myMainWindow; + SVTK_ViewWindow *myMainWindow; SVTK_CubeAxesActor2D* myActor; QTabWidget* myTabWg; diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index 57e6e49eb..d9186b84c 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -30,7 +30,7 @@ #include "SVTK_View.h" #include "SVTK_Renderer.h" -#include "SVTK_MainWindow.h" +#include "SVTK_ViewWindow.h" #include "SVTK_RenderWindowInteractor.h" #include "SALOME_ListIteratorOfListIO.hxx" @@ -44,7 +44,7 @@ Constructor */ SVTK_SignalHandler -::SVTK_SignalHandler(SVTK_MainWindow* theMainWindow): +::SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow): QObject(theMainWindow), myMainWindow(theMainWindow) { @@ -79,7 +79,7 @@ SVTK_SignalHandler /*! \return corresponding svtk main window */ -SVTK_MainWindow* +SVTK_ViewWindow* SVTK_SignalHandler ::GetMainWindow() { @@ -88,7 +88,7 @@ SVTK_SignalHandler /*! - Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility) + Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility) */ void SVTK_SignalHandler @@ -98,7 +98,7 @@ SVTK_SignalHandler } /*! - Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility) + Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility) */ SVTK_Renderer* SVTK_SignalHandler @@ -108,7 +108,7 @@ SVTK_SignalHandler } /*! - Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility) + Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility) */ vtkRenderer* SVTK_SignalHandler @@ -164,7 +164,7 @@ SVTK_SignalHandler Constructor */ SVTK_View -::SVTK_View(SVTK_MainWindow* theMainWindow) : +::SVTK_View(SVTK_ViewWindow* theMainWindow) : SVTK_SignalHandler(theMainWindow) { } diff --git a/src/SVTK/SVTK_View.h b/src/SVTK/SVTK_View.h index ff463ab5e..7e31e56b2 100644 --- a/src/SVTK/SVTK_View.h +++ b/src/SVTK/SVTK_View.h @@ -31,7 +31,7 @@ class vtkActorCollection; class vtkRenderer; -class SVTK_MainWindow; +class SVTK_ViewWindow; class SVTK_Renderer; class SALOME_Actor; @@ -43,12 +43,12 @@ class QContextMenuEvent; class QColor; -//! Main purpose of the class is to provide a way to customize #SVTK_MainWindow. +//! Main purpose of the class is to provide a way to customize #SVTK_ViewWindow. /*! - This class is initialized by #SVTK_MainWindow and just pass Qt signals from - corresponding #SVTK_RenderWindowInteractor of the #SVTK_MainWindow. - Its main purpose is to provide a simple and flexible way to customize the #SVTK_MainWindow. - So, in your own viewer it is possible to derive new #SVTK_MainWindow and + This class is initialized by #SVTK_ViewWindow and just pass Qt signals from + corresponding #SVTK_RenderWindowInteractor of the #SVTK_ViewWindow. + Its main purpose is to provide a simple and flexible way to customize the #SVTK_ViewWindow. + So, in your own viewer it is possible to derive new #SVTK_ViewWindow and use existing functionality without any modifications. */ class SVTK_EXPORT SVTK_SignalHandler : public QObject @@ -56,26 +56,26 @@ class SVTK_EXPORT SVTK_SignalHandler : public QObject Q_OBJECT; public: - SVTK_SignalHandler(SVTK_MainWindow* theMainWindow); + SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow); virtual ~SVTK_SignalHandler(); - //! Get reference to its #SVTK_MainWindow - SVTK_MainWindow* + //! Get reference to its #SVTK_ViewWindow + SVTK_ViewWindow* GetMainWindow(); //---------------------------------------------------------------------------- - //! Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility) + //! Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility) void Repaint(bool theUpdateTrihedron = true); //---------------------------------------------------------------------------- - //! Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility) + //! Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility) SVTK_Renderer* GetRenderer(); - //! Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility) + //! Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility) vtkRenderer* getRenderer(); @@ -98,7 +98,7 @@ public: void selectionChanged(); protected: - SVTK_MainWindow* myMainWindow; + SVTK_ViewWindow* myMainWindow; }; @@ -113,7 +113,7 @@ class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler Q_OBJECT; public: - SVTK_View(SVTK_MainWindow* theMainWindow); + SVTK_View(SVTK_ViewWindow* theMainWindow); virtual ~SVTK_View(); diff --git a/src/SVTK/SVTK_ViewParameterDlg.cxx b/src/SVTK/SVTK_ViewParameterDlg.cxx index cc456fac1..7a7a9d25c 100755 --- a/src/SVTK/SVTK_ViewParameterDlg.cxx +++ b/src/SVTK/SVTK_ViewParameterDlg.cxx @@ -27,7 +27,7 @@ // $Header: #include "SVTK_ViewParameterDlg.h" -#include "SVTK_MainWindow.h" +#include "SVTK_ViewWindow.h" #include "SVTK_RenderWindowInteractor.h" #include "SVTK_Event.h" #include "SVTK_InteractorStyle.h" @@ -57,7 +57,7 @@ using namespace std; Constructor */ SVTK_ViewParameterDlg::SVTK_ViewParameterDlg(QtxAction* theAction, - SVTK_MainWindow* theParent, + SVTK_ViewWindow* theParent, const char* theName): SVTK_DialogBase(theAction, theParent, theName), myMainWindow(theParent), diff --git a/src/SVTK/SVTK_ViewParameterDlg.h b/src/SVTK/SVTK_ViewParameterDlg.h index c5722ec02..4ad77f3f4 100755 --- a/src/SVTK/SVTK_ViewParameterDlg.h +++ b/src/SVTK/SVTK_ViewParameterDlg.h @@ -36,7 +36,7 @@ #include #include -class SVTK_MainWindow; +class SVTK_ViewWindow; class SVTK_RenderWindowInteractor; class QtxAction; @@ -56,7 +56,7 @@ class SVTK_EXPORT SVTK_ViewParameterDlg : public SVTK_DialogBase public: SVTK_ViewParameterDlg(QtxAction* theAction, - SVTK_MainWindow* theParent, + SVTK_ViewWindow* theParent, const char* theName); ~SVTK_ViewParameterDlg(); @@ -64,7 +64,7 @@ public: void addObserver(); protected: - SVTK_MainWindow *myMainWindow; + SVTK_ViewWindow *myMainWindow; SVTK_RenderWindowInteractor* myRWInteractor; bool myIsObserverAdded; bool myBusy; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 0b461cb91..52fb85675 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -21,6 +21,7 @@ #include "SVTK_UpdateRateDlg.h" #include "SVTK_CubeAxesDlg.h" #include "SVTK_SetRotationPointDlg.h" +#include "SVTK_ViewParameterDlg.h" #include "SALOME_Actor.h" @@ -36,6 +37,7 @@ #include #include #include +#include #include "QtxAction.h" @@ -63,6 +65,11 @@ #include "SVTK_RenderWindowInteractor.h" #include "SVTK_GenericRenderWindowInteractor.h" #include "SVTK_CubeAxesActor2D.h" +#include "SVTK_ComboAction.h" +#include "SVTK_KeyFreeInteractorStyle.h" +#include "SVTK_Selector.h" +#include "SVTK_Recorder.h" +#include "SVTK_RecorderDlg.h" #include "SALOME_ListIteratorOfListIO.hxx" @@ -101,8 +108,12 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): SUIT_ViewWindow(theDesktop), //myMainWindow(0), myView(NULL), - myDumpImage(QImage()) -{} + myDumpImage(QImage()), + myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()) +{ + // specific of vtkSmartPointer + myKeyFreeInteractorStyle->Delete(); +} /*! To initialize #SVTK_ViewWindow instance @@ -133,8 +144,11 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) //myMainWindow->Initialize(anIteractor); myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this ); + myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), -1, this ); + createActions( SUIT_Session::session()->activeApplication()->resourceMgr() ); createToolBar(); + SetEventDispatcher(myInteractor->GetDevice()); myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground myInteractor->setFocusPolicy(Qt::StrongFocus); @@ -146,11 +160,21 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" ); mySetRotationPointDlg = new SVTK_SetRotationPointDlg ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" ); + myViewParameterDlg = new SVTK_ViewParameterDlg + ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" ); SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); myInteractor->PushInteractorStyle(aStyle); aStyle->Delete(); + myRecorder = SVTK_Recorder::New(); + + myRecorder->SetNbFPS( 17.3 ); + myRecorder->SetQuality( 100 ); + myRecorder->SetProgressiveMode( true ); + myRecorder->SetUseSkippedFrames( true ); + myRecorder->SetRenderWindow( myInteractor->getRenderWindow() ); + //setCentralWidget(myMainWindow); setCentralWidget(myInteractor); @@ -159,7 +183,7 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) Initialize(myView,theModel); myInteractor->getRenderWindow()->Render(); - //myMainWindow->onResetView(); + onResetView(); } } @@ -485,6 +509,31 @@ QColor SVTK_ViewWindow::backgroundColor() const int(aBackgroundColor[2]*255)); } + +/*! + Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle +*/ +vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const +{ + return GetInteractor()->GetInteractorStyle(); +} + +/*! + Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle +*/ +void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle) +{ + GetInteractor()->PushInteractorStyle(theStyle); +} + +/*! + Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle +*/ +void SVTK_ViewWindow::PopInteractorStyle() +{ + GetInteractor()->PopInteractorStyle(); +} + /*! Updates current viewer */ @@ -591,9 +640,38 @@ vtkFloatingPointType SVTK_ViewWindow::GetTrihedronSize() const */ void SVTK_ViewWindow::SetProjectionMode(const int theMode) { - //myMainWindow->activateProjectionMode( theMode ); + activateProjectionMode( theMode ); +} + + +/*! + Set the gravity center as a focal point +*/ +void SVTK_ViewWindow::activateSetFocalPointGravity() +{ + myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0); +} + +/*! + Set the selected point as a focal point +*/ +void SVTK_ViewWindow::activateSetFocalPointSelected() +{ + myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0); +} + +/*! + Set the point selected by user as a focal point +*/ +void SVTK_ViewWindow::activateStartFocalPointSelection() +{ + myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0); +} + +void SVTK_ViewWindow::activateProjectionMode(int theMode) +{ SVTK_ComboAction* a = ::qobject_cast( toolMgr()->action( ProjectionModeId ) ); - if ( a ) a->setCurrentIndex(mode); + if ( a ) a->setCurrentIndex(theMode); } /*! @@ -602,7 +680,14 @@ void SVTK_ViewWindow::SetProjectionMode(const int theMode) */ void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) { - //myMainWindow->onSwitchInteractionStyle( theStyle==1 ); + onSwitchInteractionStyle( theStyle==1 ); +} + +/*! + Switches "keyboard free" interaction style on/off +*/ +void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) +{ if (theOn) { // check if style is already set if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() ) @@ -624,7 +709,7 @@ void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) } // update action state if method is called outside - QtxAction* a = action( SwitchInteractionStyleId ); + QtxAction* a = getAction( SwitchInteractionStyleId ); if ( a->isChecked() != theOn ) a->setChecked( theOn ); } @@ -754,7 +839,7 @@ void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, bool theUpdate ) { //myMainWindow->AddActor( theActor, theUpdate ); - getRenderer()->AddActor(theActor); + GetRenderer()->AddActor(theActor); if(theUpdate) Repaint(); emit actorAdded(theActor); @@ -767,7 +852,7 @@ void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate ) { //myMainWindow->RemoveActor( theActor, theUpdate ); - getRenderer()->RemoveActor(theActor); + GetRenderer()->RemoveActor(theActor); if(theUpdate) Repaint(); emit actorRemoved(theActor); @@ -1179,6 +1264,16 @@ void SVTK_ViewWindow::activateStartPointSelection() myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0); } +/*! + Set the view projection mode: orthogonal or perspective +*/ +void SVTK_ViewWindow::onProjectionMode(int mode) +{ + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + aCamera->SetParallelProjection(mode==0); + GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST); +} + void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher) { myEventDispatcher = theDispatcher; @@ -1342,6 +1437,67 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) anAction->setCheckable(true); connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool))); mgr->registerAction( anAction, UpdateRate ); + + // Set projection mode + SVTK_ComboAction* aModeAction = new SVTK_ComboAction(tr("MNU_SVTK_PROJECTION_MODE"), this); + aModeAction->setStatusTip(tr("DSC_SVTK_PROJECTION_MODE")); + aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ) ); + aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ) ); + connect(aModeAction, SIGNAL(triggered(int)), this, SLOT(onProjectionMode(int))); + mgr->registerAction( aModeAction, ProjectionModeId ); + + // View Parameters + anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ), + tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool))); + mgr->registerAction( anAction, ViewParametersId ); + + // Switch between interaction styles + anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ), + tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this); + anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); + mgr->registerAction( anAction, SwitchInteractionStyleId ); + + // Start recording + myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ), + tr( "MNU_SVTK_RECORDING_START" ), 0, this); + myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START")); + connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) ); + mgr->registerAction( myStartAction, StartRecordingId ); + + // Play recording + myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ), + tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this); + myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY")); + myPlayAction->setEnabled( false ); + connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) ); + mgr->registerAction( myPlayAction, PlayRecordingId ); + + // Pause recording + myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ), + tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this); + myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE")); + myPauseAction->setEnabled( false ); + connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) ); + mgr->registerAction( myPauseAction, PauseRecordingId ); + + // Stop recording + myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ), + tr( "MNU_SVTK_RECORDING_STOP" ), 0, this); + myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP")); + myStopAction->setEnabled( false ); + connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) ); + mgr->registerAction( myStopAction, StopRecordingId ); } /*! @@ -1352,6 +1508,7 @@ void SVTK_ViewWindow::createToolBar() QtxActionToolMgr* mgr = toolMgr(); mgr->append( DumpId, myToolBar ); + mgr->append( SwitchInteractionStyleId, myToolBar ); mgr->append( ViewTrihedronId, myToolBar ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); @@ -1383,6 +1540,14 @@ void SVTK_ViewWindow::createToolBar() mgr->append( UpdateRate, myToolBar ); mgr->append( NonIsometric, myToolBar ); mgr->append( GraduatedAxes, myToolBar ); + + mgr->append( ViewParametersId, myToolBar ); + mgr->append( ProjectionModeId, myToolBar ); + + mgr->append( StartRecordingId, myRecordingToolBar ); + mgr->append( PlayRecordingId, myRecordingToolBar ); + mgr->append( PauseRecordingId, myRecordingToolBar ); + mgr->append( StopRecordingId, myRecordingToolBar ); } void SVTK_ViewWindow::onUpdateRate(bool theIsActivate) @@ -1452,3 +1617,82 @@ void SVTK_ViewWindow::activateGlobalPanning() { myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0); } + +void SVTK_ViewWindow::onStartRecording() +{ + myRecorder->CheckExistAVIMaker(); + if (myRecorder->ErrorStatus()) { + SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") ); + } + else { + SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder ); + + if( !aRecorderDlg->exec() ) + return; + + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( true ); + myStopAction->setEnabled( true ); + + // to prevent resizing the window while recording + myPreRecordingMinSize = minimumSize(); + myPreRecordingMaxSize = maximumSize(); + setFixedSize( size() ); + + myRecorder->Record(); + } +} + +void SVTK_ViewWindow::onPlayRecording() +{ + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( true ); + myStopAction->setEnabled( true ); + + myRecorder->Pause(); +} + +void SVTK_ViewWindow::onPauseRecording() +{ + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( true ); + myPauseAction->setEnabled( false ); + myStopAction->setEnabled( true ); + + myRecorder->Pause(); +} + +void SVTK_ViewWindow::onStopRecording() +{ + myStartAction->setEnabled( true ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( false ); + myStopAction->setEnabled( false ); + + myRecorder->Stop(); + + setMinimumSize( myPreRecordingMinSize ); + setMaximumSize( myPreRecordingMaxSize ); +} + +/*! + To invoke a VTK event on SVTK_RenderWindowInteractor instance +*/ +void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData) +{ + GetInteractor()->InvokeEvent(theEvent,theCallData); +} + +/*! + Modify view parameters +*/ +void SVTK_ViewWindow::onViewParameters(bool theIsActivate) +{ + if(theIsActivate){ + myViewParameterDlg->addObserver(); + myViewParameterDlg->show(); + }else + myViewParameterDlg->hide(); +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 2faaf83a8..7b1916c35 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -48,12 +48,16 @@ class SVTK_CubeAxesActor2D; class vtkRenderer; class vtkRenderWindow; class vtkRenderWindowInteractor; +class vtkInteractorStyle; class SVTK_RenderWindowInteractor; class SVTK_Renderer; class SVTK_NonIsometricDlg; class SVTK_UpdateRateDlg; class SVTK_CubeAxesDlg; class SVTK_SetRotationPointDlg; +class SVTK_KeyFreeInteractorStyle; +class SVTK_ViewParameterDlg; +class SVTK_Recorder; class vtkObject; class QtxAction; @@ -90,13 +94,21 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow vtkRenderWindow* getRenderWindow(); //! Redirect the request to #SVTK_MainWindow::getInteractor - vtkRenderWindowInteractor* getInteractor(); + vtkRenderWindowInteractor* getInteractor() const; //! Redirect the request to #SVTK_MainWindow::getInteractor SVTK_RenderWindowInteractor* GetInteractor() const; + vtkInteractorStyle* GetInteractorStyle() const; + + //! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle + void PushInteractorStyle(vtkInteractorStyle* theStyle); + + //! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle + void PopInteractorStyle(); + //! Redirect the request to #SVTK_MainWindow::getRenderer - vtkRenderer* getRenderer(); + vtkRenderer* getRenderer() const; SVTK_Renderer* GetRenderer() const; @@ -230,6 +242,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow virtual bool eventFilter( QObject*, QEvent* ); virtual void RefreshDumpImage(); + + //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance + void InvokeEvent(unsigned long theEvent, void* theCallData); public slots: virtual void onSelectionChanged(); @@ -250,6 +265,23 @@ public slots: void activatePanning(); void activateGlobalPanning(); + void onProjectionMode(int mode); + + void activateProjectionMode(int); + + void activateSetFocalPointGravity(); + void activateSetFocalPointSelected(); + void activateStartFocalPointSelection(); + + void onViewParameters(bool theIsActivate); + + void onSwitchInteractionStyle(bool theOn); + + void onStartRecording(); + void onPlayRecording(); + void onPauseRecording(); + void onStopRecording(); + signals: void selectionChanged(); void actorAdded(VTKViewer_Actor*); @@ -319,7 +351,9 @@ protected: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, - ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate}; + ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, + ProjectionModeId, ViewParametersId, SwitchInteractionStyleId, + StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId }; SVTK_View* myView; @@ -327,6 +361,7 @@ protected: SVTK_ViewModelBase* myModel; SVTK_RenderWindowInteractor* myInteractor; + vtkSmartPointer myKeyFreeInteractorStyle; QString myVisualParams; // used for delayed setting of view parameters @@ -336,8 +371,19 @@ protected: SVTK_UpdateRateDlg* myUpdateRateDlg; SVTK_CubeAxesDlg* myCubeAxesDlg; SVTK_SetRotationPointDlg* mySetRotationPointDlg; + SVTK_ViewParameterDlg* myViewParameterDlg; + + QSize myPreRecordingMinSize; + QSize myPreRecordingMaxSize; + + SVTK_Recorder* myRecorder; + QtxAction* myStartAction; + QtxAction* myPlayAction; + QtxAction* myPauseAction; + QtxAction* myStopAction; int myToolBar; + int myRecordingToolBar; private: QImage myDumpImage; diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 7235f9196..0570fae78 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -268,7 +268,7 @@ - SVTK_MainWindow + SVTK_ViewWindow DSC_SVTK_UPDATE_RATE Update rate -- 2.39.2