From e2b22889cd71a86d49701f7ee8114fffc6748a80 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 22 Jun 2014 22:17:11 +0100 Subject: [PATCH] Add support to sincronize the zoom buttons to all windows playing syncronized --- source/app/SubWindowHandle.h | 6 +++++ source/app/ViewArea.cpp | 6 ----- source/app/ViewArea.h | 6 ++++- source/app/plaYUVerApp.cpp | 51 +++++++++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 8715a13..e90e9db 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -102,6 +102,12 @@ public: { return m_cViewArea; } + + Double getZoomFactor() + { + return m_cViewArea->getZoomFactor(); + } + Void setModule( PlaYUVerModuleIf* pcCurrentModule ) { m_pcCurrentModule = pcCurrentModule; diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 3eba98b..6638ac9 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -102,12 +102,6 @@ void ViewArea::clearMask() m_mask.clear(); } -Double ViewArea::getZoomFactor() -{ - return m_zoomFactor; -} - - // QSize ViewArea::sizeHint() const // { // int w = m_pixmap.width()*m_zoomFactor; diff --git a/source/app/ViewArea.h b/source/app/ViewArea.h index 3659066..de6f103 100644 --- a/source/app/ViewArea.h +++ b/source/app/ViewArea.h @@ -99,11 +99,15 @@ public: return m_maskColor; } + Double getZoomFactor() + { + return m_zoomFactor; + } + void setInputStream( PlaYUVerStream *stream ); PlaYUVerStream* getInputStream(); Void zoomChangeEvent(Double factor, QPoint center); - Double getZoomFactor(); void setTool( enum eTool tool ); // QSize sizeHint() const; diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 5d05f9d..323356d 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -616,6 +616,7 @@ Void plaYUVerApp::videoSelectionButtonEvent() m_acPlayingSubWindows.clear(); SubWindowHandle *subWindow; QString windowName; + Double scaleFactor = qobject_cast( mdiArea->subWindowList().at( 0 ) )->getZoomFactor(); for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); @@ -624,6 +625,7 @@ Void plaYUVerApp::videoSelectionButtonEvent() { m_acPlayingSubWindows.append( subWindow ); subWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); + subWindow->scaleView( scaleFactor ); subWindow->play(); m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )subWindow->getInputStream()->getFrameNum() - 1 ) ); } @@ -638,14 +640,38 @@ Void plaYUVerApp::videoSelectionButtonEvent() Void plaYUVerApp::normalSize() { - if( activeSubWindow() ) - activeSubWindow()->normalSize(); + if( m_pcCurrentSubWindow ) + { + if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->normalSize(); + } + } + else + { + m_pcCurrentSubWindow->normalSize(); + } + } } Void plaYUVerApp::zoomToFit() { - if( activeSubWindow() ) - activeSubWindow()->zoomToFit(); + if( m_pcCurrentSubWindow ) + { + if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->zoomToFit(); + } + } + else + { + m_pcCurrentSubWindow->zoomToFit(); + } + } } Void plaYUVerApp::zoomToFitAll() @@ -660,12 +686,19 @@ Void plaYUVerApp::zoomToFitAll() Void plaYUVerApp::scaleFrame( Int ratio ) { - if( activeSubWindow() ) + if( m_pcCurrentSubWindow ) { - activeSubWindow()->scaleViewByRatio( ( Double )( ratio ) / 100.0 ); - -// m_arrayActions[ZOOM_IN_ACT]->setEnabled( activeSubWindow()->getScaleFactor() < 3.0 ); -// m_arrayActions[ZOOM_OUT_ACT]->setEnabled( activeSubWindow()->getScaleFactor() > 0.333 ); + if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->scaleViewByRatio( ( Double )( ratio ) / 100.0 ); + } + } + else + { + m_pcCurrentSubWindow->scaleViewByRatio( ( Double )( ratio ) / 100.0 ); + } } }