diff --git a/CMakeLists.txt b/CMakeLists.txt
index 535f465..d82dffc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ SET( PROJECT_NAME "playuver" )
PROJECT( ${PROJECT_NAME} )
SET( PLAYUVER_VERSION_MAJOR "0" )
SET( PLAYUVER_VERSION_MINOR "6" )
-SET( PLAYUVER_VERSION_PATCH "0" )
+SET( PLAYUVER_VERSION_PATCH "3" )
SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}")
diff --git a/README.md b/README.md
index 0de8b61..b6a1604 100644
--- a/README.md
+++ b/README.md
@@ -7,12 +7,33 @@ plaYUVer is an open-source video player with the following features:
- Support for wide range of raw video formats;
- Support for OpenCV imag/video processing library
- Advanced frame zoom with easy to use pan function
+- Synchronized zoom across several videos (perfect for comparison operations)
- Usefull information in status bar, *e.g.*, pixel information
-- Usefull sidebars with stream and frame information, *e.g.*, frame histogram
+ Usefull sidebars with frame information, *e.g.*, frame histogram
- Constant growing libs for stream and frame processing (PlaYUVerStream PlaYUVerFrame)
- Advanced API for frame/video processing algorithms
- Frame level quality measurement API based on the PlaYUVerFrame class
+- Command-line tool for quality and frame processing algorithms (uses the referred APIs)
+Supported Quality Metrics
+----------------------------------------------------------------
+- PSNR
+- SSIM
+- MSE
+
+Frame Processing Modules
+----------------------------------------------------------------
+- FilterComponentLuma
+- FilterComponentChromaU
+- FilterComponentChromaV
+- FrameDifference
+- AbsoluteFrameDifference
+- FrameCrop
+- FrameBinarization
+- EightBitsSampling
+- LumaAverage
+- DisparityStereoVar
+- DisparityStereoBM
Developers
----------------------------------------------------------------
@@ -21,25 +42,20 @@ Developers
- LuiĀs Lucas (luisfrlucas@gmail.com)
-Builds
+Build
----------------------------------------------------------------
Download update build for windows and linux from our SourceForge project page
+Building yourself
-Build/Install using cmake
-----------------------------------------------------------------
-
-1. The following are required for compilation:
+1. Dependencies
- an ordinary C++ development environment (g++, make, C++ libraries and headers, ...)
- cmake
- a Qt development environment (libraries, headers, qmake, ...): only QtCore, QtGui and QtWidgets are required, at least in version 4
-
-2. Optional Dependencies:
- - QtDBus
- - OpenCv
- - FFmpeg
-
-3. Run the following commands: (this will create an executable named playuver)
+ - QtDBus (optional)
+ - OpenCv (optional)
+ - FFmpeg (optional)
+2. Example configuration command
```
mkdir build
cd build
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 53c9f25..7eccdda 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -45,16 +45,16 @@ ENDIF()
set(plaYUVer_App_SRCS
# Main
main.cpp
- plaYUVerApp.cpp
+ PlaYUVerApp.cpp
PlaYUVerSubWindowHandle.cpp
PlaYUVerMdiSubWindow.cpp
- SubWindowHandle.cpp
+ SubWindowAbstract.cpp
Settings.cpp
# Module Video
VideoSubWindow.cpp
ViewArea.cpp
VideoHandle.cpp
- FramePropertiesSidebar.cpp
+ FramePropertiesDock.cpp
# Module Quality
QualityHandle.cpp
QualityMeasurementSidebar.cpp
@@ -62,6 +62,7 @@ set(plaYUVer_App_SRCS
external/qcustomplot.cpp
# Module Plugins
ModulesHandle.cpp
+ ModulesHandleOptDialog.cpp
ModuleHandleDock.cpp
PlaYUVerAppModuleIf.cpp
GridManager.cpp
@@ -69,6 +70,7 @@ set(plaYUVer_App_SRCS
AboutDialog.cpp
ConfigureFormatDialog.cpp
DialogSubWindowSelector.cpp
+ ProgressBar.cpp
# Widgets
HistogramWidget.cpp
WidgetFrameNumber.cpp
diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp
index e5dc4fa..ab3caf4 100644
--- a/app/ConfigureFormatDialog.cpp
+++ b/app/ConfigureFormatDialog.cpp
@@ -32,16 +32,6 @@ namespace plaYUVer
ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
QDialog( parent )
{
- QFont titleFont, menusFont;
-
- titleFont.setPointSize( 14 );
- titleFont.setBold( true );
- titleFont.setWeight( 75 );
-
- menusFont.setBold( true );
- menusFont.setWeight( 75 );
-
-
QString Name;
UInt uiWidth, uiHeight;
std::vector listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes();
@@ -51,174 +41,238 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
uiWidth = listPlaYUVerStdResolution[i].uiWidth;
uiHeight = listPlaYUVerStdResolution[i].uiHeight;
standardResolutionNames.append( QString( "%1 (%2x%3)" ).arg( Name ).arg( uiWidth ).arg( uiHeight ) );
- standardResolutionSizes.append( QSize( uiWidth, uiHeight) );
+ standardResolutionSizes.append( QSize( uiWidth, uiHeight ) );
}
setObjectName( "ConfigureFormat" );
- resize( 400, 370 );
setWindowTitle( "Configure Resolution" );
setWindowIcon( QIcon( ":/images/configureformat.png" ) );
QVBoxLayout* MainLayout = new QVBoxLayout( this );
- MainLayout->setObjectName( QStringLiteral( "MainLayout" ) );
- // headLayout
- QHBoxLayout* headLayout = new QHBoxLayout();
- QLabel* dialogTitleLabel = new QLabel();
- dialogTitleLabel->setFont( titleFont );
- dialogTitleLabel->setText( "Configure Resolution" );
- QLabel* dialogIconLabel = new QLabel();
- dialogIconLabel->setObjectName( QStringLiteral( "dialogIconLabel" ) );
- dialogIconLabel->setPixmap( QPixmap( ":/images/dialogheader-grid.png" ) );
- headLayout->addWidget( dialogTitleLabel );
- headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- headLayout->addWidget( dialogIconLabel );
+ QFont titleFont, menusFont, normalFont;
- MainLayout->addLayout( headLayout );
+ titleFont.setPointSize( 12 );
+ titleFont.setBold( true );
+ titleFont.setWeight( 75 );
- MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
+ menusFont.setBold( true );
+ titleFont.setWeight( 75 );
- // Filename layout
-// QHBoxLayout* filenameLayout = new QHBoxLayout();
-// QLabel* filenameLabel = new QLabel();
-// filenameLabel->setText( "Name" );
-// filenameLabel->setFont( menusFont );
-// m_labelFilename = new QLabel();
-// m_labelFilename->setText( "Test" );
-// filenameLayout->addWidget( filenameLabel );
-// filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
-// filenameLayout->addWidget( m_labelFilename );
- //MainLayout->addLayout( filenameLayout );
+ normalFont.setBold( false );
+ // menusFont.setPointSize( 12 );
+
+// // headLayout
+// QHBoxLayout* headLayout = new QHBoxLayout();
+// QLabel* dialogTitleLabel = new QLabel();
+// dialogTitleLabel->setFont( titleFont );
+// dialogTitleLabel->setText( "Configure Resolution" );
+// headLayout->addWidget( dialogTitleLabel );
+// headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+//
+// MainLayout->addLayout( headLayout );
+// MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
+
+ /*
+ * Filename layout
+ */
+ QHBoxLayout* filenameLayout = new QHBoxLayout();
+ QLabel* filenameLabel = new QLabel();
+ filenameLabel->setText( "Name" );
+ filenameLabel->setFont( menusFont );
+ m_labelFilename = new QLabel();
+ m_labelFilename->setFont( titleFont );
+ filenameLayout->addWidget( filenameLabel );
+ filenameLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ filenameLayout->addWidget( m_labelFilename );
+ MainLayout->addLayout( filenameLayout );
- // standardResolutionLayout
- MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
- QHBoxLayout* standardResolutionLayout = new QHBoxLayout();
- QLabel* standardResolutionLabel = new QLabel();
- standardResolutionLabel->setText( "Standard Resolution" );
- standardResolutionLabel->setFont( menusFont );
- m_comboBoxStandardResolution = new QComboBox();
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
- sizePolicy.setHeightForWidth( m_comboBoxStandardResolution->sizePolicy().hasHeightForWidth() );
+
+ /*
+ * Resolution
+ */
+ QGroupBox* resolutionGroup = new QGroupBox();
+ resolutionGroup->setTitle( QStringLiteral( "Resolution" ) );
+ resolutionGroup->setFont( menusFont );
+
+ QGridLayout* resolutionGrid = new QGridLayout();
+ resolutionGroup->setLayout( resolutionGrid );
+
+ m_comboBoxStandardResolution = new QComboBox();
+
+ m_comboBoxStandardResolution->setFont( normalFont );
m_comboBoxStandardResolution->setSizePolicy( sizePolicy );
m_comboBoxStandardResolution->setAcceptDrops( true );
m_comboBoxStandardResolution->clear();
m_comboBoxStandardResolution->insertItems( 0, standardResolutionNames );
m_comboBoxStandardResolution->setCurrentIndex( -1 );
- standardResolutionLayout->addWidget( standardResolutionLabel );
- standardResolutionLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- standardResolutionLayout->addWidget( m_comboBoxStandardResolution );
- MainLayout->addLayout( standardResolutionLayout );
-
- // Resolution Grid
- //resolutionGridVerticalSpacer = new QSpacerItem( 10, 20, QSizePolicy::Minimum );
- MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
-
- QGridLayout* resolutionGrid = new QGridLayout();
-
- QLabel* resolutionLabel = new QLabel();
- resolutionLabel->setFont( menusFont );
- resolutionLabel->setText( "Resolution chosen" );
- resolutionLabel->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
QLabel* widthLabel = new QLabel( "Width" );
+ widthLabel->setFont( normalFont );
m_spinBoxWidth = new QSpinBox();
- m_spinBoxWidth->setRange( 0, 9999 );
+ m_spinBoxWidth->setRange( 0, 99999 );
m_spinBoxWidth->setValue( 0 );
+ m_spinBoxWidth->setFont( normalFont );
QLabel* heightLabel = new QLabel( "Height" );
+ heightLabel->setFont( normalFont );
m_spinBoxheight = new QSpinBox();
- m_spinBoxheight->setRange( 0, 9999 );
+ m_spinBoxheight->setRange( 0, 99999 );
m_spinBoxheight->setValue( 0 );
+ m_spinBoxheight->setFont( normalFont );
QLabel* pixelsLabel = new QLabel();
pixelsLabel->setText( "Pixels" );
+ pixelsLabel->setFont( normalFont );
+ resolutionGrid->addWidget( m_comboBoxStandardResolution, 1, 0, Qt::AlignCenter );
+ resolutionGrid->addWidget( widthLabel, 0, 1, Qt::AlignCenter );
+ resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, Qt::AlignCenter );
+ resolutionGrid->addWidget( heightLabel, 0, 2, Qt::AlignCenter );
+ resolutionGrid->addWidget( m_spinBoxheight, 1, 2, Qt::AlignCenter );
+ resolutionGrid->addWidget( pixelsLabel, 1, 3, Qt::AlignCenter );
- resolutionGrid->addWidget( resolutionLabel, 1, 0, 1, 1 );
- resolutionGrid->addWidget( widthLabel, 0, 1, 1, 1 );
- resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, 1, 1 );
- resolutionGrid->addWidget( heightLabel, 0, 2, 1, 1 );
- resolutionGrid->addWidget( m_spinBoxheight, 1, 2, 1, 1 );
- resolutionGrid->addWidget( pixelsLabel, 1, 3, 1, 1 );
- MainLayout->addLayout( resolutionGrid );
+ /*
+ * Pixel format
+ */
+ QGroupBox* pixelGroup = new QGroupBox();
+ pixelGroup->setTitle( QStringLiteral( "Pixel Format" ) );
+ pixelGroup->setFont( menusFont );
+ QGridLayout* pixelGridLayout = new QGridLayout();
+ pixelGroup->setLayout( pixelGridLayout );
+
+ QLabel* colorSpaceLabel = new QLabel();
+ colorSpaceLabel->setText( "Color Space" );
+ colorSpaceLabel->setFont( normalFont );
+ m_comboBoxColorSpace = new QComboBox();
+ m_comboBoxColorSpace->setSizePolicy( sizePolicy );
+ m_comboBoxColorSpace->setFont( normalFont );
+ m_comboBoxColorSpace->clear();
- // Pixel format
- QHBoxLayout* pixelFormatLayout = new QHBoxLayout();
QLabel* pixelFormatLabel = new QLabel();
- pixelFormatLabel->setText( "Pixel Format" );
- pixelFormatLabel->setFont( menusFont );
+ pixelFormatLabel->setText( "Sampling" );
+ pixelFormatLabel->setFont( normalFont );
m_comboBoxPixelFormat = new QComboBox();
- QSizePolicy sizePolicyPixelFormat( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
- sizePolicyPixelFormat.setHorizontalStretch( 0 );
- sizePolicyPixelFormat.setVerticalStretch( 0 );
- sizePolicyPixelFormat.setHeightForWidth( m_comboBoxPixelFormat->sizePolicy().hasHeightForWidth() );
- m_comboBoxPixelFormat->setSizePolicy( sizePolicyPixelFormat );
- m_comboBoxPixelFormat->setAcceptDrops( true );
+ m_comboBoxPixelFormat->setSizePolicy( sizePolicy );
+ m_comboBoxPixelFormat->setFont( normalFont );
m_comboBoxPixelFormat->clear();
- for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
+
+ for( UInt i = 0; i < PlaYUVerFrame::supportedColorSpacesListNames().size(); i++ )
{
- m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() );
+ m_comboBoxColorSpace->insertItem( i, PlaYUVerFrame::supportedColorSpacesListNames()[i].c_str() );
}
- m_comboBoxPixelFormat->setCurrentIndex( 1 );
+ m_comboBoxColorSpace->setCurrentIndex( 1 );
- MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
- pixelFormatLayout->addWidget( pixelFormatLabel );
- pixelFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- pixelFormatLayout->addWidget( m_comboBoxPixelFormat );
- MainLayout->addLayout( pixelFormatLayout );
+ pixelGridLayout->addWidget( colorSpaceLabel, 0, 0 );
+ pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+ pixelGridLayout->addWidget( m_comboBoxColorSpace, 0, 2 );
- // Frame rate format
+ pixelGridLayout->addWidget( pixelFormatLabel, 1, 0 );
+ pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 );
+ pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 );
+
+ QHBoxLayout* bitsPerPelLayout = new QHBoxLayout();
+ QLabel* bitsPerPelLabel = new QLabel();
+ bitsPerPelLabel->setFont( normalFont );
+ bitsPerPelLabel->setText( "Pixel bit depth" );
+ m_spinBoxBits = new QSpinBox();
+ m_spinBoxBits->setFont( normalFont );
+ m_spinBoxBits->setMinimumWidth( 30 );
+ m_spinBoxBits->setRange( 0, 16 );
+ m_spinBoxBits->setValue( 8 );
+ pixelGridLayout->addWidget( bitsPerPelLabel, 2, 0 );
+ pixelGridLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 2, 1 );
+ pixelGridLayout->addWidget( m_spinBoxBits, 2, 2 );
+
+ /*
+ * Frame rate format
+ */
QHBoxLayout* framerateFormatLayout = new QHBoxLayout();
QLabel* framerateFormatLabel = new QLabel();
framerateFormatLabel->setFont( menusFont );
framerateFormatLabel->setText( "Frame Rate" );
m_spinBoxFrameRate = new QSpinBox();
+ m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) );
+ m_spinBoxFrameRate->setMinimumWidth( 30 );
m_spinBoxFrameRate->setRange( 0, 200 );
m_spinBoxFrameRate->setValue( 30 );
-
- MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
framerateFormatLayout->addWidget( framerateFormatLabel );
- framerateFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ framerateFormatLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
framerateFormatLayout->addWidget( m_spinBoxFrameRate );
- MainLayout->addLayout( framerateFormatLayout );
-
- // Confirmation buttons
-
- MainLayout->addItem( new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
-
+ /*
+ * Confirmation buttons
+ */
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) );
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
dialogButtonOkCancel->setCenterButtons( false );
+ MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
+ // MainLayout->addLayout( standardResolutionLayout );
+ // MainLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum ) );
+ MainLayout->addWidget( resolutionGroup );
+ MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
+ MainLayout->addWidget( pixelGroup );
+ MainLayout->addLayout( bitsPerPelLayout );
+ MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
+ MainLayout->addLayout( framerateFormatLayout );
+ MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
MainLayout->addWidget( dialogButtonOkCancel );
- connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( StandardResolutionSelection() ) );
+ connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotStandardResolutionSelected(int) ) );
+ connect( m_spinBoxWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) );
+ connect( m_spinBoxheight, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) );
+
+ connect( m_comboBoxColorSpace, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotColorSpaceChange(int) ) );
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
- QMetaObject::connectSlotsByName( this );
+ m_comboBoxColorSpace->setCurrentIndex( 0 );
+
+ setFixedSize( MainLayout->sizeHint() );
}
-Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
+Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate )
{
// Set default values
- //m_labelFilename->setText( Filename );
- setWindowTitle( "Configure resolution for " + Filename );
- //m_labelFilename->setText( QFileInfo( Filename ).fileName() );
+ //setWindowTitle( "Configure resolution for " + Filename );
+ m_labelFilename->setText( QFileInfo( Filename ).fileName() );
m_spinBoxWidth->setValue( rWidth );
m_spinBoxheight->setValue( rHeight );
- m_comboBoxPixelFormat->setCurrentIndex( rInputFormat >= 0 ? rInputFormat : 0 );
+
+ Int colorSpace = 0;
+ Int sampling = 0;
+ if( rInputFormat >= 0 )
+ {
+ std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[rInputFormat];
+ for( UInt j = 0; j < PlaYUVerFrame::supportedColorSpacesListNames().size(); j++ )
+ {
+ for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( j ).size(); i++ )
+ {
+ if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames( j )[i] )
+ {
+ colorSpace = j;
+ sampling = i;
+ break;
+ }
+ }
+ }
+ }
+ m_comboBoxColorSpace->setCurrentIndex( colorSpace );
+ m_comboBoxPixelFormat->setCurrentIndex( sampling );
+ m_spinBoxBits->setValue( rBits );
m_spinBoxFrameRate->setValue( rFrameRate );
for( Int i = 0; i < standardResolutionSizes.size(); i++ )
{
if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) )
{
m_comboBoxStandardResolution->setCurrentIndex( i );
+ break;
}
}
if( exec() == QDialog::Rejected )
@@ -227,20 +281,63 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi
}
rWidth = m_spinBoxWidth->value();
rHeight = m_spinBoxheight->value();
- rInputFormat = m_comboBoxPixelFormat->currentIndex();
+ colorSpace = m_comboBoxColorSpace->currentIndex();
+ sampling = m_comboBoxPixelFormat->currentIndex();
+ std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames( colorSpace )[sampling];
+ for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
+ {
+ if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames()[i] )
+ {
+ rInputFormat = i;
+ break;
+ }
+ }
+ rBits = m_spinBoxBits->value();
rFrameRate = m_spinBoxFrameRate->value();
return QDialog::Accepted;
}
-void ConfigureFormatDialog::StandardResolutionSelection()
+void ConfigureFormatDialog::slotStandardResolutionSelected( Int idx )
{
- Int currIdx = m_comboBoxStandardResolution->currentIndex();
- if( currIdx == -1 )
- return;
-
- QSize currSize = standardResolutionSizes.at( currIdx );
- m_spinBoxWidth->setValue( currSize.width() );
- m_spinBoxheight->setValue( currSize.height() );
+ if( idx >= 0 )
+ {
+ QSize currSize = standardResolutionSizes.at( idx );
+ m_spinBoxWidth->blockSignals( true );
+ m_spinBoxWidth->setValue( currSize.width() );
+ m_spinBoxWidth->blockSignals( false );
+ m_spinBoxheight->blockSignals( true );
+ m_spinBoxheight->setValue( currSize.height() );
+ m_spinBoxheight->blockSignals( false );
+ }
}
-} // Namespace SCode
+void ConfigureFormatDialog::slotResolutionChange()
+{
+ m_comboBoxStandardResolution->blockSignals( true );
+ Int newIdx = -1;
+ for( Int i = 0; i < standardResolutionSizes.size(); i++ )
+ {
+ if( standardResolutionSizes.at( i ) == QSize( m_spinBoxWidth->value(), m_spinBoxheight->value() ) )
+ {
+ newIdx = i;
+ break;
+ }
+ }
+ m_comboBoxStandardResolution->setCurrentIndex( newIdx );
+ m_comboBoxStandardResolution->blockSignals( false );
+}
+
+Void ConfigureFormatDialog::slotColorSpaceChange( Int idx )
+{
+ if( idx == -1 )
+ return;
+
+ m_comboBoxPixelFormat->clear();
+ for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( idx ).size(); i++ )
+ {
+ m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames( idx )[i].c_str() );
+ }
+ m_comboBoxPixelFormat->setCurrentIndex( 0 );
+}
+
+} // NAMESPACE
diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h
index cb10ab4..fe74524 100644
--- a/app/ConfigureFormatDialog.h
+++ b/app/ConfigureFormatDialog.h
@@ -34,18 +34,12 @@
#endif
#include
-
-
class QPixmap;
class QColor;
namespace plaYUVer
{
-#define ADD_STANDARD_RESOLUTION( name, width, height) \
- standardResolutionNames.push_back( QString( name ) ); \
- standardResolutionSizesList.push_back( QSize( width, height ) )
-
/**
*
*/
@@ -56,10 +50,12 @@ Q_OBJECT
public:
ConfigureFormatDialog( QWidget *parent = 0 );
- Int runConfigureFormatDialog ( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
+ Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate );
private Q_SLOTS:
- void StandardResolutionSelection();
+ void slotStandardResolutionSelected( int );
+ void slotResolutionChange();
+ void slotColorSpaceChange( int );
private:
QStringList standardResolutionNames;
@@ -69,7 +65,9 @@ private:
QComboBox *m_comboBoxStandardResolution;
QSpinBox *m_spinBoxWidth;
QSpinBox *m_spinBoxheight;
+ QComboBox *m_comboBoxColorSpace;
QComboBox *m_comboBoxPixelFormat;
+ QSpinBox *m_spinBoxBits;
QSpinBox *m_spinBoxFrameRate;
};
diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp
index 0b7d191..fd9a644 100644
--- a/app/DialogSubWindowSelector.cpp
+++ b/app/DialogSubWindowSelector.cpp
@@ -22,6 +22,8 @@
* \brief Dialog box to select sub windows
*/
+#include
+#include
#include "PlaYUVerSubWindowHandle.h"
#include "DialogSubWindowSelector.h"
#include "VideoSubWindow.h"
@@ -29,135 +31,140 @@
namespace plaYUVer
{
-DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected, Int maxWindowsSelected ) :
+DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected,
+ Int maxWindowsSelected ) :
QDialog( parent ),
m_uiCategory( uiCategory ),
m_iMinSelectedWindows( minWindowsSelected ),
m_iMaxSlectedWindows( maxWindowsSelected ),
m_pcMainWindowManager( windowManager )
{
- QFont titleFont, menusFont;
-
- titleFont.setPointSize( 14 );
- titleFont.setBold( true );
- titleFont.setWeight( 75 );
-
- menusFont.setBold( true );
- menusFont.setWeight( 75 );
QSize windowSize( 350, 80 );
resize( windowSize );
- setWindowTitle( "Sub Windows Selection" );
+ setWindowTitle( "Select desired Sub-Windows" );
- QHBoxLayout* MainLayout = new QHBoxLayout( this );
+ QVBoxLayout* mainLayout = new QVBoxLayout( this );
- // Window list and add button
- m_comboBoxWindowList = new QComboBox();
- QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
- sizePolicy.setHorizontalStretch( 0 );
- sizePolicy.setVerticalStretch( 0 );
- sizePolicy.setHeightForWidth( m_comboBoxWindowList->sizePolicy().hasHeightForWidth() );
- m_comboBoxWindowList->setSizePolicy( sizePolicy );
- m_comboBoxWindowList->setAcceptDrops( true );
+ minWindowsSelected = minWindowsSelected == 0 ? 1 : minWindowsSelected;
+
+ m_pcGroupCheckBox = new QGroupBox();
+ m_pcGroupCheckBox->setLayout( new QVBoxLayout() );
+
+ mainLayout->addWidget( m_pcGroupCheckBox );
- m_pushButtonAdd = new QPushButton( "Add", this );
m_pushButtonAddAll = new QPushButton( "Add all", this );
- m_pushButtonRemove = new QPushButton( "Remove", this );
m_pushButtonRemoveAll = new QPushButton( "Remove All", this );
- m_pushButtonRemove->setEnabled( false );
m_pushButtonRemoveAll->setEnabled( false );
- // Selected Sub Window List
- m_listSelectedWindows = new QListWidget( this );
-
// Confirmation buttons
m_pushButtonOkCancel = new QDialogButtonBox();
m_pushButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
- m_pushButtonOkCancel->setOrientation( Qt::Vertical );
+ m_pushButtonOkCancel->setOrientation( Qt::Horizontal );
m_pushButtonOkCancel->setCenterButtons( false );
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false );
- // Create Layouts
- QVBoxLayout* LeftVLayout = new QVBoxLayout();
- LeftVLayout->addWidget( m_comboBoxWindowList );
- //LeftVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- LeftVLayout->addWidget( m_listSelectedWindows );
-
- QVBoxLayout* RightVLayout = new QVBoxLayout();
- RightVLayout->addWidget( m_pushButtonAdd );
- RightVLayout->addWidget( m_pushButtonAddAll );
- RightVLayout->addWidget( m_pushButtonRemove );
- RightVLayout->addWidget( m_pushButtonRemoveAll );
- RightVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
- RightVLayout->addWidget( m_pushButtonOkCancel );
+ QHBoxLayout* BottomHLayout = new QHBoxLayout();
+ BottomHLayout->addWidget( m_pushButtonAddAll );
+ BottomHLayout->addWidget( m_pushButtonRemoveAll );
+ BottomHLayout->addWidget( m_pushButtonOkCancel );
// Add components
- //MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MainLayout->addLayout( LeftVLayout );
- MainLayout->addLayout( RightVLayout );
+ mainLayout->addLayout( BottomHLayout );
- setLayout( MainLayout );
+ setLayout( mainLayout );
// Create actions
connect( m_pushButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( m_pushButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
- connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addSubWindow() ) );
- connect( m_pushButtonAddAll, SIGNAL( clicked() ), this, SLOT( addAllSubWindow() ) );
- connect( m_pushButtonRemove, SIGNAL( clicked() ), this, SLOT( removeSubWindow() ) );
- connect( m_pushButtonRemoveAll, SIGNAL( clicked() ), this, SLOT( removeAllSubWindow() ) );
- QMetaObject::connectSlotsByName( this );
- updateSubWindowList();
+ connect( m_pushButtonAddAll, SIGNAL( clicked() ), this, SLOT( addAllSubWindow() ) );
+ connect( m_pushButtonRemoveAll, SIGNAL( clicked() ), this, SLOT( removeAllSubWindow() ) );
+
+ m_mapperWindowsList = new QSignalMapper( this );
+ connect( m_mapperWindowsList, SIGNAL( mapped(int) ), this, SLOT( toggleSubWindow(int) ) );
+
+ SubWindowAbstract *subWindow;
+ QString currSubWindowName;
+ QCheckBox* windowCheckBox;
+ m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory );
+ for( Int i = 0; i < m_apcSubWindowList.size(); i++ )
+ {
+ subWindow = m_apcSubWindowList.at( i );
+ currSubWindowName = subWindow->getWindowName();
+ windowCheckBox = new QCheckBox( currSubWindowName, this );
+ connect( windowCheckBox, SIGNAL( stateChanged(int) ), m_mapperWindowsList, SLOT( map() ) );
+ m_mapperWindowsList->setMapping( windowCheckBox, i );
+ m_apcWindowsListCheckBox.append( windowCheckBox );
+ }
+
+ update();
+
+ setFixedSize( mainLayout->sizeHint() );
+
}
Void DialogSubWindowSelector::updateSubWindowList()
{
- SubWindowHandle *subWindow;
- QString currSubWindowName;
- m_pcWindowListNames.clear();
- QList subWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory );
- for( Int i = 0; i < subWindowList.size(); i++ )
- {
- subWindow = subWindowList.at( i );
- currSubWindowName = subWindow->getWindowName();
- if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) )
- m_pcWindowListNames.append( currSubWindowName );
- }
- m_comboBoxWindowList->clear();
- m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames );
- m_comboBoxWindowList->setCurrentIndex( -1 );
+ QLayout* pcLayout = m_pcGroupCheckBox->layout();
+ QLayoutItem* pcLayoutItem;
+ QCheckBox* windowCheckBox;
+ Int iIdx;
- Bool enableAddAll = true;
-
- if( m_iMaxSlectedWindows >= 0 )
+ /**
+ * Remove all check boxes
+ */
+ for( Int i = 0; i < pcLayout->count(); i++ )
{
- if( m_pcSelectedWindowListNames.size() >= m_iMaxSlectedWindows )
+ pcLayoutItem = pcLayout->itemAt( i );
+ if( pcLayoutItem )
{
- m_pushButtonAdd->setEnabled( false );
- }
- else
- {
- m_pushButtonAdd->setEnabled( true );
- }
- if( m_pcWindowListNames.size() > m_iMaxSlectedWindows )
- {
- enableAddAll = false;
+ pcLayout->removeWidget( pcLayoutItem->widget() );
+ pcLayout->removeItem( pcLayoutItem );
}
}
- m_pushButtonAddAll->setEnabled( enableAddAll );
- if( m_pcSelectedWindowListNames.size() > 0 )
+ for( Int i = 0; i < m_apcSelectedSubWindowList.size(); i++ )
+ {
+ iIdx = m_apcSubWindowList.indexOf( m_apcSelectedSubWindowList.at( i ) );
+ if( iIdx >= 0 )
+ {
+ windowCheckBox = m_apcWindowsListCheckBox.at( iIdx );
+ m_pcGroupCheckBox->layout()->addWidget( windowCheckBox );
+ }
+ }
+ for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ )
+ {
+ if( !m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) )
+ m_pcGroupCheckBox->layout()->addWidget( m_apcWindowsListCheckBox.at( i ) );
+ }
+
+// qDebug( ) << "Selected windows: "
+// << m_apcSelectedSubWindowList.size();
+}
+
+Void DialogSubWindowSelector::selectSubWindow( SubWindowAbstract * subWindow )
+{
+ Int iIdx = m_apcSubWindowList.indexOf( subWindow );
+ if( iIdx >= 0 )
+ {
+ m_apcWindowsListCheckBox.at( iIdx )->setChecked( true );
+ //m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( iIdx ) );
+ }
+}
+
+Void DialogSubWindowSelector::update()
+{
+ if( m_apcSelectedSubWindowList.size() > 0 )
{
- m_pushButtonRemove->setEnabled( true );
m_pushButtonRemoveAll->setEnabled( true );
}
else
{
- m_pushButtonRemove->setEnabled( false );
m_pushButtonRemoveAll->setEnabled( false );
}
- if( m_pcSelectedWindowListNames.size() >= m_iMinSelectedWindows )
+ if( m_apcSelectedSubWindowList.size() >= m_iMinSelectedWindows )
{
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( true );
}
@@ -166,68 +173,76 @@ Void DialogSubWindowSelector::updateSubWindowList()
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false );
}
-}
-
-Void DialogSubWindowSelector::setSubWindowList( QStringList cWindowListNames )
-{
- m_pcSelectedWindowListNames = cWindowListNames;
- m_listSelectedWindows->clear();
- m_listSelectedWindows->insertItems( 0, cWindowListNames );
+ if( m_iMaxSlectedWindows > 0 )
+ {
+ if( m_apcWindowsListCheckBox.size() > m_iMaxSlectedWindows )
+ {
+ m_pushButtonAddAll->setEnabled( false );
+ }
+ else
+ {
+ m_pushButtonAddAll->setEnabled( true );
+ }
+ if( m_apcSelectedSubWindowList.size() >= m_iMaxSlectedWindows )
+ {
+ for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ )
+ {
+ if( m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) )
+ {
+ m_apcWindowsListCheckBox.at( i )->setEnabled( true );
+ }
+ else
+ {
+ m_apcWindowsListCheckBox.at( i )->setEnabled( false );
+ }
+ }
+ }
+ else
+ {
+ for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ )
+ {
+ m_apcWindowsListCheckBox.at( i )->setEnabled( true );
+ }
+ }
+ }
updateSubWindowList();
}
// ----------------------- Slot Functions -----------------------
-Void DialogSubWindowSelector::addSubWindow()
+Void DialogSubWindowSelector::toggleSubWindow( Int idx )
{
- Int iSelectedIdx = m_comboBoxWindowList->currentIndex();
- if( iSelectedIdx >= 0 )
+ Bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked();
+
+ if( isChecked )
{
- m_pcSelectedWindowListNames.append( m_pcWindowListNames.at( iSelectedIdx ) );
- m_listSelectedWindows->clear();
- m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
- updateSubWindowList();
+ m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) );
}
+ else
+ {
+ m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) );
+ }
+ update();
}
Void DialogSubWindowSelector::addAllSubWindow()
{
- if( m_iMaxSlectedWindows <= 0 || m_pcWindowListNames.size() <= m_iMaxSlectedWindows )
+ m_apcSelectedSubWindowList.clear();
+ for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ )
{
- for( Int i = 0; i < m_pcWindowListNames.size(); i++ )
- {
- m_pcSelectedWindowListNames.append( m_pcWindowListNames.at( i ) );
- }
- m_listSelectedWindows->clear();
- m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
- updateSubWindowList();
- }
-}
-
-Void DialogSubWindowSelector::removeSubWindow()
-{
- QList selectedWindows = m_listSelectedWindows->selectedItems();
- if( selectedWindows.size() )
- {
- for( Int i = 0; i < selectedWindows.size(); i++ )
- {
- QString currName = selectedWindows.at( i )->text();
- Int indexCurrName = m_pcSelectedWindowListNames.indexOf( currName );
- m_pcSelectedWindowListNames.removeAt( indexCurrName );
- m_listSelectedWindows->removeItemWidget( selectedWindows[i] );
- }
- m_listSelectedWindows->clear();
- m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
- updateSubWindowList();
+ m_apcWindowsListCheckBox.at( i )->setChecked( true );
}
+ update();
}
Void DialogSubWindowSelector::removeAllSubWindow()
{
- QList selectedWindows = m_listSelectedWindows->selectedItems();
- m_listSelectedWindows->clear();
- m_pcSelectedWindowListNames.clear();
- updateSubWindowList();
+ for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ )
+ {
+ m_apcWindowsListCheckBox.at( i )->setChecked( false );
+ }
+ m_apcSelectedSubWindowList.clear();
+ update();
}
} // Namespace SCode
diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h
index 3779826..619b508 100644
--- a/app/DialogSubWindowSelector.h
+++ b/app/DialogSubWindowSelector.h
@@ -34,13 +34,19 @@
#endif
#include
+#include
+
class QPixmap;
class QColor;
+class QCheckBox;
+class QGroupBox;
namespace plaYUVer
{
class PlaYUVerSubWindowHandle;
+class SubWindowAbstract;
+
/**
* Class to define the dialog box to select sub windows
* This class enable the selection of several group of windows
@@ -50,35 +56,37 @@ class DialogSubWindowSelector: public QDialog
Q_OBJECT
public:
- DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected = 0, Int maxWindowsSelected = -1 );
+ DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected = 1, Int maxWindowsSelected = -1 );
- Void setSubWindowList( QStringList cWindowListNames );
- QStringList getSelectedWindows()
+ Void selectSubWindow( SubWindowAbstract* subWindow );
+ QList getSelectedWindows()
{
- return m_pcSelectedWindowListNames;
+ return m_apcSelectedSubWindowList;
}
private:
UInt m_uiCategory;
Int m_iMinSelectedWindows;
Int m_iMaxSlectedWindows;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
- QStringList m_pcWindowListNames;
- QStringList m_pcSelectedWindowListNames;
+
+ QList m_apcSubWindowList;
+ QList m_apcSelectedSubWindowList;
+
+ QSignalMapper* m_mapperWindowsList;
+ QGroupBox* m_pcGroupCheckBox;
+ QVector m_apcWindowsListCheckBox;
QComboBox* m_comboBoxWindowList;
QDialogButtonBox* m_pushButtonOkCancel;
- QPushButton* m_pushButtonAdd;
QPushButton* m_pushButtonAddAll;
- QPushButton* m_pushButtonRemove;
QPushButton* m_pushButtonRemoveAll;
- QListWidget* m_listSelectedWindows;
Void updateSubWindowList();
+ Void update();
private Q_SLOTS:
- void addSubWindow();
+ void toggleSubWindow( int );
void addAllSubWindow();
- void removeSubWindow();
void removeAllSubWindow();
};
diff --git a/app/FramePropertiesSidebar.cpp b/app/FramePropertiesDock.cpp
similarity index 92%
rename from app/FramePropertiesSidebar.cpp
rename to app/FramePropertiesDock.cpp
index 205ed42..dfa2c33 100644
--- a/app/FramePropertiesSidebar.cpp
+++ b/app/FramePropertiesDock.cpp
@@ -18,19 +18,19 @@
*/
/**
- * \file FramePropertiesSideBar.cpp
+ * \file FramePropertiesDock.cpp
* \brief Main side bar definition
*/
#include
#include
#include
-#include "FramePropertiesSidebar.h"
+#include "FramePropertiesDock.h"
namespace plaYUVer
{
-FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPlaySwitch ) :
+FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ) :
QWidget( parent ),
pbMainPlaySwitch( pbMainPlaySwitch )
{
@@ -235,14 +235,14 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPla
connect( renderingButtonGroup, SIGNAL( buttonClicked(int) ), this, SLOT( slotRenderingChanged(int) ) );
connect( histogramWidget, SIGNAL( signalIntervalChanged( int, int ) ), this, SLOT( slotUpdateInterval(int, int) ) );
connect( histogramWidget, SIGNAL( signalMaximumValueChanged(int) ), this, SLOT( slotUpdateIntervRange(int) ) );
- connect( histogramWidget, SIGNAL( signalHistogramComputationDone(bool) ), this, SLOT( slotRefreshOptions(bool) ) );
+ connect( histogramWidget, SIGNAL( signalHistogramComputationDone(int) ), this, SLOT( slotRefreshOptions(int) ) );
connect( histogramWidget, SIGNAL( signalHistogramComputationFailed(void) ), this, SLOT( slotHistogramComputationFailed(void) ) );
connect( minInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMinValueChanged(int) ) );
connect( maxInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMaxValueChanged(int) ) );
}
-FramePropertiesSideBar::~FramePropertiesSideBar()
+FramePropertiesDock::~FramePropertiesDock()
{
// If there is a currently histogram computation when dialog is closed,
// stop it before the image data are deleted automatically!
@@ -251,7 +251,7 @@ FramePropertiesSideBar::~FramePropertiesSideBar()
delete histogramWidget;
}
-QSize FramePropertiesSideBar::sizeHint() const
+QSize FramePropertiesDock::sizeHint() const
{
QSize currSize = size();
QSize bestSize( 180, currSize.height() );
@@ -260,7 +260,7 @@ QSize FramePropertiesSideBar::sizeHint() const
return currSize;
}
-Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying )
+Void FramePropertiesDock::setData( PlaYUVerFrame* pcFrame, Bool isPlaying )
{
m_pbIsPlaying = isPlaying;
if( !pcFrame )
@@ -284,7 +284,7 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying )
if( m_iLastFrameType != colorSpace )
{
m_iLastFrameType = colorSpace;
- if ( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB )
+ if( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB )
{
channelCB->clear();
channelCB->clear();
@@ -340,7 +340,7 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying )
}
}
setEnabled( true );
- if( m_pcFrame || !(*pbMainPlaySwitch) )
+ if( m_pcFrame || !( *pbMainPlaySwitch ) )
{
m_pcFrame = pcFrame;
updateDataHistogram();
@@ -348,7 +348,7 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying )
}
}
-Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
+Void FramePropertiesDock::setSelection( const QRect &selectionArea )
{
// This is necessary to stop computation because image.bits() is
// currently used by threaded histogram algorithm.
@@ -360,9 +360,8 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
if( selectionArea.isValid() )
{
histogramWidget->stopHistogramComputation();
- histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame,
- selectionArea.x(), selectionArea.y(),
- selectionArea.width(), selectionArea.height() ) );
+ histogramWidget->updateSelectionData(
+ new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), selectionArea.height() ) );
fullImageButton->show();
selectionImageButton->show();
selectionImageButton->click();
@@ -377,7 +376,7 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
}
}
-Void FramePropertiesSideBar::updateDataHistogram()
+Void FramePropertiesDock::updateDataHistogram()
{
if( m_pcFrame->isValid() && isVisible() )
{
@@ -404,7 +403,7 @@ Void FramePropertiesSideBar::updateDataHistogram()
}
}
-Void FramePropertiesSideBar::updateStatistiques()
+Void FramePropertiesDock::updateStatistiques()
{
QString value;
@@ -445,7 +444,7 @@ Void FramePropertiesSideBar::updateStatistiques()
}
}
-Void FramePropertiesSideBar::stopHistogram()
+Void FramePropertiesDock::stopHistogram()
{
histogramWidget->stopHistogramComputation();
}
@@ -454,7 +453,7 @@ Void FramePropertiesSideBar::stopHistogram()
// SLOTS
////////////////////////////////////////////////////////////////////////////////
-Void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/)
+Void FramePropertiesDock::slotRefreshOptions( int range )
{
if( !isVisible() )
return;
@@ -477,12 +476,12 @@ Void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/)
}
}
-Void FramePropertiesSideBar::slotHistogramComputationFailed()
+Void FramePropertiesDock::slotHistogramComputationFailed()
{
m_pcFrame = NULL;
}
-Void FramePropertiesSideBar::slotChannelChanged( Int channel )
+Void FramePropertiesDock::slotChannelChanged( Int channel )
{
if( m_pcFrame->getColorSpace() == PlaYUVerFrame::COLOR_YUV )
channel += 1;
@@ -520,13 +519,13 @@ Void FramePropertiesSideBar::slotChannelChanged( Int channel )
updateStatistiques();
}
-Void FramePropertiesSideBar::slotScaleChanged( Int scale )
+Void FramePropertiesDock::slotScaleChanged( Int scale )
{
histogramWidget->m_scaleType = scale;
histogramWidget->update();
}
-Void FramePropertiesSideBar::slotColorsChanged( Int color )
+Void FramePropertiesDock::slotColorsChanged( Int color )
{
switch( color )
{
@@ -545,14 +544,14 @@ Void FramePropertiesSideBar::slotColorsChanged( Int color )
updateStatistiques();
}
-Void FramePropertiesSideBar::slotRenderingChanged( Int rendering )
+Void FramePropertiesDock::slotRenderingChanged( Int rendering )
{
histogramWidget->m_renderingType = rendering;
histogramWidget->update();
updateStatistiques();
}
-Void FramePropertiesSideBar::slotMinValueChanged( Int min )
+Void FramePropertiesDock::slotMinValueChanged( Int min )
{
// Called when user changes values of spin box.
// Communicate the change to histogram widget.
@@ -566,7 +565,7 @@ Void FramePropertiesSideBar::slotMinValueChanged( Int min )
updateStatistiques();
}
-Void FramePropertiesSideBar::slotMaxValueChanged( Int max )
+Void FramePropertiesDock::slotMaxValueChanged( Int max )
{
if( max == minInterv->value() - 1 )
minInterv->setValue( max );
@@ -576,7 +575,7 @@ Void FramePropertiesSideBar::slotMaxValueChanged( Int max )
updateStatistiques();
}
-Void FramePropertiesSideBar::slotUpdateInterval( Int min, Int max )
+Void FramePropertiesDock::slotUpdateInterval( Int min, Int max )
{
// Called when value is set from within histogram widget.
// Block signals to prevent slotMinValueChanged and
@@ -594,7 +593,7 @@ Void FramePropertiesSideBar::slotUpdateInterval( Int min, Int max )
updateStatistiques();
}
-Void FramePropertiesSideBar::slotUpdateIntervRange( Int range )
+Void FramePropertiesDock::slotUpdateIntervRange( Int range )
{
maxInterv->blockSignals( true );
maxInterv->setMaximum( range );
diff --git a/app/FramePropertiesSidebar.h b/app/FramePropertiesDock.h
similarity index 90%
rename from app/FramePropertiesSidebar.h
rename to app/FramePropertiesDock.h
index 71a9b0f..dbb34ad 100644
--- a/app/FramePropertiesSidebar.h
+++ b/app/FramePropertiesDock.h
@@ -18,12 +18,12 @@
*/
/**
- * \file FramePropertiesSidebar.h
+ * \file FramePropertiesDock.h
* \brief Main side bar definition
*/
-#ifndef __FRAMEPROPERTIESSIDEBAR_H__
-#define __FRAMEPROPERTIESSIDEBAR_H__
+#ifndef __FRAMEPROPERTIESDOCK_H__
+#define __FRAMEPROPERTIESDOCK_H__
#include "config.h"
#include "PlaYUVerAppDefs.h"
@@ -40,12 +40,12 @@
namespace plaYUVer
{
-class FramePropertiesSideBar: public QWidget
+class FramePropertiesDock: public QWidget
{
Q_OBJECT
public:
- FramePropertiesSideBar( QWidget* parent, Bool* pbMainPlaySwitch );
- ~FramePropertiesSideBar();
+ FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch );
+ ~FramePropertiesDock();
QSize sizeHint() const;
@@ -116,7 +116,7 @@ private:
Void updateDataHistogram();
private Q_SLOTS:
- void slotRefreshOptions( bool sixteenBit );
+ void slotRefreshOptions( int range );
void slotHistogramComputationFailed( void );
void slotChannelChanged( int channel );
void slotScaleChanged( int scale );
@@ -132,4 +132,4 @@ private Q_SLOTS:
} // NAMESPACE
-#endif // __FRAMEPROPERTIESSIDEBAR_H__
+#endif // __FRAMEPROPERTIESDOCK_H__
diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp
index d1502bf..3c8e40c 100644
--- a/app/HistogramWidget.cpp
+++ b/app/HistogramWidget.cpp
@@ -58,7 +58,7 @@ public:
if( m_histogram && m_parent )
{
EventData *eventData = new EventData();
-// eventData->starting = true;
+// eventDm_imageHistogramata->starting = true;
// eventData->success = false;
// eventData->histogram = m_histogram;
// QCoreApplication::postEvent( m_parent, eventData );
@@ -125,7 +125,7 @@ public:
HistogramWidgetPrivate()
{
blinkTimer = 0;
- sixteenBits = false;
+ imageBits = 8;
inSelected = false;
blinkFlag = false;
clearFlag = HistogramNone;
@@ -146,7 +146,7 @@ public:
// Image informations
Int imageChannels;
Int imageColorSpace;
- bool sixteenBits;
+ Int imageBits;
bool guideVisible; // Display color guide.
bool statisticsVisible; // Display tooltip histogram statistics.
@@ -313,7 +313,7 @@ Void HistogramWidget::customEvent( QEvent *event )
setUpdatesEnabled( false );
notifyValuesChanged();
- emit signalHistogramComputationDone( d->sixteenBits );
+ emit signalHistogramComputationDone( d->range );
setUpdatesEnabled( true );
update();
@@ -397,7 +397,7 @@ Void HistogramWidget::stopHistogramComputation()
Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFrame *pcFrameSelection )
{
- d->sixteenBits = false;
+ d->imageBits = pcFrame->getBitsPel();
//d->imageColorSpace = image.getPelFormat();
d->imageColorSpace = pcFrame->getColorSpace();
d->imageChannels = pcFrame->getNumberChannels();
@@ -409,7 +409,7 @@ Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFr
// Do not using PlaYUVerFrameStatistics::getHistogramSegment()
// method here because histogram hasn't yet been computed.
- d->range = d->sixteenBits ? 65535 : 255;
+ d->range = ( 1 << d->imageBits ) - 1;
emit signalMaximumValueChanged( d->range );
m_imageHistogram = ( PlaYUVerFrameStats* )pcFrame;
diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h
index 393f63f..a5242ec 100644
--- a/app/HistogramWidget.h
+++ b/app/HistogramWidget.h
@@ -152,7 +152,7 @@ public:
Q_SIGNALS:
void signalIntervalChanged( int min, int max );
void signalMaximumValueChanged( int );
- void signalHistogramComputationDone( bool );
+ void signalHistogramComputationDone( int );
void signalHistogramComputationFailed( void );
public Q_SLOTS:
diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp
index 4e19ce7..6470667 100644
--- a/app/ModulesHandle.cpp
+++ b/app/ModulesHandle.cpp
@@ -23,11 +23,14 @@
*/
#include
+#include "PlaYUVerApp.h"
#include "ModulesHandle.h"
#include "PlaYUVerSubWindowHandle.h"
+#include "VideoSubWindow.h"
#include "VideoHandle.h"
#include "PlaYUVerModuleFactory.h"
#include "DialogSubWindowSelector.h"
+#include "ModulesHandleOptDialog.h"
namespace plaYUVer
{
@@ -163,24 +166,23 @@ Void ModulesHandle::updateMenus()
{
m_arrayActions.at( i )->setEnabled( false );
}
- m_arrayActions[DISABLE_ACT]->setEnabled( hasSubWindow );
- m_arrayActions[DISABLE_ALL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow );
+ m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcPlaYUVerAppModuleIfList.size() > 0 );
+
if( pcSubWindow )
{
QList apcCurrentModule = pcSubWindow->getModuleArray();
+ m_arrayActions[DISABLE_ACT]->setEnabled( apcCurrentModule.size() > 0 );
if( pcSubWindow->getDisplayModule() )
{
m_arrayActions[APPLY_ALL_ACT]->setEnabled( true );
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true );
- apcCurrentModule.append( pcSubWindow->getDisplayModule() );
}
for( Int i = 0; i < apcCurrentModule.size(); i++ )
{
currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction;
currModuleAction->setChecked( true );
}
-
}
}
@@ -248,27 +250,34 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
QString windowName;
QList videoSubWindowList;
- UInt numberOfFrames = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames;
+ Int numberOfFrames = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames;
if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows
{
- DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames );
+ DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowAbstract::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames );
+ QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
+
+ if( windowsList.size() <= numberOfFrames )
+ {
+ for( Int i = 0; i < windowsList.size(); i++ )
+ {
+ dialogWindowsSelection.selectSubWindow( windowsList.at( i ) );
+ }
+ }
+ else
+ {
+ dialogWindowsSelection.selectSubWindow( pcVideoSubWindow );
+ }
+
if( dialogWindowsSelection.exec() == QDialog::Accepted )
{
- QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows();
VideoSubWindow *videoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow();
- for( Int j = 0; j < selectedWindows.size(); j++ )
+ QList subWindowList = dialogWindowsSelection.getSelectedWindows();
+ for( Int i = 0; i < subWindowList.size(); i++ )
{
- for( Int i = 0; i < subWindowList.size(); i++ )
- {
- videoSubWindow = qobject_cast( subWindowList.at( i ) );
- if( videoSubWindow->getWindowName() == selectedWindows.at( j ) )
- {
- videoSubWindowList.append( videoSubWindow );
- pcCurrModuleIf->m_pcSubWindow[j] = videoSubWindow;
- }
- }
+ videoSubWindow = qobject_cast( subWindowList.at( i ) );
+ videoSubWindowList.append( videoSubWindow );
}
+
}
// Check for same fmt in more than one frame modules
for( Int i = 1; i < videoSubWindowList.size(); i++ )
@@ -288,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;
}
@@ -302,11 +311,41 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
pcCurrModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i );
}
+ if( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_OPTIONS )
+ {
+ ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf );
+ moduleOptDialog.runConfiguration();
+ }
+
+ // Create Module
+ Bool moduleCreated = false;
+ if( pcCurrModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_2 )
+ {
+ std::vector apcFrameList;
+ for( UInt i = 0; i < pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; i++ )
+ {
+ apcFrameList.push_back( pcCurrModuleIf->m_pcSubWindow[i]->getCurrFrame() );
+ }
+ moduleCreated = pcCurrModuleIf->m_pcModule->create( apcFrameList );
+ }
+ else if( pcCurrModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_1 )
+ {
+ pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() );
+ moduleCreated = true;
+ }
+
+ if( !moduleCreated )
+ {
+ qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be applied", LOG_ERROR );
+ destroyModuleIf( pcCurrModuleIf );
+ return;
+ }
+
if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
{
if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
{
- pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW, this );
+ pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
pcModuleSubWindow->setWindowShortName( windowName );
pcModuleSubWindow->setWindowName( windowName );
@@ -322,23 +361,17 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
else if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE )
{
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
- if( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SIDEBAR )
- {
- pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrModuleIf );
- QString titleDockWidget;
- titleDockWidget.append( pcCurrModuleIf->m_pcModule->m_pchModuleName );
- titleDockWidget.append( " Information" );
- pcCurrModuleIf->m_pcDockWidget = new QDockWidget( titleDockWidget, m_pcParent );
- pcCurrModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
- pcCurrModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
- pcCurrModuleIf->m_pcDockWidget->setWidget( pcCurrModuleIf->m_pcModuleDock );
- qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget );
- }
+ pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrModuleIf );
+ QString titleDockWidget;
+ titleDockWidget.append( pcCurrModuleIf->m_pcModule->m_pchModuleName );
+ titleDockWidget.append( " Information" );
+ pcCurrModuleIf->m_pcDockWidget = new QDockWidget( titleDockWidget, m_pcParent );
+ pcCurrModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
+ pcCurrModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
+ pcCurrModuleIf->m_pcDockWidget->setWidget( pcCurrModuleIf->m_pcModuleDock );
+ qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget );
}
- // Create Module
- pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() );
-
// Associate module with subwindows
if( !pcCurrModuleIf->m_pcDisplaySubWindow && !pcCurrModuleIf->m_pcModuleDock )
{
@@ -348,7 +381,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
{
if( pcCurrModuleIf->m_pcDisplaySubWindow )
pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf );
- for( UInt i = 0; i < numberOfFrames; i++ )
+ for( Int i = 0; i < numberOfFrames; i++ )
{
pcCurrModuleIf->m_pcSubWindow[i]->associateModule( pcCurrModuleIf );
}
@@ -426,7 +459,8 @@ Void ModulesHandle::destroyAllModulesIf()
Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isPlaying, Bool disableThreads )
{
Bool bRet = false;
- if( !isPlaying || ( isPlaying && pcCurrModuleIf->m_pcModule->m_bApplyWhilePlaying ) )
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ if( !( isPlaying && ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) )
{
#ifdef PLAYUVER_THREADED_MODULES
if( !disableThreads )
@@ -444,6 +478,7 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isP
{
bRet = true;
}
+ QApplication::restoreOverrideCursor();
return bRet;
}
diff --git a/app/ModulesHandle.h b/app/ModulesHandle.h
index 4329111..498a281 100644
--- a/app/ModulesHandle.h
+++ b/app/ModulesHandle.h
@@ -82,7 +82,6 @@ private:
QMenu* m_pcModulesMenu;
QList m_pcModulesSubMenuList;
- QList m_pcPlaYUVerModulesIfList;
QList m_pcPlaYUVerAppModuleIfList;
QVector m_arrayModulesActions;
diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp
new file mode 100644
index 0000000..17e3ad3
--- /dev/null
+++ b/app/ModulesHandleOptDialog.cpp
@@ -0,0 +1,133 @@
+/* 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 ModulesHandleOptDialog.cpp
+ * \brief Dialog box to config modules opts
+ */
+
+#include "ModulesHandleOptDialog.h"
+#include "lib/ProgramOptions.h"
+#include
+#include
+#include
+#include
+#include
+
+namespace plaYUVer
+{
+
+class OpionConfiguration: public QWidget
+{
+public:
+ OpionConfiguration( OptionBase* option )
+ {
+ m_cName = option->opt_string;
+ m_pcDescription = new QLabel;
+ m_pcDescription->setText( QString::fromStdString( option->opt_desc ) );
+ m_pcValue = new QLineEdit;
+ m_pcValue->setMinimumWidth( 40 );
+ m_pcValue->setMaximumWidth( 65 );
+ QHBoxLayout* layout = new QHBoxLayout;
+ layout->addWidget( m_pcDescription, Qt::AlignLeft );
+ layout->addWidget( m_pcValue, Qt::AlignRight );
+ layout->setContentsMargins( 1, 1, 1, 1 );
+ setLayout( layout );
+ }
+ const QString getValue() const
+ {
+ return m_pcValue->text();
+ }
+ const std::string& getName()
+ {
+ return m_cName;
+ }
+private:
+ QLineEdit* m_pcValue;
+ QLabel* m_pcDescription;
+ std::string m_cName;
+};
+
+ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf ) :
+ QDialog( parent ),
+ m_pcCurrModuleIf( pcCurrModuleIf )
+{
+ resize( 400, 10 );
+ setWindowTitle( "Select module parameters" );
+ setWindowIcon( QIcon( ":/images/configureformat.png" ) );
+
+ const Options::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList();
+
+ QVBoxLayout* optionsLayout = new QVBoxLayout;
+ OpionConfiguration* pcOption;
+ for( Options::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it )
+ {
+ pcOption = new OpionConfiguration( ( *it )->opt );
+ m_apcOptionList.append( pcOption );
+ optionsLayout->addWidget( pcOption );
+ }
+
+ QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
+ dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) );
+ dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
+ dialogButtonOkCancel->setCenterButtons( false );
+
+ QVBoxLayout* mainLayout = new QVBoxLayout;
+ mainLayout->addItem( optionsLayout );
+ mainLayout->addWidget( dialogButtonOkCancel );
+ setLayout( mainLayout );
+
+ setFixedSize( mainLayout->sizeHint() );
+
+ connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
+ connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
+}
+
+Int ModulesHandleOptDialog::runConfiguration()
+{
+ if( exec() == QDialog::Rejected )
+ {
+ return QDialog::Rejected;
+ }
+
+ std::vector argsArray;
+ std::string optionString;
+ QString valueString( "" );
+
+ for( Int i = 0; i < m_apcOptionList.size(); i++ )
+ {
+ valueString = m_apcOptionList.at( i )->getValue();
+ if( !valueString.isEmpty() )
+ {
+ optionString.append( "--" );
+ optionString.append( m_apcOptionList.at( i )->getName() );
+ optionString.append( "=" );
+ optionString.append( valueString.toStdString() );
+ argsArray.push_back( optionString );
+ }
+ optionString.clear();
+ }
+ if( argsArray.size() > 0 )
+ {
+ m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.scanArgs( argsArray );
+ }
+ return QDialog::Accepted;
+}
+
+} // NAMESPACE
diff --git a/app/ModulesHandleOptDialog.h b/app/ModulesHandleOptDialog.h
new file mode 100644
index 0000000..bb7eac2
--- /dev/null
+++ b/app/ModulesHandleOptDialog.h
@@ -0,0 +1,56 @@
+/* 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 ModulesHandleOptDialog.h
+ * \brief Dialog box to config modules opts
+ */
+
+#ifndef __MODULEHANDLEOPTDIALOG_H__
+#define __MODULEHANDLEOPTDIALOG_H__
+
+#include "config.h"
+#include "PlaYUVerAppDefs.h"
+#include "PlaYUVerAppModuleIf.h"
+#include
+#include
+
+namespace plaYUVer
+{
+
+class OpionConfiguration;
+
+/**
+ *
+ */
+class ModulesHandleOptDialog: public QDialog
+{
+Q_OBJECT
+
+public:
+ ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf );
+ Int runConfiguration();
+private:
+ PlaYUVerAppModuleIf *m_pcCurrModuleIf;
+ QVector m_apcOptionList;
+};
+
+} // NAMESPACE
+
+#endif // __MODULEHANDLEOPTDIALOG_H__
diff --git a/app/plaYUVerApp.cpp b/app/PlaYUVerApp.cpp
similarity index 84%
rename from app/plaYUVerApp.cpp
rename to app/PlaYUVerApp.cpp
index 4119ced..de6f705 100644
--- a/app/plaYUVerApp.cpp
+++ b/app/PlaYUVerApp.cpp
@@ -18,20 +18,30 @@
*/
/**
- * \file plaYUVerApp.cpp
- * \brief Main definition of the plaYUVerApp app
+ * \file PlaYUVerApp.cpp
+ * \brief Main definition of the PlaYUVerApp app
*/
#include
-#include "plaYUVerApp.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "PlaYUVerApp.h"
#ifdef USE_FERVOR
#include "fvupdater.h"
#endif
+#include "lib/PlaYUVerCmdParser.h"
#include "PlaYUVerSubWindowHandle.h"
+#include "AboutDialog.h"
+#include "SubWindowAbstract.h"
+#include "VideoSubWindow.h"
#include "VideoHandle.h"
#include "QualityHandle.h"
#include "ModulesHandle.h"
-
#include "DialogSubWindowSelector.h"
#define SYNCHRONISED_ZOON 1
@@ -39,7 +49,10 @@
namespace plaYUVer
{
-plaYUVerApp::plaYUVerApp()
+PlaYUVerApp::PlaYUVerApp() :
+ m_pcCurrentSubWindow( NULL ),
+ m_pcCurrentVideoSubWindow( NULL ),
+ m_pcAboutDialog( NULL )
{
setWindowModality( Qt::ApplicationModal );
@@ -78,37 +91,64 @@ plaYUVerApp::plaYUVerApp()
connect( m_appModuleQuality, SIGNAL( changed() ), this, SLOT( update() ) );
connect( m_appModuleExtensions, SIGNAL( changed() ), this, SLOT( update() ) );
- m_pcAboutDialog = NULL;
- m_pcCurrentSubWindow = NULL;
- m_pcCurrentVideoSubWindow = NULL;
}
-Void plaYUVerApp::parseArgs( Int argc, Char *argv[] )
+Bool PlaYUVerApp::parseArgs( Int argc, Char *argv[] )
{
- if( argc >= 2 )
+ Bool bRet = false;
+ m_pcCmdParser = new PlaYUVerCmdParser();
+ m_pcCmdParser->config( argc, argv );
+
+ std::vector m_apcInputs;
+ std::string strResolution( "" );
+ std::string strPelFmt( "" );
+
+ m_pcCmdParser->Opts().addOptions()/**/
+ ( "input,i", m_apcInputs, "input file" ) /**/
+ ( "size,s", strResolution, "size (WxH)" ) /**/
+ ( "pel_fmt", strPelFmt, "pixel format" );
+
+ if( !m_pcCmdParser->parse() )
{
- for( Int i = 1; i < argc; i++ )
- {
- loadFile( argv[i] );
- }
- m_pcWindowHandle->tileSubWindows();
- zoomToFitAll();
+ bRet |= true;
}
+
+ if( m_pcCmdParser->Opts()["help"]->count() )
+ {
+ printf( "Usage: %s [options] input_file[s]\n", argv[0] );
+ m_pcCmdParser->Opts().doHelp( std::cout );
+ bRet |= true;
+ }
+ if( m_pcCmdParser->Opts()["input"]->count() )
+ {
+ for( UInt i = 1; i < m_apcInputs.size(); i++ )
+ {
+ loadFile( QString::fromStdString( m_apcInputs[i] ) );
+ }
+ }
+ std::list& argv_unhandled = m_pcCmdParser->getNoArgs();
+ for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ )
+ {
+ loadFile( QString::fromStdString( *it ) );
+ }
+ m_pcWindowHandle->tileSubWindows();
+ zoomToFitAll();
+ return bRet;
}
-Void plaYUVerApp::about()
+Void PlaYUVerApp::about()
{
if( !m_pcAboutDialog )
m_pcAboutDialog = new AboutDialog( this );
m_pcAboutDialog->exec();
}
-Void plaYUVerApp::closeEvent( QCloseEvent *event )
+Void PlaYUVerApp::closeEvent( QCloseEvent *event )
{
Int mayCloseAll = true;
Int msgBoxCloseRet = QMessageBox::Yes;
- QList subWindowList = m_pcWindowHandle->findSubWindow();
+ QList subWindowList = m_pcWindowHandle->findSubWindow();
if( subWindowList.size() >= 1 )
{
QMessageBox msgBoxClose( QMessageBox::Question, "PlaYUVer", "There are open files!", QMessageBox::Yes | QMessageBox::No, this );
@@ -143,26 +183,26 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event )
}
}
-Void plaYUVerApp::closeAll()
+Void PlaYUVerApp::closeAll()
{
m_pcWindowHandle->removeAllSubWindow();
}
-Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
+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 );
+ VideoSubWindow *videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
if( videoSubWindow )
{
m_pcWindowHandle->setActiveSubWindow( videoSubWindow );
return;
}
videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); //createSubWindow();
- SubWindowHandle *subWindow = videoSubWindow;
+ SubWindowAbstract *subWindow = videoSubWindow;
if( !pStreamInfo )
{
Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, fileName );
@@ -180,11 +220,13 @@ 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();
connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) );
+
+ connect( subWindow, SIGNAL( aboutToClose( SubWindowAbstract* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowAbstract* ) ) );
connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) );
connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) );
@@ -194,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
@@ -207,14 +249,13 @@ 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 );
}
}
// ----------------------- File Functions -----------------------
-Void plaYUVerApp::open()
+Void PlaYUVerApp::open()
{
QString supported = tr( "Supported Files (" );
QStringList formatsList;
@@ -250,7 +291,7 @@ Void plaYUVerApp::open()
}
}
-Void plaYUVerApp::openRecent()
+Void PlaYUVerApp::openRecent()
{
QAction *action = qobject_cast( sender() );
PlaYUVerStreamInfo recentFile = action->data().value();
@@ -258,7 +299,7 @@ Void plaYUVerApp::openRecent()
loadFile( recentFile.m_cFilename, &recentFile );
}
-Void plaYUVerApp::save()
+Void PlaYUVerApp::save()
{
if( m_pcCurrentVideoSubWindow )
{
@@ -301,7 +342,7 @@ Void plaYUVerApp::save()
}
}
-Void plaYUVerApp::format()
+Void PlaYUVerApp::format()
{
if( m_pcCurrentVideoSubWindow )
{
@@ -317,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();
}
@@ -326,47 +367,51 @@ Void plaYUVerApp::format()
}
}
-Void plaYUVerApp::reload()
+Void PlaYUVerApp::reload()
{
- if( m_pcCurrentVideoSubWindow )
+ if( m_pcCurrentSubWindow )
{
- m_pcCurrentVideoSubWindow->reloadFile();
+ m_pcCurrentSubWindow->refreshSubWindow();
m_pcCurrentSubWindow = NULL;
update();
}
}
-Void plaYUVerApp::reloadAll()
+Void PlaYUVerApp::reloadAll()
{
- VideoSubWindow *videoSubWindow;
- QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
- for( Int i = 0; i < subWindowList.size(); i++ )
+ UInt windowCategoryOrder[] =
{
- videoSubWindow = qobject_cast( subWindowList.at( i ) );
- if( !videoSubWindow->getIsModule() )
+ SubWindowAbstract::VIDEO_STREAM_SUBWINDOW,
+ SubWindowAbstract::MODULE_SUBWINDOW,
+ SubWindowAbstract::MODULE_SUBWINDOW };
+
+ for( UInt c = 0; c < 3; c++ )
+ {
+ QList subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] );
+ for( Int i = 0; i < subWindowList.size(); i++ )
{
- videoSubWindow->reloadFile();
+ subWindowList.at( i )->refreshSubWindow();
}
}
m_pcCurrentSubWindow = NULL;
update();
}
-Void plaYUVerApp::loadAll()
+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 );
}
}
-Void plaYUVerApp::setTool( Int idxTool )
+Void PlaYUVerApp::setTool( Int idxTool )
{
m_uiViewTool = idxTool;
actionGroupTools->actions().at( m_uiViewTool )->setChecked( true );
- QList subWindowList = m_pcWindowHandle->findSubWindow();
+ QList subWindowList = m_pcWindowHandle->findSubWindow();
for( Int i = 0; i < subWindowList.size(); i++ )
{
subWindowList.at( i )->setTool( m_uiViewTool );
@@ -375,7 +420,7 @@ Void plaYUVerApp::setTool( Int idxTool )
// ----------------------- Zoom Functions -----------------------
-Void plaYUVerApp::normalSize()
+Void PlaYUVerApp::normalSize()
{
if( m_pcCurrentSubWindow )
{
@@ -384,7 +429,7 @@ Void plaYUVerApp::normalSize()
}
}
-Void plaYUVerApp::zoomToFit()
+Void PlaYUVerApp::zoomToFit()
{
if( m_pcCurrentSubWindow )
{
@@ -393,10 +438,10 @@ Void plaYUVerApp::zoomToFit()
}
}
-Void plaYUVerApp::zoomToFitAll()
+Void PlaYUVerApp::zoomToFitAll()
{
VideoSubWindow *videoSubWindow;
- QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
+ QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast( subWindowList.at( i ) );
@@ -407,7 +452,7 @@ Void plaYUVerApp::zoomToFitAll()
updateZoomFactorSBox();
}
-Void plaYUVerApp::scaleFrame( int ratio )
+Void PlaYUVerApp::scaleFrame( int ratio )
{
if( m_pcCurrentSubWindow )
{
@@ -416,9 +461,9 @@ Void plaYUVerApp::scaleFrame( int ratio )
}
}
-Void plaYUVerApp::zoomFromSBox( double zoom )
+Void PlaYUVerApp::zoomFromSBox( double zoom )
{
- SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow();
+ SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow();
Double factor = zoom / 100;
if( activeSubWindow )
{
@@ -426,7 +471,7 @@ Void plaYUVerApp::zoomFromSBox( double zoom )
}
}
-Void plaYUVerApp::updateZoomFactorSBox()
+Void PlaYUVerApp::updateZoomFactorSBox()
{
Double factor;
if( m_pcCurrentSubWindow )
@@ -438,14 +483,14 @@ Void plaYUVerApp::updateZoomFactorSBox()
// ----------------------- Drag and drop functions ----------------------
-Void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event )
+Void PlaYUVerApp::dragEnterEvent( QDragEnterEvent *event )
{
//setText(tr(""));
//mdiArea->setBackgroundRole( QPalette::Highlight );
event->acceptProposedAction();
}
-Void plaYUVerApp::dropEvent( QDropEvent *event )
+Void PlaYUVerApp::dropEvent( QDropEvent *event )
{
const QMimeData *mimeData = event->mimeData();
QList urlList = mimeData->urls();
@@ -459,11 +504,11 @@ Void plaYUVerApp::dropEvent( QDropEvent *event )
// ----------------------- Sub Window Functions -----------------------
-VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName )
+VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName )
{
QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath();
VideoSubWindow* pcSubWindow;
- QList subWindowList = windowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW );
+ QList subWindowList = windowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcSubWindow = qobject_cast( subWindowList.at( i ) );
@@ -475,9 +520,9 @@ VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHa
// ----------------------- Update Functions -----------------------
-Void plaYUVerApp::update()
+Void PlaYUVerApp::update()
{
- SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow();
+ SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow();
QCoreApplication::processEvents();
//if( activeSubWindow() != m_pcCurrentSubWindow )
{
@@ -487,7 +532,7 @@ Void plaYUVerApp::update()
{
m_pcCurrentSubWindow = activeSubWindow;
- if( m_pcCurrentSubWindow->getCategory() & SubWindowHandle::VIDEO_SUBWINDOW )
+ if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_SUBWINDOW )
{
m_pcCurrentVideoSubWindow = qobject_cast( m_pcCurrentSubWindow );
}
@@ -507,25 +552,30 @@ 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 );
+ }
}
}
-Void plaYUVerApp::updateMenus()
+Void PlaYUVerApp::updateMenus()
{
Bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 );
Bool hasVideoStreamSubWindow = false;
if( m_pcCurrentSubWindow )
- if( m_pcCurrentSubWindow->getCategory() & SubWindowHandle::VIDEO_STREAM_SUBWINDOW )
+ if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
hasVideoStreamSubWindow = true;
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
@@ -533,10 +583,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 );
@@ -556,7 +606,7 @@ Void plaYUVerApp::updateMenus()
// ----------------------- Create Functions -----------------------
-Void plaYUVerApp::createActions()
+Void PlaYUVerApp::createActions()
{
m_arrayActions.resize( TOTAL_ACT );
@@ -609,7 +659,7 @@ Void plaYUVerApp::createActions()
m_arrayActions[CLOSEALL_ACT] = new QAction( tr( "Close &All" ), this );
m_arrayActions[CLOSEALL_ACT]->setStatusTip( tr( "Close all the windows" ) );
- connect( m_arrayActions[CLOSEALL_ACT], SIGNAL( triggered() ), this, SLOT( closeAll() ) );
+ connect( m_arrayActions[CLOSEALL_ACT], SIGNAL( triggered() ), m_pcWindowHandle, SLOT( removeAllSubWindow() ) );
m_arrayActions[EXIT_ACT] = new QAction( tr( "E&xit" ), this );
m_arrayActions[EXIT_ACT]->setShortcuts( QKeySequence::Quit );
@@ -696,7 +746,7 @@ Void plaYUVerApp::createActions()
connect( m_arrayActions[ABOUTQT_ACT], SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
}
-Void plaYUVerApp::createMenus()
+Void PlaYUVerApp::createMenus()
{
m_arrayMenu.resize( TOTAL_MENUS );
@@ -764,7 +814,7 @@ Void plaYUVerApp::createMenus()
}
-Void plaYUVerApp::createToolBars()
+Void PlaYUVerApp::createToolBars()
{
m_arrayToolBars.resize( TOTAL_TOOLBAR );
@@ -799,7 +849,7 @@ Void plaYUVerApp::createToolBars()
}
-Void plaYUVerApp::createDockWidgets()
+Void PlaYUVerApp::createDockWidgets()
{
// Properties Dock Window
m_arraySideBars.resize( TOTAL_DOCK );
@@ -807,14 +857,14 @@ Void plaYUVerApp::createDockWidgets()
addDockWidget( Qt::RightDockWidgetArea, m_appModuleQuality->createDock() );
}
-Void plaYUVerApp::createStatusBar()
+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 )
+Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo )
{
Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, streamInfo.m_cFilename );
if( idx >= 0 )
@@ -825,7 +875,7 @@ Void plaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo )
updateRecentFileActions();
}
-Void plaYUVerApp::updateRecentFileActions()
+Void PlaYUVerApp::updateRecentFileActions()
{
Int numRecentFiles = m_aRecentFileStreamInfo.size();
numRecentFiles = qMin( numRecentFiles, MAX_RECENT_FILES );
@@ -848,7 +898,7 @@ Void plaYUVerApp::updateRecentFileActions()
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
}
-Void plaYUVerApp::checkRecentFileActions()
+Void PlaYUVerApp::checkRecentFileActions()
{
Int i = 0;
while( i < m_aRecentFileStreamInfo.size() )
@@ -871,7 +921,7 @@ Void plaYUVerApp::checkRecentFileActions()
}
}
-Void plaYUVerApp::readSettings()
+Void PlaYUVerApp::readSettings()
{
QSettings appSettings;
@@ -893,9 +943,10 @@ Void plaYUVerApp::readSettings()
m_appModuleVideo->readSettings();
m_appModuleQuality->readSettings();
m_appModuleExtensions->readSettings();
+ m_pcWindowHandle->readSettings();
}
-Void plaYUVerApp::writeSettings()
+Void PlaYUVerApp::writeSettings()
{
QSettings appSettings;
@@ -911,6 +962,7 @@ Void plaYUVerApp::writeSettings()
m_appModuleVideo->writeSettings();
m_appModuleQuality->writeSettings();
m_appModuleExtensions->writeSettings();
+ m_pcWindowHandle->writeSettings();
}
} // NAMESPACE
diff --git a/app/plaYUVerApp.h b/app/PlaYUVerApp.h
similarity index 88%
rename from app/plaYUVerApp.h
rename to app/PlaYUVerApp.h
index 13fb5e2..be14e14 100644
--- a/app/plaYUVerApp.h
+++ b/app/PlaYUVerApp.h
@@ -18,9 +18,9 @@
*/
/**
- * \file plaYUVerApp.h
+ * \file PlaYUVerApp.h
* \ingroup PlaYUVerApp
- * \brief Main definition of the plaYUVerApp app
+ * \brief Main definition of the PlaYUVerApp app
*
* @defgroup PlaYUVerApp PlaYUVer App (GUI)
* @{
@@ -37,40 +37,50 @@
#define __PLAYUVERAPP_H__
#include "config.h"
+#include
+#include
+#include
#include "PlaYUVerAppDefs.h"
-#if( QT_VERSION_PLAYUVER == 5 )
-#include
-#elif( QT_VERSION_PLAYUVER == 4 )
-#include
-#endif
#ifdef USE_QTDBUS
#include "PlaYUVerAppAdaptor.h"
#endif
-#include
-
-#include "SubWindowHandle.h"
-#include "AboutDialog.h"
#include "VideoSubWindow.h"
+class QCloseEvent;
+class QDragEnterEvent;
+class QDropEvent;
+class QDoubleSpinBox;
+class QActionGroup;
+class QAction;
+class QSignalMapper;
+
namespace plaYUVer
{
+class PlaYUVerCmdParser;
class PlaYUVerStream;
class PlaYUVerSubWindowHandle;
class VideoHandle;
class QualityHandle;
class ModulesHandle;
class PlaYUVerAppAdaptor;
+class VideoSubWindow;
+class SubWindowAbstract;
+class AboutDialog;
-class plaYUVerApp: public QMainWindow
+class PlaYUVerApp: public QMainWindow
{
Q_OBJECT
public:
- plaYUVerApp();
- Void parseArgs( Int argc, Char *argv[] );
+ PlaYUVerApp();
+ 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 );
@@ -108,16 +118,15 @@ private Q_SLOTS:
void update();
void updateZoomFactorSBox();
- void updateStatusBar( const QString& );
private:
PlaYUVerAppAdaptor* m_pDBusAdaptor;
-
+ PlaYUVerCmdParser* m_pcCmdParser;
/**
* Save the current subwindow for every category
*/
- SubWindowHandle* m_pcCurrentSubWindow; //!< General always set
+ SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set
VideoSubWindow* m_pcCurrentVideoSubWindow;
QString m_cLastOpenPath;
@@ -246,3 +255,4 @@ private:
} // NAMESPACE
#endif // __PLAYUVERAPP_H__
+
diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/PlaYUVerAppAdaptor.cpp
index 9314035..ff1d86d 100644
--- a/app/PlaYUVerAppAdaptor.cpp
+++ b/app/PlaYUVerAppAdaptor.cpp
@@ -24,12 +24,12 @@
#include
#include "PlaYUVerAppAdaptor.h"
-#include "plaYUVerApp.h"
+#include "PlaYUVerApp.h"
namespace plaYUVer
{
-PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( plaYUVerApp *app ) :
+PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( PlaYUVerApp *app ) :
QDBusAbstractAdaptor( app ),
m_app( app )
{
diff --git a/app/PlaYUVerAppAdaptor.h b/app/PlaYUVerAppAdaptor.h
index 4210724..ae64e69 100644
--- a/app/PlaYUVerAppAdaptor.h
+++ b/app/PlaYUVerAppAdaptor.h
@@ -38,7 +38,7 @@ namespace plaYUVer
#define PLAYUVER_DBUS_SESSION_NAME "org.pixlra.PlaYUVer.application"
#define PLAYUVER_DBUS_PATH "/MainApplication"
-class plaYUVerApp;
+class PlaYUVerApp;
class PlaYUVerAppAdaptor: public QDBusAbstractAdaptor
{
@@ -46,7 +46,7 @@ Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.pixlra.PlaYUVer.application")
Q_PROPERTY(QString activeSession READ activeSession)
public:
- PlaYUVerAppAdaptor( plaYUVerApp *app );
+ PlaYUVerAppAdaptor( PlaYUVerApp *app );
~PlaYUVerAppAdaptor();
/**
* emit the exiting signal
@@ -78,7 +78,7 @@ Q_SIGNALS:
public:
QString activeSession();
private:
- plaYUVerApp *m_app;
+ PlaYUVerApp *m_app;
};
} // NAMESPACE
diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp
index 5145312..1732cf9 100644
--- a/app/PlaYUVerAppModuleIf.cpp
+++ b/app/PlaYUVerAppModuleIf.cpp
@@ -24,6 +24,7 @@
#include "PlaYUVerAppModuleIf.h"
#include "VideoSubWindow.h"
+#include "VideoSubWindow.h"
namespace plaYUVer
{
@@ -47,37 +48,36 @@ PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaY
void PlaYUVerAppModuleIf::run()
{
+
m_pcProcessedFrame = NULL;
m_dMeasurementResult = 0;
+ std::vector apcFrameList;
+ for( UInt i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ )
+ {
+ apcFrameList.push_back( m_pcSubWindow[i]->getCurrFrame() );
+ }
+
if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
{
- switch( m_pcModule->m_uiNumberOfFrames )
+ if( m_pcModule->m_iModuleAPI == MODULE_API_2 )
+ {
+ m_pcProcessedFrame = m_pcModule->process( apcFrameList );
+ }
+ else
{
- case MODULE_REQUIRES_ONE_FRAME:
m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() );
- break;
- case MODULE_REQUIRES_TWO_FRAMES:
- m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() );
- break;
- case MODULE_REQUIRES_THREE_FRAMES:
- m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() );
- break;
}
}
else if( m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE )
{
- switch( m_pcModule->m_uiNumberOfFrames )
+ if( m_pcModule->m_iModuleAPI == MODULE_API_2 )
+ {
+ m_dMeasurementResult = m_pcModule->measure( apcFrameList );
+ }
+ else
{
- case MODULE_REQUIRES_ONE_FRAME:
m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() );
- break;
- case MODULE_REQUIRES_TWO_FRAMES:
- m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() );
- break;
- case MODULE_REQUIRES_THREE_FRAMES:
- m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() );
- break;
}
}
else
diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h
index 5dda03d..69524b3 100644
--- a/app/PlaYUVerAppModuleIf.h
+++ b/app/PlaYUVerAppModuleIf.h
@@ -43,20 +43,20 @@ class VideoSubWindow;
class PlaYUVerAppModuleIf
#ifdef PLAYUVER_THREADED_MODULES
- : public QThread
+ : public QThread
#else
- : public QObject
+ : public QObject
#endif
{
friend class ModulesHandle;
friend class ModuleHandleDock;
+ friend class ModulesHandleOptDialog;
private:
QAction* m_pcModuleAction;
PlaYUVerModuleIf* m_pcModule;
-
VideoSubWindow* m_pcSubWindow[MAX_NUMBER_FRAMES];
VideoSubWindow* m_pcDisplaySubWindow;
@@ -83,8 +83,10 @@ public:
PlaYUVerAppModuleIf* m_pcModule;
};
- PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
- virtual ~PlaYUVerAppModuleIf() {}
+ PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
+ virtual ~PlaYUVerAppModuleIf()
+ {
+ }
protected:
virtual void run();
diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/PlaYUVerMdiSubWindow.cpp
index e29348f..7f407d6 100644
--- a/app/PlaYUVerMdiSubWindow.cpp
+++ b/app/PlaYUVerMdiSubWindow.cpp
@@ -22,8 +22,9 @@
* \brief Re-implementation QMdiSubWindow
*/
+#include
#include "PlaYUVerMdiSubWindow.h"
-#include "SubWindowHandle.h"
+#include "SubWindowAbstract.h"
namespace plaYUVer
{
@@ -31,6 +32,8 @@ namespace plaYUVer
PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) :
QMdiSubWindow( parent )
{
+ setAttribute( Qt::WA_DeleteOnClose );
+ setBackgroundRole( QPalette::Background );
}
QSize PlaYUVerMdiSubWindow::sizeHint() const
@@ -38,7 +41,7 @@ QSize PlaYUVerMdiSubWindow::sizeHint() const
QSize maxSize;
if( parent() )
maxSize = parentWidget()->size();
- QSize sizeHint = qobject_cast( widget() )->sizeHint( maxSize );
+ QSize sizeHint = qobject_cast( widget() )->sizeHint( maxSize );
return sizeHint;
}
diff --git a/app/PlaYUVerMdiSubWindow.h b/app/PlaYUVerMdiSubWindow.h
index 5b78920..6982339 100644
--- a/app/PlaYUVerMdiSubWindow.h
+++ b/app/PlaYUVerMdiSubWindow.h
@@ -27,11 +27,8 @@
#include "config.h"
#include "PlaYUVerAppDefs.h"
-#if( QT_VERSION_PLAYUVER == 5 )
-#include
-#elif( QT_VERSION_PLAYUVER == 4 )
-#include
-#endif
+#include
+
namespace plaYUVer
{
diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp
index 1958d3d..f377814 100644
--- a/app/PlaYUVerSubWindowHandle.cpp
+++ b/app/PlaYUVerSubWindowHandle.cpp
@@ -22,10 +22,10 @@
* \brief Handle multiple sub-windows
*/
-#include "plaYUVerApp.h"
#include "PlaYUVerSubWindowHandle.h"
+#include "PlaYUVerApp.h"
#include "PlaYUVerMdiSubWindow.h"
-#include "SubWindowHandle.h"
+#include "SubWindowAbstract.h"
namespace plaYUVer
{
@@ -33,130 +33,203 @@ namespace plaYUVer
class PlaYUVerMdiArea: public QMdiArea
{
public:
- PlaYUVerMdiArea( QWidget *parent ) :
+ PlaYUVerMdiArea( QWidget *parent = 0 ) :
QMdiArea( parent ),
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
{
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 )
{
QMdiArea::paintEvent( event );
QPainter painter( viewport() );
-
QPixmap pixFinalLogo = m_pixmapLogo.scaled( 2 * size() / 3, Qt::KeepAspectRatio );
-
// Calculate the logo position - the bottom right corner of the mdi area.
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;
};
PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) :
QWidget( parent )
{
- m_uiWindowMode = 0;
-
- setWindowMode( MdiWSubWindows );
-
+ m_iWindowMode = -1;
+ m_pcWindowManagerLayout = NULL;
+ m_pcMdiArea = NULL;
m_pcActiveWindow = NULL;
m_apcSubWindowList.clear();
m_apcMdiSubWindowList.clear();
+
+ m_pcApp = qobject_cast( parentWidget() );
+ //setWindowMode( DETACHEDSUBWINDOWMODE );
+ setWindowMode( MDISUBWINDOWMODE );
+}
+
+Void PlaYUVerSubWindowHandle::processLogMsg( const QString& msg )
+{
+ if( m_pcMdiArea )
+ {
+ m_pcMdiArea->appendLogMessage( msg );
+ }
}
Void PlaYUVerSubWindowHandle::resetWindowMode()
{
- if( m_uiWindowMode == MdiWSubWindows )
+ QList apcSubWindowList = m_apcSubWindowList;
+
+ if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
- removeAllSubWindow();
+
+ }
+ if( m_iWindowMode == MDISUBWINDOWMODE )
+ {
+ m_cMdiModeWindowPosition = m_pcApp->pos();
+ m_cMdiModeWindowSize = m_pcApp->size();
+ for( Int i = 0; i < m_apcSubWindowList.size(); i++ )
+ {
+ m_apcSubWindowList.at( i )->setParent( NULL );
+ }
+ for( Int i = 0; i < m_apcMdiSubWindowList.size(); i++ )
+ {
+ disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
+ m_apcMdiSubWindowList.at( i )->close();
+ }
m_apcMdiSubWindowList.clear();
if( m_pcMdiArea )
delete m_pcMdiArea;
if( m_pcWindowManagerLayout )
delete m_pcWindowManagerLayout;
+
}
}
-Void PlaYUVerSubWindowHandle::setWindowMode( UInt uiWindowMode )
+Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode )
{
- if( m_uiWindowMode == uiWindowMode )
+ if( m_iWindowMode == iWindowMode )
return;
resetWindowMode();
- if( uiWindowMode == NormalSubWindows )
+ if( iWindowMode == DETACHEDSUBWINDOWMODE )
{
-
+ for( Int i = 0; i < m_apcSubWindowList.size(); i++ )
+ {
+ m_apcSubWindowList.at( i )->setParent( NULL );
+ m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() );
+ m_apcSubWindowList.at( i )->show();
+ }
+ setVisible( false );
+ parentWidget()->update();
+ m_pcApp->showNormal();
+ qApp->processEvents();
+ QSize screenSize = QApplication::desktop()->availableGeometry().size();
+ m_pcApp->move( 0, 0 );
+ m_pcApp->resize( screenSize.width(), 5 );
+ m_pcApp->setWindowTitle( QApplication::applicationName() );
}
- if( uiWindowMode == MdiWSubWindows )
+ if( iWindowMode == MDISUBWINDOWMODE )
{
- m_pcMdiArea = new PlaYUVerMdiArea( this );
+ setVisible( true );
+ m_pcMdiArea = new PlaYUVerMdiArea;
m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) );
m_pcWindowManagerLayout = new QHBoxLayout( this );
m_pcWindowManagerLayout->addWidget( m_pcMdiArea );
setLayout( m_pcWindowManagerLayout );
+ for( Int i = 0; i < m_apcSubWindowList.size(); i++ )
+ {
+ addMdiSubWindow( m_apcSubWindowList.at( i ) );
+ m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() );
+ }
+ m_pcApp->move( m_cMdiModeWindowPosition );
+ m_pcApp->resize( m_cMdiModeWindowSize );
+ if( m_pcActiveWindow )
+ {
+ m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
+ }
}
-
- m_uiWindowMode = uiWindowMode;
+ m_iWindowMode = iWindowMode;
+ //tileSubWindows();
+ parentWidget()->update();
+ qApp->processEvents();
}
-Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window )
+Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window )
{
- if( m_uiWindowMode == NormalSubWindows )
+ if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
if( window )
+ {
m_pcActiveWindow = window;
+ emit changed();
+ }
}
- if( m_uiWindowMode == MdiWSubWindows )
+ if( m_iWindowMode == MDISUBWINDOWMODE )
{
m_pcActiveWindow = NULL;
QMdiSubWindow* mdiSubWindow = m_pcMdiArea->activeSubWindow();
if( mdiSubWindow )
{
QWidget* activeWidget = m_pcMdiArea->activeSubWindow()->widget();
- Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) );
+ Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) );
if( windowIdx >= 0 )
{
m_pcActiveWindow = m_apcSubWindowList.at( windowIdx );
emit changed();
}
}
+ if( m_pcActiveWindow )
+ {
+ m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
+ }
}
-
- if( m_pcActiveWindow )
- {
- parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
- }
-
}
-Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowFlags flags )
+Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract *window )
+{
+ PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow;
+ mdiSubWindow->setWidget( window );
+ m_pcMdiArea->addSubWindow( mdiSubWindow );
+ m_apcMdiSubWindowList.append( mdiSubWindow );
+ window->setSubWindow( mdiSubWindow );
+ connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
+}
+
+Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::WindowFlags flags )
{
if( window )
{
- connect( window, SIGNAL( updateStatusBar( const QString& ) ), qobject_cast( parent() ), SLOT( updateStatusBar( const QString& ) ) );
- connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), qobject_cast( parent() ),
- SLOT( updateZoomFactorSBox() ) );
- if( m_uiWindowMode == NormalSubWindows )
+ 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 )
{
- connect( window, SIGNAL( aboutToActivate( SubWindowHandle* ) ), this, SLOT( updateActiveSubWindow( SubWindowHandle* ) ) );
- connect( window, SIGNAL( aboutToClose( SubWindowHandle* ) ), this, SLOT( removeSubWindow( SubWindowHandle* ) ) );
+ connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this, SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) );
+ connect( window, SIGNAL( aboutToClose( SubWindowAbstract* ) ), this, SLOT( removeSubWindow( SubWindowAbstract* ) ) );
}
- if( m_uiWindowMode == MdiWSubWindows )
+ if( m_iWindowMode == MDISUBWINDOWMODE )
{
- PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow;
- mdiSubWindow->setWidget( window );
- m_pcMdiArea->addSubWindow( mdiSubWindow );
- m_apcMdiSubWindowList.append( mdiSubWindow );
- window->setSubWindow( mdiSubWindow );
- connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
+ addMdiSubWindow( window );
}
m_apcSubWindowList.append( window );
}
@@ -166,13 +239,13 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx )
{
if( windowIdx >= 0 )
{
- if( m_uiWindowMode == NormalSubWindows )
+ if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
{
- SubWindowHandle* subWindow = m_apcSubWindowList.at( windowIdx );
+ SubWindowAbstract* subWindow = m_apcSubWindowList.at( windowIdx );
m_apcSubWindowList.removeAt( windowIdx );
subWindow->close();
}
- if( m_uiWindowMode == MdiWSubWindows )
+ if( m_iWindowMode == MDISUBWINDOWMODE )
{
PlaYUVerMdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx );
m_apcMdiSubWindowList.removeAt( windowIdx );
@@ -190,7 +263,7 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx )
}
}
-Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowHandle* window )
+Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowAbstract* window )
{
removeSubWindow( m_apcSubWindowList.indexOf( window ) );
}
@@ -213,14 +286,14 @@ Void PlaYUVerSubWindowHandle::removeActiveSubWindow()
removeSubWindow( m_pcActiveWindow );
}
-SubWindowHandle* PlaYUVerSubWindowHandle::activeSubWindow() const
+SubWindowAbstract* PlaYUVerSubWindowHandle::activeSubWindow() const
{
return m_pcActiveWindow;
}
-QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const
+QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const
{
- QList apcSubWindowList;
+ QList apcSubWindowList;
if( uiCategory == 0 )
{
apcSubWindowList = m_apcSubWindowList;
@@ -236,10 +309,10 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCat
return apcSubWindowList;
}
-QList PlaYUVerSubWindowHandle::findSubWindow( const QString &windowName, const UInt uiCategory ) const
+QList PlaYUVerSubWindowHandle::findSubWindow( const QString &windowName, const UInt uiCategory ) const
{
- QList subWindowList = findSubWindow( uiCategory );
- QList apcSubWindowList;
+ QList subWindowList = findSubWindow( uiCategory );
+ QList apcSubWindowList;
if( !windowName.isEmpty() )
{
for( Int i = 0; i < subWindowList.size(); i++ )
@@ -251,9 +324,9 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const QString &w
return apcSubWindowList;
}
-SubWindowHandle* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowHandle* subWindow ) const
+SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstract* subWindow ) const
{
- QList subWindowList = findSubWindow();
+ QList subWindowList = findSubWindow();
for( Int i = 0; i < subWindowList.size(); i++ )
{
if( subWindow == subWindowList.at( i ) )
@@ -267,21 +340,89 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window )
if( !window )
return;
- m_pcActiveWindow = qobject_cast( window );
- m_pcActiveWindow->window()->activateWindow();
+ m_pcActiveWindow = qobject_cast( window );
+
+ if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
+ {
+ m_pcActiveWindow->window()->activateWindow();
+ }
+ if( m_iWindowMode == MDISUBWINDOWMODE )
+ {
+ m_pcActiveWindow->setFocus();
+ }
}
Void PlaYUVerSubWindowHandle::tileSubWindows()
{
- if( m_uiWindowMode == MdiWSubWindows )
+ UInt numberOfWindows = m_apcSubWindowList.size();
+ if( numberOfWindows == 0 )
+ return;
+
+ if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
+ {
+ QSize screenSize = QApplication::desktop()->availableGeometry().size();
+ UInt minWindowsInRow = 1;
+ while( ( screenSize.width() / minWindowsInRow ) > 500 )
+ {
+ minWindowsInRow++;
+ }
+ m_pcApp->showNormal();
+ qApp->processEvents();
+ m_pcApp->move( 0, 0 );
+ m_pcApp->resize( screenSize.width(), 5 );
+ QSize appSize = m_pcApp->size();
+ QPoint topLeftCornerWindow( 0, appSize.height() );
+ //Select the arrangement based on the number of windows
+
+ if( numberOfWindows % 2 != 0 && numberOfWindows > minWindowsInRow )
+ {
+ numberOfWindows++;
+ }
+ UInt numberTillingRows = 1;
+ UInt numberTillingColumns;
+ if( numberOfWindows > minWindowsInRow )
+ {
+ numberTillingColumns = minWindowsInRow;
+ for( Int i = numberOfWindows; i > 0; )
+ {
+ numberTillingRows = ( numberOfWindows + numberTillingColumns - 1 ) / numberTillingColumns;
+ if( numberTillingColumns > numberTillingRows )
+ {
+ break;
+ }
+ numberTillingColumns++;
+ }
+ }
+ else
+ {
+ numberTillingColumns = numberOfWindows;
+ }
+ if( numberOfWindows / numberTillingRows == 1 )
+ {
+ numberTillingColumns = numberTillingRows;
+ }
+
+ QSize totalWindowsSize( screenSize.width(), screenSize.height() - topLeftCornerWindow.y() );
+ QSize windowsSize( totalWindowsSize.width() / numberTillingColumns, totalWindowsSize.height() / numberTillingRows );
+ QPoint windowRelativePos;
+ for( Int i = 0; i < m_apcSubWindowList.size(); i++ )
+ {
+ windowRelativePos.setY( ( i / numberTillingColumns ) * windowsSize.height() );
+ windowRelativePos.setX( ( i % numberTillingColumns ) * windowsSize.width() );
+ m_apcSubWindowList.at( i )->resize( windowsSize );
+ m_apcSubWindowList.at( i )->move( topLeftCornerWindow + windowRelativePos );
+ }
+ }
+ if( m_iWindowMode == MDISUBWINDOWMODE )
{
m_pcMdiArea->tileSubWindows();
}
+
}
Void PlaYUVerSubWindowHandle::cascadeSubWindows()
{
- if( m_uiWindowMode == MdiWSubWindows )
+ if( m_iWindowMode == MDISUBWINDOWMODE )
{
m_pcMdiArea->cascadeSubWindows();
}
@@ -294,6 +435,32 @@ Void PlaYUVerSubWindowHandle::createActions()
m_arrayActions.resize( TOTAL_ACT );
+ // ------------ Tools ------------
+ m_actionGroupWindowMode = new QActionGroup( this );
+ m_actionGroupWindowMode->setExclusive( true );
+
+ m_mapperWindowMode = new QSignalMapper( this );
+ connect( m_mapperWindowMode, SIGNAL( mapped(int) ), this, SLOT( setWindowMode(int) ) );
+
+ m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] = new QAction( tr( "&Detached SubWindows" ), this );
+ m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT]->setCheckable( true );
+ m_actionGroupWindowMode->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] );
+ connect( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) );
+ m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], DETACHEDSUBWINDOWMODE );
+
+ m_arrayActions[MDI_SUBWINDOW_MODE_ACT] = new QAction( "&MDI SubWindows", this );
+ m_arrayActions[MDI_SUBWINDOW_MODE_ACT]->setCheckable( true );
+ m_actionGroupWindowMode->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] );
+ connect( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) );
+ m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], MDISUBWINDOWMODE );
+
+ m_actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true );
+
+ m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
+ m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
+ m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
+ connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) );
+
m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
@@ -306,7 +473,7 @@ Void PlaYUVerSubWindowHandle::createActions()
m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "Tile" ), this );
m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) );
m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) );
- //connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
+//connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( tileSubWindows() ) );
m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "Cascade" ), this );
@@ -318,13 +485,13 @@ Void PlaYUVerSubWindowHandle::createActions()
m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild );
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) );
m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) );
- // connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) );
+// connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) );
- // connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) );
+// connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) );
m_arrayActions[SEPARATOR_ACT] = new QAction( this );
m_arrayActions[SEPARATOR_ACT]->setSeparator( true );
@@ -342,15 +509,18 @@ QMenu* PlaYUVerSubWindowHandle::createMenu()
Void PlaYUVerSubWindowHandle::updateMenu()
{
m_pcMenuWindow->clear();
+ m_pcMenuWindow->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] );
+ m_pcMenuWindow->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] );
+ m_pcMenuWindow->addSeparator();
m_pcMenuWindow->addAction( m_arrayActions[CLOSE_ACT] );
m_pcMenuWindow->addAction( m_arrayActions[CLOSE_ALL_ACT] );
m_pcMenuWindow->addSeparator();
m_pcMenuWindow->addAction( m_arrayActions[TILE_WINDOWS_ACT] );
m_pcMenuWindow->addAction( m_arrayActions[CASCADE_WINDOWS_ACT] );
m_pcMenuWindow->addSeparator();
- m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] );
- m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] );
- m_pcMenuWindow->addSeparator();
+// m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] );
+// m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] );
+// m_pcMenuWindow->addSeparator();
Int number_windows = m_apcSubWindowList.size();
if( number_windows > 1 )
@@ -368,7 +538,7 @@ Void PlaYUVerSubWindowHandle::updateMenu()
for( Int i = 0; i < number_windows; ++i )
{
- SubWindowHandle *subWindow = m_apcSubWindowList.at( i );
+ SubWindowAbstract *subWindow = m_apcSubWindowList.at( i );
QString text;
if( i < 9 )
@@ -389,12 +559,20 @@ Void PlaYUVerSubWindowHandle::updateMenu()
Void PlaYUVerSubWindowHandle::readSettings()
{
-
+ QSettings appSettings;
+ m_cMdiModeWindowPosition = appSettings.value( "SubWindowManager/LastMdiPosition", QPoint( 200, 200 ) ).toPoint();
+ m_cMdiModeWindowSize = appSettings.value( "SubWindowManager/LastMdiSize", QSize( 500, 400 ) ).toSize();
+ Int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MDISUBWINDOWMODE ).toInt();
+ setWindowMode( iWindowMode );
+ m_actionGroupWindowMode->actions().at( iWindowMode )->setChecked( true );
}
Void PlaYUVerSubWindowHandle::writeSettings()
{
-
+ QSettings appSettings;
+ appSettings.setValue( "SubWindowManager/LastMdiPosition", m_cMdiModeWindowPosition );
+ appSettings.setValue( "SubWindowManager/LastMdiSize", m_cMdiModeWindowSize );
+ appSettings.setValue( "SubWindowManager/SubWindowMode", m_iWindowMode );
}
} // NAMESPACE
diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h
index b7c682c..ad7412f 100644
--- a/app/PlaYUVerSubWindowHandle.h
+++ b/app/PlaYUVerSubWindowHandle.h
@@ -36,7 +36,8 @@
namespace plaYUVer
{
-class SubWindowHandle;
+class PlaYUVerApp;
+class SubWindowAbstract;
class PlaYUVerMdiArea;
class PlaYUVerMdiSubWindow;
@@ -47,13 +48,15 @@ Q_OBJECT
public:
PlaYUVerSubWindowHandle( QWidget *parent );
- Void addSubWindow( SubWindowHandle *widget, Qt::WindowFlags flags = 0 );
+ Void processLogMsg( const QString& msg );
- SubWindowHandle *activeSubWindow() const;
+ Void addSubWindow( SubWindowAbstract *widget, Qt::WindowFlags flags = 0 );
- QList findSubWindow( const UInt uiCategory = 0 ) const;
- QList findSubWindow( const QString &aName, const UInt uiCategory = 0 ) const;
- SubWindowHandle* findSubWindow( const SubWindowHandle* subWindow ) const;
+ SubWindowAbstract *activeSubWindow() const;
+
+ QList findSubWindow( const UInt uiCategory = 0 ) const;
+ QList findSubWindow( const QString &aName, const UInt uiCategory = 0 ) const;
+ SubWindowAbstract* findSubWindow( const SubWindowAbstract* subWindow ) const;
Void createActions();
QMenu* createMenu();
@@ -63,22 +66,28 @@ public:
enum WindowMode
{
- NormalSubWindows = 0,
- MdiWSubWindows = 1,
+ DETACHEDSUBWINDOWMODE = 0,
+ MDISUBWINDOWMODE = 1,
};
private:
- UInt m_uiWindowMode;
- QList m_apcSubWindowList;
+ PlaYUVerApp* m_pcApp;
+ Int m_iWindowMode;
+ QList m_apcSubWindowList;
QHBoxLayout* m_pcWindowManagerLayout;
PlaYUVerMdiArea* m_pcMdiArea;
QList m_apcMdiSubWindowList;
- SubWindowHandle* m_pcActiveWindow;
+ SubWindowAbstract* m_pcActiveWindow;
+
+ QPoint m_cMdiModeWindowPosition;
+ QSize m_cMdiModeWindowSize;
enum
{
+ NORMAL_SUBWINDOW_MODE_ACT,
+ MDI_SUBWINDOW_MODE_ACT,
CLOSE_ACT,
CLOSE_ALL_ACT,
TILE_WINDOWS_ACT,
@@ -89,20 +98,23 @@ private:
TOTAL_ACT,
};
QVector m_arrayActions;
+ QSignalMapper* m_mapperWindowMode;
+ QActionGroup* m_actionGroupWindowMode;
QSignalMapper* m_mapperWindow;
QMenu* m_pcMenuWindow;
/**
* Internal functions
*/
+ Void addMdiSubWindow( SubWindowAbstract *window );
Void resetWindowMode();
- Void setWindowMode( UInt uiWindowMode );
Void removeSubWindow( Int windowIdx );
public Q_SLOTS:
- void updateActiveSubWindow( SubWindowHandle *window = 0 );
+ void setWindowMode( int iWindowMode );
+ void updateActiveSubWindow( SubWindowAbstract *window = 0 );
void setActiveSubWindow( QWidget *window );
- void removeSubWindow( SubWindowHandle *window );
+ void removeSubWindow( SubWindowAbstract *window );
void removeMdiSubWindow( PlaYUVerMdiSubWindow* window );
void removeActiveSubWindow();
void removeAllSubWindow();
diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp
index 35b019b..9916e03 100644
--- a/app/PlotSubWindow.cpp
+++ b/app/PlotSubWindow.cpp
@@ -23,44 +23,75 @@
*/
#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 );
+ m_arrayColorList.append( Qt::magenta );
+ m_arrayColorList.append( Qt::yellow );
+ m_arrayColorList.append( Qt::gray );
+ m_arrayColorList.append( Qt::darkRed );
+ m_arrayColorList.append( Qt::darkGreen );
+ m_arrayColorList.append( Qt::darkRed );
+ m_arrayColorList.append( Qt::darkBlue );
+ m_arrayColorList.append( Qt::darkMagenta );
+ m_arrayColorList.append( Qt::darkCyan );
+ m_arrayColorList.append( Qt::darkYellow );
}
-Void PlotSubWindow::Example()
+PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) :
+ SubWindowAbstract( parent, SubWindowAbstract::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 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_iNumberPlots = 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 +99,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 +124,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 +142,103 @@ 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 &arrayX, const QVector &arrayY, const QString& key )
+{
+ QCPGraph *newPlot = m_cPlotArea->addGraph();
+ QColor plotColor = m_arrayColorList.at( 0 );
+ if( m_iNumberPlots < m_arrayColorList.size() )
+ {
+ plotColor = m_arrayColorList.at( m_iNumberPlots );
+ }
+ m_cPlotPen.setColor( plotColor );
+ 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_iNumberPlots > 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_iNumberPlots++;
+}
} // NAMESPACE
diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h
index 9dfb063..81538a6 100644
--- a/app/PlotSubWindow.h
+++ b/app/PlotSubWindow.h
@@ -32,31 +32,50 @@
#elif( QT_VERSION_PLAYUVER == 4 )
#include
#endif
-#include "SubWindowHandle.h"
-#include "qcustomplot.h"
+#include "SubWindowAbstract.h"
+
+class QCustomPlot;
namespace plaYUVer
{
-class PlotSubWindow: public SubWindowHandle
+class PlotSubWindow: public SubWindowAbstract
{
Q_OBJECT
private:
QCustomPlot* m_cPlotArea;
- Void Example();
+ QVector m_arrayColorList;
+ QPen m_cPlotPen;
+
+ enum Axis
+ {
+ HORIZONTAL,
+ VERTICAL,
+ };
+ Double m_aAxisRange[2][2];
+ Double m_dScaleFactor;
+ Int m_iNumberPlots;
public:
- PlotSubWindow( QWidget * parent = 0 );
+
+ PlotSubWindow( const QString& windowTitle, QWidget * parent = NULL );
~PlotSubWindow();
+ Void definePlotColors();
+
+ Void refreshSubWindow()
+ {
+
+ }
+
Void setTool( UInt uiTool )
{
}
/**
- * Virtual functions from SubWindowHandle
+ * Virtual functions from SubWindowAbstract
*/
Void normalSize();
Void zoomToFit();
@@ -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 &arrayX, const QVector &arrayY, const QString& key = QString() );
+
};
} // NAMESPACE
diff --git a/app/ProgressBar.cpp b/app/ProgressBar.cpp
new file mode 100644
index 0000000..6f0104f
--- /dev/null
+++ b/app/ProgressBar.cpp
@@ -0,0 +1,64 @@
+/* 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 appSize = QApplication::desktop()->availableGeometry().size();
+// QPoint appCenter = QApplication::desktop()->availableGeometry().center();
+ QSize appSize = parent->size();
+ QPoint appPos = parent->pos();
+ QPoint appCenter = QPoint( appPos.x() + appSize.width() / 2, appPos.y() + appSize.height() / 2 );
+ resize( appSize.width() / 4, appSize.height() / 10 );
+ move( appCenter.x() - appSize.width() / 8, appCenter.y() - appSize.height() / 20 );
+ show();
+}
+
+Void ProgressBar::incrementProgress( UInt increment )
+{
+ m_uiProgress += increment;
+ m_pcProgressBar->setValue( m_uiProgress );
+ update();
+}
+} // NAMESPACE
diff --git a/app/ProgressBar.h b/app/ProgressBar.h
new file mode 100644
index 0000000..8cba896
--- /dev/null
+++ b/app/ProgressBar.h
@@ -0,0 +1,54 @@
+/* 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
+#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 0230970..ab20471 100644
--- a/app/QualityHandle.cpp
+++ b/app/QualityHandle.cpp
@@ -23,11 +23,16 @@
*/
#include
+#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,14 @@ Void QualityHandle::createActions()
}
m_arrayActions.resize( TOTAL_ACT );
- 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[SELECT_CURR_REF_ACT] = new QAction( "Mark as Reference", this );
+ connect( m_arrayActions[SELECT_CURR_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectCurrentAsReference() ) );
+
+ 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 +82,10 @@ 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->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;
}
@@ -96,12 +106,35 @@ QDockWidget* QualityHandle::createDock()
Void QualityHandle::updateMenus()
{
- VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
- Bool hasSubWindow = pcSubWindow ? true : false;
+ VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ Bool hasSubWindow = pcCurrentVideoSubWindow ? true : false;
+ Bool hasReference = false;
+ Bool isReference = false;
+
+ if( hasSubWindow )
+ {
+ hasReference = pcCurrentVideoSubWindow->getRefSubWindow() != NULL ? true : false;
+ if( hasSubWindow && !hasReference )
+ {
+ VideoSubWindow* pcVideoSubWindow;
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ for( Int i = 0; i < subWindowList.size(); i++ )
+ {
+ pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
+ if( pcVideoSubWindow->getRefSubWindow() == pcCurrentVideoSubWindow )
+ {
+ isReference = true;
+ break;
+ }
+ }
+ }
+ }
m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow );
- m_arrayActions[SELECT_REF_ACT]->setEnabled( hasSubWindow );
- m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow );
+ m_arrayActions[SELECT_CURR_REF_ACT]->setEnabled( hasSubWindow );
+
+ m_arrayActions[PLOT_QUALITY]->setEnabled( hasReference );
+ m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasReference | isReference );
m_pcQualityHandleSideBar->updateSideBar( hasSubWindow );
}
@@ -127,6 +160,87 @@ Void QualityHandle::update( VideoSubWindow* currSubWindow )
m_pcQualityHandleSideBar->updateCurrentWindow( currSubWindow );
}
+Void QualityHandle::measureQuality( QVector apcWindowList )
+{
+ QVector* 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 [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( 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,40 +249,85 @@ Void QualityHandle::slotQualityMetricChanged( Int idx )
m_iQualityMetricIdx = idx;
}
-Void QualityHandle::slotSelectReference()
+Void QualityHandle::slotSelectCurrentAsReference()
{
- DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 );
- if( dialogWindowSelection.exec() == QDialog::Accepted )
+ VideoSubWindow* pcRefSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ if( pcRefSubWindow )
{
VideoSubWindow* pcVideoSubWindow;
- VideoSubWindow* pcRefSubWindow = NULL;
- QStringList selectedWindows = dialogWindowSelection.getSelectedWindows();
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
- if( pcVideoSubWindow->getWindowName() == selectedWindows.at( 0 ) )
- {
- pcRefSubWindow = pcVideoSubWindow;
- break;
- }
- }
- for( Int i = 0; i < subWindowList.size(); i++ )
- {
- pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
- pcVideoSubWindow->setRefSubWindow( pcRefSubWindow );
+ if( pcVideoSubWindow != pcRefSubWindow )
+ pcVideoSubWindow->setRefSubWindow( pcRefSubWindow );
}
m_pcQualityHandleSideBar->updateSidebarData();
m_pcQualityHandleDock->show();
+ emit changed();
}
}
-Void QualityHandle::slotCreatePlot()
+Void QualityHandle::slotPlotQualitySingle()
{
- PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet );
- m_pcMainWindowManager->addSubWindow( pcPlotWindow );
- pcPlotWindow->show();
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ if( pcSubWindow )
+ {
+ if( pcSubWindow->getRefSubWindow() )
+ {
+ QVector 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
+ emit changed();
+ }
+ }
+}
+
+Void QualityHandle::slotPlotQualitySeveral()
+{
+ VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() );
+ if( pcSubWindow )
+ {
+ QVector apcWindowList;
+
+ VideoSubWindow* pcRefSubWindow = pcSubWindow->getRefSubWindow();
+ if( !pcRefSubWindow )
+ {
+ pcRefSubWindow = pcSubWindow;
+ }
+
+ VideoSubWindow* pcVideoSubWindow;
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
+ for( Int i = 0; i < subWindowList.size(); i++ )
+ {
+ pcVideoSubWindow = qobject_cast( 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
+ emit changed();
+ }
+ }
}
} // NAMESPACE
diff --git a/app/QualityHandle.h b/app/QualityHandle.h
index faa42d5..e1bc0b4 100644
--- a/app/QualityHandle.h
+++ b/app/QualityHandle.h
@@ -33,6 +33,7 @@
#elif( QT_VERSION_PLAYUVER == 4 )
#include
#endif
+#include "QFuture"
#include "QualityMeasurementSidebar.h"
namespace plaYUVer
@@ -61,10 +62,12 @@ public:
private:
QWidget* m_pcParet;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
+
enum
{
- SELECT_REF_ACT,
+ SELECT_CURR_REF_ACT,
PLOT_QUALITY,
+ PLOT_SEVERAL_QUALITY,
TOTAL_ACT,
};
QVector m_arrayActions;
@@ -78,13 +81,17 @@ private:
QDockWidget* m_pcQualityHandleDock;
QualityMeasurementSidebar* m_pcQualityHandleSideBar;
+ QFuture m_cMeasurementResult;
+ Void measureQuality( QVector apcWindowList );
+
Q_SIGNALS:
void changed();
private Q_SLOTS:
void slotQualityMetricChanged( int );
- void slotSelectReference();
- void slotCreatePlot();
+ void slotSelectCurrentAsReference();
+ void slotPlotQualitySingle();
+ void slotPlotQualitySeveral();
};
} // NAMESPACE
diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp
index e140dd4..b8772bc 100644
--- a/app/QualityMeasurementSidebar.cpp
+++ b/app/QualityMeasurementSidebar.cpp
@@ -56,15 +56,17 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS
m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
m_comboBoxRef = new QComboBox;
- m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength );
+ QSpacerItem* spaceQuality = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed );
+ //m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength );
m_comboBoxRef->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
updateSubWindowList();
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget( MetricLabel, 0, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxMetric, 0, 1, Qt::AlignLeft );
+ mainLayout->addItem( spaceQuality, 0, 2, Qt::AlignRight );
mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft );
- mainLayout->addWidget( m_comboBoxRef, 1, 1, Qt::AlignLeft );
+ mainLayout->addWidget( m_comboBoxRef, 1, 1, 1, 2, Qt::AlignLeft );
m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" );
m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
@@ -134,7 +136,7 @@ Void QualityMeasurementSidebar::updateSubWindowList()
m_pcVideoWindowList.clear();
VideoSubWindow* pcVideoSubWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
pcVideoSubWindow = qobject_cast( subWindowList.at( i ) );
@@ -185,7 +187,7 @@ Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow *subWindow )
Void QualityMeasurementSidebar::updateSidebarData()
{
- QString value( "0.0000" );
+ QString zeroValue( "0.0000" );
if( m_pcCurrentVideoSubWindow )
{
VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow();
@@ -194,12 +196,18 @@ Void QualityMeasurementSidebar::updateSidebarData()
PlaYUVerFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame();
Double quality;
-
- for( Int component = 0; component < 3; component++ )
+ QString value;
+ UInt component = 0;
+ for( ; component < currFrame->getNumberChannels(); component++ )
{
quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component );
m_ppcLabelQualityValue[component]->setText( value.setNum( quality, 'f', 4 ) );
}
+ for( ; component < 3; component++ )
+ {
+ quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component );
+ m_ppcLabelQualityValue[component]->setText( zeroValue );
+ }
return;
}
else
@@ -209,7 +217,7 @@ Void QualityMeasurementSidebar::updateSidebarData()
}
for( Int component = 0; component < 3; component++ )
{
- m_ppcLabelQualityValue[component]->setText( value );
+ m_ppcLabelQualityValue[component]->setText( zeroValue );
}
}
diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp
new file mode 100644
index 0000000..ab88e7a
--- /dev/null
+++ b/app/SubWindowAbstract.cpp
@@ -0,0 +1,117 @@
+/* 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 SubWindowAbstract.cpp
+ * \brief Abstract class to handle subwindows
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "SubWindowAbstract.h"
+#include "PlaYUVerMdiSubWindow.h"
+
+namespace plaYUVer
+{
+
+SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) :
+ QWidget( parent ),
+ m_cSubWindow( NULL )
+{
+ setParent( parent );
+ setVisible( false );
+ setFocusPolicy( Qt::WheelFocus );
+ setAttribute( Qt::WA_DeleteOnClose );
+ setBackgroundRole( QPalette::Background );
+
+ setWindowIcon( QIcon( ":/images/playuver.png" ) );
+
+ //setWidgetResizable( true );
+ m_pcLayout = NULL;
+ m_uiCategory = category;
+ m_cWindowName = QString( " " );
+
+ connect( this, SIGNAL( destroyed() ), this, SLOT( onDestroyed() ) );
+}
+
+SubWindowAbstract::~SubWindowAbstract()
+{
+ return;
+}
+
+Void SubWindowAbstract::setWidget( QWidget* widget )
+{
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setContentsMargins( 0, 0, 0, 0 );
+ layout->addWidget( widget, 0, 0 );
+}
+
+void SubWindowAbstract::onDestroyed()
+{
+ return;
+}
+
+Void SubWindowAbstract::setWindowName( QString name )
+{
+ m_cWindowName = name;
+ setWindowTitle( m_cWindowName );
+}
+
+QString SubWindowAbstract::getWindowName()
+{
+ return m_cWindowName;
+}
+
+Bool SubWindowAbstract::mayClose()
+{
+ return true;
+}
+
+QSize SubWindowAbstract::sizeHint() const
+{
+ return QSize();
+}
+
+QSize SubWindowAbstract::sizeHint( const QSize & ) const
+{
+ return QSize();
+}
+
+Void SubWindowAbstract::focusInEvent( QFocusEvent * event )
+{
+ emit aboutToActivate( this );
+}
+
+Void SubWindowAbstract::closeEvent( QCloseEvent *event )
+{
+ emit aboutToClose( this );
+ event->accept();
+}
+
+Void SubWindowAbstract::closeSubWindow()
+{
+ close();
+ if( m_cSubWindow )
+ m_cSubWindow->close();
+}
+
+} // NAMESPACE
diff --git a/app/SubWindowHandle.h b/app/SubWindowAbstract.h
similarity index 71%
rename from app/SubWindowHandle.h
rename to app/SubWindowAbstract.h
index 8b77dc1..cd89aff 100644
--- a/app/SubWindowHandle.h
+++ b/app/SubWindowAbstract.h
@@ -18,9 +18,9 @@
*/
/**
- * \file SubWindowHandle.h
+ * \file SubWindowAbstract.h
* \ingroup PlaYUVerApp PlaYUVerApp_Subwindow
- * \brief Sub windows handling
+ * \brief Abstract class to handle subwindows
*
* @defgroup PlaYUVerApp_Subwindow SubWindow definition
* @{
@@ -34,30 +34,31 @@
* @}
*/
-#ifndef __SUBWINDOWHANDLE_H__
-#define __SUBWINDOWHANDLE_H__
+#ifndef __SUBWINDOWABSTRACT_H__
+#define __SUBWINDOWABSTRACT_H__
#include "config.h"
#include "PlaYUVerAppDefs.h"
-#if( QT_VERSION_PLAYUVER == 5 )
-#include
-#elif( QT_VERSION_PLAYUVER == 4 )
-#include
-#endif
+#include
+#include
+#include
+#include
+
+class QHBoxLayout;
+class QFocusEvent;
+class QCloseEvent;
namespace plaYUVer
{
class PlaYUVerMdiSubWindow;
-class SubWindowHandle: public QScrollArea
+class SubWindowAbstract: public QWidget
{
Q_OBJECT
private:
- QPoint m_cLastScroll;
- QPoint m_cCurrScroll;
-
+ QHBoxLayout* m_pcLayout;
UInt m_uiCategory;
QString m_cWindowName;
@@ -73,8 +74,13 @@ public:
PLOT_SUBWINDOW = 8,
};
- SubWindowHandle( QWidget *, UInt );
- ~SubWindowHandle();
+ SubWindowAbstract( QWidget *, UInt );
+ ~SubWindowAbstract();
+
+ /**
+ * Show the image at its original size
+ */
+ virtual Void refreshSubWindow() = 0;
/**
* Show the image at its original size
@@ -105,7 +111,7 @@ public:
/**
* Size related functions
*/
- //virtual QSize sizeHint() const;
+ virtual QSize sizeHint() const;
virtual QSize sizeHint( const QSize & ) const;
/**
@@ -117,11 +123,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;
@@ -130,9 +153,10 @@ public:
Void closeSubWindow();
protected:
- void focusInEvent( QFocusEvent * event );
- void closeEvent( QCloseEvent *event );
- QSize getScrollSize();
+ void focusInEvent( QFocusEvent* event );
+ void closeEvent( QCloseEvent* event );
+
+ Void setWidget( QWidget* widget );
Q_SIGNALS:
/**
@@ -148,19 +172,15 @@ Q_SIGNALS:
*/
void updateStatusBar( const QString& );
- void aboutToActivate( SubWindowHandle* );
- void aboutToClose( SubWindowHandle* );
+ void aboutToActivate( SubWindowAbstract* );
+ void aboutToClose( SubWindowAbstract* );
public Q_SLOTS:
void onDestroyed();
- void adjustScrollBarByScale( double scale, QPoint center );
- void adjustScrollBarByOffset( QPoint Offset );
- void updateCurScrollValues();
- void setCurScrollValues();
};
} // NAMESPACE
-#endif // __SUBWINDOWHANDLE_H__
+#endif // __SUBWINDOWABSTRACT_H__
diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp
deleted file mode 100644
index 7830ba9..0000000
--- a/app/SubWindowHandle.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* 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 SubWindowHandle.cpp
- * \brief Sub windows handling
- */
-
-#include "SubWindowHandle.h"
-#include "PlaYUVerMdiSubWindow.h"
-namespace plaYUVer
-{
-
-SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) :
- QScrollArea( parent ),
- m_cSubWindow( NULL )
-{
- setParent( parent );
- setFocusPolicy( Qt::WheelFocus );
- setAttribute( Qt::WA_DeleteOnClose );
- setBackgroundRole( QPalette::Background );
-
- setWindowIcon( QIcon( ":/images/playuver.png" ) );
-
- // Create a new scroll area inside the sub-window
- connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
- connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
-
- setWidgetResizable( true );
-
- m_uiCategory = category;
- m_cLastScroll = QPoint();
- m_cWindowName = QString( " " );
-
- connect(this, SIGNAL(destroyed()), this, SLOT(onDestroyed()));
-}
-
-void SubWindowHandle::onDestroyed()
-{
- return;
-}
-
-SubWindowHandle::~SubWindowHandle()
-{
- return;
-}
-
-QSize SubWindowHandle::getScrollSize()
-{
- return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 );
-}
-
-Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
-{
- QPoint cLastScroll = m_cCurrScroll;
- QScrollBar *scrollBarH, *scrollBarV;
- Int valueX, valueY;
-
- valueX = int( cLastScroll.x() + Offset.x() );
- valueY = int( cLastScroll.y() + Offset.y() );
-
- scrollBarH = horizontalScrollBar();
- if( valueX > scrollBarH->maximum() )
- valueX = scrollBarH->maximum();
- if( valueX < scrollBarH->minimum() )
- valueX = scrollBarH->minimum();
- m_cCurrScroll.setX(valueX);
-
- scrollBarV = verticalScrollBar();
- if( valueY > scrollBarV->maximum() )
- valueY = scrollBarV->maximum();
- if( valueY < scrollBarV->minimum() )
- valueY = scrollBarV->minimum();
- m_cCurrScroll.setY( valueY );
-
- // Update window scroll
- scrollBarH->setValue( m_cCurrScroll.x() );
- scrollBarV->setValue( m_cCurrScroll.y() );
-}
-
-// This function was developed with help of the schematics presented in
-// http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position
-Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center )
-{
- QPoint cLastScroll = m_cCurrScroll;
- QScrollBar *scrollBarH, *scrollBarV;
-
- scrollBarH = horizontalScrollBar();
- if( center.isNull() )
- {
- m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ));
- }
- else
- {
- Int x = center.x() - cLastScroll.x();
- Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) );
- if( value > scrollBarH->maximum() )
- value = scrollBarH->maximum();
- if( value < scrollBarH->minimum() )
- value = scrollBarH->minimum();
- m_cCurrScroll.setX(value);
- }
-
- scrollBarV = verticalScrollBar();
- if( center.isNull() )
- {
- m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ));
- }
- else
- {
- Int y = center.y() - cLastScroll.y();
- Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) );
- if( value > scrollBarV->maximum() )
- value = scrollBarV->maximum();
- if( value < scrollBarV->minimum() )
- value = scrollBarV->minimum();
- m_cCurrScroll.setY(value);
- }
-
- // Update window scroll
- scrollBarH->setValue( m_cCurrScroll.x() );
- scrollBarV->setValue( m_cCurrScroll.y() );
-
-}
-
-Void SubWindowHandle::updateCurScrollValues()
-{
- QScrollBar *scrollBar = horizontalScrollBar();
- m_cCurrScroll.setX( scrollBar->value() );
- scrollBar = verticalScrollBar();
- m_cCurrScroll.setY( scrollBar->value() );
-}
-
-Void SubWindowHandle::setCurScrollValues()
-{
- QScrollBar *scrollBar = horizontalScrollBar();
- scrollBar->setValue(m_cCurrScroll.x() );
- scrollBar = verticalScrollBar();
- scrollBar->setValue(m_cCurrScroll.y() );
-}
-
-Void SubWindowHandle::setWindowName( QString name )
-{
- m_cWindowName = name;
- setWindowTitle( m_cWindowName );
-}
-
-QString SubWindowHandle::getWindowName()
-{
- return m_cWindowName;
-}
-
-Bool SubWindowHandle::mayClose()
-{
- return true;
-}
-
-QSize SubWindowHandle::sizeHint( const QSize & ) const
-{
- return QSize();
-}
-
-Void SubWindowHandle::focusInEvent( QFocusEvent * event )
-{
- emit aboutToActivate( this );
-}
-
-Void SubWindowHandle::closeEvent( QCloseEvent *event )
-{
- emit aboutToClose( this );
- event->accept();
-}
-
-Void SubWindowHandle::closeSubWindow()
-{
- close();
- if( m_cSubWindow )
- m_cSubWindow->close();
-}
-
-} // NAMESPACE
diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp
index 759dafb..7d53411 100644
--- a/app/VideoHandle.cpp
+++ b/app/VideoHandle.cpp
@@ -22,10 +22,20 @@
* \brief Class to handle video playback
*/
-#include
-#include "PlaYUVerSubWindowHandle.h"
+#include "PlaYUVerApp.h"
#include "VideoHandle.h"
+#include "VideoSubWindow.h"
+#include "PlaYUVerSubWindowHandle.h"
#include "DialogSubWindowSelector.h"
+#include "FramePropertiesDock.h"
+#include "WidgetFrameNumber.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#if( _CONTROL_PLAYING_TIME_ == 1 )
#include
#endif
@@ -121,6 +131,7 @@ QToolBar* VideoHandle::createToolBar()
m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] );
QLabel* pcLockLabel = new QLabel( "PlayingLock", this );
+ pcLockLabel->setAlignment( Qt::AlignCenter );
m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel );
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
@@ -136,7 +147,7 @@ QToolBar* VideoHandle::createToolBar()
QDockWidget* VideoHandle::createDock()
{
- m_pcFramePropertiesSideBar = new FramePropertiesSideBar( this, &m_bIsPlaying );
+ m_pcFramePropertiesSideBar = new FramePropertiesDock( this, &m_bIsPlaying );
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), this );
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar );
@@ -232,19 +243,20 @@ Void VideoHandle::update()
total_frame_num = getMaxFrameNumber();
resolution.append( QString( "@%1" ).arg( pcStream->getFrameRate() ) );
}
- else
- {
- m_pcFrameNumInfo->setCurrFrameNum( 0 );
- }
if( pcFrame )
+ {
+ resolution.append( QString( " %1 bpp" ).arg( pcFrame->getBitsPel() ) );
m_pcResolutionLabel->setText( resolution );
+ }
m_pcFramePropertiesSideBar->setData( pcFrame, m_pcCurrentVideoSubWindow->isPlaying() );
- m_pcFrameSlider->setValue( frame_num );
- m_pcFrameSlider->setMaximum( total_frame_num - 1 );
m_pcFrameNumInfo->setTotalFrameNum( total_frame_num );
+ m_pcFrameSlider->setMaximum( total_frame_num - 1 );
+
+ m_pcFrameNumInfo->setCurrFrameNum( frame_num );
+ m_pcFrameSlider->setValue( frame_num );
if( m_pcCurrentVideoSubWindow->isPlaying() )
m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) );
@@ -276,11 +288,13 @@ Void VideoHandle::updateSelectionArea( QRect area )
}
}
-Void VideoHandle::closeSubWindow( VideoSubWindow* currSubWindow )
+Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow )
{
- if( m_acPlayingSubWindows.contains( currSubWindow ) )
+ VideoSubWindow* videoSubWindow = qobject_cast( subWindow );
+
+ if( m_acPlayingSubWindows.contains( videoSubWindow ) )
{
- Int pos = m_acPlayingSubWindows.indexOf( currSubWindow );
+ Int pos = m_acPlayingSubWindows.indexOf( videoSubWindow );
m_acPlayingSubWindows.at( pos )->stop();
m_acPlayingSubWindows.remove( pos );
if( m_acPlayingSubWindows.size() < 2 )
@@ -299,8 +313,8 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center )
factor = m_pcCurrentVideoSubWindow->getScaleFactor();
- SubWindowHandle *subWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
+ SubWindowAbstract *subWindow;
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( Int i = 0; i < subWindowList.size(); i++ )
{
subWindow = subWindowList.at( i );
@@ -319,11 +333,11 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset )
QPoint newOffset = offset;
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() )
{
- SubWindowHandle *subWindow;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW );
+ VideoSubWindow *videoSubWindow;
+ QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
QScrollBar *scrollBar;
- scrollBar = m_pcCurrentVideoSubWindow->horizontalScrollBar();
+ scrollBar = m_pcCurrentVideoSubWindow->getScroll()->horizontalScrollBar();
// Do not move other images, if current image reached maximum or minimum scroll position
if( scrollBar->value() == scrollBar->maximum() && offset.x() > 0 )
@@ -331,7 +345,7 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset )
if( scrollBar->value() == scrollBar->minimum() && offset.x() < 0 )
newOffset.setX( 0 );
- scrollBar = m_pcCurrentVideoSubWindow->verticalScrollBar();
+ scrollBar = m_pcCurrentVideoSubWindow->getScroll()->verticalScrollBar();
if( scrollBar->value() == scrollBar->maximum() && offset.y() > 0 )
newOffset.setY( 0 );
if( scrollBar->value() == scrollBar->minimum() && offset.y() < 0 )
@@ -339,12 +353,12 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset )
for( Int i = 0; i < subWindowList.size(); i++ )
{
- subWindow = subWindowList.at( i );
- if( m_pcCurrentVideoSubWindow == subWindow )
+ videoSubWindow = qobject_cast( subWindowList.at( i ) );
+ if( m_pcCurrentVideoSubWindow == videoSubWindow )
continue;
else
{
- subWindow->adjustScrollBarByOffset( newOffset );
+ videoSubWindow->adjustScrollBarByOffset( newOffset );
}
}
}
@@ -401,12 +415,12 @@ Void VideoHandle::setTimerStatus()
else
{
#if( _CONTROL_PLAYING_TIME_ == 1 )
- if( m_pcPlayControlTimer )
+ if( m_pcPlayControlTimer && m_pcPlayingTimer->interval() > 0 )
{
qDebug( ) << "Desired Fps: "
- << 1000 / m_pcPlayingTimer->interval()
- << "Real Fps: "
- << 1000 / m_dAverageFps;
+ << 1000 / m_pcPlayingTimer->interval()
+ << "Real Fps: "
+ << 1000 / m_dAverageFps;
delete m_pcPlayControlTimer;
m_pcPlayControlTimer = NULL;
@@ -570,29 +584,21 @@ Void VideoHandle::seekSliderEvent( Int new_frame_num )
Void VideoHandle::videoSelectionButtonEvent()
{
- DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_STREAM_SUBWINDOW );
+ DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
QStringList cWindowListNames;
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
- cWindowListNames.append( m_acPlayingSubWindows.at( i )->getWindowName() );
- dialogWindowsSelection.setSubWindowList( cWindowListNames );
+ dialogWindowsSelection.selectSubWindow( m_acPlayingSubWindows.at( i ) );
}
if( dialogWindowsSelection.exec() == QDialog::Accepted )
{
- QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows();
m_acPlayingSubWindows.clear();
VideoSubWindow *videoSubWindow;
- QString windowName;
- QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW );
- for( Int i = 0; i < subWindowList.size(); i++ )
+ QList selectedSubWindowList = dialogWindowsSelection.getSelectedWindows();
+ for( Int i = 0; i < selectedSubWindowList.size(); i++ )
{
- videoSubWindow = qobject_cast( subWindowList.at( i ) );
- windowName = videoSubWindow->getWindowName();
- if( selectedWindows.contains( windowName ) )
- {
- m_acPlayingSubWindows.append( videoSubWindow );
- videoSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
- }
+ videoSubWindow = qobject_cast( selectedSubWindowList.at( i ) );
+ m_acPlayingSubWindows.append( videoSubWindow );
}
if( m_acPlayingSubWindows.size() > 0 )
{
diff --git a/app/VideoHandle.h b/app/VideoHandle.h
index 1dc13e0..60d6c90 100644
--- a/app/VideoHandle.h
+++ b/app/VideoHandle.h
@@ -27,25 +27,29 @@
#include "config.h"
#include "PlaYUVerAppDefs.h"
-#include
-#if( QT_VERSION_PLAYUVER == 5 )
-#include
-#elif( QT_VERSION_PLAYUVER == 4 )
-#include
-#endif
-#include "VideoSubWindow.h"
-#include "WidgetFrameNumber.h"
-#include "FramePropertiesSidebar.h"
-#define _CONTROL_PLAYING_TIME_ 1
+#include
+#include
+#include
+#include
+#define _CONTROL_PLAYING_TIME_ 0
+
+class QToolBar;
+class QDockWidget;
+class QSignalMapper;
+class QLabel;
+class QSlider;
class QElapsedTimer;
namespace plaYUVer
{
class PlaYUVerSubWindowHandle;
+class SubWindowAbstract;
class VideoSubWindow;
+class FramePropertiesDock;
+class WidgetFrameNumber;
class VideoHandle: public QWidget
{
@@ -66,8 +70,6 @@ public:
Void update( VideoSubWindow* currSubWindow );
- Void closeSubWindow( VideoSubWindow* currSubWindow );
-
private:
QWidget* m_pcParet;
PlaYUVerSubWindowHandle* m_pcMainWindowManager;
@@ -93,7 +95,7 @@ private:
QToolBar* m_toolbarVideo;
QDockWidget* m_pcFramePropertiesDock;
- FramePropertiesSideBar* m_pcFramePropertiesSideBar;
+ FramePropertiesDock* m_pcFramePropertiesSideBar;
QLabel* m_pcVideoFormatLabel;
QLabel* m_pcResolutionLabel;
@@ -119,6 +121,7 @@ Q_SIGNALS:
private Q_SLOTS:
void update();
void updateSelectionArea( QRect area );
+ void closeSubWindow( SubWindowAbstract* subWindow );
void zoomToFactorAll( const double factor, const QPoint center = QPoint() );
void moveAllScrollBars( const QPoint offset );
void play();
diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp
index f3c049b..479590d 100644
--- a/app/VideoSubWindow.cpp
+++ b/app/VideoSubWindow.cpp
@@ -24,8 +24,9 @@
#include "VideoSubWindow.h"
#include "ModulesHandle.h"
-#include "SubWindowHandle.h"
#include "ConfigureFormatDialog.h"
+#include "SubWindowAbstract.h"
+#include
#if( QT_VERSION_PLAYUVER == 5 )
#include "QtConcurrent/qtconcurrentrun.h"
#endif
@@ -43,6 +44,7 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
out << d.m_cFilename << d.m_uiWidth
<< d.m_uiHeight
<< d.m_iPelFormat
+ << d.m_uiBitsPelPixel
<< d.m_uiFrameRate
<< d.m_uiFileSize;
}
@@ -60,6 +62,7 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array )
in >> d.m_uiWidth;
in >> d.m_uiHeight;
in >> d.m_iPelFormat;
+ in >> d.m_uiBitsPelPixel;
in >> d.m_uiFrameRate;
in >> d.m_uiFileSize;
array.append( d );
@@ -76,7 +79,7 @@ Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename )
}
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget * parent ) :
- SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW | category ),
+ SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
m_pCurrStream( NULL ),
m_pcCurrFrame( NULL ),
m_pcCurrentDisplayModule( NULL ),
@@ -84,10 +87,14 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget
m_bIsPlaying( false ),
m_bIsModule( category == MODULE_SUBWINDOW )
{
- setVisible( false );
+
+ // Create a new scroll area inside the sub-window
+ m_pcScrollArea = new QScrollArea;
+ connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
+ connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
// Create a new interface to show images
- m_cViewArea = new ViewArea( this );
+ m_cViewArea = new ViewArea;
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
@@ -97,12 +104,18 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
- setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
- setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
// Define the cViewArea as the widget inside the scroll area
- m_cViewArea->setMinimumSize( size() );
- setWidget( m_cViewArea );
+ // m_cViewArea->setMinimumSize( size() );
+
+ m_pcScrollArea->setWidget( m_cViewArea );
+ m_pcScrollArea->setWidgetResizable( true );
+
+ setWidget( m_pcScrollArea );
+
+ m_cLastScroll = QPoint();
m_apcCurrentModule.clear();
@@ -110,6 +123,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget
VideoSubWindow::~VideoSubWindow()
{
+ m_pcCurrFrame = NULL;
disableModule();
delete m_cViewArea;
if( m_pCurrStream )
@@ -118,35 +132,46 @@ VideoSubWindow::~VideoSubWindow()
Void VideoSubWindow::loadAll()
{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
m_pCurrStream->loadAll();
refreshFrame();
+ QApplication::restoreOverrideCursor();
}
-Void VideoSubWindow::reloadFile()
+Void VideoSubWindow::refreshSubWindow()
{
- Int currFrameNum = m_pCurrStream->getCurrFrameNum();
- loadFile( m_cFilename, false );
- seekAbsoluteEvent( currFrameNum );
+ if( getCategory() & SubWindowAbstract::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 )
{
- UInt Width = 0, Height = 0, FrameRate = 30;
+ UInt Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
Int InputFormat = PlaYUVerFrame::YUV420p;
if( m_pCurrStream )
- m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate );
+ m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, FrameRate );
if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
{
ConfigureFormatDialog formatDialog( this );
- if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, FrameRate ) == QDialog::Rejected )
+ if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, FrameRate ) == QDialog::Rejected )
{
return false;
}
}
- QApplication::setOverrideCursor( Qt::WaitCursor );
- QApplication::restoreOverrideCursor();
if( !m_pCurrStream )
{
@@ -158,12 +183,13 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
m_pCurrStream = new PlaYUVerStream;
}
- m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, FrameRate );
+ m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, FrameRate );
m_sStreamInfo.m_cFilename = cFilename;
m_sStreamInfo.m_uiWidth = Width;
m_sStreamInfo.m_uiHeight = Height;
m_sStreamInfo.m_iPelFormat = InputFormat;
+ m_sStreamInfo.m_uiBitsPelPixel = BitsPel;
m_sStreamInfo.m_uiFrameRate = FrameRate;
m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size();
@@ -190,7 +216,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
}
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
- streamInfo->m_uiFrameRate ) )
+ streamInfo->m_uiBitsPelPixel, streamInfo->m_uiFrameRate ) )
{
return false;
}
@@ -214,23 +240,23 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
Void VideoSubWindow::updateVideoWindowInfo()
{
- if( m_pCurrStream )
+ m_cStreamInformation = "";
+ if( m_pcCurrentDisplayModule )
+ {
+ m_cStreamInformation = "Module";
+ }
+ else if( m_pCurrStream )
{
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;
+ m_cStreamInformation = m_cFormatName + " | " + m_cCodedName;
}
- else if( m_pcCurrFrame )
+ if( m_pcCurrFrame )
{
- if( m_bIsModule || m_pcCurrentDisplayModule )
- {
- m_cStreamInformation = "Module | ";
- }
- QString m_cPelFmtName = QString::fromStdString( PlaYUVerFrame::supportedPixelFormatListNames()[m_pcCurrFrame->getPelFormat()].c_str() );
- m_cStreamInformation += m_cPelFmtName;
+ QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() );
+ m_cStreamInformation += " | " + m_cPelFmtName;
}
- else
+ if( m_cStreamInformation.isEmpty() )
{
m_cStreamInformation = " ";
}
@@ -309,7 +335,7 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
Int count = 0, module, frame_bytes, match;
for( UInt i = 0; i < stdResList.size(); i++ )
{
- frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat );
+ frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
@@ -391,8 +417,8 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule )
}
if( bRefresh )
{
- updateVideoWindowInfo();
refreshFrame();
+ updateVideoWindowInfo();
}
}
@@ -403,8 +429,12 @@ Void VideoSubWindow::associateModule( PlaYUVerAppModuleIf* pcModule )
Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame )
{
- m_pcCurrFrame = pcCurrFrame;
- m_cViewArea->setImage( m_pcCurrFrame );
+ // if( m_pcCurrFrame )
+ {
+ m_pcCurrFrame = pcCurrFrame;
+ m_cViewArea->setImage( m_pcCurrFrame );
+ updateVideoWindowInfo();
+ }
}
Void VideoSubWindow::refreshFrameOperation()
@@ -535,6 +565,100 @@ Void VideoSubWindow::stop()
return;
}
+QSize VideoSubWindow::getScrollSize()
+{
+ return QSize( m_pcScrollArea->viewport()->size().width() - 5, m_pcScrollArea->viewport()->size().height() - 5 );
+}
+
+Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset )
+{
+ QPoint cLastScroll = m_cCurrScroll;
+ QScrollBar *scrollBarH, *scrollBarV;
+ Int valueX, valueY;
+
+ valueX = int( cLastScroll.x() + Offset.x() );
+ valueY = int( cLastScroll.y() + Offset.y() );
+
+ scrollBarH = m_pcScrollArea->horizontalScrollBar();
+ if( valueX > scrollBarH->maximum() )
+ valueX = scrollBarH->maximum();
+ if( valueX < scrollBarH->minimum() )
+ valueX = scrollBarH->minimum();
+ m_cCurrScroll.setX( valueX );
+
+ scrollBarV = m_pcScrollArea->verticalScrollBar();
+ if( valueY > scrollBarV->maximum() )
+ valueY = scrollBarV->maximum();
+ if( valueY < scrollBarV->minimum() )
+ valueY = scrollBarV->minimum();
+ m_cCurrScroll.setY( valueY );
+
+ // Update window scroll
+ scrollBarH->setValue( m_cCurrScroll.x() );
+ scrollBarV->setValue( m_cCurrScroll.y() );
+}
+
+// This function was developed with help of the schematics presented in
+// http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position
+Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center )
+{
+ QPoint cLastScroll = m_cCurrScroll;
+ QScrollBar *scrollBarH, *scrollBarV;
+
+ scrollBarH = m_pcScrollArea->horizontalScrollBar();
+ if( center.isNull() )
+ {
+ m_cCurrScroll.setX( int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ) );
+ }
+ else
+ {
+ Int x = center.x() - cLastScroll.x();
+ Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) );
+ if( value > scrollBarH->maximum() )
+ value = scrollBarH->maximum();
+ if( value < scrollBarH->minimum() )
+ value = scrollBarH->minimum();
+ m_cCurrScroll.setX( value );
+ }
+
+ scrollBarV = m_pcScrollArea->verticalScrollBar();
+ if( center.isNull() )
+ {
+ m_cCurrScroll.setY( int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ) );
+ }
+ else
+ {
+ Int y = center.y() - cLastScroll.y();
+ Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) );
+ if( value > scrollBarV->maximum() )
+ value = scrollBarV->maximum();
+ if( value < scrollBarV->minimum() )
+ value = scrollBarV->minimum();
+ m_cCurrScroll.setY( value );
+ }
+
+ // Update window scroll
+ scrollBarH->setValue( m_cCurrScroll.x() );
+ scrollBarV->setValue( m_cCurrScroll.y() );
+
+}
+
+Void VideoSubWindow::updateCurScrollValues()
+{
+ QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
+ m_cCurrScroll.setX( scrollBar->value() );
+ scrollBar = m_pcScrollArea->verticalScrollBar();
+ m_cCurrScroll.setY( scrollBar->value() );
+}
+
+Void VideoSubWindow::setCurScrollValues()
+{
+ QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
+ scrollBar->setValue( m_cCurrScroll.x() );
+ scrollBar = m_pcScrollArea->verticalScrollBar();
+ scrollBar->setValue( m_cCurrScroll.y() );
+}
+
Void VideoSubWindow::normalSize()
{
Double factor = 1.0;
@@ -680,17 +804,17 @@ QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const
return isize;
}
-Void VideoSubWindow::closeEvent( QCloseEvent *event )
-{
- Bool bAccept = m_bIsPlaying ? false : true;
- if( bAccept )
- {
- event->accept();
- }
- else
- {
- event->ignore();
- }
-}
+//Void VideoSubWindow::closeEvent( QCloseEvent *event )
+//{
+// Bool bAccept = m_bIsPlaying ? false : true;
+// if( bAccept )
+// {
+// event->accept();
+// }
+// else
+// {
+// event->ignore();
+// }
+//}
-} // NAMESPACE
+}// NAMESPACE
diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h
index 2208f15..8654e00 100644
--- a/app/VideoSubWindow.h
+++ b/app/VideoSubWindow.h
@@ -26,17 +26,18 @@
#define __VIDEOSUBWINDOW_H__
#include "config.h"
+#include
+#include
+#include
+#include
+#include
#include "PlaYUVerAppDefs.h"
-#if( QT_VERSION_PLAYUVER == 5 )
-#include
-#elif( QT_VERSION_PLAYUVER == 4 )
-#include
-#endif
-#include "QFuture"
#include "lib/PlaYUVerStream.h"
-#include "SubWindowHandle.h"
+#include "SubWindowAbstract.h"
#include "ViewArea.h"
+class QScrollArea;
+
namespace plaYUVer
{
@@ -49,6 +50,7 @@ typedef struct
UInt m_uiWidth;
UInt m_uiHeight;
Int m_iPelFormat;
+ UInt m_uiBitsPelPixel;
UInt m_uiFrameRate;
UInt64 m_uiFileSize;
} PlaYUVerStreamInfo;
@@ -58,12 +60,16 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& d );
QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& d );
Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename );
-class VideoSubWindow: public SubWindowHandle
+class VideoSubWindow: public SubWindowAbstract
{
Q_OBJECT
private:
+ QScrollArea* m_pcScrollArea;
+ QPoint m_cLastScroll;
+ QPoint m_cCurrScroll;
+
ViewArea* m_cViewArea;
QString m_cFilename;
@@ -102,9 +108,10 @@ private:
* zoom to fit
*/
Void scaleView( const QSize & size, QPoint center = QPoint() );
-
Void updateVideoWindowInfo();
+ QSize getScrollSize();
+
public:
enum VideoSubWindowCategories
{
@@ -117,9 +124,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();
@@ -135,6 +143,10 @@ public:
Void setCurrFrame( PlaYUVerFrame* pcCurrFrame );
+ QScrollArea* getScroll()
+ {
+ return m_pcScrollArea;
+ }
PlaYUVerStreamInfo getStreamInfo()
{
return m_sStreamInfo;
@@ -187,7 +199,11 @@ public:
QList getModuleArray()
{
- return m_apcCurrentModule;
+ QList apcModulesArray;
+ if( m_pcCurrentDisplayModule )
+ apcModulesArray.append( m_pcCurrentDisplayModule );
+ apcModulesArray.append( m_apcCurrentModule );
+ return apcModulesArray;
}
Void setTool( UInt uiTool )
@@ -196,7 +212,7 @@ public:
}
/**
- * Virtual functions from SubWindowHandle
+ * Virtual functions from SubWindowAbstract
*/
Void normalSize();
Void zoomToFit();
@@ -232,10 +248,14 @@ public:
return m_bIsModule;
}
-protected:
- void closeEvent( QCloseEvent *event );
+//protected:
+ //void closeEvent( QCloseEvent *event );
public Q_SLOTS:
+ void adjustScrollBarByScale( double scale, QPoint center );
+ void adjustScrollBarByOffset( QPoint Offset );
+ void updateCurScrollValues();
+ void setCurScrollValues();
void updateSelectedArea( QRect area );
void updatePixelValueStatusBar( const QPoint& pos );
};
diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp
index 0d44545..6ebb6c7 100644
--- a/app/ViewArea.cpp
+++ b/app/ViewArea.cpp
@@ -71,6 +71,7 @@ ViewArea::ViewArea( QWidget *parent ) :
void ViewArea::setImage( PlaYUVerFrame* pcFrame )
{
m_pcCurrFrame = pcFrame;
+ m_uiPixelHalfScale = 1 << ( m_pcCurrFrame->getBitsPel() - 1 );
m_pcCurrFrame->fillRGBBuffer();
QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB32 );
setImage( QPixmap::fromImage( qimg ) );
@@ -122,29 +123,28 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize
return new_scale;
Double zoomFactor = m_zoomFactor * scale * 100.0;
- zoomFactor=round(zoomFactor);
- zoomFactor=zoomFactor/100.0;
- scale = zoomFactor/m_zoomFactor;
+ zoomFactor = round( zoomFactor );
+ zoomFactor = zoomFactor / 100.0;
+ scale = zoomFactor / m_zoomFactor;
-
- if(!minimumSize.isNull())
+ if( !minimumSize.isNull() )
{
- Double cw = m_pixmap.width()*m_zoomFactor;
- Double ch = m_pixmap.height()*m_zoomFactor;
- Double fw = m_pixmap.width()*zoomFactor;
- Double fh = m_pixmap.height()*zoomFactor;
+ Double cw = m_pixmap.width() * m_zoomFactor;
+ Double ch = m_pixmap.height() * m_zoomFactor;
+ Double fw = m_pixmap.width() * zoomFactor;
+ Double fh = m_pixmap.height() * zoomFactor;
Double mw = minimumSize.width();
Double mh = minimumSize.height();
- if( (cw < mw) && (ch < mh) && (scale < 1) )
+ if( ( cw < mw ) && ( ch < mh ) && ( scale < 1 ) )
{
return new_scale;
}
- if( (fw < mw) && (fh < mh) && (scale < 1) )
+ if( ( fw < mw ) && ( fh < mh ) && ( scale < 1 ) )
{
- Double wfactor = mw/fw;
- Double hfactor = mh/fh;
+ Double wfactor = mw / fw;
+ Double hfactor = mh / fh;
if( wfactor < hfactor )
scale = wfactor;
@@ -152,9 +152,9 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize
scale = hfactor;
zoomFactor = zoomFactor * scale * 100.0;
- zoomFactor=round(zoomFactor);
- zoomFactor=zoomFactor/100.0;
- scale = zoomFactor/m_zoomFactor;
+ zoomFactor = round( zoomFactor );
+ zoomFactor = zoomFactor / 100.0;
+ scale = zoomFactor / m_zoomFactor;
}
}
@@ -163,14 +163,14 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize
if( zoomFactor < minZoom )
{
zoomFactor = minZoom;
- new_scale = zoomFactor/m_zoomFactor;
+ new_scale = zoomFactor / m_zoomFactor;
}
else
{
if( zoomFactor > maxZoom )
{
zoomFactor = maxZoom;
- new_scale = zoomFactor/m_zoomFactor;
+ new_scale = zoomFactor / m_zoomFactor;
}
}
@@ -335,7 +335,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
{
QRect winRect = event->rect();
- if(visibleRegion().isEmpty())
+ if( visibleRegion().isEmpty() )
return;
if( size().isEmpty() || m_pixmap.isNull() )
@@ -384,13 +384,12 @@ void ViewArea::paintEvent( QPaintEvent *event )
painter.restore();
-
// Draw a border around the image.
-/* if( m_xOffset || m_yOffset )
- {
- painter.setPen( Qt::black );
- painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_zoomFactor + 1, m_pixmap.height() * m_zoomFactor + 1 );
- }*/
+ /* if( m_xOffset || m_yOffset )
+ {
+ painter.setPen( Qt::black );
+ painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_zoomFactor + 1, m_pixmap.height() * m_zoomFactor + 1 );
+ }*/
// Draw pixel values in grid
if( m_zoomFactor >= 50.0 )
@@ -420,7 +419,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
- if( sPixelValue.Y() < 128 )
+ if( sPixelValue.Y() < m_uiPixelHalfScale )
painter.setPen( QColor( Qt::white ) );
else
painter.setPen( QColor( Qt::black ) );
@@ -433,7 +432,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
- if( sPixelValue.Y() < 128 )
+ if( sPixelValue.Y() < m_uiPixelHalfScale )
painter.setPen( QColor( Qt::white ) );
else
painter.setPen( QColor( Qt::black ) );
@@ -445,7 +444,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
- if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < 128 * 3 )
+ if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
painter.setPen( QColor( Qt::white ) );
else
painter.setPen( QColor( Qt::black ) );
@@ -457,7 +456,6 @@ void ViewArea::paintEvent( QPaintEvent *event )
}
}
-
QColor color( Qt::white );
QPen mainPen = QPen( color, 1, Qt::SolidLine );
painter.setPen( mainPen );
@@ -540,7 +538,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
myPath.addRect( imgr );
- myPath.addRect( sr); //m_selectedArea
+ myPath.addRect( sr ); //m_selectedArea
painter.drawPath( myPath );
// 2) Draw the selection rectangle
@@ -627,14 +625,14 @@ void ViewArea::wheelEvent( QWheelEvent *event )
if( event->modifiers() & Qt::ControlModifier )
{
scale = 0.001 * event->delta();
- if(scale>0)
- scale=1.25;
+ if( scale > 0 )
+ scale = 1.25;
else
- scale=0.8;
+ scale = 0.8;
QWidget *p = parentWidget();
QSize minimumSize = QSize( p->size().width() - 5, p->size().height() - 5 );
- usedScale = scaleZoomFactor( scale , event->pos(), minimumSize );
+ usedScale = scaleZoomFactor( scale, event->pos(), minimumSize );
if( usedScale != 1.0 )
{
emit zoomFactorChanged_byWheel( usedScale, event->pos() );
@@ -763,7 +761,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
// From left to right
if( m_lastPos.x() < actualPos.x() )
{
- QPoint bottomR = actualPos;// - QPoint( 1, 1 );
+ QPoint bottomR = actualPos; // - QPoint( 1, 1 );
m_selectedArea = QRect( m_lastPos, bottomR );
}
// From right to left
@@ -788,7 +786,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
// From right to left
else
{
- QPoint bottomR = m_lastPos;// - QPoint( 1, 1 );
+ QPoint bottomR = m_lastPos; // - QPoint( 1, 1 );
m_selectedArea = QRect( actualPos, bottomR );
}
}
@@ -895,57 +893,56 @@ void ViewArea::mouseReleaseEvent( QMouseEvent *event )
}
}
-
////////////////////////////////////////////////////////////////////////////////
bool ViewArea::isPosValid( const QPoint &pos ) const
{
-if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() )
- return false;
-else
- return true;
+ if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() )
+ return false;
+ else
+ return true;
}
////////////////////////////////////////////////////////////////////////////////
QPoint ViewArea::windowToView( const QPoint& pt ) const
{
-QPoint p;
-p.setX( static_cast( ( pt.x() - m_xOffset ) / m_zoomFactor ) );
-p.setY( static_cast( ( pt.y() - m_yOffset ) / m_zoomFactor ) );
+ QPoint p;
+ p.setX( static_cast( ( pt.x() - m_xOffset ) / m_zoomFactor ) );
+ p.setY( static_cast( ( pt.y() - m_yOffset ) / m_zoomFactor ) );
-return p;
+ return p;
}
QRect ViewArea::windowToView( const QRect& rc ) const
{
-QRect r;
+ QRect r;
-r.setTopLeft( windowToView( rc.topLeft() ) );
+ r.setTopLeft( windowToView( rc.topLeft() ) );
// r.setRight ( (int)( ceil(( rc.right() - m_xOffset)/m_zoomFactor )));
// r.setBottom( (int)( ceil(( rc.bottom()- m_yOffset)/m_zoomFactor )));
// r.setRight ( static_cast(( rc.right() - m_xOffset ) / m_zoomFactor +1));
// r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / m_zoomFactor+1));
-r.setBottomRight( windowToView( rc.bottomRight() ) );
-return r;
+ r.setBottomRight( windowToView( rc.bottomRight() ) );
+ return r;
}
QPoint ViewArea::viewToWindow( const QPoint& pt ) const
{
-QPoint p;
+ QPoint p;
-p.setX( static_cast( pt.x() * m_zoomFactor + m_xOffset ) );
-p.setY( static_cast( pt.y() * m_zoomFactor + m_yOffset ) );
+ p.setX( static_cast( pt.x() * m_zoomFactor + m_xOffset ) );
+ p.setY( static_cast( pt.y() * m_zoomFactor + m_yOffset ) );
-return p;
+ return p;
}
QRect ViewArea::viewToWindow( const QRect& rc ) const
{
-QRect r;
+ QRect r;
-r.setTopLeft( viewToWindow( rc.topLeft() ) );
+ r.setTopLeft( viewToWindow( rc.topLeft() ) );
// r.setRight ( (int)( ceil(( rc.right() +1+m_xOffset )*m_zoomFactor ) - 1 ));
// r.setBottom( (int)( ceil(( rc.bottom()+1+m_yOffset )*m_zoomFactor ) - 1 ));
// r.setRight ( (int)( ceil(( rc.right()+0.5)*m_zoomFactor )+ m_xOffset )-1);
@@ -953,9 +950,9 @@ r.setTopLeft( viewToWindow( rc.topLeft() ) );
// qDebug()<<"Right = "<< r.right();
// r.setRight ( static_cast(( rc.right()+1) * m_zoomFactor + m_xOffset -1) );
// r.setBottom( static_cast(( rc.bottom()+1) * m_zoomFactor + m_yOffset -1));
-r.setBottomRight( viewToWindow( rc.bottomRight() ) );
+ r.setBottomRight( viewToWindow( rc.bottomRight() ) );
-return r;
+ return r;
}
////////////////////////////////////////////////////////////////////////////////
@@ -963,41 +960,41 @@ return r;
////////////////////////////////////////////////////////////////////////////////
void ViewArea::updateMask( const QRect &rect )
{
-switch( tool() )
-{
-case MaskTool:
-{
- // Add rect to the mask
- QPainter painter( &m_mask );
- painter.setBrush( Qt::color1 );
- painter.setPen( Qt::NoPen );
- painter.drawRect( rect );
- painter.end();
- break;
-}
-case EraserTool:
-{
- // Clears rect area in the mask
- QPainter painter( &m_mask );
- painter.setBrush( Qt::color0 );
- painter.setPen( Qt::NoPen );
- painter.drawRect( rect );
- painter.end();
- break;
-}
-default: /* Do Nothing */
- ;
-}
+ switch( tool() )
+ {
+ case MaskTool:
+ {
+ // Add rect to the mask
+ QPainter painter( &m_mask );
+ painter.setBrush( Qt::color1 );
+ painter.setPen( Qt::NoPen );
+ painter.drawRect( rect );
+ painter.end();
+ break;
+ }
+ case EraserTool:
+ {
+ // Clears rect area in the mask
+ QPainter painter( &m_mask );
+ painter.setBrush( Qt::color0 );
+ painter.setPen( Qt::NoPen );
+ painter.drawRect( rect );
+ painter.end();
+ break;
+ }
+ default: /* Do Nothing */
+ ;
+ }
}
void ViewArea::setInputStream( PlaYUVerStream *stream )
{
-m_pStream = stream;
+ m_pStream = stream;
}
PlaYUVerStream* ViewArea::getInputStream()
{
-return m_pStream;
+ return m_pStream;
}
} // NameSpace plaYUVer
diff --git a/app/ViewArea.h b/app/ViewArea.h
index 4a1d4bd..dafec9f 100644
--- a/app/ViewArea.h
+++ b/app/ViewArea.h
@@ -51,7 +51,8 @@ public:
enum ViewMode
{
- NormalMode, MaskMode,
+ NormalMode,
+ MaskMode,
};
typedef enum
{
@@ -60,7 +61,7 @@ public:
BlockSelectionTool,
MaskTool,
EraserTool
- }eTool;
+ } eTool;
ViewArea( QWidget *parent = 0 );
@@ -116,7 +117,7 @@ public:
PlaYUVerStream* getInputStream();
// Scale function. Return used scale value (it may change when it touches the min or max zoom value)
- Double scaleZoomFactor(Double scale, QPoint center, QSize minimumSize);
+ Double scaleZoomFactor( Double scale, QPoint center, QSize minimumSize );
void setTool( eTool tool );
@@ -126,7 +127,7 @@ Q_SIGNALS:
void selectionChanged( const QRect &rect );
void positionChanged( const QPoint &pos );
void scrollBarMoved( QPoint offset );
- void zoomFactorChanged_byWheel( const double factor , const QPoint center);
+ void zoomFactorChanged_byWheel( const double factor, const QPoint center );
public Q_SLOTS:
void setNormalMode();
@@ -163,6 +164,7 @@ private:
QRect viewToWindow( const QRect& rc ) const;
PlaYUVerFrame *m_pcCurrFrame;
+ Pel m_uiPixelHalfScale;
QPixmap m_pixmap;
QBitmap m_mask;
QRect m_selectedArea;
@@ -185,6 +187,6 @@ private:
};
-} // NameSpace plaYUVer
+} // NameSpace plaYUVer
#endif // __VIEWAREA_H__
diff --git a/app/main.cpp b/app/main.cpp
index 3e04ea1..4c86951 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -23,10 +23,10 @@
*/
#include "config.h"
-#include "PlaYUVerAppDefs.h"
#include
-#include "plaYUVerApp.h"
-#include "SubWindowHandle.h"
+#include "PlaYUVerAppDefs.h"
+#include "PlaYUVerApp.h"
+#include "VideoSubWindow.h"
#ifdef USE_QTDBUS
#include "PlaYUVerAppAdaptor.h"
#endif
@@ -48,8 +48,7 @@ int main( int argc, char *argv[] )
QApplication application( argc, argv );
QApplication::setApplicationName( "PlaYUVer" );
QApplication::setApplicationVersion( PLAYUVER_VERSION_STRING );
- QApplication::setOrganizationName( "pixlra" );
- QApplication::setOrganizationDomain( "playuver.pixlra" );
+ QApplication::setOrganizationName( "PixLRA" );
#ifdef USE_QTDBUS
/**
@@ -93,33 +92,32 @@ int main( int argc, char *argv[] )
QStringList tokens;
// open given files...
- foreach(const QString & file, filenameList)
+ foreach(const QString & file, filenameList){
+ QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME,
+ QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile"));
+
+ QList dbusargs;
+ dbusargs.append( file );
+ m.setArguments(dbusargs);
+
+ QDBusMessage res = QDBusConnection::sessionBus().call(m);
+ if (res.type() == QDBusMessage::ReplyMessage)
{
- QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME,
- QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile"));
-
- QList dbusargs;
- dbusargs.append( file );
- m.setArguments(dbusargs);
-
- QDBusMessage res = QDBusConnection::sessionBus().call(m);
- if (res.type() == QDBusMessage::ReplyMessage)
+ if (res.arguments().count() == 1)
{
- if (res.arguments().count() == 1)
+ QVariant v = res.arguments()[0];
+ if (v.isValid())
{
- QVariant v = res.arguments()[0];
- if (v.isValid())
+ QString s = v.toString();
+ if ((!s.isEmpty()) && (s != QStringLiteral("ERROR")))
{
- QString s = v.toString();
- if ((!s.isEmpty()) && (s != QStringLiteral("ERROR")))
- {
- tokens << s;
- }
+ tokens << s;
}
}
}
}
- // this will wait until exiting is emitted by the used instance, if wanted...
+ }
+ // this will wait until exiting is emitted by the used instance, if wanted...
return needToBlock ? application.exec() : 0;
}
}
@@ -129,13 +127,16 @@ int main( int argc, char *argv[] )
*/
QDBusConnection::sessionBus().registerService( PLAYUVER_DBUS_SESSION_NAME );
#endif
- plaYUVerApp mainwindow;
+ PlaYUVerApp mainwindow;
mainwindow.show();
- mainwindow.parseArgs( argc, argv );
+ if( mainwindow.parseArgs( argc, argv ) )
+ {
+ return 0;
+ }
#ifdef USE_FERVOR
- FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml");
- FvUpdater::sharedUpdater()->SetDependencies("ALL");
+ FvUpdater::sharedUpdater()->SetFeedURL( "http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml" );
+ FvUpdater::sharedUpdater()->SetDependencies( "ALL" );
#endif
return application.exec();
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 758c9ae..89182f9 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -46,7 +46,7 @@ CONFIGURE_FILE( PlaYUVerConfig.cmake.in ${CMAKE_BINARY_DIR}/PlaYUVerConfig.cmake
ADD_LIBRARY( PlaYUVerLib STATIC ${plaYUver_Lib_SRCS} )
INCLUDE_DIRECTORIES( ${FFMPEG_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
-TARGET_LINK_LIBRARIES( PlaYUVerLib ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} )
+TARGET_LINK_LIBRARIES( PlaYUVerLib ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES} )
INSTALL(FILES ${plaYUver_Lib_HEADERS} DESTINATION include )
# INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libPlaYUVerLib${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION lib )
diff --git a/lib/LibAvContextHandle.cpp b/lib/LibAvContextHandle.cpp
index f9c5055..4c0c3aa 100644
--- a/lib/LibAvContextHandle.cpp
+++ b/lib/LibAvContextHandle.cpp
@@ -216,10 +216,10 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt&
frame_rate = fr;
/*if( video_stream->nb_frames )
- {
- num_frames = video_stream->nb_frames;
- }
- else*/ if( fmt_ctx->duration != AV_NOPTS_VALUE )
+ {
+ num_frames = video_stream->nb_frames;
+ }
+ else*/if( fmt_ctx->duration != AV_NOPTS_VALUE )
{
Int64 duration = fmt_ctx->duration + 5000;
m_uiSecs = duration / AV_TIME_BASE;
@@ -316,8 +316,7 @@ Bool LibAvContextHandle::decodeVideoPkt()
{
pkt.size = 0;
}
- Bool bRet = got_frame > 0 ? true : false;
- return bRet;
+ return got_frame > 0 ? true : false;
}
Bool LibAvContextHandle::decodeAvFormat()
@@ -356,7 +355,8 @@ Bool LibAvContextHandle::decodeAvFormat()
av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
video_dec_ctx->height, 1 );
- av_free_packet( &orig_pkt );
+ if( orig_pkt.size )
+ av_free_packet( &orig_pkt );
return true;
}
diff --git a/lib/LibOpenCVHandler.cpp b/lib/LibOpenCVHandler.cpp
index ea191b8..a28516b 100644
--- a/lib/LibOpenCVHandler.cpp
+++ b/lib/LibOpenCVHandler.cpp
@@ -66,95 +66,23 @@ std::vector LibOpenCVHandler::supportedWriteFormatsName()
std::vector LibOpenCVHandler::supportedSaveFormatsExt()
{
- std::vector formatsExt;
- formatsExt.push_back( "bmp" );
- formatsExt.push_back( "bmp" );
- formatsExt.push_back( "jpg" );
- formatsExt.push_back( "png" );
- return formatsExt;
+ return supportedReadFormatsExt();
}
std::vector LibOpenCVHandler::supportedSaveFormatsName()
{
- std::vector formatsName;
- formatsName.push_back( "Windows Bitmap" );
- formatsName.push_back( "Windows Bitmap" );
- formatsName.push_back( "Joint Photographic Experts Group" );
- formatsName.push_back( "Portable Network Graphics" );
- return formatsName;
+ return supportedReadFormatsName();
}
PlaYUVerFrame* LibOpenCVHandler::loadFrame( std::string filename )
{
- cv::Mat pcCvFrame = cv::imread( filename );
- Int cvChannels = pcCvFrame.channels();
- std::string pelFormatName;
- Int iPelFormat = -1;
- switch( cvChannels )
- {
- case 1:
- pelFormatName = "GRAY";
- break;
- case 3:
- pelFormatName = "BRG24";
- break;
- default:
- return NULL;
- }
-
- for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
- {
- if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == pelFormatName )
- {
- iPelFormat = i;
- break;
- }
- }
-
- if( iPelFormat >= 0 )
- {
- PlaYUVerFrame* pcFrame = new PlaYUVerFrame( pcCvFrame.cols, pcCvFrame.rows, iPelFormat );
- pcFrame->frameFromBuffer( pcCvFrame.ptr(), pcFrame->getBytesPerFrame() );
- return pcFrame;
- }
return NULL;
}
Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename )
{
- Int cvType = CV_8UC3;
- switch( pcFrame->getNumberChannels() )
- {
- case 3:
- cvType = CV_8UC3;
- break;
- case 1:
- cvType = CV_8UC1;
- break;
- default:
- return false;
- break;
- }
-
- cv::Mat pcCvFrame( pcFrame->getHeight(), pcFrame->getWidth(), cvType );
-
- if( pcFrame->getColorSpace() != PlaYUVerFrame::COLOR_GRAY )
- {
- UChar* pCvPel = pcCvFrame.data;
- UChar* pARGB = pcFrame->getRGBBuffer();
- for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ )
- {
- *pCvPel++ = *pARGB++;
- *pCvPel++ = *pARGB++;
- *pCvPel++ = *pARGB++;
- pARGB++;
- }
- }
- else
- {
- memcpy( pcCvFrame.data, pcFrame->getPelBufferYUV()[LUMA][0], pcFrame->getHeight() * pcFrame->getWidth() * sizeof(Pel) );
- }
- return cv::imwrite( filename, pcCvFrame );
+ cv::Mat* pcCvFrame = pcFrame->getCvMat();
+ return cv::imwrite( filename, *pcCvFrame );
}
} // NAMESPACE
diff --git a/lib/LibOpenCVHandler.h b/lib/LibOpenCVHandler.h
index c310068..257ba5e 100644
--- a/lib/LibOpenCVHandler.h
+++ b/lib/LibOpenCVHandler.h
@@ -55,8 +55,6 @@ public:
static PlaYUVerFrame* loadFrame( std::string filename );
static Bool saveFrame( PlaYUVerFrame* pcFrame, std::string filename );
-private:
- std::string m_cFilename;
};
} // NAMESPACE
diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp
index 65bda94..bee40bc 100644
--- a/lib/PlaYUVerCmdParser.cpp
+++ b/lib/PlaYUVerCmdParser.cpp
@@ -55,17 +55,22 @@ Options& PlaYUVerCmdParser::Opts()
return m_cParserOptions;
}
-Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] )
+std::list& PlaYUVerCmdParser::getNoArgs()
+{
+ return m_aUnhandledArgs;
+}
+
+Bool PlaYUVerCmdParser::parse()
{
try
{
// m_cParserOptions.setDefaults();
- const std::list& argv_unhandled = scanArgv( m_cParserOptions, argc, ( const Char** )argv );
+ m_aUnhandledArgs = m_cParserOptions.scanArgv( m_iArgc, ( const Char** )m_ppArgv );
- for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ )
- {
- fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it );
- }
+ // for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ )
+ // {
+ // fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it );
+ // }
if( checkListingOpts() )
{
@@ -86,16 +91,32 @@ Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] )
return true;
}
+Bool PlaYUVerCmdParser::parse( Options& opts, Int argc, Char *argv[] )
+{
+ try
+ {
+ // m_cParserOptions.setDefaults();
+ m_aUnhandledArgs = opts.scanArgv( argc, ( const Char** )argv );
+
+ }
+ catch( std::exception& e )
+ {
+ std::cerr << "error: "
+ << e.what()
+ << "\n";
+ return false;
+ }
+ catch( ... )
+ {
+ std::cerr << "Exception of unknown type!\n";
+ }
+ return true;
+}
+
Bool PlaYUVerCmdParser::checkListingOpts()
{
Bool bRet = false;
- if( m_cParserOptions["help"]->count() )
- {
- doHelp( std::cout, m_cParserOptions );
- bRet |= true;
- }
-
if( m_cParserOptions["version"]->count() )
{
std::cout << "PlaYUVer version "
@@ -112,6 +133,15 @@ Bool PlaYUVerCmdParser::checkListingOpts()
}
bRet |= true;
}
+ if( Opts()["quality_metrics"]->count() )
+ {
+ printf( "PlaYUVer supported quality metrics: \n" );
+ for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
+ {
+ printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() );
+ }
+ bRet |= true;
+ }
return bRet;
}
diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h
index e602b6e..75ea8c7 100644
--- a/lib/PlaYUVerCmdParser.h
+++ b/lib/PlaYUVerCmdParser.h
@@ -25,7 +25,6 @@
#include "PlaYUVerDefs.h"
#include "ProgramOptions.h"
-
namespace plaYUVer
{
@@ -35,12 +34,23 @@ public:
PlaYUVerCmdParser();
~PlaYUVerCmdParser();
- Bool parse( Int argc, Char *argv[] );
+ Void config( Int argc, Char *argv[] )
+ {
+ m_iArgc = argc;
+ m_ppArgv = argv;
+ }
+ Bool parse();
+ Bool parse( Options& opts, Int argc, Char *argv[] );
+ std::list& getNoArgs();
Options& Opts();
private:
+ Int m_iArgc;
+ Char** m_ppArgv;
Options m_cParserOptions;
+ std::list m_aUnhandledArgs;
Bool checkListingOpts();
+ Void listModules();
};
} // NAMESPACE
diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h
index fa07c3e..00c2985 100644
--- a/lib/PlaYUVerDefs.h
+++ b/lib/PlaYUVerDefs.h
@@ -18,13 +18,13 @@
*/
/**
- * \file TypeDef.h
+ * \file PlaYUVerDefs.h
* \ingroup PlaYUVerLib
* \brief Define basic types, new types and enumerations
*/
-#ifndef __TYPEDEF_H__
-#define __TYPEDEF_H__
+#ifndef __PLAYUVERDEFS_H__
+#define __PLAYUVERDEFS_H__
#include
#include
@@ -75,8 +75,8 @@ typedef unsigned long long UInt64;
// Type definition
// ====================================================================================================================
-typedef UChar Pel; ///< 8-bit pixel type
-//typedef Short Pel; ///< 16-bit pixel type
+typedef UShort Pel; ///< 16-bit pixel type
+typedef UChar Byte;
// ====================================================================================================================
// Limits definition
@@ -106,6 +106,14 @@ typedef UChar Pel; ///< 8-bit pixel type
// PlaYUVer definitions
// ====================================================================================================================
+enum LOG_LEVEL
+{
+ LOG_INFO = 1,
+ LOG_WARNINGS = 2,
+ LOG_RESULT = 3,
+ LOG_ERROR = 4,
+};
+
enum YUVcomponent
{
LUMA = 0,
@@ -130,4 +138,4 @@ inline std::string lowercase( const std::string& in )
} // NAMESPACE
-#endif // __TYPEDEF_H__
+#endif // __PLAYUVERDEFS_H__
diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp
index 386875e..ef90a67 100644
--- a/lib/PlaYUVerFrame.cpp
+++ b/lib/PlaYUVerFrame.cpp
@@ -42,6 +42,15 @@
namespace plaYUVer
{
+std::vector PlaYUVerFrame::supportedColorSpacesListNames()
+{
+ std::vector colorSpaceList;
+ colorSpaceList.push_back( "YUV" );
+ colorSpaceList.push_back( "RGB" );
+ colorSpaceList.push_back( "GRAY" );
+ return colorSpaceList;
+}
+
std::vector PlaYUVerFrame::supportedPixelFormatListNames()
{
std::vector formatsList;
@@ -53,6 +62,18 @@ std::vector PlaYUVerFrame::supportedPixelFormatListNames()
return formatsList;
}
+std::vector PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace )
+{
+ std::vector formatsList;
+ Int numberFormats = PLAYUVER_NUMBER_FORMATS;
+ for( Int i = 0; i < numberFormats; i++ )
+ {
+ if( g_PlaYUVerPixFmtDescriptorsList[i].colorSpace == colorSpace )
+ formatsList.push_back( g_PlaYUVerPixFmtDescriptorsList[i].name );
+ }
+ return formatsList;
+}
+
PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace eOutputSpace )
{
Int outA, outB, outC;
@@ -78,20 +99,19 @@ PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace e
return outPixel;
}
-PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format )
+PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel )
{
- init( width, height, pel_format );
+ init( width, height, pelFormat, bitsPixel );
}
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
{
- init( other->getWidth(), other->getHeight(), other->getPelFormat() );
+ init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel() );
copyFrom( other );
}
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight )
{
-
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] );
if( pcPelFormat->log2ChromaWidth )
{
@@ -110,7 +130,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt a
areaHeight++;
}
- init( areaWidth, areaHeight, other->getPelFormat() );
+ init( areaWidth, areaHeight, other->getPelFormat(), other->getBitsPel() );
copyFrom( other, posX, posY );
}
@@ -159,7 +179,7 @@ static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2
return total_mem_size;
}
-Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
+Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel )
{
m_pppcInputPel = NULL;
m_pcARGB32 = NULL;
@@ -167,13 +187,11 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
m_uiHeight = height;
m_iPixelFormat = pel_format;
m_iNumberChannels = 3;
- m_iBitsChannels = 8;
+ m_iBitsPel = bitsPixel > 8 ? bitsPixel : 8;
- Int max_bits_per_pel = sizeof(Pel) * 8;
-
- if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || m_iBitsChannels > max_bits_per_pel )
+ if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
{
- return;
+ throw "Cannot create a PlYUVerFrame of this type";
}
m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] );
@@ -190,7 +208,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 );
xSetupStatistics( this );
- openPixfc();
+ m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str();
}
Int PlaYUVerFrame::getColorSpace() const
@@ -205,28 +223,33 @@ UInt PlaYUVerFrame::getNumberChannels() const
UInt64 PlaYUVerFrame::getBytesPerFrame()
{
- return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
+ return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_iBitsPel );
}
-UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat )
+UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel )
{
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] );
+ UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
UInt64 numberBytes = uiWidth * uiHeight;
if( pcPelFormat->numberChannels > 1 )
{
UInt64 numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma;
}
- return numberBytes;
+ return numberBytes * bytesPerPixel;
}
UInt PlaYUVerFrame::getChromaWidth() const
{
+ if( m_pcPelFormat->colorSpace == GRAY )
+ return 0;
return CHROMASHIFT( m_uiWidth, m_pcPelFormat->log2ChromaWidth );
}
UInt PlaYUVerFrame::getChromaHeight() const
{
+ if( m_pcPelFormat->colorSpace == GRAY )
+ return 0;
return CHROMASHIFT( m_uiHeight, m_pcPelFormat->log2ChromaHeight );
}
@@ -235,22 +258,24 @@ UInt PlaYUVerFrame::getChromaLength() const
return getChromaWidth() * getChromaHeight();
}
-Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize )
+Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize )
{
if( uiBuffSize != getBytesPerFrame() )
return;
- Pel* ppBuff[MAX_NUMBER_PLANES];
- Pel* pTmpPel, *pTmpBuff;
+ Byte* ppBuff[MAX_NUMBER_PLANES];
+ Byte* pTmpBuff;
+ Pel* pTmpPel;
+ UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1;
Int ratioH, ratioW, step;
- UInt i, ch;
+ UInt i, ch, b;
ppBuff[0] = Buff;
- for( Int i = 1; i < MAX_NUMBER_PLANES; i++ )
+ for( i = 1; i < MAX_NUMBER_PLANES; i++ )
{
ratioW = i > 1 ? m_pcPelFormat->log2ChromaWidth : 0;
ratioH = i > 1 ? m_pcPelFormat->log2ChromaHeight : 0;
- ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW );
+ ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel;
}
for( ch = 0; ch < m_pcPelFormat->numberChannels; ch++ )
@@ -264,28 +289,35 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize )
for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ )
{
- *pTmpPel++ = *pTmpBuff;
+ *pTmpPel = *pTmpBuff;
+ for( b = 1; b < bytesPixel; b++ )
+ {
+ pTmpBuff++;
+ *pTmpPel |= ( *pTmpBuff << ( 8 * b ) );
+ }
+ pTmpPel++;
pTmpBuff += step;
}
}
-
m_bHasRGBPel = false;
m_bHasHistogram = false;
}
-Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer )
+Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer )
{
- Pel* ppBuff[MAX_NUMBER_PLANES];
- Pel* pTmpPel, *pTmpBuff;
+ UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1;
+ Byte* ppBuff[MAX_NUMBER_PLANES];
+ Byte* pTmpBuff;
+ Pel* pTmpPel;
Int ratioH, ratioW, step;
- UInt i, ch;
+ UInt i, ch, b;
ppBuff[0] = output_buffer;
for( Int i = 1; i < MAX_NUMBER_PLANES; i++ )
{
ratioW = i > 1 ? m_pcPelFormat->log2ChromaWidth : 0;
ratioH = i > 1 ? m_pcPelFormat->log2ChromaHeight : 0;
- ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW );
+ ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel;
}
for( ch = 0; ch < m_pcPelFormat->numberChannels; ch++ )
@@ -299,7 +331,13 @@ Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer )
for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ )
{
- *pTmpBuff = *pTmpPel++;
+ *pTmpBuff = ( *pTmpPel & 0x00FF );
+ for( b = 1; b < bytesPixel; b++ )
+ {
+ pTmpBuff++;
+ *pTmpBuff = ( *pTmpPel >> ( 8 * b ) ) & 0x00FF;
+ }
+ pTmpPel++;
pTmpBuff += step;
}
}
@@ -310,24 +348,80 @@ Void PlaYUVerFrame::fillRGBBuffer()
{
if( m_bHasRGBPel )
return;
- if( m_pcPelFormat->colorSpace == COLOR_RGB )
+ Int iR, iG, iB;
+ Int shiftBits = m_iBitsPel - 8;
+ UInt* pARGB = ( UInt* )m_pcARGB32;
+ if( m_pcPelFormat->colorSpace == COLOR_GRAY )
+ {
+ Pel* pY = m_pppcInputPel[LUMA][0];
+ Int iY;
+ for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
+ {
+ iY = *pY++;
+ iY >>= shiftBits;
+ iR = iY;
+ iG = iY;
+ iB = iY;
+ *pARGB++ = PEL_RGB( iR, iG, iB );
+ }
+ }
+ else if( m_pcPelFormat->colorSpace == COLOR_RGB )
{
Pel* pR = m_pppcInputPel[COLOR_R][0];
Pel* pG = m_pppcInputPel[COLOR_G][0];
Pel* pB = m_pppcInputPel[COLOR_B][0];
- Int iR, iG, iB;
- UInt* pARGB = ( UInt* )m_pcARGB32;
+
for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
{
iR = *pR++;
iG = *pG++;
iB = *pB++;
- *pARGB++ = PEL_RGB( iR, iG, iB );
+ *pARGB++ = PEL_RGB( ( iR >> shiftBits ), ( iG >> shiftBits ), ( iB >> shiftBits ) );
}
}
- else
+ else if( m_pcPelFormat->colorSpace == COLOR_YUV )
{
- m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight );
+ Pel* pLineY = m_pppcInputPel[LUMA][0];
+ Pel* pLineU = m_pppcInputPel[CHROMA_U][0];
+ Pel* pLineV = m_pppcInputPel[CHROMA_V][0];
+ UInt uiChromaStride = CHROMASHIFT( m_uiWidth, m_pcPelFormat->log2ChromaWidth );
+ Pel* pY;
+ Pel* pU;
+ Pel* pV;
+ Int iY, iU, iV, iR, iG, iB;
+ UInt* pARGBLine = pARGB;
+ UInt* pARGB;
+
+ UInt y, x;
+ Int i, j;
+ for( y = 0; y < m_uiHeight >> m_pcPelFormat->log2ChromaHeight; y++ )
+ {
+ for( i = 0; i < 1 << m_pcPelFormat->log2ChromaHeight; i++ )
+ {
+ pY = pLineY;
+ pU = pLineU;
+ pV = pLineV;
+ pARGB = pARGBLine;
+ for( x = 0; x < m_uiWidth >> m_pcPelFormat->log2ChromaWidth; x++ )
+ {
+ iU = *pU++;
+ iU >>= shiftBits;
+ iV = *pV++;
+ iV >>= shiftBits;
+ for( j = 0; j < ( 1 << m_pcPelFormat->log2ChromaWidth ); j++ )
+ {
+ iY = *pY++;
+ iY >>= shiftBits;
+ YUV2RGB( iY, iU, iV, iR, iG, iB );
+ *pARGB++ = PEL_RGB( iR, iG, iB );
+ }
+ }
+ pLineY += m_uiWidth;
+ pARGBLine += m_uiWidth;
+ }
+ pLineU += uiChromaStride;
+ pLineV += uiChromaStride;
+ }
}
m_bHasRGBPel = true;
}
@@ -431,47 +525,59 @@ Void PlaYUVerFrame::FrametoRGB8Pixfc()
#endif
}
-Void PlaYUVerFrame::getCvMat( Void** ppCvFrame )
+cv::Mat* PlaYUVerFrame::getCvMat( Bool convertToGray )
{
#ifdef USE_OPENCV
- Int cvType = CV_8UC3;
- switch( m_pcPelFormat->numberChannels )
+ if( convertToGray && !( m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_YUV || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_GRAY ) )
{
- case 3:
- cvType = CV_8UC4;
- break;
- case 1:
- cvType = CV_8UC1;
- break;
- default:
- break;
+ return NULL;
}
+ Int cvType = CV_MAKETYPE( CV_8U, convertToGray ? 1 : m_pcPelFormat->numberChannels );
cv::Mat *pcCvFrame = new cv::Mat( m_uiHeight, m_uiWidth, cvType );
- if( m_pcPelFormat->colorSpace != PlaYUVerFrame::COLOR_GRAY )
+ UChar* pCvPel = pcCvFrame->data;
+ if( !convertToGray && ( m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_YUV || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_RGB ) )
{
fillRGBBuffer();
- memcpy( pcCvFrame->data, m_pcARGB32, m_uiWidth * m_uiHeight * 4 * sizeof(UChar) );
+ UChar* pARGB = m_pcARGB32;
+ for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ )
+ {
+ *pCvPel++ = *pARGB++;
+ *pCvPel++ = *pARGB++;
+ *pCvPel++ = *pARGB++;
+ pARGB++;
+ }
+ }
+ else if( convertToGray || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_GRAY )
+ {
+ Pel* pPel = m_pppcInputPel[LUMA][0];
+ for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ )
+ {
+ *pCvPel++ = *pPel++;
+ }
}
else
{
- memcpy( pcCvFrame->data, &( m_pppcInputPel[LUMA][0][0] ), m_uiWidth * m_uiHeight * sizeof(Pel) );
+ if( pcCvFrame )
+ delete pcCvFrame;
+ pcCvFrame = NULL;
}
- *ppCvFrame = pcCvFrame;
+ return pcCvFrame;
+#else
+ return NULL;
#endif
}
-Void PlaYUVerFrame::fromCvMat( Void* voidFrame )
+Void PlaYUVerFrame::fromCvMat( cv::Mat* pcCvFrame )
{
#ifdef USE_OPENCV
- cv::Mat* opencvFrame = ( cv::Mat* )voidFrame;
if( m_iPixelFormat == NO_FMT )
{
- switch( opencvFrame->channels() )
+ switch( pcCvFrame->channels() )
{
case 1:
m_iPixelFormat = GRAY;
break;
- case 4:
+ case 3:
m_iPixelFormat = RGB24;
break;
default:
@@ -481,31 +587,32 @@ Void PlaYUVerFrame::fromCvMat( Void* voidFrame )
if( !isValid() )
{
- init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat );
+ init( pcCvFrame->cols, pcCvFrame->rows, m_iPixelFormat, 8 );
}
m_bHasRGBPel = false;
m_bHasHistogram = false;
+ UChar* pCvPel = pcCvFrame->data;
if( m_iPixelFormat != GRAY )
{
- Pel* pInputPelY = m_pppcInputPel[LUMA][0];
- Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0];
- Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0];
- Pel* pcRGBPelInterlaced = m_pcARGB32;
- memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 4 * sizeof(Pel) );
- UInt* buff = ( UInt* )pcRGBPelInterlaced;
+ Pel* pInputPelR = m_pppcInputPel[COLOR_R][0];
+ Pel* pInputPelG = m_pppcInputPel[COLOR_G][0];
+ Pel* pInputPelB = m_pppcInputPel[COLOR_B][0];
for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
{
- *pInputPelY++ = pelRed( *buff );
- *pInputPelU++ = pelGreen( *buff );
- *pInputPelV++ = pelBlue( *buff++ );
+ *pInputPelR++ = pelRed( *pCvPel++ );
+ *pInputPelG++ = pelGreen( *pCvPel++ );
+ *pInputPelB++ = pelBlue( *pCvPel++ );
}
- m_bHasRGBPel = true;
}
else
{
- memcpy( m_pppcInputPel[LUMA][0], opencvFrame->data, m_uiWidth * m_uiHeight * sizeof(Pel) );
+ Pel* pPel = m_pppcInputPel[LUMA][0];
+ for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ )
+ {
+ *pPel++ = *pCvPel++;
+ }
}
#endif
}
diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h
index 0625cd1..593d9ee 100644
--- a/lib/PlaYUVerFrame.h
+++ b/lib/PlaYUVerFrame.h
@@ -34,6 +34,10 @@
#include "PlaYUVerFrameStats.h"
class PixFcSSE;
+namespace cv
+{
+class Mat;
+}
namespace plaYUVer
{
@@ -117,9 +121,9 @@ public:
{
COLOR_INVALID = -1, //!< Invalid
COLOR_YUV = 0, //!< YUV
- COLOR_RGB, //!< RGB
- COLOR_ARGB, //!< RGB + Alpha
- COLOR_GRAY, //!< Grayscale
+ COLOR_RGB = 1, //!< RGB
+ COLOR_ARGB = 3, //!< RGB + Alpha
+ COLOR_GRAY = 2, //!< Grayscale
};
/** ColorSpace Enum
@@ -138,19 +142,27 @@ public:
NUMBER_FORMATS
};
+ /**
+ * Function that handles the supported color space
+ * of PlaYUVerFrame
+ * @return vector of strings with pixel formats names
+ */
+ static std::vector supportedColorSpacesListNames();
+
/**
* Function that handles the supported pixel formats
* of PlaYUVerFrame
* @return vector of strings with pixel formats names
*/
static std::vector supportedPixelFormatListNames();
+ static std::vector supportedPixelFormatListNames( Int colorSpace );
/**
* Get number of bytes per frame of a specific
* pixel format
* @return number of bytes per frame
*/
- static UInt64 getBytesPerFrame( UInt, UInt, Int );
+ static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel );
/**
* Convert a Pixel to a new color space
@@ -169,7 +181,7 @@ public:
*
* @note this function might misbehave if the pixel format enum is not correct
*/
- PlaYUVerFrame( UInt width, UInt height, Int pel_format = 0 );
+ PlaYUVerFrame( UInt width, UInt height, Int pelFormat = 0, Int bitsPixel = 8 );
/**
* Creates and new frame with the configuration of an
@@ -206,8 +218,8 @@ public:
UInt getChromaHeight() const;
UInt getChromaLength() const;
- Void frameFromBuffer( Pel*, UInt64 );
- Void frameToBuffer( Pel* );
+ Void frameFromBuffer( Byte*, UInt64 );
+ Void frameToBuffer( Byte* );
Void fillRGBBuffer();
@@ -216,6 +228,10 @@ public:
PlaYUVerFrame::Pixel getPixelValue( Int xPos, Int yPos, ColorSpace eColorSpace = COLOR_INVALID );
+ std::string getPelFmtName()
+ {
+ return m_cPelFmtName;
+ }
UInt getWidth() const
{
return m_uiWidth;
@@ -228,9 +244,9 @@ public:
{
return m_iPixelFormat;
}
- Int getBitsChannel() const
+ Int getBitsPel() const
{
- return m_iBitsChannels;
+ return m_iBitsPel;
}
Bool isValid() const
{
@@ -278,8 +294,8 @@ public:
/**
* Interface with OpenCV lib
*/
- Void getCvMat( Void** );
- Void fromCvMat( Void* );
+ cv::Mat* getCvMat( Bool convertToGray = false );
+ Void fromCvMat( cv::Mat* );
/**
* @defgroup PlaYUVerLib_QualityMetrics Quality Metrics Interface
@@ -321,12 +337,13 @@ private:
//! Strcut with the pixel format description.
PlaYUVerPixFmtDescriptor* m_pcPelFormat;
+ std::string m_cPelFmtName;
UInt m_uiWidth; //!< Width of the frame
UInt m_uiHeight; //!< Height of the frame
Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
Int m_iNumberChannels; //!< Number of channels
- Int m_iBitsChannels; //!< Bits per pixel/channel
+ Int m_iBitsPel; //!< Bits per pixel/channel
Pel*** m_pppcInputPel;
@@ -341,7 +358,7 @@ private:
* @param pel_format pixel format index (always use PixelFormats enum)
*
*/
- Void init( UInt width, UInt height, Int pel_format );
+ Void init( UInt width, UInt height, Int pel_format, Int bitsPixel );
Void openPixfc();
Void closePixfc();
diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp
index 2ad9565..a916622 100644
--- a/lib/PlaYUVerFramePixelFormats.cpp
+++ b/lib/PlaYUVerFramePixelFormats.cpp
@@ -52,48 +52,8 @@ namespace plaYUVer
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
#endif
-
-Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt ratioChromaHor, UInt ratioChromaVer )
-{
- Pel* pLineY = in[LUMA][0];
- Pel* pLineU = in[CHROMA_U][0];
- Pel* pLineV = in[CHROMA_V][0];
- UInt uiChromaStride = CHROMASHIFT( width, ratioChromaHor );
- Pel* pY;
- Pel* pU;
- Pel* pV;
- Int iY, iU, iV, iR, iG, iB;
- UInt* pARGBLine = ( UInt* )out;
- UInt* pARGB;
-
- for( UInt y = 0; y < height >> ratioChromaVer; y++ )
- {
- for( Int i = 0; i < 1 << ratioChromaVer; i++ )
- {
- pY = pLineY;
- pU = pLineU;
- pV = pLineV;
- pARGB = pARGBLine;
- for( UInt x = 0; x < width >> ratioChromaHor; x++ )
- {
- iU = *pU++;
- iV = *pV++;
- for( Int j = 0; j < 1 << ratioChromaHor; j++ )
- {
- iY = *pY++;
- YUV2RGB( iY, iU, iV, iR, iG, iB );
- *pARGB++ = PEL_RGB( iR, iG, iB );
- }
- }
- pLineY += width;
- pARGBLine += width;
- }
- pLineU += uiChromaStride;
- pLineV += uiChromaStride;
- }
-}
-
-Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
+#if 0
+Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth )
{
#ifdef USE_SSE
if( ( width % 16 ) == 0 )
@@ -184,14 +144,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
b00 = _mm_srai_epi16( _mm_add_epi16( y00r0, bu00 ), 6 );
b01 = _mm_srai_epi16( _mm_add_epi16( y01r0, bu01 ), 6 );
- r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated
- g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated
- b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated
+ r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated
+ g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated
+ b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated
- r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r..
- gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb..
- rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb..
- rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb..
+ r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r..
+ gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb..
+ rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb..
+ rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb..
r01 = _mm_unpackhi_epi8( r00, zero );
gbgb = _mm_unpackhi_epi8( b00, g00 );
@@ -211,14 +171,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
b00 = _mm_srai_epi16( _mm_add_epi16( y00r1, bu00 ), 6 );
b01 = _mm_srai_epi16( _mm_add_epi16( y01r1, bu01 ), 6 );
- r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated
- g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated
- b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated
+ r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated
+ g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated
+ b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated
- r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r..
- gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb..
- rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb..
- rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb..
+ r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r..
+ gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb..
+ rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb..
+ rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb..
r01 = _mm_unpackhi_epi8( r00, zero );
gbgb = _mm_unpackhi_epi8( b00, g00 );
@@ -236,49 +196,10 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
else
#endif
{
- fillARGB32bufferYUV( in, out, width, height, 1, 1 );
+ fillARGB32bufferYUV( in, out, width, height, depth, 1, 1 );
}
}
-
-Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height )
-{
- fillARGB32bufferYUV( in, out, width, height, 0, 0 );
-}
-
-Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height )
-{
- fillARGB32bufferYUV( in, out, width, height, 1, 0 );
-}
-
-Void fillARGB32bufferGray( Pel*** in, UChar* out, UInt width, UInt height )
-{
- Pel *inPel = in[0][0];
- Pel iY;
- UInt* buff = ( UInt* )out;
- for( UInt i = 0; i < height * width; i++ )
- {
- iY = *inPel;
- *buff++ = PEL_RGB( iY, iY, iY );
- inPel++;
- }
-}
-
-Void fillARGB32bufferRGB( Pel*** in, UChar* out, UInt width, UInt height )
-{
- Pel* pR = in[COLOR_R][0];
- Pel* pG = in[COLOR_G][0];
- Pel* pB = in[COLOR_B][0];
- Int iR, iG, iB;
- UInt* buff = ( UInt* )out;
- for( UInt i = 0; i < height * width; i++ )
- {
- iR = *pR++;
- iG = *pG++;
- iB = *pB++;
- *buff++ = PEL_RGB( iR, iG, iB );
- }
-}
-
+#endif
PlaYUVerPixFmtDescriptor yuv420p =
{
@@ -294,7 +215,6 @@ PlaYUVerPixFmtDescriptor yuv420p =
{ 1, 0, 1, 0, 7 }, /* U */
{ 2, 0, 1, 0, 7 }, /* V */
},
- fillARGB32bufferYUV420p,
};
PlaYUVerPixFmtDescriptor yuv422p =
@@ -311,7 +231,6 @@ PlaYUVerPixFmtDescriptor yuv422p =
{ 1, 0, 1, 0, 7 }, /* U */
{ 2, 0, 1, 0, 7 }, /* V */
},
- fillARGB32bufferYUV422,
};
PlaYUVerPixFmtDescriptor yuv444p =
@@ -328,7 +247,6 @@ PlaYUVerPixFmtDescriptor yuv444p =
{ 1, 0, 1, 0, 7 }, /* U */
{ 2, 0, 1, 0, 7 }, /* V */
},
- fillARGB32bufferYUV444p,
};
PlaYUVerPixFmtDescriptor yuyv422 =
@@ -345,7 +263,6 @@ PlaYUVerPixFmtDescriptor yuyv422 =
{ 0, 3, 2, 0, 7 }, /* U */
{ 0, 3, 4, 0, 7 }, /* V */
},
- fillARGB32bufferYUV422,
};
PlaYUVerPixFmtDescriptor gray =
@@ -358,7 +275,6 @@ PlaYUVerPixFmtDescriptor gray =
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ),
{ { 0, 0, 1, 0, 7 } }, /* Y */
- fillARGB32bufferGray,
};
PlaYUVerPixFmtDescriptor RGB24 =
@@ -375,7 +291,6 @@ PlaYUVerPixFmtDescriptor RGB24 =
{ 0, 2, 2, 0, 7 }, /* G */
{ 0, 2, 3, 0, 7 }, /* B */
},
- fillARGB32bufferRGB,
};
PlaYUVerPixFmtDescriptor BGR24 =
@@ -392,7 +307,6 @@ PlaYUVerPixFmtDescriptor BGR24 =
{ 0, 2, 2, 0, 7 }, /* G */
{ 0, 2, 1, 0, 7 }, /* B */
},
- fillARGB32bufferRGB,
};
PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] =
@@ -405,5 +319,4 @@ PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS
RGB24,
BGR24,
};
-
} // NAMESPACE
diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h
index 1052ade..deede8b 100644
--- a/lib/PlaYUVerFramePixelFormats.h
+++ b/lib/PlaYUVerFramePixelFormats.h
@@ -156,8 +156,6 @@ typedef struct PlaYUVerPixFmtDescriptor
*/
PlaYUVerComponentDescriptor comp[4];
- Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height );
-
} PlaYUVerPixFmtDescriptor;
#define MAX_NUMBER_PLANES 3
diff --git a/lib/PlaYUVerFrameStats.cpp b/lib/PlaYUVerFrameStats.cpp
index 8337fe2..ab455ef 100644
--- a/lib/PlaYUVerFrameStats.cpp
+++ b/lib/PlaYUVerFrameStats.cpp
@@ -36,15 +36,15 @@ namespace plaYUVer
{
PlaYUVerFrameStats::PlaYUVerFrameStats() :
- m_pdHistogram( NULL ),
+ m_puiHistogram( NULL ),
m_bHasHistogram( false )
{
}
PlaYUVerFrameStats::~PlaYUVerFrameStats()
{
- if( m_pdHistogram )
- freeMem1D( m_pdHistogram );
+ if( m_puiHistogram )
+ freeMem1D( m_puiHistogram );
}
@@ -56,7 +56,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op
m_uiImageHeight = pcFrame->getHeight();
m_uiChannels = pcFrame->getNumberChannels();
- m_uiHistoSegments = ( pcFrame->getBitsChannel() == 16 ) ? 65536 : 256;
+ m_uiHistoSegments = 1 << pcFrame->getBitsPel();
imageColorSpace = pcFrame->getColorSpace();
imageChromaSize = pcFrame->getChromaLength();
@@ -77,9 +77,9 @@ Void PlaYUVerFrameStats::calcHistogram()
//m_bHasHistogram = false;
if( m_bHasHistogram )
return;
- getMem1D( &( m_pdHistogram ), m_uiHistoSegments * histoChannels );
+ getMem1D( &( m_puiHistogram ), m_uiHistoSegments * histoChannels );
- if( !m_pdHistogram )
+ if( !m_puiHistogram )
{
// qWarning( ) << "PlaYUVerFrameStats::calcHistogramValuess: "
// "Unable to allocate memory!"
@@ -95,16 +95,16 @@ Void PlaYUVerFrameStats::calcHistogram()
data[LUMA] = m_pppImageData[LUMA][0];
data[CHROMA_U] = m_pppImageData[CHROMA_U][0];
data[CHROMA_V] = m_pppImageData[CHROMA_V][0];
- for( i = 0; i < m_uiImageHeight * m_uiImageWidth; i++ )
+ for( i = 0; i < m_uiImageHeight * m_uiImageWidth && m_bRunningFlag; i++ )
{
- m_pdHistogram[*( data[LUMA] ) + LUMA * m_uiHistoSegments]++;
+ m_puiHistogram[*( data[LUMA] ) + LUMA * m_uiHistoSegments]++;
data[LUMA] += 1;
}
for( i = 0; ( i < imageChromaSize ) && m_bRunningFlag; i++ )
{
for( j = 1; j < m_uiChannels; j++ )
{
- m_pdHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
+ m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
}
for( j = 1; j < m_uiChannels; j++ )
data[j] += 1;
@@ -122,13 +122,13 @@ Void PlaYUVerFrameStats::calcHistogram()
{
for( j = 0; j < m_uiChannels; j++ )
{
- m_pdHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
+ m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++;
}
if( calcLuma && ( imageColorSpace == PlaYUVerFrame::COLOR_RGB || imageColorSpace == PlaYUVerFrame::COLOR_ARGB ) )
{
PlaYUVerFrame::Pixel currPixel( imageColorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ), *( data[COLOR_B] ) );
luma = PlaYUVerFrame::ConvertPixel( currPixel, PlaYUVerFrame::COLOR_YUV ).Y();
- m_pdHistogram[luma + j * m_uiHistoSegments]++;
+ m_puiHistogram[luma + j * m_uiHistoSegments]++;
}
for( j = 0; j < m_uiChannels; j++ )
data[j] += 1;
@@ -228,7 +228,7 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end )
Int indexStart;
Double count = 0.0;
- if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
+ if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
{
return 0.0;
}
@@ -244,14 +244,14 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end )
for( i = start; i <= end; i++ )
{
- count += m_pdHistogram[indexStart + i];
+ count += m_puiHistogram[indexStart + i];
}
return count;
}
Double PlaYUVerFrameStats::getPixels()
{
- if( !m_pdHistogram )
+ if( !m_puiHistogram )
{
return 0.0;
}
@@ -266,7 +266,7 @@ Double PlaYUVerFrameStats::getMean( Int channel, UInt start, UInt end )
Double mean = 0.0;
Double count;
- if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
+ if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
{
return 0.0;
}
@@ -282,7 +282,7 @@ Double PlaYUVerFrameStats::getMean( Int channel, UInt start, UInt end )
for( UInt i = start; i <= end; i++ )
{
- mean += i * m_pdHistogram[indexStart + i];
+ mean += i * m_puiHistogram[indexStart + i];
}
count = getCount( channel, start, end );
@@ -302,7 +302,7 @@ Int PlaYUVerFrameStats::getMedian( Int channel, UInt start, UInt end )
Double sum = 0.0;
Double count;
- if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
+ if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
{
return 0;
}
@@ -320,7 +320,7 @@ Int PlaYUVerFrameStats::getMedian( Int channel, UInt start, UInt end )
for( UInt i = start; i <= end; i++ )
{
- sum += m_pdHistogram[indexStart + i];
+ sum += m_puiHistogram[indexStart + i];
if( sum * 2 > count )
return i;
}
@@ -336,7 +336,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end )
Double count;
Double mean;
- if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
+ if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end )
{
return 0.0;
}
@@ -359,7 +359,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end )
for ( i = start ; i <= end ; i++ )
{
- dev += ( i - mean ) * ( i - mean ) * m_pdHistogram[indexStart +i];
+ dev += ( i - mean ) * ( i - mean ) * m_puiHistogram[indexStart +i];
}
return sqrt( dev / count );
@@ -368,7 +368,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end )
for( UInt i = start; i <= end; i++ )
{
- dev += ( i * i ) * m_pdHistogram[indexStart + i];
+ dev += ( i * i ) * m_puiHistogram[indexStart + i];
}
return sqrt( ( dev - count * mean * mean ) / ( count - 1 ) );
@@ -381,7 +381,7 @@ Double PlaYUVerFrameStats::getHistogramValue( Int channel, UInt bin )
Int histoChannel;
Int indexStart;
- if( !m_pdHistogram || bin < 0 || bin > m_uiHistoSegments - 1 )
+ if( !m_puiHistogram || bin < 0 || bin > m_uiHistoSegments - 1 )
return 0.0;
histoChannel = getRealHistoChannel( channel );
@@ -393,7 +393,7 @@ Double PlaYUVerFrameStats::getHistogramValue( Int channel, UInt bin )
indexStart = histoChannel * m_uiHistoSegments;
- value = m_pdHistogram[indexStart + bin];
+ value = m_puiHistogram[indexStart + bin];
return value;
}
@@ -405,7 +405,7 @@ Double PlaYUVerFrameStats::getMaximum( Int channel )
Int histoChannel;
Int indexStart;
- if( !m_pdHistogram )
+ if( !m_puiHistogram )
return 0.0;
histoChannel = getRealHistoChannel( channel );
@@ -419,9 +419,9 @@ Double PlaYUVerFrameStats::getMaximum( Int channel )
for( UInt x = 0; x < m_uiHistoSegments; x++ )
{
- if( m_pdHistogram[indexStart + x] > max )
+ if( m_puiHistogram[indexStart + x] > max )
{
- max = m_pdHistogram[indexStart + x];
+ max = m_puiHistogram[indexStart + x];
}
}
diff --git a/lib/PlaYUVerFrameStats.h b/lib/PlaYUVerFrameStats.h
index d853a87..dce1c84 100644
--- a/lib/PlaYUVerFrameStats.h
+++ b/lib/PlaYUVerFrameStats.h
@@ -95,7 +95,7 @@ public:
private:
/** The histogram data.*/
- Double* m_pdHistogram;
+ UInt* m_puiHistogram;
/** If true, calc the luminosity channel histogram when the image is RGB */
Bool calcLuma;
diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp
index 901e598..5b09f1e 100644
--- a/lib/PlaYUVerStream.cpp
+++ b/lib/PlaYUVerStream.cpp
@@ -46,10 +46,10 @@ std::vector PlaYUVerStream::supportedReadFormatsExt()
std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsExt();
formatsExt.insert( formatsExt.end(), libAvFmt.begin(), libAvFmt.end() );
#endif
-#ifdef USE_OPENCV
- std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsExt();
- formatsExt.insert( formatsExt.end(), opencvFmt.begin(), opencvFmt.end() );
-#endif
+//#ifdef USE_OPENCV
+// std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsExt();
+// formatsExt.insert( formatsExt.end(), opencvFmt.begin(), opencvFmt.end() );
+//#endif
return formatsExt;
}
@@ -61,10 +61,10 @@ std::vector PlaYUVerStream::supportedReadFormatsName()
std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsName();
formatsName.insert( formatsName.end(), libAvFmt.begin(), libAvFmt.end() );
#endif
-#ifdef USE_OPENCV
- std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsName();
- formatsName.insert( formatsName.end(), opencvFmt.begin(), opencvFmt.end() );
-#endif
+//#ifdef USE_OPENCV
+// std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsName();
+// formatsName.insert( formatsName.end(), opencvFmt.begin(), opencvFmt.end() );
+//#endif
return formatsName;
}
@@ -84,28 +84,22 @@ std::vector PlaYUVerStream::supportedWriteFormatsName()
std::vector PlaYUVerStream::supportedSaveFormatsExt()
{
- std::vector