From 78279015d46d3acedd9a9d22e5175b65109f86d8 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 19:48:17 +0000 Subject: [PATCH] Add progress bar to quality plots --- app/CMakeLists.txt | 1 + app/ConfigureFormatDialog.h | 4 --- app/ProgressBar.cpp | 60 +++++++++++++++++++++++++++++++++++++ app/ProgressBar.h | 53 ++++++++++++++++++++++++++++++++ app/QualityHandle.cpp | 8 ++++- 5 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 app/ProgressBar.cpp create mode 100644 app/ProgressBar.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 53c9f25..7494733 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -69,6 +69,7 @@ set(plaYUVer_App_SRCS AboutDialog.cpp ConfigureFormatDialog.cpp DialogSubWindowSelector.cpp + ProgressBar.cpp # Widgets HistogramWidget.cpp WidgetFrameNumber.cpp diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h index cb10ab4..7a745fd 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/ConfigureFormatDialog.h @@ -42,10 +42,6 @@ class QColor; namespace plaYUVer { -#define ADD_STANDARD_RESOLUTION( name, width, height) \ - standardResolutionNames.push_back( QString( name ) ); \ - standardResolutionSizesList.push_back( QSize( width, height ) ) - /** * */ diff --git a/app/ProgressBar.cpp b/app/ProgressBar.cpp new file mode 100644 index 0000000..c264599 --- /dev/null +++ b/app/ProgressBar.cpp @@ -0,0 +1,60 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ProgressBar.cpp + * \brief Progress bar code + */ + +#include "ProgressBar.h" +#include +#include +#include +#include +#include + +namespace plaYUVer +{ + +ProgressBar::ProgressBar( QWidget *parent, UInt maxValue ) : + QWidget( parent ), + m_uiTotalProgress( maxValue ), + m_uiProgress( 0 ) +{ + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + m_pcProgressBar = new QProgressBar; + m_pcProgressBar->setMaximum( m_uiTotalProgress ); + m_pcProgressBar->setAlignment( Qt::AlignCenter ); + mainLayout->addWidget( m_pcProgressBar ); + setLayout( mainLayout ); + setWindowTitle( QStringLiteral( "Progress" ) ); + + QSize screenSize = QApplication::desktop()->availableGeometry().size(); + QPoint screenCenter = QApplication::desktop()->availableGeometry().center(); + resize( screenSize.width() / 4, screenSize.height() / 10 ); + move( screenCenter.x() - screenSize.width() / 8, screenCenter.y() - screenSize.height() / 10 ); + show(); +} + +Void ProgressBar::incrementProgress( UInt increment ) +{ + m_uiProgress += increment; + m_pcProgressBar->setValue( m_uiProgress ); +} +} // NAMESPACE diff --git a/app/ProgressBar.h b/app/ProgressBar.h new file mode 100644 index 0000000..fffa430 --- /dev/null +++ b/app/ProgressBar.h @@ -0,0 +1,53 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ProgressBar.h + * \brief Progress bar code + */ + +#ifndef __PROGRESSBAR_H__ +#define __PROGRESSBAR_H__ + +#include "PlaYUVerAppDefs.h" +#include + +class QProgressBar; + +namespace plaYUVer +{ + +class ProgressBar: public QWidget +{ +Q_OBJECT + +public: + ProgressBar( QWidget *parent, UInt maxValue ); + + Void incrementProgress( UInt ); + +private: + UInt m_uiTotalProgress; + UInt m_uiProgress; + QProgressBar* m_pcProgressBar; +}; + +} // NAMESPACE + +#endif // __PROGRESSBAR_H__ diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 61b071b..a83d7bc 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -23,12 +23,13 @@ */ #include +#include "lib/LibMemory.h" #include "PlaYUVerSubWindowHandle.h" #include "QualityHandle.h" #include "VideoSubWindow.h" #include "PlotSubWindow.h" #include "DialogSubWindowSelector.h" -#include "lib/LibMemory.h" +#include "ProgressBar.h" #if( QT_VERSION_PLAYUVER == 5 ) #include "QtConcurrent/qtconcurrentrun.h" #endif @@ -169,6 +170,8 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) } pcReferenceWindow->stop(); + ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames ); + padQualityValues = new QVector [numberOfWindows + 1]; PlaYUVerFrame* pcReferenceFrame; @@ -184,6 +187,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) apcWindowList.at( i )->seekRelativeEvent( true ); } pcReferenceWindow->seekRelativeEvent( true ); + pcProgressBar->incrementProgress( 1 ); } for( UInt i = 0; i < numberOfWindows; i++ ) { @@ -216,6 +220,8 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) m_pcMainWindowManager->addSubWindow( pcPlotWindow ); pcPlotWindow->show(); + pcProgressBar->close(); + } Void QualityHandle::slotQualityMetricChanged( Int idx )