Merge branch 'develPlots' into devel

This commit is contained in:
jfmcarreira committed 2015-03-24 17:51:35 +00:00
commit 48bf385f4c
14 files changed
+554 -89

No files matched your search

+1
View File
@@ -70,6 +70,7 @@ set(plaYUVer_App_SRCS
AboutDialog.cpp
ConfigureFormatDialog.cpp
DialogSubWindowSelector.cpp
ProgressBar.cpp
# Widgets
HistogramWidget.cpp
WidgetFrameNumber.cpp
-4
View File
@@ -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 ) )
/**
*
*/
+3 -1
View File
@@ -257,7 +257,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
{
QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows();
VideoSubWindow *videoSubWindow;
QList<SubWindowHandle*> subWindowList = m_pcMainWindowManager->findSubWindow();
QList<SubWindowHandle*> subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
for( Int j = 0; j < selectedWindows.size(); j++ )
{
for( Int i = 0; i < subWindowList.size(); i++ )
@@ -430,6 +430,7 @@ Void ModulesHandle::destroyAllModulesIf()
Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isPlaying, Bool disableThreads )
{
Bool bRet = false;
QApplication::setOverrideCursor( Qt::WaitCursor );
if( !isPlaying || ( isPlaying && pcCurrModuleIf->m_pcModule->m_bApplyWhilePlaying ) )
{
#ifdef PLAYUVER_THREADED_MODULES
@@ -448,6 +449,7 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isP
{
bRet = true;
}
QApplication::restoreOverrideCursor();
return bRet;
}
+14 -10
View File
@@ -358,9 +358,9 @@ Void plaYUVerApp::format()
Void plaYUVerApp::reload()
{
if( m_pcCurrentVideoSubWindow )
if( m_pcCurrentSubWindow )
{
m_pcCurrentVideoSubWindow->reloadFile();
m_pcCurrentSubWindow->refreshSubWindow();
m_pcCurrentSubWindow = NULL;
update();
}
@@ -368,14 +368,18 @@ Void plaYUVerApp::reload()
Void plaYUVerApp::reloadAll()
{
VideoSubWindow *videoSubWindow;
QList<SubWindowHandle*> subWindowList = m_pcWindowHandle->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
UInt windowCategoryOrder[] =
{
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
if( !videoSubWindow->getIsModule() )
SubWindowHandle::VIDEO_STREAM_SUBWINDOW,
SubWindowHandle::MODULE_SUBWINDOW,
SubWindowHandle::MODULE_SUBWINDOW };
for( UInt c = 0; c < 3; c++ )
{
QList<SubWindowHandle*> subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] );
for( Int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow->reloadFile();
subWindowList.at( i )->refreshSubWindow();
}
}
m_pcCurrentSubWindow = NULL;
@@ -563,10 +567,10 @@ Void plaYUVerApp::updateMenus()
m_arrayActions[SAVE_ACT]->setEnabled( hasSubWindow );
m_arrayActions[CLOSE_ACT]->setEnabled( hasSubWindow );
m_arrayActions[CLOSEALL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[RELOAD_ACT]->setEnabled( hasSubWindow );
m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[FORMAT_ACT]->setEnabled( hasVideoStreamSubWindow );
m_arrayActions[RELOAD_ACT]->setEnabled( hasVideoStreamSubWindow );
m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow );
m_arrayActions[LOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow );
m_arrayActions[ZOOM_IN_ACT]->setEnabled( hasSubWindow );
+159 -50
View File
@@ -23,44 +23,65 @@
*/
#include "PlotSubWindow.h"
#include "qcustomplot.h"
namespace plaYUVer
{
PlotSubWindow::PlotSubWindow( QWidget * parent ) :
SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW )
Void PlotSubWindow::definePlotColors()
{
setParent( parent );
setAttribute( Qt::WA_DeleteOnClose );
setBackgroundRole( QPalette::Light );
setVisible( false );
m_cPlotArea = new QCustomPlot( this );
setWidget( m_cPlotArea );
Example();
m_arrayColorList.append( Qt::blue );
m_arrayColorList.append( Qt::red );
m_arrayColorList.append( Qt::green );
m_arrayColorList.append( Qt::black );
m_arrayColorList.append( Qt::cyan );
}
Void PlotSubWindow::Example()
PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) :
SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW )
{
// add two new graphs and set their look:
m_cPlotArea->addGraph();
m_cPlotArea->graph( 0 )->setPen( QPen( Qt::blue ) ); // line color blue for first graph
m_cPlotArea->graph( 0 )->setBrush( QBrush( QColor( 0, 0, 255, 20 ) ) ); // first graph will be filled with translucent blue
m_cPlotArea->addGraph();
m_cPlotArea->graph( 1 )->setPen( QPen( Qt::red ) ); // line color red for second graph
// generate some points of data (y0 for first, y1 for second graph):
QVector<double> x( 250 ), y0( 250 ), y1( 250 );
for( int i = 0; i < 250; ++i )
{
x[i] = i;
y0[i] = exp( -i / 150.0 ) * cos( i / 10.0 ); // exponentially decaying cosine
y1[i] = exp( -i / 150.0 ); // exponential envelope
}
definePlotColors();
m_uiNumberPlots = 0;
m_dScaleFactor = 1;
setWindowName( windowTitle );
m_cPlotArea = new QCustomPlot( this );
QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
sizePolicy.setHeightForWidth( m_cPlotArea->sizePolicy().hasHeightForWidth() );
m_cPlotArea->setSizePolicy( sizePolicy );
m_cPlotArea->setBackgroundRole( backgroundRole() );
QBrush backgroundBrush = palette().brush( backgroundRole() );
QBrush foregroundBrush = palette().brush( foregroundRole() );
m_cPlotArea->setBackground( backgroundBrush );
m_cPlotArea->xAxis->setLabelColor( palette().text().color() );
m_cPlotArea->yAxis->setLabelColor( palette().text().color() );
m_cPlotArea->xAxis->setTickLabelColor( palette().text().color() );
m_cPlotArea->yAxis->setTickLabelColor( palette().text().color() );
m_cPlotArea->xAxis->setBasePen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis->setBasePen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->xAxis->setTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis->setTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->xAxis->setSubTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis->setSubTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->xAxis2->setSubTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis2->setSubTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->xAxis2->setBasePen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis2->setBasePen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->xAxis2->setTickPen( QPen( foregroundBrush, 1 ) );
m_cPlotArea->yAxis2->setTickPen( QPen( foregroundBrush, 1 ) );
// configure right and top axis to show ticks but no labels:
// (see QCPAxisRect::setupFullAxesBox for a quicker method to do this)
m_cPlotArea->axisRect( 0 )->setupFullAxesBox( true );
m_cPlotArea->xAxis2->setVisible( true );
m_cPlotArea->xAxis2->setTickLabels( false );
m_cPlotArea->yAxis2->setVisible( true );
@@ -68,17 +89,22 @@ Void PlotSubWindow::Example()
// make left and bottom axes always transfer their ranges to right and top axes:
connect( m_cPlotArea->xAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->xAxis2, SLOT( setRange(QCPRange) ) );
connect( m_cPlotArea->yAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->yAxis2, SLOT( setRange(QCPRange) ) );
// pass data points to graphs:
m_cPlotArea->graph( 0 )->setData( x, y0 );
m_cPlotArea->graph( 1 )->setData( x, y1 );
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
m_cPlotArea->graph( 0 )->rescaleAxes();
// same thing for graph 1, but only enlarge ranges (in case graph 1 is smaller than graph 0):
m_cPlotArea->graph( 1 )->rescaleAxes( true );
// Note: we could have also just called m_cPlotArea->rescaleAxes(); instead
// Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking:
m_cPlotArea->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables );
QFont legendFont = font(); // start out with MainWindow's font..
legendFont.setPointSize( 9 ); // and make a bit smaller for legend
m_cPlotArea->legend->setFont( legendFont );
m_cPlotArea->legend->setBrush( backgroundBrush );
m_cPlotArea->legend->setTextColor( palette().text().color() );
m_cPlotArea->legend->setBorderPen( QPen( palette().brush( QPalette::Active, QPalette::Shadow ), 1 ) );
m_cPlotArea->legend->setVisible( false );
m_cPlotArea->setInteractions( QCP::iRangeZoom | QCP::iRangeDrag ); //QCP::iSelectPlottables
m_cPlotPen.setStyle( Qt::SolidLine );
m_cPlotPen.setColor( Qt::black );
m_cPlotPen.setWidthF( 2 );
setWidget( m_cPlotArea );
}
PlotSubWindow::~PlotSubWindow()
@@ -88,12 +114,15 @@ PlotSubWindow::~PlotSubWindow()
Void PlotSubWindow::normalSize()
{
m_cPlotArea->xAxis->setRange( m_aAxisRange[HORIZONTAL][0], m_aAxisRange[HORIZONTAL][1] );
m_cPlotArea->yAxis->setRange( m_aAxisRange[VERTICAL][0], m_aAxisRange[VERTICAL][1] );
m_cPlotArea->replot();
m_dScaleFactor = 1;
}
Void PlotSubWindow::zoomToFit()
{
normalSize();
}
Void PlotSubWindow::zoomToFactor( Double factor, QPoint center )
@@ -103,18 +132,98 @@ Void PlotSubWindow::zoomToFactor( Double factor, QPoint center )
Void PlotSubWindow::scaleView( Double scale, QPoint center )
{
scale -= 1;
scale /= 10;
scale += 1;
m_dScaleFactor *= scale;
//
// UInt aNewAxisRange[2][2];
// for( UInt axis = 0; axis < 2; axis++ )
// for( UInt dim = 0; dim < 2; dim++ )
// aNewAxisRange[axis][dim] = m_aAxisRange[axis][dim] / m_dScaleFactor;
//
// m_cPlotArea->xAxis->setRange( aNewAxisRange[HORIZONTAL][0], aNewAxisRange[HORIZONTAL][1] );
// m_cPlotArea->yAxis->setRange( aNewAxisRange[VERTICAL][0], aNewAxisRange[VERTICAL][1] );
m_cPlotArea->xAxis->scaleRange( scale, 0 );
m_cPlotArea->yAxis->scaleRange( scale, 0 );
m_cPlotArea->replot();
}
//QSize PlotSubWindow::sizeHint() const
//{
//
//}
//
//
//QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const
//{
//
//}
QSize PlotSubWindow::sizeHint() const
{
QSize maxSize;
QWidget *p = parentWidget();
if( p )
{
maxSize = p->size();
}
else
{
maxSize = QApplication::desktop()->availableGeometry().size();
}
return sizeHint( maxSize );
}
QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const
{
return maxSize * 2 / 3;
}
Void PlotSubWindow::setAxisName( const QString& nameAxisX, const QString& nameAxisY )
{
m_cPlotArea->xAxis->setLabel( nameAxisX );
m_cPlotArea->yAxis->setLabel( nameAxisY );
}
Void PlotSubWindow::setAxisRange( const QLine& axisLimits )
{
setAxisRange( HORIZONTAL, axisLimits.x1(), axisLimits.x2() );
setAxisRange( VERTICAL, axisLimits.y1(), axisLimits.y2() );
}
Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd )
{
if( eAxis == HORIZONTAL )
{
m_cPlotArea->xAxis->setRange( axisStart, axisEnd );
horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
m_aAxisRange[HORIZONTAL][0] = axisStart;
m_aAxisRange[HORIZONTAL][1] = axisEnd;
}
if( eAxis == VERTICAL )
{
m_cPlotArea->yAxis->setRange( axisStart, axisEnd );
verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 );
m_aAxisRange[VERTICAL][0] = axisStart;
m_aAxisRange[VERTICAL][1] = axisEnd;
}
m_cPlotArea->replot();
}
Void PlotSubWindow::addPlot( const QVector<Double> &arrayX, const QVector<Double> &arrayY, const QString& key )
{
QCPGraph *newPlot = m_cPlotArea->addGraph();
m_cPlotPen.setColor( m_arrayColorList.at( m_uiNumberPlots ) );
newPlot->setPen( m_cPlotPen ); // line style
// pass data points to graphs:
newPlot->setData( arrayX, arrayY );
// let the ranges scale themselves so graph 0 fits perfectly in the visible area:
newPlot->rescaleAxes( m_uiNumberPlots > 1 ? true : false );
if( !key.isEmpty() )
{
m_cPlotArea->legend->setVisible( true );
newPlot->setName( key );
}
m_aAxisRange[HORIZONTAL][0] = m_cPlotArea->xAxis->range().lower;
m_aAxisRange[HORIZONTAL][1] = m_cPlotArea->xAxis->range().upper;
m_aAxisRange[VERTICAL][0] = m_cPlotArea->yAxis->range().lower;
m_aAxisRange[VERTICAL][1] = m_cPlotArea->yAxis->range().upper;
m_uiNumberPlots++;
}
} // NAMESPACE
+35 -6
View File
@@ -33,7 +33,8 @@
#include <QtGui>
#endif
#include "SubWindowHandle.h"
#include "qcustomplot.h"
class QCustomPlot;
namespace plaYUVer
{
@@ -45,12 +46,30 @@ Q_OBJECT
private:
QCustomPlot* m_cPlotArea;
Void Example();
QVector<QColor> m_arrayColorList;
QPen m_cPlotPen;
enum Axis
{
HORIZONTAL,
VERTICAL,
};
Double m_aAxisRange[2][2];
Double m_dScaleFactor;
UInt m_uiNumberPlots;
public:
PlotSubWindow( QWidget * parent = 0 );
PlotSubWindow( QWidget * parent, const QString& windowTitle );
~PlotSubWindow();
Void definePlotColors();
Void refreshSubWindow()
{
}
Void setTool( UInt uiTool )
{
}
@@ -65,14 +84,24 @@ public:
Double getScaleFactor()
{
return 0;
return m_dScaleFactor;
}
/**
* Size related functions
*/
// QSize sizeHint() const;
// QSize sizeHint( const QSize & ) const;
QSize sizeHint() const;
QSize sizeHint( const QSize & ) const;
Void setAxisName( const QString& nameAxisX, const QString& nameAxisY );
Void setAxisRange( const QLine& axisLimits );
Void setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd );
Void setKey( const QString& key );
Void addPlot( const QVector<Double> &arrayX, const QVector<Double> &arrayY, const QString& key = QString() );
};
} // NAMESPACE
+60
View File
@@ -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 <QApplication>
#include <QLabel>
#include <QVBoxLayout>
#include <QProgressBar>
#include <QDesktopWidget>
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
+53
View File
@@ -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 <QWidget>
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__
+179 -9
View File
@@ -23,11 +23,16 @@
*/
#include <QtGui>
#include "lib/LibMemory.h"
#include "PlaYUVerSubWindowHandle.h"
#include "QualityHandle.h"
#include "VideoSubWindow.h"
#include "PlotSubWindow.h"
#include "DialogSubWindowSelector.h"
#include "ProgressBar.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include "QtConcurrent/qtconcurrentrun.h"
#endif
namespace plaYUVer
{
@@ -62,10 +67,16 @@ Void QualityHandle::createActions()
}
m_arrayActions.resize( TOTAL_ACT );
m_arrayActions[SELECT_CURR_REF_ACT] = new QAction( "Mark as Reference", this );
connect( m_arrayActions[SELECT_CURR_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectCurrentAsReference() ) );
m_arrayActions[SELECT_REF_ACT] = new QAction( "Select Reference", this );
connect( m_arrayActions[SELECT_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectReference() ) );
m_arrayActions[PLOT_QUALITY] = new QAction( "CREATE_PLOT", this );
connect( m_arrayActions[PLOT_QUALITY], SIGNAL( triggered() ), this, SLOT( slotCreatePlot() ) );
m_arrayActions[PLOT_QUALITY] = new QAction( "Plot Window's Quality", this );
connect( m_arrayActions[PLOT_QUALITY], SIGNAL( triggered() ), this, SLOT( slotPlotQualitySingle() ) );
m_arrayActions[PLOT_SEVERAL_QUALITY] = new QAction( "Plot Several Quality", this );
connect( m_arrayActions[PLOT_SEVERAL_QUALITY], SIGNAL( triggered() ), this, SLOT( slotPlotQualitySeveral() ) );
}
QMenu* QualityHandle::createMenu()
@@ -73,9 +84,11 @@ QMenu* QualityHandle::createMenu()
m_pcMenuQuality = new QMenu( "Quality", this );
m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" );
m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() );
m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] );
m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] );
//m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] );
m_pcMenuQuality->addSeparator();
//m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] );
m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] );
m_pcMenuQuality->addAction( m_arrayActions[PLOT_SEVERAL_QUALITY] );
return m_pcMenuQuality;
}
@@ -100,8 +113,11 @@ Void QualityHandle::updateMenus()
Bool hasSubWindow = pcSubWindow ? true : false;
m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow );
m_arrayActions[SELECT_CURR_REF_ACT]->setEnabled( hasSubWindow );
m_arrayActions[SELECT_REF_ACT]->setEnabled( hasSubWindow );
m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow );
m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasSubWindow );
m_pcQualityHandleSideBar->updateSideBar( hasSubWindow );
}
@@ -127,6 +143,87 @@ Void QualityHandle::update( VideoSubWindow* currSubWindow )
m_pcQualityHandleSideBar->updateCurrentWindow( currSubWindow );
}
Void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
{
QVector<Double>* padQualityValues;
UInt numberOfWindows = apcWindowList.size();
UInt64 currFrames = 0;
UInt64 numberOfFrames = INT_MAX;
//! Check reference window
for( UInt i = 0; i < numberOfWindows; i++ )
{
if( !apcWindowList.at( i )->getRefSubWindow() )
{
return;
}
}
VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow();
numberOfFrames = pcReferenceWindow->getInputStream()->getFrameNum();
for( UInt i = 0; i < numberOfWindows; i++ )
{
currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum();
if( currFrames < numberOfFrames )
numberOfFrames = currFrames;
apcWindowList.at( i )->stop();
}
pcReferenceWindow->stop();
ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames );
padQualityValues = new QVector<Double> [numberOfWindows + 1];
PlaYUVerFrame* pcReferenceFrame;
PlaYUVerFrame* pcCurrFrame;
for( UInt f = 0; f < numberOfFrames; f++ )
{
padQualityValues[0].append( f );
pcReferenceFrame = pcReferenceWindow->getCurrFrame();
for( UInt i = 0; i < numberOfWindows; i++ )
{
pcCurrFrame = apcWindowList.at( i )->getCurrFrame();
padQualityValues[i + 1].append( pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, LUMA ) );
apcWindowList.at( i )->seekRelativeEvent( true );
}
pcReferenceWindow->seekRelativeEvent( true );
pcProgressBar->incrementProgress( 1 );
}
for( UInt i = 0; i < numberOfWindows; i++ )
{
apcWindowList.at( i )->stop();
}
pcReferenceWindow->stop();
QString plotWindowTitle( QStringLiteral( "Quality" ) );
if( apcWindowList.size() == 1 )
{
plotWindowTitle += " - " + apcWindowList.at( 0 )->getWindowName();
}
PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet, plotWindowTitle );
pcPlotWindow->setAxisName( "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) );
if( apcWindowList.size() > 1 )
{
QString key;
for( UInt i = 0; i < numberOfWindows; i++ )
{
key = apcWindowList.at( i )->getWindowName();
pcPlotWindow->addPlot( padQualityValues[0], padQualityValues[i + 1], key );
}
}
else
{
pcPlotWindow->addPlot( padQualityValues[0], padQualityValues[1] );
}
m_pcMainWindowManager->addSubWindow( pcPlotWindow );
pcPlotWindow->show();
pcProgressBar->close();
}
Void QualityHandle::slotQualityMetricChanged( Int idx )
{
m_actionGroupQualityMetric->actions().at( idx )->setChecked( true );
@@ -135,6 +232,24 @@ Void QualityHandle::slotQualityMetricChanged( Int idx )
m_iQualityMetricIdx = idx;
}
Void QualityHandle::slotSelectCurrentAsReference()
{
VideoSubWindow* pcRefSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
if( pcRefSubWindow )
{
VideoSubWindow* pcVideoSubWindow;
QList<SubWindowHandle*> subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
if( pcVideoSubWindow != pcRefSubWindow )
pcVideoSubWindow->setRefSubWindow( pcRefSubWindow );
}
m_pcQualityHandleSideBar->updateSidebarData();
m_pcQualityHandleDock->show();
}
}
Void QualityHandle::slotSelectReference()
{
DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 );
@@ -156,19 +271,74 @@ Void QualityHandle::slotSelectReference()
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
pcVideoSubWindow->setRefSubWindow( pcRefSubWindow );
if( pcVideoSubWindow != pcRefSubWindow )
pcVideoSubWindow->setRefSubWindow( pcRefSubWindow );
}
m_pcQualityHandleSideBar->updateSidebarData();
m_pcQualityHandleDock->show();
}
}
Void QualityHandle::slotCreatePlot()
Void QualityHandle::slotPlotQualitySingle()
{
PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet );
m_pcMainWindowManager->addSubWindow( pcPlotWindow );
pcPlotWindow->show();
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow *>( m_pcMainWindowManager->activeSubWindow() );
if( pcSubWindow )
{
if( pcSubWindow->getRefSubWindow() )
{
QVector<VideoSubWindow*> apcWindowList;
apcWindowList.append( pcSubWindow );
//#ifndef QT_NO_CONCURRENT
// m_cMeasurementResult.waitForFinished();
// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
//#else
QApplication::setOverrideCursor( Qt::WaitCursor );
measureQuality( apcWindowList );
QApplication::restoreOverrideCursor();
//#endif
}
}
}
Void QualityHandle::slotPlotQualitySeveral()
{
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow *>( m_pcMainWindowManager->activeSubWindow() );
if( pcSubWindow )
{
QVector<VideoSubWindow*> apcWindowList;
VideoSubWindow* pcRefSubWindow = pcSubWindow->getRefSubWindow();
if( !pcRefSubWindow )
{
pcRefSubWindow = pcSubWindow;
}
VideoSubWindow* pcVideoSubWindow;
QList<SubWindowHandle*> subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast<VideoSubWindow *>( subWindowList.at( i ) );
if( pcVideoSubWindow->getRefSubWindow() == pcRefSubWindow )
{
apcWindowList.append( pcVideoSubWindow );
}
}
if( apcWindowList.size() > 0 )
{
//#ifndef QT_NO_CONCURRENT
// m_cMeasurementResult.waitForFinished();
// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList );
//#else
QApplication::setOverrideCursor( Qt::WaitCursor );
measureQuality( apcWindowList );
QApplication::restoreOverrideCursor();
//#endif
}
}
}
} // NAMESPACE
+10 -1
View File
@@ -33,6 +33,7 @@
#elif( QT_VERSION_PLAYUVER == 4 )
#include <QtGui>
#endif
#include "QFuture"
#include "QualityMeasurementSidebar.h"
namespace plaYUVer
@@ -61,10 +62,13 @@ public:
private:
QWidget* m_pcParet;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
enum
{
SELECT_CURR_REF_ACT,
SELECT_REF_ACT,
PLOT_QUALITY,
PLOT_SEVERAL_QUALITY,
TOTAL_ACT,
};
QVector<QAction*> m_arrayActions;
@@ -78,13 +82,18 @@ private:
QDockWidget* m_pcQualityHandleDock;
QualityMeasurementSidebar* m_pcQualityHandleSideBar;
QFuture<Void> m_cMeasurementResult;
Void measureQuality( QVector<VideoSubWindow*> apcWindowList );
Q_SIGNALS:
void changed();
private Q_SLOTS:
void slotQualityMetricChanged( int );
void slotSelectCurrentAsReference();
void slotSelectReference();
void slotCreatePlot();
void slotPlotQualitySingle();
void slotPlotQualitySeveral();
};
} // NAMESPACE
+1
View File
@@ -32,6 +32,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) :
m_cSubWindow( NULL )
{
setParent( parent );
setVisible( false );
setFocusPolicy( Qt::WheelFocus );
setAttribute( Qt::WA_DeleteOnClose );
setBackgroundRole( QPalette::Background );
+22
View File
@@ -76,6 +76,11 @@ public:
SubWindowHandle( QWidget *, UInt );
~SubWindowHandle();
/**
* Show the image at its original size
*/
virtual Void refreshSubWindow() = 0;
/**
* Show the image at its original size
*/
@@ -117,11 +122,28 @@ public:
virtual Bool mayClose();
/**
* Get category of the SubWindow
* @return category value based on enum SubWindowCategories
* @note This function should be used with enum SubWindowCategories
* with an & operation and it may belong to several categories
*/
UInt getCategory()
{
return m_uiCategory;
}
/**
* Check category of the SubWindow
* @param checkCateory SubWindow category to check against;
* it should be enum SubWindowCategories type
* @return true when SubWindow belong to checkCateory
*/
Bool checkCategory( UInt checkCateory )
{
return m_uiCategory & checkCateory;
}
Void setSubWindow( PlaYUVerMdiSubWindow* subWindow )
{
m_cSubWindow = subWindow;
+15 -7
View File
@@ -84,7 +84,6 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget
m_bIsPlaying( false ),
m_bIsModule( category == MODULE_SUBWINDOW )
{
setVisible( false );
// Create a new interface to show images
m_cViewArea = new ViewArea( this );
@@ -122,11 +121,22 @@ Void VideoSubWindow::loadAll()
refreshFrame();
}
Void VideoSubWindow::reloadFile()
Void VideoSubWindow::refreshSubWindow()
{
Int currFrameNum = m_pCurrStream->getCurrFrameNum();
loadFile( m_cFilename, false );
seekAbsoluteEvent( currFrameNum );
if( getCategory() & SubWindowHandle::VIDEO_STREAM_SUBWINDOW )
{
Int currFrameNum = m_pCurrStream->getCurrFrameNum();
if( !loadFile( m_cFilename, false ) )
{
close();
return;
}
seekAbsoluteEvent( currFrameNum );
}
else
{
refreshFrame();
}
}
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
@@ -145,8 +155,6 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
return false;
}
}
QApplication::setOverrideCursor( Qt::WaitCursor );
QApplication::restoreOverrideCursor();
if( !m_pCurrStream )
{
+2 -1
View File
@@ -117,9 +117,10 @@ public:
Bool loadFile( QString cFilename, Bool bForceDialog = false );
Bool loadFile( PlaYUVerStreamInfo* streamInfo );
Void loadAll();
Void reloadFile();
Bool save( QString filename );
Void refreshSubWindow();
Bool play();
Void pause();
Bool playEvent();