diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index d2ff4b0..6470667 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -23,6 +23,7 @@ */ #include +#include "PlaYUVerApp.h" #include "ModulesHandle.h" #include "PlaYUVerSubWindowHandle.h" #include "VideoSubWindow.h" @@ -296,7 +297,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( videoSubWindowList.size() == 0 ) { - qobject_cast( m_pcParent )->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); + qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be applied", LOG_ERROR ); destroyModuleIf( pcCurrModuleIf ); return; } @@ -335,7 +336,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( !moduleCreated ) { - qobject_cast( m_pcParent )->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); + qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be applied", LOG_ERROR ); destroyModuleIf( pcCurrModuleIf ); return; } diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 298179c..d00aaae 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -192,7 +192,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) { if( !QFileInfo( fileName ).exists() ) { - statusBar()->showMessage( "File " + fileName + " do not exist!", 2000 ); + printMessage( "File " + fileName + " do not exist!", LOG_ERROR ); return; } VideoSubWindow *videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); @@ -220,7 +220,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) if( opened ) { - statusBar()->showMessage( tr( "Loading file..." ) ); + printMessage( "Loading file...", LOG_INFO ); m_pcWindowHandle->addSubWindow( videoSubWindow ); videoSubWindow->show(); @@ -236,7 +236,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) addStreamInfoToRecentList( videoSubWindow->getStreamInfo() ); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); + printMessage( "File loaded", LOG_INFO ); m_cLastOpenPath = QFileInfo( fileName ).path(); } else @@ -249,8 +249,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) videoSubWindow->close(); QString warningMsg = "Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + msg; QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - statusBar()->showMessage( warningMsg, 2000 ); - qDebug( ) << warningMsg; + printMessage( warningMsg, LOG_ERROR ); } } @@ -359,7 +358,7 @@ Void PlaYUVerApp::format() { 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 ); + printMessage( warningMsg, LOG_ERROR ); qDebug( ) << warningMsg; m_pcCurrentSubWindow->close(); } @@ -402,9 +401,9 @@ Void PlaYUVerApp::loadAll() { if( m_pcCurrentVideoSubWindow ) { - statusBar()->showMessage( tr( "Loading file into memory ..." ) ); + printMessage( "Loading file into memory...", LOG_INFO ); m_pcCurrentVideoSubWindow->loadAll(); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); + printMessage( "File loaded", LOG_INFO ); } } @@ -553,16 +552,25 @@ Void PlaYUVerApp::update() updateMenus(); } -Void PlaYUVerApp::updateStatusBar( const QString& statusBarString ) +Void PlaYUVerApp::printMessage( const QString& msg ) { - if( !statusBarString.isEmpty() ) + printMessage( msg, 0 ); +} + +Void PlaYUVerApp::printMessage( const QString& msg, UInt logLevel ) +{ + if( !msg.isEmpty() ) { - statusBar()->showMessage( statusBarString, 5000 ); - } - else - { - statusBar()->showMessage( " " ); + statusBar()->showMessage( msg, 5000 ); + if( logLevel >= LOG_INFO ) + { + m_pcWindowHandle->processLogMsg( msg ); + } } +// else +// { +// statusBar()->showMessage( " " ); +// } } Void PlaYUVerApp::updateMenus() @@ -855,9 +863,9 @@ Void PlaYUVerApp::createDockWidgets() Void PlaYUVerApp::createStatusBar() { -//! Warning: the following widget cannot change size too much + //! Warning: the following widget cannot change size too much statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); - statusBar()->showMessage( tr( "Ready" ) ); + printMessage( "Ready!", LOG_INFO ); } Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index 8160ed1..be14e14 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -77,6 +77,10 @@ public: Bool parseArgs( Int argc, Char *argv[] ); Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); +public Q_SLOTS: + void printMessage( const QString& msg ); + void printMessage( const QString& msg, UInt logLevel ); + protected: Void closeEvent( QCloseEvent *event ); @@ -114,7 +118,6 @@ private Q_SLOTS: void update(); void updateZoomFactorSBox(); - void updateStatusBar( const QString& ); private: diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 9289c21..f377814 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -22,8 +22,8 @@ * \brief Handle multiple sub-windows */ -#include "PlaYUVerApp.h" #include "PlaYUVerSubWindowHandle.h" +#include "PlaYUVerApp.h" #include "PlaYUVerMdiSubWindow.h" #include "SubWindowAbstract.h" @@ -39,6 +39,14 @@ public: { setBackgroundRole( QPalette::Background ); } + + Void appendLogMessage( const QString& msg ) + { + m_acLogMessages.push_front( msg ); + if( m_acLogMessages.size() > 5 ) + m_acLogMessages.removeLast(); + update(); + } protected: void paintEvent( QPaintEvent *event ) { @@ -49,9 +57,15 @@ protected: int x = width() / 2 - pixFinalLogo.width() / 2; int y = height() / 2 - pixFinalLogo.height() / 2; painter.drawPixmap( x, y, pixFinalLogo ); + +// for( Int i = 0; i < m_acLogMessages.size(); i++ ) +// { +// painter.drawText( 5, height() - 5 - i * 15, m_acLogMessages.at( i ) ); +// } // QPoint bottomLeftCorner( 0, viewport()->height() ); } private: + QVector m_acLogMessages; QPixmap m_pixmapLogo; }; @@ -70,6 +84,14 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : setWindowMode( MDISUBWINDOWMODE ); } +Void PlaYUVerSubWindowHandle::processLogMsg( const QString& msg ) +{ + if( m_pcMdiArea ) + { + m_pcMdiArea->appendLogMessage( msg ); + } +} + Void PlaYUVerSubWindowHandle::resetWindowMode() { QList apcSubWindowList = m_apcSubWindowList; @@ -198,7 +220,7 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::Windo { if( window ) { - connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( updateStatusBar( const QString& ) ) ); + connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( printMessage( const QString& ) ) ); connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) ); if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 6a55969..ad7412f 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -48,6 +48,8 @@ Q_OBJECT public: PlaYUVerSubWindowHandle( QWidget *parent ); + Void processLogMsg( const QString& msg ); + Void addSubWindow( SubWindowAbstract *widget, Qt::WindowFlags flags = 0 ); SubWindowAbstract *activeSubWindow() const; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index fabacf1..7d53411 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -22,6 +22,7 @@ * \brief Class to handle video playback */ +#include "PlaYUVerApp.h" #include "VideoHandle.h" #include "VideoSubWindow.h" #include "PlaYUVerSubWindowHandle.h" diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 0d597d6..00c2985 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -106,6 +106,14 @@ typedef UChar Byte; // PlaYUVer definitions // ==================================================================================================================== +enum LOG_LEVEL +{ + LOG_INFO = 1, + LOG_WARNINGS = 2, + LOG_RESULT = 3, + LOG_ERROR = 4, +}; + enum YUVcomponent { LUMA = 0, diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index 75fb37c..70fad11 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -84,7 +84,7 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) if( m_bQuiet ) { - m_uiLogLevel = RESULT; + m_uiLogLevel = LOG_RESULT; } if( Opts()["module"]->count() && Opts()["help"]->count() ) diff --git a/tools/CommandLineHandle.h b/tools/CommandLineHandle.h index e778d1e..df25f05 100644 --- a/tools/CommandLineHandle.h +++ b/tools/CommandLineHandle.h @@ -42,13 +42,6 @@ public: CommandLineHandle(); ~CommandLineHandle(); - enum LOG_LEVEL - { - INFO = 0, - WARNINGS = 1, - RESULT = 2, - ERROR = 3, - }; Void setLogLevel( enum LOG_LEVEL level ) { m_uiLogLevel = level; diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 547561b..0f37c51 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -81,14 +81,14 @@ Int PlaYUVerTools::openInputs() { if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 8, 1 ) ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); + m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2; } m_apcInputStreams.push_back( pcStream ); } catch( const char *msg ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); + m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); return 2; } } @@ -134,7 +134,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric; // if( m_apcInputStreams.size() != 2 ) // { -// m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); +// m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); // return 2; // } for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) @@ -146,12 +146,12 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( m_uiQualityMetric == -1 ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid quality metric! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Invalid quality metric! " ); return 2; } m_uiOperation = QUALITY_OPERATION; m_fpProcess = &PlaYUVerTools::QualityOperation; - m_cCmdLineHandler.log( CommandLineHandle::INFO, "PlaYUVer Quality\n" ); + m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Quality\n" ); } /** @@ -174,7 +174,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) if( m_apcInputStreams.size() != m_pcCurrModuleIf->m_uiNumberOfFrames ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); return 2; } @@ -198,7 +198,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( !moduleCreated ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Module is not supported with the selected inputs! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Module is not supported with the selected inputs! " ); return 2; } @@ -231,19 +231,19 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } else { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "One output is required! " ); + m_cCmdLineHandler.log( LOG_ERROR, "One output is required! " ); return 2; } } m_uiOperation = MODULE_OPERATION; m_fpProcess = &PlaYUVerTools::ModuleOperation; - m_cCmdLineHandler.log( CommandLineHandle::INFO, "PlaYUVer Module\n" ); + m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Module\n" ); } if( m_uiOperation == INVALID_OPERATION ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "No operation was selected! " ); + m_cCmdLineHandler.log( LOG_ERROR, "No operation was selected! " ); return 2; } return iRet; @@ -267,8 +267,7 @@ Int PlaYUVerTools::QualityOperation() Double adAverageQuality[MAX_NUMBER_INPUTS - 1][MAX_NUMBER_COMPONENTS]; Double dQuality; - m_cCmdLineHandler.log( CommandLineHandle::INFO, " Measuring Quality using %s ... \n", - PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str() ); + m_cCmdLineHandler.log( LOG_INFO, " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str() ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { @@ -280,21 +279,21 @@ Int PlaYUVerTools::QualityOperation() } for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); + m_cCmdLineHandler.log( LOG_INFO, " %3d", frame ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame(); for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) { - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " " ); + m_cCmdLineHandler.log( LOG_RESULT, " " ); for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { dQuality = apcCurrFrame[s]->getQuality( m_uiQualityMetric, apcCurrFrame[0], c ); adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * Double( frame ) + dQuality ) / Double( frame + 1 ); - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %5.3f", dQuality ); + m_cCmdLineHandler.log( LOG_RESULT, " %5.3f", dQuality ); } } - m_cCmdLineHandler.log( CommandLineHandle::RESULT, "\n" ); + m_cCmdLineHandler.log( LOG_RESULT, "\n" ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = m_apcInputStreams[s]->setNextFrame(); @@ -304,15 +303,15 @@ Int PlaYUVerTools::QualityOperation() } } } - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n Mean Values: \n " ); + m_cCmdLineHandler.log( LOG_INFO, "\n Mean Values: \n " ); for( UInt s = 0; s < m_apcInputStreams.size() - 1; s++ ) { for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %5.3f", adAverageQuality[s][c] ); + m_cCmdLineHandler.log( LOG_INFO, " %5.3f", adAverageQuality[s][c] ); } } - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n" ); + m_cCmdLineHandler.log( LOG_INFO, "\n" ); return 0; } @@ -329,7 +328,7 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() Int PlaYUVerTools::ModuleOperation() { std::vector apcFrameList; - m_cCmdLineHandler.log( CommandLineHandle::INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); + m_cCmdLineHandler.log( LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); PlaYUVerFrame* pcProcessedFrame = NULL; Double dMeasurementResult = 0.0; @@ -370,8 +369,8 @@ Int PlaYUVerTools::ModuleOperation() { dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); } - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %8.3f \n", dMeasurementResult ); + m_cCmdLineHandler.log( LOG_INFO, " %3d", frame ); + m_cCmdLineHandler.log( LOG_RESULT, " %8.3f \n", dMeasurementResult ); dAveragedMeasurementResult = ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 ); } @@ -387,7 +386,7 @@ Int PlaYUVerTools::ModuleOperation() if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); + m_cCmdLineHandler.log( LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); } return 0;