From 6f489687edf3bac069da2faf8218c08dd2dbb84c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 2 Feb 2015 14:34:58 +0000 Subject: [PATCH] Change some functions in Modules and Video --- app/ModulesHandle.cpp | 25 +++++++++++------ app/VideoHandle.cpp | 2 -- app/VideoSubWindow.cpp | 64 +++++++++++++++++++++++++++++++----------- app/VideoSubWindow.h | 6 +++- 4 files changed, 68 insertions(+), 29 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 56535b5..76e05ea 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -29,7 +29,6 @@ #include "PlaYUVerModuleFactory.h" #include "DialogSubWindowSelector.h" - namespace plaYUVer { @@ -309,14 +308,15 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) pcModuleSubWindow->setWindowName( windowName ); connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); - connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) ); + connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, + SLOT( zoomToFactorAll( double, QPoint ) ) ); connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) ); connect( pcModuleSubWindow, SIGNAL( updateStatusBar( const QString& ) ), this, SLOT( updateStatusBar( const QString& ) ) ); connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( updateZoomFactorSBox() ) ); pcCurrModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow; - pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf, true ); + //m_pcMdiArea->addSubWindow( pcModuleSubWindow ); } } @@ -336,15 +336,22 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) } } - // Associate module with subwindows - for( UInt i = 0; i < numberOfFrames; i++ ) - { - pcCurrModuleIf->m_pcSubWindow[i]->enableModule( pcCurrModuleIf ); - } - // Create Module pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); + // Associate module with subwindows + if( pcCurrModuleIf->m_pcDisplaySubWindow ) + { + pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf, true ); + } + else + { + for( UInt i = 0; i < numberOfFrames; i++ ) + { + pcCurrModuleIf->m_pcSubWindow[i]->associateModule( pcCurrModuleIf ); + } + } + applyModuleIf( pcCurrModuleIf, false ); QCoreApplication::processEvents(); diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 029d20d..ac5edb5 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -231,8 +231,6 @@ Void VideoHandle::update() else { m_pcFrameNumInfo->setCurrFrameNum( 0 ); - if( m_pcCurrentVideoSubWindow->getIsModule() ) - m_pcVideoFormatLabel->setText( QString( "Module" ) ); } if( pcFrame ) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index bdab765..1b7c17a 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -75,6 +75,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW | category ), m_pCurrStream( NULL ), m_pcCurrFrame( NULL ), + m_pcCurrentDisplayModule( NULL ), m_pcReferenceSubWindow( NULL ), m_bIsPlaying( false ), m_bIsModule( category == MODULE_SUBWINDOW ) @@ -160,10 +161,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) m_cFilename = cFilename; m_cWindowShortName = QFileInfo( cFilename ).fileName(); - QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() ); - QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() ); - QString m_cPelFmtName = QString::fromStdString( m_pCurrStream->getPelFmtName() ); - m_cStreamInformation = m_cFormatName + " | " + m_cCodedName + " | " + m_cPelFmtName; + + updateVideoWindowInfo(); setWindowName( m_cWindowShortName ); return true; @@ -176,7 +175,8 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) m_pCurrStream = new PlaYUVerStream; } - if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, streamInfo->m_uiFrameRate ) ) + if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, + streamInfo->m_uiFrameRate ) ) { return false; } @@ -191,15 +191,30 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) m_cFilename = streamInfo->m_cFilename; m_cWindowShortName = QFileInfo( streamInfo->m_cFilename ).fileName(); - QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() ); - QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() ); - QString m_cPelFmtName = QString::fromStdString( m_pCurrStream->getPelFmtName() ); - m_cStreamInformation = m_cFormatName + " | " + m_cCodedName + " | " + m_cPelFmtName; + + updateVideoWindowInfo(); setWindowName( m_cWindowShortName ); return true; } +Void VideoSubWindow::updateVideoWindowInfo() +{ + if( !m_bIsModule && !m_pcCurrentDisplayModule) + { + QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() ); + QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() ); + QString m_cPelFmtName = QString::fromStdString( m_pCurrStream->getPelFmtName() ); + m_cStreamInformation = m_cFormatName + " | " + m_cCodedName + " | " + m_cPelFmtName; + } + else + { + QString m_cPelFmtName = QString::fromStdString( PlaYUVerFrame::supportedPixelFormatListNames()[m_pcCurrFrame->getPelFormat()].data() ); + m_cStreamInformation = "Module | " + m_cPelFmtName; + } + +} + Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { std::vector stdResList = PlaYUVerStream::stdResolutionSizes(); @@ -296,7 +311,6 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, return !bGuessed; } - Void VideoSubWindow::updateSelectedArea( QRect area ) { m_cSelectedArea = area; @@ -308,12 +322,12 @@ Void VideoSubWindow::updateSelectedArea( QRect area ) */ Void VideoSubWindow::enableModule( PlaYUVerAppModuleIf* pcModule, Bool bThisWindow ) { - if( bThisWindow ) + if( bThisWindow && m_pcCurrentDisplayModule) { - m_apcCurrentModule.clear(); - disableModule(); + disableModule( m_pcCurrentDisplayModule ); + m_pcCurrentDisplayModule = pcModule; + updateVideoWindowInfo(); } - m_apcCurrentModule.append( pcModule ); } Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) @@ -324,8 +338,8 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) if( modIdx != -1 ) { m_apcCurrentModule.removeAt( modIdx ); - ModulesHandle::destroyModuleIf( pcModule ); } + ModulesHandle::destroyModuleIf( pcModule ); } else { @@ -336,10 +350,22 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) ModulesHandle::destroyModuleIf( apcCurrentModule.at( i ) ); } assert( m_apcCurrentModule.size() == 0 ); + if( m_pcCurrentDisplayModule ) + { + pcModule = m_pcCurrentDisplayModule; + m_pcCurrentDisplayModule = 0; + ModulesHandle::destroyModuleIf( m_pcCurrentDisplayModule ); + } } + updateVideoWindowInfo(); refreshFrame(); } +Void VideoSubWindow::associateModule( PlaYUVerAppModuleIf* pcModule ) +{ + m_apcCurrentModule.append( pcModule ); +} + Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) { m_pcCurrFrame = pcCurrFrame; @@ -352,11 +378,15 @@ Void VideoSubWindow::refreshFrame() if( m_pCurrStream ) { m_pcCurrFrame = m_pCurrStream->getCurrFrame(); - bSetFrame = true; + bSetFrame = m_pcCurrFrame ? true : false; + } + if( m_pcCurrentDisplayModule ) + { + bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentDisplayModule, m_bIsPlaying ); } for( Int i = 0; i < m_apcCurrentModule.size(); i++ ) { - bSetFrame = ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); + ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); } if( bSetFrame ) { diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 5518778..77caabe 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -72,7 +72,7 @@ private: PlaYUVerFrame* m_pcCurrFrame; QRect m_cSelectedArea; - //PlaYUVerAppModuleIf* m_pcCurrentModule; + PlaYUVerAppModuleIf* m_pcCurrentDisplayModule; QList m_apcCurrentModule; VideoSubWindow* m_pcReferenceSubWindow; @@ -91,6 +91,8 @@ private: */ Void scaleView( const QSize & size, QPoint center = QPoint() ); + Void updateVideoWindowInfo(); + public: enum VideoSubWindowCategories { @@ -164,6 +166,8 @@ public: */ Void enableModule( PlaYUVerAppModuleIf* pcModule, Bool bThisWindow = true ); Void disableModule( PlaYUVerAppModuleIf* pcModule = NULL ); + Void associateModule( PlaYUVerAppModuleIf* pcModule ); + QList getModuleArray() { return m_apcCurrentModule;