diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index da31427..9976790 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -17,7 +17,6 @@ set(plaYUver_App_SRCS # Sub Window SubWindowHandle.cpp VideoSubWindow.cpp - PlotSubWindow.cpp # Dialogs AboutDialog.cpp ConfigureFormatDialog.cpp diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index d28eed0..b31b0a3 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -23,7 +23,7 @@ */ #include "DialogSubWindowSelector.h" -#include "SubWindowHandle.h" +#include "VideoSubWindow.h" namespace plaYUVer { @@ -108,14 +108,19 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi Void DialogSubWindowSelector::updateSubWindowList() { SubWindowHandle *subWindow; + VideoSubWindow *videoSubWindow; QString currSubWindowName; m_pcWindowListNames.clear(); for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); - currSubWindowName = subWindow->getWindowName(); - if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() ) - m_pcWindowListNames.append( currSubWindowName ); + if( subWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) + { + videoSubWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); + currSubWindowName = videoSubWindow->getWindowName(); + if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !videoSubWindow->getIsModule() ) + m_pcWindowListNames.append( currSubWindowName ); + } } m_comboBoxWindowList->clear(); m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames ); @@ -133,7 +138,7 @@ Void DialogSubWindowSelector::updateSubWindowList() { m_pushButtonAdd->setEnabled( true ); } - if( m_pcWindowListNames.size() > m_iMaxSlectedWindows ) + if( m_pcWindowListNames.size() > m_iMaxSlectedWindows ) { enableAddAll = false; } diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index d469663..b0e20b4 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -104,11 +104,11 @@ SubWindowHandle* ModulesHandle::processModuleHandlingOpt() SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { Bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked(); - SubWindowHandle* pcSubWindow = qobject_cast( m_pcMdiArea->activeSubWindow() ); - SubWindowHandle* interfaceChild = NULL; + VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcMdiArea->activeSubWindow() ); + QString windowName; - QVector subWindowList; + QVector subWindowList; UInt numberOfFrames = pcCurrModuleIf->m_pcModule->m_cModuleDef.m_uiNumberOfFrames; if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { @@ -122,11 +122,11 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul { for( Int i = 0; i < m_pcMdiArea->subWindowList().size(); i++ ) { - subWindow = qobject_cast( m_pcMdiArea->subWindowList().at( i ) ); - if( subWindow->getWindowName() == selectedWindows.at( j ) ) + subWindow = qobject_cast( m_pcMdiArea->subWindowList().at( i ) ); + if( subWindow->windowTitle() == selectedWindows.at( j ) ) { - subWindowList.append( subWindow ); - pcCurrModuleIf->m_pcSubWindow[j] = subWindow; + subWindowList.append( qobject_cast( m_pcMdiArea->subWindowList().at( i ) ) ); + pcCurrModuleIf->m_pcSubWindow[j] = qobject_cast( m_pcMdiArea->subWindowList().at( i ) ); } } } @@ -143,15 +143,15 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul } else { - windowName.append( pcSubWindow->getWindowName() ); - subWindowList.append( pcSubWindow ); + windowName.append( pcVideoSubWindow->windowTitle() ); + subWindowList.append( pcVideoSubWindow ); } if( subWindowList.size() == 0 ) { pcCurrModuleIf->m_pcAction->setChecked( false ); m_pcParent->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); - return interfaceChild; + return NULL; } windowName.append( " <" ); @@ -165,11 +165,13 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul } pcCurrModuleIf->m_pcDisplaySubWindow = NULL; + + VideoSubWindow* interfaceChild = NULL; if( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_iModuleType == FRAME_PROCESSING_MODULE ) { if( ( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) { - interfaceChild = new SubWindowHandle( m_pcParent, true ); + interfaceChild = new VideoSubWindow( m_pcParent, true ); interfaceChild->setWindowName( windowName ); connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent, SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) ); @@ -385,7 +387,7 @@ Void ModulesHandle::swapModulesWindowsIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { if( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_uiNumberOfFrames == MODULE_REQUIRES_TWO_FRAMES ) { - SubWindowHandle* auxWindowHandle = pcCurrModuleIf->m_pcSubWindow[0]; + VideoSubWindow* auxWindowHandle = pcCurrModuleIf->m_pcSubWindow[0]; pcCurrModuleIf->m_pcSubWindow[0] = pcCurrModuleIf->m_pcSubWindow[1]; pcCurrModuleIf->m_pcSubWindow[1] = auxWindowHandle; } diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index bb063e7..92d5753 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -23,7 +23,7 @@ */ #include "PlaYUVerAppModuleIf.h" -#include "SubWindowHandle.h" +#include "VideoSubWindow.h" namespace plaYUVer { diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h index 5873b49..6a41c4d 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/PlaYUVerAppModuleIf.h @@ -39,7 +39,6 @@ class QAction; namespace plaYUVer { -class SubWindowHandle; class VideoSubWindow; class PlaYUVerAppModuleIf @@ -59,7 +58,7 @@ private: QAction* m_pcAction; VideoSubWindow* m_pcSubWindow[MAX_NUMBER_FRAMES]; - SubWindowHandle* m_pcDisplaySubWindow; + VideoSubWindow* m_pcDisplaySubWindow; QDockWidget* m_pcDockWidget; ModuleHandleDock* m_pcModuleDock; diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp index 4720601..852c5d3 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/QualityMeasurementSidebar.cpp @@ -25,7 +25,7 @@ #include "lib/PlaYUVerDefs.h" #include #include "QualityMeasurementSidebar.h" -#include "SubWindowHandle.h" +#include "VideoSubWindow.h" namespace plaYUVer { @@ -33,7 +33,7 @@ namespace plaYUVer QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea *mdiArea ) : QWidget( parent ), m_pcMainWindowMdiArea( mdiArea ), - m_pcCurrentSubWindow( NULL ) + m_pcCurrentVideoSubWindow( NULL ) { // Side bar area ----------------------------------------------------- @@ -119,16 +119,19 @@ QSize QualityMeasurementSidebar::sizeHint() const Void QualityMeasurementSidebar::updateSubWindowList() { - SubWindowHandle *subWindow; + VideoSubWindow* pcVideoSubWindow; QString currSubWindowName; m_pcWindowListNames.clear(); - for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ ) + + + QList videoSubWindowList = m_pcMainWindowMdiArea->findChildren(); + for( Int i = 0; i < videoSubWindowList.size(); i++ ) { - subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); - if( subWindow ) + pcVideoSubWindow = videoSubWindowList.at( i ); + if( pcVideoSubWindow ) { - currSubWindowName = subWindow->getWindowShortName(); - if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() ) + currSubWindowName = pcVideoSubWindow->getWindowShortName(); + if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !pcVideoSubWindow->getIsModule() ) { m_pcWindowListNames.append( currSubWindowName ); //m_comboBoxRef->setItemText( currIdx++, currSubWindowName ); @@ -138,9 +141,9 @@ Void QualityMeasurementSidebar::updateSubWindowList() m_comboBoxRef->clear(); m_comboBoxRef->insertItems( -1, m_pcWindowListNames ); m_comboBoxRef->setCurrentIndex( -1 ); - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() ) + if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() ) { Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowShortName() ); m_comboBoxRef->setCurrentIndex( index ); @@ -149,13 +152,13 @@ Void QualityMeasurementSidebar::updateSubWindowList() m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents ); } -Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow ) +Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow *subWindow ) { - m_pcCurrentSubWindow = subWindow; - if( m_pcCurrentSubWindow ) + m_pcCurrentVideoSubWindow = subWindow; + if( m_pcCurrentVideoSubWindow ) { Int index = -1; - if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() ) + if( VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow() ) { index = m_pcWindowListNames.indexOf( refSubWindow->getWindowName() ); } @@ -167,12 +170,12 @@ Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow Void QualityMeasurementSidebar::updateSidebarData() { QString value( "0.00" ); - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow(); + VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow(); if( refSubWindow ) { - PlaYUVerFrame* currFrame = m_pcCurrentSubWindow->getCurrFrame(); + PlaYUVerFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame(); Double quality; @@ -197,14 +200,14 @@ Void QualityMeasurementSidebar::updateSidebarData() Void QualityMeasurementSidebar::slotReferenceChanged( Int index ) { - if( index > -1 && m_pcCurrentSubWindow ) + if( index > -1 && m_pcCurrentVideoSubWindow ) { - SubWindowHandle *subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( index ) ); - if( subWindow ) + VideoSubWindow *pcVideoSubWindow = m_pcMainWindowMdiArea->findChildren().at( index ); + if( pcVideoSubWindow ) { - if( m_pcCurrentSubWindow->getCurrFrame()->haveSameFmt( subWindow->getCurrFrame() ) ) + if( m_pcCurrentVideoSubWindow->getCurrFrame()->haveSameFmt( pcVideoSubWindow->getCurrFrame() ) ) { - m_pcCurrentSubWindow->setRefSubWindow( subWindow ); + m_pcCurrentVideoSubWindow->setRefSubWindow( pcVideoSubWindow ); updateSidebarData(); m_comboBoxRef->setCurrentIndex( index ); return; diff --git a/app/QualityMeasurementSidebar.h b/app/QualityMeasurementSidebar.h index 0522524..2f42c38 100644 --- a/app/QualityMeasurementSidebar.h +++ b/app/QualityMeasurementSidebar.h @@ -39,7 +39,7 @@ namespace plaYUVer { -class SubWindowHandle; +class VideoSubWindow; class QualityMeasurementSidebar: public QWidget { @@ -51,7 +51,7 @@ public: QSize sizeHint() const; Void updateSubWindowList(); - Void updateCurrentWindow( SubWindowHandle * ); + Void updateCurrentWindow( VideoSubWindow * ); Void updateSidebarData(); private: @@ -60,7 +60,7 @@ private: QStringList m_pcWindowListNames; QStringList m_pcSelectedWindowListNames; - SubWindowHandle *m_pcCurrentSubWindow; + VideoSubWindow *m_pcCurrentVideoSubWindow; QComboBox *m_comboBoxMetric; diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index e613af8..7d9149c 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -31,17 +31,22 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : QMdiSubWindow( parent ) { m_uiCategory = category; + m_cWindowName = QString( " " ); } SubWindowHandle::~SubWindowHandle() { } -QString SubWindowHandle::getWindowName() -{ - return QString(); -} - +Void SubWindowHandle::setWindowName( QString name ) + { + m_cWindowName = name; + setWindowTitle( m_cWindowName ); + } + QString SubWindowHandle::getWindowName() + { + return m_cWindowName; + } Bool SubWindowHandle::mayClose() { return true; diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 305c917..011d4d0 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -32,7 +32,6 @@ #elif( QT_VERSION_PLAYUVER == 4 ) #include #endif -#include "ModulesHandle.h" namespace plaYUVer { @@ -43,6 +42,7 @@ Q_OBJECT private: UInt m_uiCategory; + QString m_cWindowName; public: enum SubWindowCategories @@ -50,39 +50,46 @@ public: VIDEO_SUBWINDOW = 0, MODULE_SUBWINDOW, PLOT_SUBWINDOW, - } + }; + SubWindowHandle( QWidget *, UInt ); ~SubWindowHandle(); /** * Show the image at its original size */ - virtual Void normalSize() {}; + virtual Void normalSize() = 0; /** * Scale the image (zoomed in or out) to fit on the window. */ - virtual Void zoomToFit() {}; + virtual Void zoomToFit() = 0; /** * Scale the image by a given factor * @param factor factor of scale. Ex: 1.2 scale the image up by 20% and * 0.8 scale the image down by 25% */ - virtual Void scaleView( Double scale ) {}; + virtual Void scaleView( Double ) = 0; /** * The current image size is scaled to a rectangle as large as possible * inside (@p width, @p height ) preserving the aspect ratio. */ - virtual Void scaleView( Int width, Int height ) {}; + virtual Void scaleView( Int, Int ) = 0; /** * This is an overloaded member function, provided for convenience. * Scales the image to a rectangle with the given size, preserving the * aspect ratio. */ - Void scaleView( const QSize & size ) {}; + virtual Void scaleView( const QSize & ) = 0; + + virtual Void scaleViewByRatio( Double ) = 0; + + virtual Double getScaleFactor() = 0; + + Void setWindowName( QString ); + QString getWindowName(); - virtual QString getWindowName(); virtual Bool mayClose(); UInt getCategory() diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 24d44b3..dc38379 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -23,6 +23,7 @@ */ #include "VideoSubWindow.h" +#include "SubWindowHandle.h" #include "ConfigureFormatDialog.h" #include "ViewArea.h" @@ -102,7 +103,6 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : m_cScrollArea->setWidget( m_cViewArea ); m_cScrollArea->setWidgetResizable( true ); - m_cWindowName = QString( " " ); m_cLastScroll = QPoint(); } @@ -160,10 +160,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) refreshFrame(); m_cFilename = cFilename; - m_cWindowName = m_pCurrStream->getStreamInformationString(); m_cWindowShortName = QFileInfo( cFilename ).fileName(); - setWindowTitle( m_cWindowName ); - qDebug() << "File " << m_cWindowName << "was successfully opened"; + setWindowName( m_pCurrStream->getStreamInformationString() ); return true; } @@ -189,9 +187,8 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) refreshFrame(); m_cFilename = streamInfo->m_cFilename; - m_cWindowName = m_pCurrStream->getStreamInformationString(); m_cWindowShortName = QFileInfo( streamInfo->m_cFilename ).fileName(); - setWindowTitle( m_cWindowName ); + setWindowName( m_pCurrStream->getStreamInformationString() ); return true; } @@ -314,7 +311,7 @@ Bool VideoSubWindow::play() return m_bIsPlaying; } -Int VideoSubWindow::playEvent() +Bool VideoSubWindow::playEvent() { if( m_pCurrStream && m_bIsPlaying ) { @@ -322,17 +319,11 @@ Int VideoSubWindow::playEvent() refreshFrame(); if( m_pCurrStream->checkErrors( PlaYUVerStream::END_OF_SEQ ) ) { - return -2; + return true; } m_pCurrStream->readFrame(); - if( m_pCurrStream->checkErrors( PlaYUVerStream::READING ) ) - { - QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cFilename ) ); - return -3; - } - return 0; } - return -4; + return false; } Void VideoSubWindow::pause() @@ -384,6 +375,12 @@ Void VideoSubWindow::zoomToFit() scaleView( niceFit ); } +Void VideoSubWindow::scaleViewByRatio( Double ratio ) +{ + Q_ASSERT( m_cViewArea->image() ); + m_cViewArea->zoomChangeEvent( ratio, QPoint() ); +} + Void VideoSubWindow::scaleView( Double scale ) { Q_ASSERT( m_cViewArea->image() ); @@ -419,12 +416,6 @@ Void VideoSubWindow::scaleView( const QSize & size ) scaleView( hfactor ); } -Void VideoSubWindow::scaleViewByRatio( Double ratio ) -{ - Q_ASSERT( m_cViewArea->image() ); - m_cViewArea->zoomChangeEvent( ratio, QPoint() ); -} - void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) { QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index f39af96..ed5803a 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -76,8 +76,6 @@ private: VideoSubWindow* m_pcReferenceSubWindow; - QString m_cWindowName; - QString m_cWindowShortName; QString m_cCurrFileName; @@ -97,7 +95,7 @@ public: Bool play(); Void pause(); - Int playEvent(); + Bool playEvent(); Void stop(); Bool isPlaying() @@ -133,11 +131,6 @@ public: return m_cViewArea; } - Double getZoomFactor() - { - return m_cViewArea->getZoomFactor(); - } - Void setModule( PlaYUVerAppModuleIf* pcCurrentModule ) { m_pcCurrentModule = pcCurrentModule; @@ -173,7 +166,6 @@ public: Void scaleView( Double scale ); Void scaleView( Int width, Int height ); Void scaleView( const QSize & size ); - Void scaleViewByRatio( Double ratio ); Double getScaleFactor() { @@ -182,15 +174,6 @@ public: QSize sizeHint() const; - Void setWindowName( QString name ) - { - m_cWindowName = name; - setWindowTitle( m_cWindowName ); - } - QString getWindowName() - { - return m_cWindowName; - } QString getWindowShortName() { return m_cWindowShortName; diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index e62bcf1..a70a2b4 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -101,13 +101,6 @@ void ViewArea::clearMask() m_mask.clear(); } -// QSize ViewArea::sizeHint() const -// { -// int w = m_pixmap.width()*m_zoomFactor; -// int h = m_pixmap.height()*m_zoomFactor; -// return QSize( w, h ); -// } - Void ViewArea::setZoomFactor( Double f ) { m_zoomFactor = f; diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index cccceeb..b5288e7 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -76,12 +76,14 @@ plaYUVerApp::plaYUVerApp() m_pcPlayingTimer->setTimerType( Qt::CoarseTimer ); #endif connect( m_pcPlayingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) ); + m_acPlayingSubWindows.clear(); setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); m_pcAboutDialog = NULL; m_pcCurrentSubWindow = NULL; + m_pcCurrentVideoSubWindow = NULL; } Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) @@ -270,9 +272,9 @@ Void plaYUVerApp::openRecent() Void plaYUVerApp::save() { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - SubWindowHandle *saveWindow = m_pcCurrentSubWindow; + VideoSubWindow *saveWindow = m_pcCurrentVideoSubWindow; QString supported = tr( "Supported Files (" ); QStringList formatsList; QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt(); @@ -313,17 +315,16 @@ Void plaYUVerApp::save() Void plaYUVerApp::format() { - if( m_pcCurrentSubWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) + if( m_pcCurrentVideoSubWindow ) { - VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); + VideoSubWindow* pcVideoSubWindow = m_pcCurrentVideoSubWindow; try { pcVideoSubWindow->loadFile( pcVideoSubWindow->getCurrentFileName(), true ); } catch( const char *msg ) { - QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" - + msg; + QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" + msg; QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); statusBar()->showMessage( warningMsg, 2000 ); qDebug( ) << warningMsg; @@ -336,9 +337,9 @@ Void plaYUVerApp::format() Void plaYUVerApp::reload() { - if( m_pcCurrentSubWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) + if( m_pcCurrentVideoSubWindow ) { - VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); + VideoSubWindow* pcVideoSubWindow = qobject_cast( m_pcCurrentVideoSubWindow ); pcVideoSubWindow->reloadFile(); m_pcCurrentSubWindow = NULL; chageSubWindowSelection(); @@ -351,16 +352,17 @@ Void plaYUVerApp::reloadAll() for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); - subWindow->reloadFile(); + if( subWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) + qobject_cast( subWindow )->reloadFile(); } } Void plaYUVerApp::loadAll() { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { statusBar()->showMessage( tr( "Loading file into memory ..." ) ); - m_pcCurrentSubWindow->getInputStream()->loadAll(); + m_pcCurrentVideoSubWindow->getInputStream()->loadAll(); statusBar()->showMessage( tr( "File loaded" ), 2000 ); } } @@ -368,11 +370,12 @@ Void plaYUVerApp::loadAll() Void plaYUVerApp::closeActiveWindow() { SubWindowHandle *currSubWindow = activeSubWindow(); - if( currSubWindow ) + if( currSubWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) { - if( m_acPlayingSubWindows.contains( currSubWindow ) ) + VideoSubWindow* pcVideoSubWindow = qobject_cast( currSubWindow ); + if( m_acPlayingSubWindows.contains( pcVideoSubWindow ) ) { - Int pos = m_acPlayingSubWindows.indexOf( currSubWindow ); + Int pos = m_acPlayingSubWindows.indexOf( pcVideoSubWindow ); m_acPlayingSubWindows.at( pos )->stop(); m_acPlayingSubWindows.remove( pos ); } @@ -394,46 +397,76 @@ Void plaYUVerApp::ModuleHandling( QAction *curr_action ) if( interfaceChild ) { mdiArea->addSubWindow( interfaceChild ); - - interfaceChild->getViewArea()->setTool( m_appTool ); + //interfaceChild->getViewArea()->setTool( m_appTool ); } if( activeSubWindow() ) m_pcCurrentSubWindow = activeSubWindow(); - updateFrameProperties(); + + updateStreamProperties(); return; } // ----------------------- Update Properties -------------------- -Void plaYUVerApp::updateProperties() +UInt64 plaYUVerApp::getMaxFrameNumber() { - updateStreamProperties(); - updateFrameProperties(); + UInt currFrames; + UInt64 maxFrames = INT_MAX; + if( m_pcCurrentVideoSubWindow ) + { + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum(); + if( currFrames < maxFrames ) + maxFrames = currFrames; + } + } + else + { + maxFrames = m_pcCurrentVideoSubWindow->getInputStream()->getFrameNum(); + } + } + return maxFrames; } Void plaYUVerApp::updateStreamProperties() { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - m_pcStreamProperties->setData( m_pcCurrentSubWindow->getInputStream() ); - } - else - { - m_pcStreamProperties->setData( NULL ); - } -} + m_pcStreamProperties->setData( m_pcCurrentVideoSubWindow->getInputStream() ); + m_pcFrameProperties->setData( m_pcCurrentVideoSubWindow->getCurrFrame() ); -Void plaYUVerApp::updateFrameProperties() -{ - if( m_pcCurrentSubWindow ) - { - m_pcFrameProperties->setData( m_pcCurrentSubWindow->getCurrFrame() ); - //m_pcFrameProperties->setSelection( m_pcCurrentSubWindow->getViewArea()->selectedArea() ); - } - else - { - m_pcFrameProperties->setData( NULL ); + Int frame_num = 0; + UInt64 total_frame_num = 1; + if( m_pcCurrentVideoSubWindow->getInputStream() ) + { + frame_num = m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum(); + m_pcFrameNumInfo->setCurrFrameNum( frame_num ); + total_frame_num = getMaxFrameNumber(); + } + else + { + m_pcFrameNumInfo->setCurrFrameNum( 0 ); + } + m_pcFrameSlider->setValue( frame_num ); + m_pcFrameSlider->setMaximum( total_frame_num - 1 ); + m_pcFrameNumInfo->setTotalFrameNum( total_frame_num ); + + if( m_pcCurrentVideoSubWindow->isPlaying() ) + m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); + else + m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); + + m_pcQualityMeasurement->updateSidebarData(); + return; } + m_pcStreamProperties->setData( NULL ); + m_pcFrameProperties->setData( NULL ); + m_pcFrameNumInfo->setCurrFrameNum( 0 ); + m_pcFrameNumInfo->setTotalFrameNum( 0 ); + m_pcZoomFactorSBox->setValue( 0.0 ); } Void plaYUVerApp::updatePropertiesSelectedArea( QRect area ) @@ -451,43 +484,8 @@ 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() -{ - UInt currFrames; - UInt64 maxFrames = INT_MAX; - if( m_pcCurrentSubWindow ) - { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum(); - if( currFrames < maxFrames ) - maxFrames = currFrames; - } - } - else - { - maxFrames = m_pcCurrentSubWindow->getInputStream()->getFrameNum(); - } - } - return maxFrames; -} Void plaYUVerApp::setTimerStatus() { Bool status = false; @@ -495,11 +493,15 @@ Void plaYUVerApp::setTimerStatus() { status |= m_acPlayingSubWindows.at( i )->isPlaying(); } + if( m_pcCurrentVideoSubWindow ) + { + status |= m_pcCurrentVideoSubWindow->isPlaying(); + } if( status ) { if( !m_bIsPlaying ) { - m_cTimer.start(); + m_pcPlayingTimer->start(); m_bIsPlaying = true; } } @@ -510,97 +512,38 @@ Void plaYUVerApp::setTimerStatus() } } -Void plaYUVerApp::startPlay() -{ - if( !m_bIsPlaying ) - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - if( !m_acPlayingSubWindows.at( i )->play() ) - { - m_acPlayingSubWindows.remove( i ); - } - } - if( m_acPlayingSubWindows.size() > 0 ) - { - UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate(); - UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); - qDebug( ) << "Desired frame rate: " - << QString::number( 1000 / timeInterval ) - << " fps"; - m_pcPlayingTimer->start( timeInterval ); - m_cTimer.start(); - m_bIsPlaying = true; - m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); - } - } -} - Void plaYUVerApp::play() { - if( !m_pcCurrentSubWindow ) + if( !m_pcCurrentVideoSubWindow ) return; - if( !m_pcCurrentSubWindow->getInputStream() ) + if( !m_pcCurrentVideoSubWindow->getInputStream() ) return; - if( !m_pcCurrentSubWindow->isPlaying() ) + if( !m_pcCurrentVideoSubWindow->isPlaying() ) // Not playing { - if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() && m_acPlayingSubWindows.size() ) + UInt frameRate; + UInt timeInterval; + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - if( !m_pcCurrentSubWindow->play() ) + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { - return; - } - if( !m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { - m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); - m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); - updateTotalFrameNum(); + m_acPlayingSubWindows.at( i )->play(); } + frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate(); + } else { - m_pcPlayingTimer->stop(); - m_acPlayingSubWindows.clear(); - if( !m_pcCurrentSubWindow->play() ) - { - return; - } - m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); - m_uiAveragePlayInterval = 0; - m_bIsPlaying = false; + m_pcCurrentVideoSubWindow->play(); + frameRate = m_pcCurrentVideoSubWindow->getInputStream()->getFrameRate(); } - startPlay(); + timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); + m_pcPlayingTimer->setInterval( timeInterval ); } else { - if( m_pcCurrentSubWindow ) - { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - m_acPlayingSubWindows.at( i )->pause(); - } - } - else - { - m_pcCurrentSubWindow->pause(); - } - updateCurrFrameNum(); - } - setTimerStatus(); - updateFrameProperties(); - m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); - } -} - -Void plaYUVerApp::pause() -{ - if( m_pcCurrentSubWindow ) - { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { @@ -609,12 +552,31 @@ Void plaYUVerApp::pause() } else { - m_pcCurrentSubWindow->pause(); + m_pcCurrentVideoSubWindow->pause(); } - updateCurrFrameNum(); } setTimerStatus(); - updateFrameProperties(); + updateStreamProperties(); +} + +Void plaYUVerApp::pause() +{ + if( m_pcCurrentVideoSubWindow ) + { + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->pause(); + } + } + else + { + m_pcCurrentVideoSubWindow->pause(); + } + } + setTimerStatus(); + updateStreamProperties(); } Void plaYUVerApp::stop() @@ -627,98 +589,60 @@ Void plaYUVerApp::stop() } m_acPlayingSubWindows.clear(); setTimerStatus(); - updateCurrFrameNum(); - updateFrameProperties(); - if( m_uiAveragePlayInterval ) - qDebug( ) << "Real display time: " - << QString::number( 1000 / m_uiAveragePlayInterval ) - << " fps"; - m_uiAveragePlayInterval = 0; } else { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - seekSliderEvent( 0 ); + m_pcCurrentVideoSubWindow->stop(); } } - m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); - m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false ); - updateTotalFrameNum(); + updateStreamProperties(); } Void plaYUVerApp::playEvent() { - UInt time = m_cTimer.elapsed(); - m_cTimer.restart(); - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + Bool bEndOfSequence = false; + try { - switch( m_acPlayingSubWindows.at( i )->playEvent() ) + if( m_acPlayingSubWindows.size() > 0) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + bEndOfSequence |= m_acPlayingSubWindows.at( i )->playEvent(); + } + } + else + { + if( m_pcCurrentVideoSubWindow ) + { + bEndOfSequence |= m_pcCurrentVideoSubWindow->playEvent(); + } + } + if( bEndOfSequence && !m_arrayActions[VIDEO_LOOP_ACT]->isChecked() ) { - case -1: stop(); - break; - case -2: - if( !m_arrayActions[VIDEO_LOOP_ACT]->isChecked() ) - { - stop(); - } - else - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 ); - } - } - break; - case -3: - m_acPlayingSubWindows.at( i )->close(); - m_acPlayingSubWindows.remove( i ); - break; - case -4: - m_acPlayingSubWindows.remove( i ); - break; - default: - break; } } - updateCurrFrameNum(); - updateFrameProperties(); - m_pcQualityMeasurement->updateSidebarData(); - m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time ) / 2; -} - -Void plaYUVerApp::updateCurrFrameNum() -{ - if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getInputStream() ) + catch( const char *msg ) { - Int frame_num = m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum(); - m_pcFrameSlider->setValue( frame_num ); - m_pcFrameNumInfo->setCurrFrameNum( frame_num ); + QString warningMsg = "Error while playing " + QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" + msg; + QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); + statusBar()->showMessage( warningMsg, 2000 ); + qDebug( ) << warningMsg; + stop(); + m_pcCurrentVideoSubWindow->close(); } - else - { - m_pcFrameNumInfo->setCurrFrameNum( 0 ); - } -} -Void plaYUVerApp::updateTotalFrameNum() -{ - UInt64 total_frame_num = 1; - if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getInputStream() ) - { - total_frame_num = getMaxFrameNumber(); - } - m_pcFrameSlider->setMaximum( total_frame_num - 1 ); - m_pcFrameNumInfo->setTotalFrameNum( total_frame_num ); + updateStreamProperties(); } Void plaYUVerApp::seekEvent( Int direction ) { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { - if( !( ( UInt )( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() && direction > 0 ) ) + if( !( ( UInt )( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() && direction > 0 ) ) { for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { @@ -728,19 +652,19 @@ Void plaYUVerApp::seekEvent( Int direction ) } else { - m_pcCurrentSubWindow->seekRelativeEvent( direction > 0 ? true : false ); + m_pcCurrentVideoSubWindow->seekRelativeEvent( direction > 0 ? true : false ); } m_pcQualityMeasurement->updateSidebarData(); - updateFrameProperties(); - updateCurrFrameNum(); + updateStreamProperties(); + } } Void plaYUVerApp::seekSliderEvent( Int new_frame_num ) { - if( m_pcCurrentSubWindow ) + if( m_pcCurrentVideoSubWindow ) { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) ) { for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { @@ -749,40 +673,13 @@ Void plaYUVerApp::seekSliderEvent( Int new_frame_num ) } else { - m_pcCurrentSubWindow->seekAbsoluteEvent( ( UInt )new_frame_num ); + m_pcCurrentVideoSubWindow->seekAbsoluteEvent( ( UInt )new_frame_num ); } m_pcQualityMeasurement->updateSidebarData(); - updateFrameProperties(); - updateCurrFrameNum(); + updateStreamProperties(); } } -Void plaYUVerApp::lockButtonEvent() -{ - if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ) - { - if( m_acPlayingSubWindows.size() > 1 ) - m_acPlayingSubWindows.clear(); - - SubWindowHandle *subWindow; - for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) - { - subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); - if( !subWindow->getIsModule() ) - { - m_acPlayingSubWindows.append( subWindow ); - m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )subWindow->getInputStream()->getFrameNum() - 1 ) ); - } - } - } - else - { - stop(); - } - updateCurrFrameNum(); - updateTotalFrameNum(); -} - Void plaYUVerApp::videoSelectionButtonEvent() { DialogSubWindowSelector dialogWindowsSelection( this, mdiArea ); @@ -798,22 +695,19 @@ Void plaYUVerApp::videoSelectionButtonEvent() m_acPlayingSubWindows.clear(); SubWindowHandle *subWindow; QString windowName; - Double scaleFactor = qobject_cast( mdiArea->subWindowList().at( 0 ) )->getZoomFactor(); + Double scaleFactor = qobject_cast( mdiArea->subWindowList().at( 0 ) )->getScaleFactor(); for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); windowName = subWindow->getWindowName(); if( selectedWindows.contains( windowName ) ) { - 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 ) ); + VideoSubWindow* pcVideoSubWinodw = qobject_cast( subWindow ); + m_acPlayingSubWindows.append( pcVideoSubWinodw ); + pcVideoSubWinodw->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); + pcVideoSubWinodw->scaleView( scaleFactor ); } } - m_arrayActions[VIDEO_LOCK_ACT]->setChecked( true ); - //startPlay(); return; } } @@ -824,19 +718,7 @@ Void plaYUVerApp::normalSize() { if( m_pcCurrentSubWindow ) { -#if SYNCHRONISED_ZOON - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - m_acPlayingSubWindows.at( i )->normalSize(); - } - } - else -#endif - { - m_pcCurrentSubWindow->normalSize(); - } + m_pcCurrentSubWindow->normalSize(); updateZoomFactorSBox(); } } @@ -845,19 +727,8 @@ Void plaYUVerApp::zoomToFit() { if( m_pcCurrentSubWindow ) { -#if SYNCHRONISED_ZOON - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) - { - m_acPlayingSubWindows.at( i )->zoomToFit(); - } - } - else -#endif - { - m_pcCurrentSubWindow->zoomToFit(); - } + + m_pcCurrentSubWindow->zoomToFit(); updateZoomFactorSBox(); } } @@ -877,22 +748,8 @@ Void plaYUVerApp::scaleFrame( int ratio ) { if( m_pcCurrentSubWindow ) { -#if SYNCHRONISED_ZOON - 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 -#endif - { - m_pcCurrentSubWindow->scaleViewByRatio( ( Double )( ratio ) / 100.0 ); - } + 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 ); } } @@ -901,12 +758,25 @@ Void plaYUVerApp::setZoomFromSBox( double zoom ) Double lastZoom; if( activeSubWindow() ) { - lastZoom = activeSubWindow()->getViewArea()->getZoomFactor() * 100; + lastZoom = activeSubWindow()->getScaleFactor() * 100; if( zoom / lastZoom != 1.0 ) activeSubWindow()->scaleViewByRatio( zoom / lastZoom ); } } +Void plaYUVerApp::updateZoomFactorSBox() +{ + if( m_pcCurrentSubWindow ) + { + Double factor = m_pcCurrentSubWindow->getScaleFactor(); + m_pcZoomFactorSBox->setValue( factor * 100 ); + } + else + { + m_pcZoomFactorSBox->setValue( 0.0 ); + } +} + Void plaYUVerApp::chageSubWindowSelection() { SubWindowHandle *new_window = activeSubWindow(); @@ -916,29 +786,28 @@ Void plaYUVerApp::chageSubWindowSelection() { m_pcCurrentSubWindow = new_window; + m_pcCurrentVideoSubWindow = NULL; + switch( m_pcCurrentSubWindow->getCategory() ) + { + case SubWindowHandle::VIDEO_SUBWINDOW: + m_pcCurrentVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); + break; + } + setWindowTitle( QApplication::applicationName() + " - " + m_pcCurrentSubWindow->getWindowName() ); - if( ) - if( !plaYUVerApp::findSubWindow( mdiArea, m_pcCurrentSubWindow->getRefSubWindow() ) ) + if( m_pcCurrentVideoSubWindow ) { - m_pcCurrentSubWindow->setRefSubWindow( NULL ); + if( !plaYUVerApp::findSubWindow( mdiArea, m_pcCurrentVideoSubWindow->getRefSubWindow() ) ) + { + m_pcCurrentVideoSubWindow->setRefSubWindow( NULL ); + } + m_pcQualityMeasurement->updateCurrentWindow( m_pcCurrentVideoSubWindow ); } - updateCurrFrameNum(); - updateTotalFrameNum(); - updateStreamProperties(); - updateFrameProperties(); - updateZoomFactorSBox(); - - if( m_pcCurrentSubWindow->isPlaying() ) - m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); - else - m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); } - m_pcCurrentSubWindow = new_window; } updateStreamProperties(); - updateFrameProperties(); - m_pcQualityMeasurement->updateCurrentWindow( m_pcCurrentSubWindow ); + updateZoomFactorSBox(); m_pcQualityMeasurement->updateSubWindowList(); updateMenus(); } @@ -1000,26 +869,44 @@ SubWindowHandle *plaYUVerApp::activeSubWindow() return 0; } -VideoSubWindow* plaYUVerApp::findVideoSubWindow( const QMdiArea* mdiArea, const QString& fileName ) +template +T plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const QString& name ) { - QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); - - foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ - VideoSubWindow *mdiChild = qobject_cast( window); - if( mdiChild->getCurrentFileName() == canonicalFilePath ) - return mdiChild; -} + T subWindow; + QList subWindowList = mdiArea->findChildren(); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + subWindow = subWindowList.at( i ); + if( subWindow->getWindowName() == name ) + return subWindow; + } return 0; } -SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow ) +template +T plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const T subWindow ) { - foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ - SubWindowHandle *mdiChild = qobject_cast( window); - if( mdiChild == subWindow ) - return mdiChild; + QList subWindowList = mdiArea->findChildren(); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + if( subWindow == subWindowList.at( i ) ) + return subWindowList.at( i ); + } + return 0; } -return 0; + +VideoSubWindow* plaYUVerApp::findVideoSubWindow( const QMdiArea* mdiArea, const QString& fileName ) +{ + QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); + VideoSubWindow* pcVideoSubWindow; + QList videoSubWindowList = mdiArea->findChildren(); + for( Int i = 0; i < videoSubWindowList.size(); i++ ) + { + pcVideoSubWindow = videoSubWindowList.at( i ); + if( pcVideoSubWindow->getCurrentFileName() == canonicalFilePath ) + return pcVideoSubWindow; + } + return 0; } Void plaYUVerApp::setTool( Int idxTool ) @@ -1030,10 +917,10 @@ Void plaYUVerApp::setTool( Int idxTool ) Void plaYUVerApp::setAllSubWindowTool() { - foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ - SubWindowHandle *mdiChild = qobject_cast( window); - mdiChild->getViewArea()->setTool( m_appTool ); -} +// foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ +// SubWindowHandle *mdiChild = qobject_cast( window); +// mdiChild->getViewArea()->setTool( m_appTool ); +//} } Void plaYUVerApp::setActiveSubWindow( QWidget *window ) @@ -1069,7 +956,6 @@ Void plaYUVerApp::updateMenus() m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_LOOP_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[VIDEO_LOCK_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_LOCK_SELECTION_ACT]->setEnabled( hasSubWindow ); m_pcFrameSlider->setEnabled( hasSubWindow ); if( !hasSubWindow ) @@ -1277,11 +1163,6 @@ Void plaYUVerApp::createActions() m_arrayActions[VIDEO_LOOP_ACT]->setCheckable( true ); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( false ); - m_arrayActions[VIDEO_LOCK_ACT] = new QAction( "Video Lock", this ); - m_arrayActions[VIDEO_LOCK_ACT]->setCheckable( true ); - m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false ); - connect( m_arrayActions[VIDEO_LOCK_ACT], SIGNAL( triggered() ), this, SLOT( lockButtonEvent() ) ); - m_arrayActions[VIDEO_LOCK_SELECTION_ACT] = new QAction( "Video Lock Window Selection", this ); m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); connect( m_arrayActions[VIDEO_LOCK_SELECTION_ACT], SIGNAL( triggered() ), this, SLOT( videoSelectionButtonEvent() ) ); @@ -1415,7 +1296,6 @@ Void plaYUVerApp::createMenus() m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_FORWARD_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOOP_ACT] ); - m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_SELECTION_ACT] ); QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); @@ -1492,14 +1372,14 @@ Void plaYUVerApp::createDockWidgets() m_arraySideBars[STREAM_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); m_arraySideBars[STREAM_DOCK]->setWidget( m_pcStreamProperties ); addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[STREAM_DOCK] ); - connect( m_arraySideBars[STREAM_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); + connect( m_arraySideBars[STREAM_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateStreamProperties() ) ); m_pcFrameProperties = new FramePropertiesSideBar( this, &m_bIsPlaying ); m_arraySideBars[FRAME_DOCK] = new QDockWidget( tr( "Frame Information" ), this ); m_arraySideBars[FRAME_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); m_arraySideBars[FRAME_DOCK]->setWidget( m_pcFrameProperties ); addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[FRAME_DOCK] ); - connect( m_arraySideBars[FRAME_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); + connect( m_arraySideBars[FRAME_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateStreamProperties() ) ); QMainWindow::tabifyDockWidget( m_arraySideBars[FRAME_DOCK], m_arraySideBars[STREAM_DOCK] ); //QMainWindow::setTabPosition(Qt::RightDockWidgetArea, QTabWidget::North); @@ -1528,7 +1408,6 @@ Void plaYUVerApp::readSettings() //m_appTool = ( ViewArea::eTool )settings.getSelectedTool(); //setAllSubWindowTool(); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( settings.getRepeat() ); - m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false ); m_aRecentFileStreamInfo = settings.getRecentFileList(); updateRecentFileActions(); diff --git a/app/plaYUVerApp.h b/app/plaYUVerApp.h index ea59330..219d270 100644 --- a/app/plaYUVerApp.h +++ b/app/plaYUVerApp.h @@ -37,6 +37,7 @@ #include #include "lib/PlaYUVerDefs.h" #include "SubWindowHandle.h" +#include "VideoSubWindow.h" #include "ModulesHandle.h" #include "PropertiesSidebar.h" #include "QualityMeasurementSidebar.h" @@ -85,7 +86,7 @@ private Q_SLOTS: void playEvent(); void seekSliderEvent( int new_frame_num ); void seekEvent( int direction ); - void lockButtonEvent(); + void videoSelectionButtonEvent(); void ModuleHandling( QAction * ); @@ -97,14 +98,16 @@ private Q_SLOTS: */ void scaleFrame( int ratio = 100.0 ); void setZoomFromSBox( double ratio ); - void normalSize(); void zoomToFit(); - void about(); - void chageSubWindowSelection(); void updateWindowMenu(); + void updateZoomFactorSBox(); + void updateStreamProperties(); + + void about(); + void dragEnterEvent( QDragEnterEvent *event ); void dropEvent( QDropEvent *event ); @@ -112,11 +115,8 @@ private Q_SLOTS: void updatePixelValueStatusBar( const QPoint & pos, PlaYUVerFrame* frame ); - void updateProperties(); void updatePropertiesSelectedArea( QRect area ); - void updateZoomFactorSBox(); - void setAllSubWindowTool(); void setTool( int idxTool ); @@ -150,14 +150,18 @@ private: PlaYUVerAppAdaptor* m_pDBusAdaptor; PlaYUVerMdiArea *mdiArea; - SubWindowHandle *m_pcCurrentSubWindow; + + /** + * Save the current subwindow for every category + */ + SubWindowHandle* m_pcCurrentSubWindow; //!< General always set + VideoSubWindow* m_pcCurrentVideoSubWindow; + ModulesHandle *m_pcModulesHandle; QString m_cLastOpenPath; QTimer *m_pcPlayingTimer; Bool m_bIsPlaying; - QTime m_cTimer; - UInt m_uiAveragePlayInterval; Void readRecentFileList(); Void writeRecentFileList(); @@ -168,14 +172,10 @@ private: * Playing functions */ UInt64 getMaxFrameNumber(); - Void startPlay(); Void setTimerStatus(); - Void updateCurrFrameNum(); - Void updateTotalFrameNum(); + Void updateMenus(); - Void updateStreamProperties(); - Void updateFrameProperties(); Void updateRecentFileActions(); @@ -190,12 +190,16 @@ private: SubWindowHandle *activeSubWindow(); + template + T findSubWindow( const QMdiArea* mdiArea, const QString& name ); + template + T findSubWindow( const QMdiArea* mdiArea, const T subWindow ); + static VideoSubWindow* findVideoSubWindow( const QMdiArea* mdiArea, const QString& fileName ); - static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow ); QVector m_acPlayingSubWindows; - QSlider *m_pcFrameSlider; + QSlider* m_pcFrameSlider; WidgetFrameNumber* m_pcFrameNumInfo; QDoubleSpinBox *m_pcZoomFactorSBox; @@ -276,7 +280,6 @@ private: VIDEO_FORWARD_ACT, VIDEO_BACKWARD_ACT, VIDEO_LOOP_ACT, - VIDEO_LOCK_ACT, VIDEO_LOCK_SELECTION_ACT, NAVIGATION_TOOL_ACT, SELECTION_TOOL_ACT, diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index dd815bc..d1713e7 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -495,8 +495,7 @@ Void PlaYUVerStream::readFrame() if( bytes_read != frame_bytes_input ) { m_iErrorStatus = READING; - qDebug( ) << " Reading error !!!" - << endl; + throw "[PlaYUVerStream] Cannot read file"; return; } m_pcNextFrame->frameFromBuffer( m_pStreamBuffer, bytes_read );