diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index fa42088..2c2c76d 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -66,7 +66,7 @@ public: * Scale the image (zoomed in or out) to fit on the window. */ virtual Void zoomToFit() = 0; - /* + /** * Scale the image (zoomed in or out) to speficied absolute zoom value (1.0 = original size). */ virtual Void zoomToFactor( Double factor , QPoint center = QPoint() ) = 0; @@ -96,8 +96,15 @@ protected: QSize getScrollSize(); Q_SIGNALS: + /** + * Notify that zoom factor was changed by internal event (e.g. by mouse wheel) + */ void zoomFactorChanged_SWindow( const double, const QPoint ); + /** + * Notify that scrollbar position was changed by internal event (e.g. by mouse panning ) + */ void scrollBarMoved_SWindow( const QPoint ); + void updateStatusBar( const QString& ); public Q_SLOTS: diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 1e378ad..7cfc642 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -83,8 +83,8 @@ 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( adjustScrollBarByScale( double, QPoint ) ) ); - connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) ); + connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) ); + connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( 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 ) ) ); @@ -346,8 +346,9 @@ Void VideoSubWindow::normalSize() Double curFactor = getScaleFactor() ; if( factor != curFactor ) { - m_cViewArea->scaleZoomFactor( factor/curFactor, QPoint() ); - adjustScrollBarByScale( factor/curFactor, QPoint() ); + Double usedScale; + usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, QPoint() ); + adjustScrollBarByScale( usedScale, QPoint() ); } } @@ -363,8 +364,9 @@ Void VideoSubWindow::zoomToFactor( Double factor , QPoint center ) curFactor = getScaleFactor() ; if( factor != curFactor ) { - m_cViewArea->scaleZoomFactor( factor/curFactor, center ); - adjustScrollBarByScale( factor/curFactor, center ); + Double usedScale; + usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + adjustScrollBarByScale( usedScale, center ); } } @@ -373,8 +375,9 @@ Void VideoSubWindow::scaleView( Double scale , QPoint center ) Q_ASSERT( m_cViewArea->image() ); if(scale!=1.0) { - m_cViewArea->scaleZoomFactor( scale, center ); - adjustScrollBarByScale( scale, center ); + Double usedScale; + usedScale = m_cViewArea->scaleZoomFactor( scale, center ); + adjustScrollBarByScale( usedScale, center ); } } @@ -404,13 +407,12 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center ) Double curFactor = getScaleFactor() ; if( factor != curFactor ) { - m_cViewArea->scaleZoomFactor( factor/curFactor, center ); - adjustScrollBarByScale( factor/curFactor, center ); + Double usedScale; + usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + adjustScrollBarByScale( usedScale, center ); } } - - Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) { if( m_pcCurrFrame ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 9674d3e..1c57584 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -197,7 +197,7 @@ protected: public Q_SLOTS: void updateSelectedArea( QRect area ); - void updatePixelValueStatusBar( const QPoint& ); + void updatePixelValueStatusBar( const QPoint& pos ); }; } // NAMESPACE diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index b1262c0..d910afd 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -109,29 +109,39 @@ Void ViewArea::setZoomFactor( Double f ) update(); } -int ViewArea::scaleZoomFactor( Double scale, QPoint center ) +Double ViewArea::scaleZoomFactor( Double scale, QPoint center ) { Double zoomFactor; Double maxZoom = 100.0; Double minZoom = 0.01; //( 1.0 / m_pixmap.width() ); + Double new_scale = 1.0; if( ( m_zoomFactor == minZoom ) && ( scale < 1 ) ) - return 1; + return new_scale; if( ( m_zoomFactor == maxZoom ) && ( scale > 1 ) ) - return 1; + return new_scale; zoomFactor = m_zoomFactor * scale; + new_scale = scale; if( zoomFactor < minZoom ) + { zoomFactor = minZoom; - - if( zoomFactor > maxZoom ) - zoomFactor = maxZoom; + new_scale = zoomFactor/m_zoomFactor; + } + else + { + if( zoomFactor > maxZoom ) + { + zoomFactor = maxZoom; + new_scale = zoomFactor/m_zoomFactor; + } + } setZoomFactor( zoomFactor ); - return 0; + return new_scale; } void ViewArea::setMode( ViewMode mode ) @@ -228,6 +238,7 @@ void ViewArea::setSelectedArea( QRect &rect ) updateRect.adjust( 0, 0, 1, 1 ); update( updateRect.normalized() ); } + //////////////////////////////////////////////////////////////////////////////// // Geometry Updates //////////////////////////////////////////////////////////////////////////////// @@ -545,6 +556,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) void ViewArea::wheelEvent( QWheelEvent *event ) { Double scale; + Double usedScale; if( event->modifiers() & Qt::ControlModifier ) { @@ -554,8 +566,11 @@ void ViewArea::wheelEvent( QWheelEvent *event ) else scale=0.8; - if(scaleZoomFactor( scale , event->pos() ) == 0) - emit zoomFactorChanged( scale, event->pos() ); + usedScale = scaleZoomFactor( scale , event->pos() ); + if( usedScale != 1.0 ) + { + emit zoomFactorChanged_byWheel( usedScale, event->pos() ); + } } } diff --git a/app/ViewArea.h b/app/ViewArea.h index 1e18c55..77f6868 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -115,8 +115,8 @@ public: void setInputStream( PlaYUVerStream *stream ); PlaYUVerStream* getInputStream(); - // Scale function. Return 0 when scale is performed. Return 1 otherwise - int scaleZoomFactor(Double scale, QPoint center); + // Scale function. Return used scale value (it may change when it touches the min or max zoom value) + Double scaleZoomFactor(Double scale, QPoint center); void setTool( eTool tool ); @@ -126,7 +126,7 @@ Q_SIGNALS: void selectionChanged( const QRect &rect ); void positionChanged( const QPoint &pos ); void scrollBarMoved( QPoint offset ); - void zoomFactorChanged( const double factor , const QPoint center); + void zoomFactorChanged_byWheel( const double factor , const QPoint center); public Q_SLOTS: void setNormalMode(); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index f08469d..b326780 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -420,7 +420,6 @@ Void plaYUVerApp::zoomToFitAll() Void plaYUVerApp::zoomToFactorAll( const double scale, const QPoint center ) { - qDebug() << scale << center; double factor; if( m_pcCurrentSubWindow ) factor = m_pcCurrentSubWindow->getScaleFactor();