Re-format code
This commit is contained in:
1 parent
fd68d340bd
commit
ebc10d1b84
85 files changed
+8092
-4419
No files matched your search
+58
-38
@@ -22,12 +22,12 @@
|
||||
* \brief Video Sub windows handling
|
||||
*/
|
||||
|
||||
#include <QStaticText>
|
||||
#include "VideoSubWindow.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "ConfigureFormatDialog.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
#include <QScrollArea>
|
||||
#include <QStaticText>
|
||||
#if( QT_VERSION_PLAYUVER == 5 )
|
||||
#include "QtConcurrent/qtconcurrentrun.h"
|
||||
#endif
|
||||
@@ -43,8 +43,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
|
||||
for( Int i = 0; i < array.size(); i++ )
|
||||
{
|
||||
d = array.at( i );
|
||||
out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness
|
||||
<< d.m_uiFrameRate << d.m_uiFileSize;
|
||||
out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel
|
||||
<< d.m_iEndianness << d.m_uiFrameRate << d.m_uiFileSize;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -124,20 +124,21 @@ class VideoInformation : public QWidget
|
||||
if( m_bBusyWindow )
|
||||
{
|
||||
painter.setFont( m_cCenterTextFont );
|
||||
painter.drawText( rect(), Qt::AlignHCenter | Qt::AlignVCenter, QStringLiteral( "Refreshing..." ) );
|
||||
painter.drawText( rect(), Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
QStringLiteral( "Refreshing..." ) );
|
||||
painter.fillRect( rect(), QBrush( QColor::fromRgb( 255, 255, 255, 50 ), Qt::SolidPattern ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent )
|
||||
: SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
|
||||
m_bWindowBusy( false ),
|
||||
m_pCurrStream( NULL ),
|
||||
m_pcCurrFrame( NULL ),
|
||||
m_pcCurrentDisplayModule( NULL ),
|
||||
m_pcReferenceSubWindow( NULL ),
|
||||
m_bIsPlaying( false )
|
||||
: SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category )
|
||||
, m_bWindowBusy( false )
|
||||
, m_pCurrStream( NULL )
|
||||
, m_pcCurrFrame( NULL )
|
||||
, m_pcCurrentDisplayModule( NULL )
|
||||
, m_pcReferenceSubWindow( NULL )
|
||||
, m_bIsPlaying( false )
|
||||
{
|
||||
// Create a new scroll area inside the sub-window
|
||||
m_pcScrollArea = new QScrollArea;
|
||||
@@ -153,10 +154,13 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
|
||||
SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved_SWindow( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this,
|
||||
SLOT( adjustScrollBarByOffset( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this,
|
||||
SIGNAL( scrollBarMoved_SWindow( QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
|
||||
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this,
|
||||
SLOT( updateSelectedArea( QRect ) ) );
|
||||
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint& ) ), this,
|
||||
SLOT( updatePixelValueStatusBar( const QPoint& ) ) );
|
||||
|
||||
@@ -313,8 +317,9 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
|
||||
if( guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog )
|
||||
{
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
|
||||
Endianness, FrameRate ) == QDialog::Rejected )
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height,
|
||||
InputFormat, BitsPel, Endianness,
|
||||
FrameRate ) == QDialog::Rejected )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -322,16 +327,19 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
|
||||
try
|
||||
{
|
||||
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, true );
|
||||
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness,
|
||||
FrameRate, true );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
|
||||
Endianness, FrameRate ) == QDialog::Rejected )
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height,
|
||||
InputFormat, BitsPel, Endianness,
|
||||
FrameRate ) == QDialog::Rejected )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, true );
|
||||
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness,
|
||||
FrameRate, true );
|
||||
}
|
||||
|
||||
m_sStreamInfo.m_cFilename = cFilename;
|
||||
@@ -361,8 +369,9 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
|
||||
m_pCurrStream = new PlaYUVerStream;
|
||||
}
|
||||
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight,
|
||||
streamInfo->m_iPelFormat, streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth,
|
||||
streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
|
||||
streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
|
||||
streamInfo->m_uiFrameRate, true ) )
|
||||
{
|
||||
return false;
|
||||
@@ -394,7 +403,8 @@ Void VideoSubWindow::updateVideoWindowInfo()
|
||||
{
|
||||
if( arraySubWindows.at( i )->getWindowName() != getWindowName() )
|
||||
{
|
||||
sourceWindowList.append( QString( "Input %1 - " + arraySubWindows.at( i )->getWindowName() ).arg( i + 1 ) );
|
||||
sourceWindowList.append(
|
||||
QString( "Input %1 - " + arraySubWindows.at( i )->getWindowName() ).arg( i + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,11 +450,13 @@ Bool VideoSubWindow::guessFormat( QString filename,
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !fileExtension.compare( "yuv" ) || !fileExtension.compare( "rgb" ) || !fileExtension.compare( "gray" ) )
|
||||
if( !fileExtension.compare( "yuv" ) || !fileExtension.compare( "rgb" ) ||
|
||||
!fileExtension.compare( "gray" ) )
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
QVector<String> formats_list = QVector<String>::fromStdVector( PlaYUVerFrame::supportedPixelFormatListNames() );
|
||||
QVector<String> formats_list =
|
||||
QVector<String>::fromStdVector( PlaYUVerFrame::supportedPixelFormatListNames() );
|
||||
for( Int i = 0; i < formats_list.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list.at( i ).c_str(), Qt::CaseInsensitive ) )
|
||||
@@ -473,7 +485,8 @@ Bool VideoSubWindow::guessFormat( QString filename,
|
||||
|
||||
#if( QT_VERSION_PLAYUVER == 5 )
|
||||
// Guess resolution - match %dx%d
|
||||
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
QRegularExpressionMatch resolutionMatch =
|
||||
QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
if( resolutionMatch.hasMatch() )
|
||||
{
|
||||
QString resolutionString = resolutionMatch.captured( 0 );
|
||||
@@ -504,8 +517,8 @@ Bool VideoSubWindow::guessFormat( QString filename,
|
||||
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, 8 );
|
||||
frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth,
|
||||
stdResList[i].uiHeight, rInputFormat, 8 );
|
||||
module = uiFileSize % frame_bytes;
|
||||
if( module == 0 )
|
||||
{
|
||||
@@ -683,8 +696,8 @@ Bool VideoSubWindow::save( QString filename )
|
||||
PlaYUVerFrame* saveFrame = m_pcCurrFrame;
|
||||
if( m_cSelectedArea.isValid() )
|
||||
{
|
||||
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(),
|
||||
m_cSelectedArea.height() );
|
||||
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(),
|
||||
m_cSelectedArea.width(), m_cSelectedArea.height() );
|
||||
}
|
||||
if( !saveFrame )
|
||||
{
|
||||
@@ -768,7 +781,8 @@ Void VideoSubWindow::stop()
|
||||
|
||||
QSize VideoSubWindow::getScrollSize()
|
||||
{
|
||||
return QSize( m_pcScrollArea->viewport()->size().width() - 5, m_pcScrollArea->viewport()->size().height() - 5 );
|
||||
return QSize( m_pcScrollArea->viewport()->size().width() - 5,
|
||||
m_pcScrollArea->viewport()->size().height() - 5 );
|
||||
}
|
||||
|
||||
Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset )
|
||||
@@ -809,7 +823,8 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center )
|
||||
scrollBarH = m_pcScrollArea->horizontalScrollBar();
|
||||
if( center.isNull() )
|
||||
{
|
||||
m_cCurrScroll.setX( int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ) );
|
||||
m_cCurrScroll.setX(
|
||||
int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -825,7 +840,8 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center )
|
||||
scrollBarV = m_pcScrollArea->verticalScrollBar();
|
||||
if( center.isNull() )
|
||||
{
|
||||
m_cCurrScroll.setY( int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ) );
|
||||
m_cCurrScroll.setY(
|
||||
int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -958,15 +974,19 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
||||
if( ColorSpace == PlaYUVerPixel::COLOR_YUV )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
strStatus.append(
|
||||
QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
|
||||
strStatus.append( QString( "Y: %1 U: %2 V: %3" )
|
||||
.arg( sPixelValue.Y() )
|
||||
.arg( sPixelValue.Cb() )
|
||||
.arg( sPixelValue.Cr() ) );
|
||||
}
|
||||
|
||||
if( ( ColorSpace == PlaYUVerPixel::COLOR_RGB ) )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
strStatus.append(
|
||||
QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
|
||||
strStatus.append( QString( "R: %1 G: %2 B: %3" )
|
||||
.arg( sPixelValue.R() )
|
||||
.arg( sPixelValue.G() )
|
||||
.arg( sPixelValue.B() ) );
|
||||
}
|
||||
emit updateStatusBar( strStatus );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user