diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index f6ecf82..05b22a5 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -58,12 +58,6 @@ Void SubWindowHandle::setMainWidget( QWidget *widget ) m_cScrollArea->setWidget( widget ); } -Void SubWindowHandle::processZoomChange( Double scale, QPoint center ) -{ - adjustScrollBarByScale( scale, center ); - emit zoomChangedOnSubWindow(); -} - QSize SubWindowHandle::getScrollSize() { return QSize( m_cScrollArea->viewport()->size().width() - 5, m_cScrollArea->viewport()->size().height() - 5 ); diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 3d4e6a9..fa42088 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -47,8 +47,6 @@ private: UInt m_uiCategory; QString m_cWindowName; - Void adjustScrollBarByScale( Double scale, QPoint center ); - public: enum SubWindowCategories { @@ -98,12 +96,12 @@ protected: QSize getScrollSize(); Q_SIGNALS: - void zoomChangedOnSubWindow(); - void scrollBarMoved( const QPoint ); + void zoomFactorChanged_SWindow( const double, const QPoint ); + void scrollBarMoved_SWindow( const QPoint ); void updateStatusBar( const QString& ); public Q_SLOTS: - void processZoomChange( double factor, QPoint center ); + void adjustScrollBarByScale( double scale, QPoint center ); void adjustScrollBarByOffset( QPoint Offset ); void updateLastScrollValue(); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 39e0106..1e378ad 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -83,9 +83,11 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : // Create a new interface to show images m_cViewArea = new ViewArea( this ); - connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( processZoomChange( double, QPoint ) ) ); - connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) ); - connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SIGNAL( scrollBarMoved( QPoint ) ) ); + connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) ); + connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) ); + + connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) ); + connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved_SWindow( QPoint ) ) ); connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); @@ -343,7 +345,10 @@ Void VideoSubWindow::normalSize() Double factor = 1.0; Double curFactor = getScaleFactor() ; if( factor != curFactor ) + { m_cViewArea->scaleZoomFactor( factor/curFactor, QPoint() ); + adjustScrollBarByScale( factor/curFactor, QPoint() ); + } } Void VideoSubWindow::zoomToFit() @@ -357,13 +362,20 @@ Void VideoSubWindow::zoomToFactor( Double factor , QPoint center ) Double curFactor; curFactor = getScaleFactor() ; if( factor != curFactor ) + { m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + adjustScrollBarByScale( factor/curFactor, center ); + } } Void VideoSubWindow::scaleView( Double scale , QPoint center ) { Q_ASSERT( m_cViewArea->image() ); - m_cViewArea->scaleZoomFactor( scale, center ); + if(scale!=1.0) + { + m_cViewArea->scaleZoomFactor( scale, center ); + adjustScrollBarByScale( scale, center ); + } } Void VideoSubWindow::scaleView( const QSize & size, QPoint center ) @@ -391,7 +403,10 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center ) Double curFactor = getScaleFactor() ; if( factor != curFactor ) + { m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + adjustScrollBarByScale( factor/curFactor, center ); + } } diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index 36436c0..b1262c0 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -109,17 +109,17 @@ Void ViewArea::setZoomFactor( Double f ) update(); } -Void ViewArea::scaleZoomFactor( Double scale, QPoint center ) +int ViewArea::scaleZoomFactor( Double scale, QPoint center ) { Double zoomFactor; Double maxZoom = 100.0; Double minZoom = 0.01; //( 1.0 / m_pixmap.width() ); if( ( m_zoomFactor == minZoom ) && ( scale < 1 ) ) - return; + return 1; if( ( m_zoomFactor == maxZoom ) && ( scale > 1 ) ) - return; + return 1; zoomFactor = m_zoomFactor * scale; @@ -131,7 +131,7 @@ Void ViewArea::scaleZoomFactor( Double scale, QPoint center ) setZoomFactor( zoomFactor ); - emit zoomFactorChanged( scale, center ); + return 0; } void ViewArea::setMode( ViewMode mode ) @@ -554,7 +554,8 @@ void ViewArea::wheelEvent( QWheelEvent *event ) else scale=0.8; - scaleZoomFactor( scale , event->pos() ); + if(scaleZoomFactor( scale , event->pos() ) == 0) + emit zoomFactorChanged( scale, event->pos() ); } } @@ -660,7 +661,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event ) if( tool() == NavigationTool ) { QPoint offset = m_lastWindowPos - event->pos(); - emit moveScroll( offset ); + emit scrollBarMoved( offset ); } updateRect = viewToWindow( m_selectedArea ); diff --git a/app/ViewArea.h b/app/ViewArea.h index e66f5ec..1e18c55 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -115,7 +115,8 @@ public: void setInputStream( PlaYUVerStream *stream ); PlaYUVerStream* getInputStream(); - Void scaleZoomFactor(Double scale, QPoint center); + // Scale function. Return 0 when scale is performed. Return 1 otherwise + int scaleZoomFactor(Double scale, QPoint center); void setTool( eTool tool ); @@ -124,8 +125,8 @@ public: Q_SIGNALS: void selectionChanged( const QRect &rect ); void positionChanged( const QPoint &pos ); - void moveScroll( QPoint offset ); - void zoomFactorChanged( double factor , QPoint center); + void scrollBarMoved( QPoint offset ); + void zoomFactorChanged( const double factor , const QPoint center); public Q_SLOTS: void setNormalMode(); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 8a3db8a..f08469d 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -195,8 +195,9 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); connect( subWindow, SIGNAL( updateStatusBar( const QString& ) ), this, SLOT( updateStatusBar( const QString& ) ) ); - connect( subWindow, SIGNAL( zoomChangedOnSubWindow() ), this, SLOT( updateZoomFactorSBox() ) ); - connect( subWindow, SIGNAL( scrollBarMoved( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) ); + connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( updateZoomFactorSBox() ) ); + connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( zoomToFactorAll( double, QPoint ) ) ); + connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) ); videoSubWindow->zoomToFit(); videoSubWindow->getViewArea()->setTool( m_appTool ); @@ -417,8 +418,13 @@ Void plaYUVerApp::zoomToFitAll() updateZoomFactorSBox(); } -Void plaYUVerApp::zoomToFactorAll( double factor ) +Void plaYUVerApp::zoomToFactorAll( const double scale, const QPoint center ) { + qDebug() << scale << center; + double factor; + if( m_pcCurrentSubWindow ) + factor = m_pcCurrentSubWindow->getScaleFactor(); + SubWindowHandle *subWindow; for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { @@ -426,7 +432,9 @@ Void plaYUVerApp::zoomToFactorAll( double factor ) if( m_pcCurrentSubWindow == subWindow ) continue; else - subWindow->zoomToFactor(factor); + { + subWindow->zoomToFactor( factor , center ); + } } } @@ -446,21 +454,16 @@ Void plaYUVerApp::zoomFromSBox( double zoom ) { activeSubWindow()->zoomToFactor( factor ); } - - zoomToFactorAll( factor ); } -Void plaYUVerApp::updateZoomFactorSBox() +Void plaYUVerApp::updateZoomFactorSBox( ) { + Double factor; if( m_pcCurrentSubWindow ) { - Double factor = m_pcCurrentSubWindow->getScaleFactor(); + factor = m_pcCurrentSubWindow->getScaleFactor(); m_pcZoomFactorSBox->setValue( factor * 100 ); } - else - { - m_pcZoomFactorSBox->setValue( 0.0 ); - } } Void plaYUVerApp::moveAllScrollBars( const QPoint offset ) diff --git a/app/plaYUVerApp.h b/app/plaYUVerApp.h index 255ddfc..ffa4a8a 100644 --- a/app/plaYUVerApp.h +++ b/app/plaYUVerApp.h @@ -89,7 +89,7 @@ private Q_SLOTS: void normalSize(); void zoomToFit(); void zoomToFitAll(); - void zoomToFactorAll( double factor ); + void zoomToFactorAll( const double factor, const QPoint center = QPoint() ); void setTool( int idxTool );