diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 6638ac9..1c2d190 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -113,7 +113,7 @@ Void ViewArea::zoomChangeEvent(Double factor, QPoint center ) { Double zoomFactor; Double maxZoom = 100.0; - Double minZoom = ( 32.0 / m_pixmap.width() ); + Double minZoom = 0.01;//( 1.0 / m_pixmap.width() ); if( ( m_zoomFactor == minZoom ) && (factor < 1 ) ) return; diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 09ceea2..a94bf30 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 @@ -388,6 +390,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() @@ -706,6 +722,7 @@ Void plaYUVerApp::normalSize() { m_pcCurrentSubWindow->normalSize(); } + updateZoomFactorSBox(); } } @@ -724,6 +741,7 @@ Void plaYUVerApp::zoomToFit() { m_pcCurrentSubWindow->zoomToFit(); } + updateZoomFactorSBox(); } } @@ -737,7 +755,7 @@ Void plaYUVerApp::zoomToFitAll() } } -Void plaYUVerApp::scaleFrame( Int ratio ) +Void plaYUVerApp::scaleFrame( int ratio ) { if( m_pcCurrentSubWindow ) { @@ -752,6 +770,20 @@ Void plaYUVerApp::scaleFrame( Int ratio ) { m_pcCurrentSubWindow->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 ) +{ + Double lastZoom; + if( activeSubWindow() ) + { + lastZoom = activeSubWindow()->getViewArea()->getZoomFactor() * 100; + if( zoom / lastZoom != 1.0 ) + activeSubWindow()->scaleViewByRatio( zoom / lastZoom ); } } @@ -767,6 +799,7 @@ Void plaYUVerApp::chageSubWindowSelection() updateTotalFrameNum(); updateStreamProperties(); updateFrameProperties(); + updateZoomFactorSBox(); } m_pcCurrentSubWindow = new_window; } @@ -886,6 +919,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 ); @@ -1233,6 +1267,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(1.0, 10000.0); + m_pcZoomFactorSBox->setSingleStep(10.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; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 8c04c44..2d23d52 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -138,9 +138,10 @@ public: static Pixel ConvertPixel( Pixel, Int ); +#ifdef USE_OPENCV cv::Mat getCvMat(); Void copyFrom( cv::Mat* ); - +#endif UInt getWidth() const {