From 2b3e0f5ffdf4bdf07903fcb324799fcf7067d476 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Fri, 27 Jun 2014 01:49:10 +0100 Subject: [PATCH] Add zoom spin box for precise zoom setting. --- source/app/plaYUVerApp.cpp | 46 +++++++++++++++++++++++++++++++++++--- source/app/plaYUVerApp.h | 6 ++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 5e3cdd2..140e7b1 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -173,9 +173,11 @@ Void plaYUVerApp::loadFile( QString fileName ) connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this, SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) ); connect( interfaceChild->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this, SLOT( updatePropertiesSelectedArea( QRect ) ) ); + connect( interfaceChild->getViewArea(), SIGNAL( zoomFactorChanged( double , QPoint ) ), this, SLOT( updateZoomFactorSBox() ) ); interfaceChild->zoomToFit(); interfaceChild->getViewArea()->setTool( m_appTool ); + updateZoomFactorSBox( ); statusBar()->showMessage( tr( "File loaded" ), 2000 ); } else @@ -340,6 +342,20 @@ Void plaYUVerApp::updatePropertiesSelectedArea( QRect area ) } } + +Void plaYUVerApp::updateZoomFactorSBox( ) +{ + if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getViewArea() ) + { + Double factor = m_pcCurrentSubWindow->getViewArea()->getZoomFactor(); + m_pcZoomFactorSBox->setValue(factor*100); + } + else + { + m_pcZoomFactorSBox->setValue(0.0); + } +} + // ----------------------- Playing Functions -------------------- UInt64 plaYUVerApp::getMaxFrameNumber() @@ -647,13 +663,19 @@ Void plaYUVerApp::videoSelectionButtonEvent() Void plaYUVerApp::normalSize() { if( activeSubWindow() ) + { activeSubWindow()->normalSize(); + updateZoomFactorSBox(); + } } Void plaYUVerApp::zoomToFit() { if( activeSubWindow() ) + { activeSubWindow()->zoomToFit(); + updateZoomFactorSBox(); + } } Void plaYUVerApp::zoomToFitAll() @@ -666,17 +688,26 @@ Void plaYUVerApp::zoomToFitAll() } } -Void plaYUVerApp::scaleFrame( Int ratio ) +Void plaYUVerApp::scaleFrame( int ratio ) { if( activeSubWindow() ) { - activeSubWindow()->scaleViewByRatio( ( Double )( ratio ) / 100.0 ); - + activeSubWindow()->scaleViewByRatio( (Double)ratio / 100.0 ); + updateZoomFactorSBox(); // m_arrayActions[ZOOM_IN_ACT]->setEnabled( activeSubWindow()->getScaleFactor() < 3.0 ); // m_arrayActions[ZOOM_OUT_ACT]->setEnabled( activeSubWindow()->getScaleFactor() > 0.333 ); } } +Void plaYUVerApp::setZoomFromSBox( double zoom ) +{ + if( activeSubWindow() ) + { + if(activeSubWindow()->getViewArea()->getZoomFactor() != ( zoom/100.0 ) ) + activeSubWindow()->getViewArea()->setZoomFactor( zoom/100.0 ); + } +} + Void plaYUVerApp::chageSubWindowSelection() { SubWindowHandle *new_window = activeSubWindow(); @@ -689,6 +720,7 @@ Void plaYUVerApp::chageSubWindowSelection() updateTotalFrameNum(); updateStreamProperties(); updateFrameProperties(); + updateZoomFactorSBox(); } m_pcCurrentSubWindow = new_window; } @@ -808,6 +840,7 @@ Void plaYUVerApp::updateMenus() m_arrayActions[ZOOM_OUT_ACT]->setEnabled( hasSubWindow ); m_arrayActions[ZOOM_NORMAL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[ZOOM_FIT_ACT]->setEnabled( hasSubWindow ); + m_pcZoomFactorSBox->setEnabled( hasSubWindow ); m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow ); m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow ); @@ -1155,6 +1188,13 @@ Void plaYUVerApp::createToolBars() addToolBar( Qt::TopToolBarArea, m_arrayToolBars[FILE_TOOLBAR] ); m_arrayToolBars[VIEW_TOOLBAR] = new QToolBar( tr( "View" ) ); + m_pcZoomFactorSBox = new QDoubleSpinBox; + m_pcZoomFactorSBox->setRange(0.0, 10000.0); + m_pcZoomFactorSBox->setSingleStep(1.0); + m_pcZoomFactorSBox->setValue(100.0); + m_pcZoomFactorSBox->setSuffix("%"); + connect(m_pcZoomFactorSBox, SIGNAL( valueChanged(double) ), this, SLOT( setZoomFromSBox(double) ) ); + m_arrayToolBars[VIEW_TOOLBAR]->addWidget( m_pcZoomFactorSBox ); m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_IN_ACT] ); m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_OUT_ACT] ); m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_NORMAL_ACT] ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 7bfd1dd..a347cb9 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -82,7 +82,8 @@ private Q_SLOTS: * @param factor factor of scale. Ex: 120 scale the image up by 20% and * 80 scale the image down by 25% */ - void scaleFrame( int ratio = 100 ); + void scaleFrame( int ratio = 100.0 ); + void setZoomFromSBox( double ratio ); void normalSize(); void zoomToFit(); @@ -104,6 +105,8 @@ private Q_SLOTS: void updateProperties(); void updatePropertiesSelectedArea( QRect area ); + void updateZoomFactorSBox(); + void setAllSubWindowTool(); void setNavigationTool(); void setSelectionTool(); @@ -150,6 +153,7 @@ private: QSlider *m_pcFrameSlider; QLabel *m_pcCurrFrameNumLabel; QLabel *m_pcTotalFrameNumLabel; + QDoubleSpinBox *m_pcZoomFactorSBox; QSignalMapper *mapperZoom; QSignalMapper *mapperSeekVideo;