Merge with features_quality_side_bar

This commit is contained in:
jfmcarreira committed 2014-06-28 23:25:03 +01:00
1 parent 28c09969ce
commit 0212913b5c
8 files changed
+435 -154

No files matched your search

+3 -3
View File
@@ -269,7 +269,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool *pbIsPlayi
// -------------------------------------------------------------
histogramWidget = new HistogramWidget( 256, 140 );
histogramWidget = new HistogramWidget( 256, 100 );
histogramWidget->setOptions( HistogramWidget::BlinkComputation | HistogramWidget::SelectMode | HistogramWidget::ShowLumaChannel );
histogramWidget->setWhatsThis( tr( "<p>This is the histogram drawing of "
"the selected image channel" ) );
@@ -484,11 +484,11 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
if( selectionArea.isValid() )
{
histogramWidget->stopHistogramComputation();
//histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame selectionArea));
histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame));
histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame, selectionArea));
fullImageButton->show();
selectionImageButton->show();
selectionImageButton->click();
slotRenderingChanged( HistogramWidget::ImageSelectionHistogram );
}
else
{
+173
View File
@@ -0,0 +1,173 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 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 QualityMeasurementSidebar.cpp
* \brief Definition of the quality measurement sidebar
*/
#include "PlaYUVerDefs.h"
#include <QtGui>
#include "QualityMeasurementSidebar.h"
#include "SubWindowHandle.h"
namespace plaYUVer
{
QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea *mdiArea ) :
QWidget( parent ),
m_pcMainWindowMdiArea( mdiArea ),
m_pcCurrentSubWindow( NULL )
{
// Side bar area -----------------------------------------------------
QLabel *RefLabel = new QLabel( tr( "Ref:" ) );
RefLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
QLabel *RecLabel = new QLabel( tr( "Rec:" ) );
RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
m_comboBoxRef = new QComboBox;
m_comboBoxRec = new QComboBox;
updateSubWindowList();
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget( RefLabel, 0, 0, Qt::AlignLeft );
mainLayout->addWidget( m_comboBoxRef, 0, 1, Qt::AlignLeft );
//mainLayout->addWidget( RecLabel, 1, 0, Qt::AlignLeft );
//mainLayout->addWidget( m_comboBoxRec, 1, 1, Qt::AlignLeft );
m_ppcLabelQualityLabel[LUMA] = new QLabel( tr( "PSNR Y:" ) );
m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
m_ppcLabelQualityValue[LUMA] = new QLabel;
m_ppcLabelQualityValue[LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
m_ppcLabelQualityLabel[CHROMA_U] = new QLabel( tr( "PSNR U:" ) );
m_ppcLabelQualityLabel[CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
m_ppcLabelQualityValue[CHROMA_U] = new QLabel;
m_ppcLabelQualityValue[CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
m_ppcLabelQualityLabel[CHROMA_V] = new QLabel( tr( "PSNR V:" ) );
m_ppcLabelQualityLabel[CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
m_ppcLabelQualityValue[CHROMA_V] = new QLabel;
m_ppcLabelQualityValue[CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
QGridLayout *qualityResultsLayout = new QGridLayout;
qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[LUMA], 0, 0 );
qualityResultsLayout->addWidget( m_ppcLabelQualityValue[LUMA], 0, 1 );
qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_U], 1, 0 );
qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_U], 1, 1 );
qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 );
qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 );
QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) );
statisticsGroup->setLayout( qualityResultsLayout );
statisticsGroup->setWhatsThis( tr( "<p>Here you can see the quality results calculated for the "
"selected windows." ) );
mainLayout->addWidget( statisticsGroup, 4, 0, 3, 3 );
mainLayout->setRowStretch( 8, 10 );
setLayout( mainLayout );
connect( m_comboBoxRef, SIGNAL( activated(int) ), this, SLOT( slotReferenceChanged(int) ) );
}
QualityMeasurementSidebar::~QualityMeasurementSidebar()
{
}
QSize QualityMeasurementSidebar::sizeHint() const
{
QSize currSize = size();
QSize bestSize( 240, currSize.height() );
if( currSize.width() < bestSize.width() )
return bestSize;
else
return currSize;
}
Void QualityMeasurementSidebar::updateSubWindowList()
{
SubWindowHandle *subWindow;
QString currSubWindowName;
m_pcWindowListNames.clear();
for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->subWindowList().at( i ) );
currSubWindowName = subWindow->getWindowName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() )
m_pcWindowListNames.append( currSubWindowName );
}
m_comboBoxRef->clear();
m_comboBoxRef->insertItems( 0, m_pcWindowListNames );
m_comboBoxRef->setCurrentIndex( -1 );
}
Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow )
{
m_pcCurrentSubWindow = subWindow;
updateSidebarData();
}
Void QualityMeasurementSidebar::updateSidebarData()
{
QString value( "0.00" );
SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow();
if( refSubWindow )
{
PlaYUVerFrame* currFrame = m_pcCurrentSubWindow->getCurrFrame();
PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame();
Double quality;
for( Int component = 0; component < 3; component++ )
{
quality = currFrame->getPSNR( refFrame, component );
m_ppcLabelQualityLabel[component]->setText( value.setNum( quality, 'f', 2 ) );
}
}
else
{
for( Int component = 0; component < 3; component++ )
{
m_ppcLabelQualityLabel[component]->setText( value );
}
}
}
Void QualityMeasurementSidebar::slotReferenceChanged( Int index )
{
SubWindowHandle *subWindow;
if( index > -1 && m_pcCurrentSubWindow )
{
subWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->subWindowList().at( index ) );
if( subWindow )
m_pcCurrentSubWindow->setRefSubWindow( subWindow );
}
// updateSidebarData();
}
} // NAMESPACE
+81
View File
@@ -0,0 +1,81 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014 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 QualityMeasurementSidebar.h
* \brief Definition of the quality measurement sidebar
*/
#ifndef __QUALITYMEASUREMENTSIDEBAR_H__
#define __QUALITYMEASUREMENTSIDEBAR_H__
#include "config.h"
#include "PlaYUVerDefs.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
#elif( QT_VERSION_PLAYUVER == 4 )
#include <QtGui>
#include <QWidget>
#endif
#include "PlaYUVerStream.h"
#include "PlaYUVerFrame.h"
#include "HistogramWidget.h"
namespace plaYUVer
{
class SubWindowHandle;
class QualityMeasurementSidebar: public QWidget
{
Q_OBJECT
public:
QualityMeasurementSidebar( QWidget*, QMdiArea * );
~QualityMeasurementSidebar();
QSize sizeHint() const;
Void updateSubWindowList();
Void updateCurrentWindow( SubWindowHandle * );
Void updateSidebarData();
private:
QMdiArea* m_pcMainWindowMdiArea;
QStringList m_pcWindowListNames;
QStringList m_pcSelectedWindowListNames;
SubWindowHandle *m_pcCurrentSubWindow;
QComboBox *m_comboBoxRef;
QComboBox *m_comboBoxRec;
QLabel* m_ppcLabelQualityLabel[3];
QLabel* m_ppcLabelQualityValue[3];
HistogramWidget *histogramWidget;
private Q_SLOTS:
void slotReferenceChanged( int );
};
} // NAMESPACE
#endif // __QUALITYMEASUREMENTSIDEBAR_H__
+12 -13
View File
@@ -31,6 +31,11 @@ namespace plaYUVer
SubWindowHandle::SubWindowHandle( QWidget * parent, Bool isModule ) :
QMdiSubWindow( parent ),
m_pCurrStream( NULL ),
m_pcCurrFrame( NULL ),
m_pcCurrentModule( NULL ),
m_pcReferenceSubWindow( NULL ),
m_bIsPlaying( false ),
m_bIsModule( isModule )
{
setParent( parent );
@@ -50,17 +55,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, Bool isModule ) :
connect( m_cScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) );
connect( m_cScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) );
// Define the cViewArea as the widget inside the scroll area
// Define the cViewArea as the widget inside the scroll area
m_cScrollArea->setWidget( m_cViewArea );
m_cScrollArea->setWidgetResizable( true );
m_pCurrStream = NULL;
//m_pCurrStream = new PlaYUVerStream;
m_pcCurrFrame = NULL;
m_pcCurrentModule = NULL;
m_cWindowName = QString( " " );
m_bIsPlaying = false;
m_cLastScroll = QPoint();
}
@@ -130,7 +129,7 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module )
disableModule();
}
m_pcCurrentModule = select_module;
// refreshFrame();
// refreshFrame();
}
Void SubWindowHandle::disableModule()
@@ -282,7 +281,7 @@ Void SubWindowHandle::normalSize()
Void SubWindowHandle::zoomToFit()
{
// Scale to a smaller size that the real to a nicer look
// Scale to a smaller size that the real to a nicer look
QSize niceFit( m_cScrollArea->viewport()->size().width() - 5, m_cScrollArea->viewport()->size().height() - 5 );
scaleView( niceFit );
}
@@ -309,7 +308,7 @@ Void SubWindowHandle::scaleView( const QSize & size )
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
// Calc the zoom factor
// Calc the zoom factor
Double wfactor = 1;
Double hfactor = 1;
@@ -390,7 +389,7 @@ void SubWindowHandle::updateLastScrollValue()
QSize SubWindowHandle::sizeHint() const
{
QSize maxSize; // The size of the parent (viewport widget
// of the QMdiArea).
// of the QMdiArea).
QWidget *p = parentWidget();
if( p )
@@ -404,8 +403,8 @@ QSize SubWindowHandle::sizeHint() const
else if( m_pCurrStream )
isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
// If the SubWindowHandle needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
// If the SubWindowHandle needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
if( isize.width() < maxSize.width() && isize.height() < maxSize.height() )
{
return isize;
+15 -3
View File
@@ -38,6 +38,7 @@
namespace plaYUVer
{
class SubWindowHandle;
class SubWindowHandle: public QMdiSubWindow
{
@@ -48,11 +49,13 @@ private:
QScrollArea* m_cScrollArea;
ViewArea* m_cViewArea;
PlaYUVerModuleIf* m_pcCurrentModule;
PlaYUVerStream* m_pCurrStream;
PlaYUVerFrame* m_pcCurrFrame;
PlaYUVerModuleIf* m_pcCurrentModule;
SubWindowHandle* m_pcReferenceSubWindow;
QString m_cWindowName;
QString m_cCurrFileName;
@@ -68,7 +71,7 @@ public:
Bool mayClose();
Bool loadFile( QString cFilename, Bool bForceDialog = false );
Void reloadFile();
Bool save( QString filename );
Bool save( QString filename );
Bool play();
Void pause();
@@ -117,6 +120,15 @@ public:
return m_pcCurrentModule;
}
Void setRefSubWindow( SubWindowHandle* subWindow )
{
m_pcReferenceSubWindow = subWindow;
}
SubWindowHandle* getRefSubWindow()
{
return m_pcReferenceSubWindow;
}
/**
* Functions to enable a module in the
* current SubWindow
+120 -119
View File
@@ -47,7 +47,7 @@ static const QColor imageMaskColor = Qt::green;
static const QColor eraserColor = Qt::red;
ViewArea::ViewArea( QWidget *parent ) :
QWidget( parent )
QWidget( parent )
{
setAttribute( Qt::WA_StaticContents );
// setAttribute( Qt::WA_NoBackground );
@@ -109,6 +109,7 @@ void ViewArea::clearMask()
// return QSize( w, h );
// }
<<<<<<< HEAD
Void ViewArea::setZoomFactor( Double f )
{
m_zoomFactor = f;
@@ -118,15 +119,18 @@ Void ViewArea::setZoomFactor( Double f )
}
Void ViewArea::zoomChangeEvent(Double factor, QPoint center )
=======
Void ViewArea::zoomChangeEvent( Double factor, QPoint center )
>>>>>>> features_quality_side_bar
{
Double zoomFactor;
Double maxZoom = 100.0;
Double minZoom = 0.01;//( 1.0 / m_pixmap.width() );
Double minZoom = 0.01; //( 1.0 / m_pixmap.width() );
if( ( m_zoomFactor == minZoom ) && (factor < 1 ) )
if( ( m_zoomFactor == minZoom ) && ( factor < 1 ) )
return;
if( ( m_zoomFactor == maxZoom ) && (factor > 1 ) )
if( ( m_zoomFactor == maxZoom ) && ( factor > 1 ) )
return;
zoomFactor = m_zoomFactor * factor;
@@ -138,7 +142,7 @@ Void ViewArea::zoomChangeEvent(Double factor, QPoint center )
zoomFactor = maxZoom;
setZoomFactor( zoomFactor );
emit zoomFactorChanged(factor, center);
emit zoomFactorChanged( factor, center );
}
@@ -313,9 +317,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
// to draw the whole pixmap if your widget is only partially exposed), and reverse map it with the painter matrix.
// That gives us the part of the pixmap that has actually been exposed.
// See: http://blog.qt.digia.com/blog/2006/05/13/fast-transformed-pixmapimage-drawing/
QRect exposedRect = painter.worldTransform().inverted()
.mapRect(event->rect())
.adjusted(-1, -1, 1, 1);
QRect exposedRect = painter.worldTransform().inverted().mapRect( event->rect() ).adjusted( -1, -1, 1, 1 );
// Draw the pixmap.
painter.drawPixmap( exposedRect, m_pixmap, exposedRect );
@@ -346,7 +348,6 @@ void ViewArea::paintEvent( QPaintEvent *event )
painter.restore();
// Draw a border around the image.
if( m_xOffset || m_yOffset )
{
@@ -355,55 +356,54 @@ void ViewArea::paintEvent( QPaintEvent *event )
}
// Draw pixel values in grid
if(m_zoomFactor>=25.0)
if( m_zoomFactor >= 25.0 )
{
Int imageWidth = m_pixmap.width();
Int imageHeight = m_pixmap.height();
Pixel sPixelValue;
QFont font("Helvetica");
font.setPixelSize(m_zoomFactor/4);
painter.setFont(font);
QFont font( "Helvetica" );
font.setPixelSize( m_zoomFactor / 4 );
painter.setFont( font );
QRect vr = windowToView( winRect );
vr &= QRect( 0, 0, imageWidth, imageHeight );
for(Int i=vr.x() ; i<=vr.right() ; i++)
for( Int i = vr.x(); i <= vr.right(); i++ )
{
for(Int j=vr.y() ; j<=vr.bottom() ; j++)
for( Int j = vr.y(); j <= vr.bottom(); j++ )
{
QPoint pixelTopLeft(i,j);
QPoint pixelTopLeft( i, j );
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV );
QRect pixelRect(viewToWindow(pixelTopLeft), QSize(m_zoomFactor,m_zoomFactor));
QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_zoomFactor, m_zoomFactor ) );
if( sPixelValue.Luma < 128 )
painter.setPen(QColor(Qt::white));
painter.setPen( QColor( Qt::white ) );
else
painter.setPen(QColor(Qt::black));
painter.drawText(pixelRect, Qt::AlignCenter, QString::number(sPixelValue.Luma));
painter.setPen( QColor( Qt::black ) );
painter.drawText( pixelRect, Qt::AlignCenter, QString::number( sPixelValue.Luma ) );
}
}
QColor color( Qt::white );
QPen mainPen = QPen( color, 1, Qt::SolidLine );
painter.setPen(mainPen);
painter.setPen( mainPen );
// Draw vertical line
for( Int x = vr.x(); x <= (vr.right()+1); x ++ )
for( Int x = vr.x(); x <= ( vr.right() + 1 ); x++ )
{
// Always draw the full line otherwise the line stippling
// varies with the location of view area and we get glitchy
// patterns.
painter.drawLine( viewToWindow(QPoint(x,0)), viewToWindow(QPoint(x,imageHeight)) );
painter.drawLine( viewToWindow( QPoint( x, 0 ) ), viewToWindow( QPoint( x, imageHeight ) ) );
}
// Draw horizontal line
for( Int y = vr.y(); y <= (vr.bottom()+1); y ++ )
for( Int y = vr.y(); y <= ( vr.bottom() + 1 ); y++ )
{
painter.drawLine( viewToWindow(QPoint(0,y)), viewToWindow(QPoint(imageWidth,y)) );
painter.drawLine( viewToWindow( QPoint( 0, y ) ), viewToWindow( QPoint( imageWidth, y ) ) );
}
}
QRect sr = viewToWindow( m_selectedArea );
QRect ir = sr & winRect;
@@ -498,7 +498,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
break;
}
default:
color = selectionColor; // ?Problems!
color = selectionColor; // ?Problems!
}
color.setAlpha( 120 );
@@ -532,7 +532,6 @@ void ViewArea::wheelEvent( QWheelEvent *event )
factor=0.8;
zoomChangeEvent( factor , event->pos() );
}
}
void ViewArea::mousePressEvent( QMouseEvent *event )
@@ -549,7 +548,7 @@ void ViewArea::mousePressEvent( QMouseEvent *event )
{
if( tool() == NavigationTool )
{
if( !(m_xOffset && m_yOffset) )
if( !( m_xOffset && m_yOffset ) )
setCursor( Qt::ClosedHandCursor );
m_lastWindowPos = event->pos();
@@ -609,14 +608,14 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
#ifndef _MSC_VER
// Add this code line to avoid slow navigation with some specific mouses
// This seems to always appear on windows
if(qApp->hasPendingEvents())
return;
if( qApp->hasPendingEvents())
return;
#endif
QPoint actualPos = windowToView( event->pos() );
QRect updateRect;
emit positionChanged( actualPos , m_pcCurrFrame );
emit positionChanged( actualPos, m_pcCurrFrame );
// If mouse left button pressed
if( event->buttons() == Qt::LeftButton && m_lastPos != QPoint( -1, -1 ) )
@@ -636,7 +635,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
if( tool() == NavigationTool )
{
QPoint offset = m_lastWindowPos - event->pos() ;
QPoint offset = m_lastWindowPos - event->pos();
emit moveScroll( offset );
}
@@ -686,19 +685,19 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
}
}
}
/* else // if tool() == BlockSelectionTool || MaskTool || EraserTool
{
m_blockTrackEnable = false;
// If cursor is inside the selected area, we most redraw
// the selection rect because it may be smaller.
if( m_selectedArea.contains( actualPos ) )
{
m_selectedArea = m_grid.rectContains( m_lastPos );
}
/* else // if tool() == BlockSelectionTool || MaskTool || EraserTool
{
m_blockTrackEnable = false;
// If cursor is inside the selected area, we most redraw
// the selection rect because it may be smaller.
if( m_selectedArea.contains( actualPos ) )
{
m_selectedArea = m_grid.rectContains( m_lastPos );
}
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
}
*/
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
}
*/
if( tool() == NormalSelectionTool )
{
// Intercept the selected area with the image area to limit the
@@ -751,89 +750,92 @@ void ViewArea::mouseReleaseEvent( QMouseEvent *event )
{
if( tool() == NavigationTool )
{
unsetCursor();
unsetCursor();
}
// Normal Mode ------------------------------------------------------
if( mode() == NormalMode )
else if( tool() == NormalSelectionTool )
{
if( vpos == m_lastPos )
// Normal Mode ------------------------------------------------------
if( mode() == NormalMode )
{
if( vpos == m_lastPos )
{
m_selectedArea = QRect();
if( tool() == BlockSelectionTool )
m_blockTrackEnable = true;
}
emit selectionChanged( m_selectedArea );
}
// Mask Mode -----------------------------------------------------------
else if( mode() == MaskMode )
{
if( !m_selectedArea.isNull() )
{
updateMask( m_selectedArea );
}
m_selectedArea = QRect();
if( tool() == BlockSelectionTool )
m_blockTrackEnable = true;
m_blockTrackEnable = true;
}
emit selectionChanged( m_selectedArea );
m_newShape = false;
update();
m_lastPos = QPoint( -1, -1 );
}
// Mask Mode -----------------------------------------------------------
else if( mode() == MaskMode )
{
if( !m_selectedArea.isNull() )
{
updateMask( m_selectedArea );
}
m_selectedArea = QRect();
m_blockTrackEnable = true;
}
m_newShape = false;
update();
m_lastPos = QPoint( -1, -1 );
}
}
////////////////////////////////////////////////////////////////////////////////
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<int>( ( pt.x() - m_xOffset ) / m_zoomFactor ) );
p.setY( static_cast<int>( ( pt.y() - m_yOffset ) / m_zoomFactor ) );
QPoint p;
p.setX( static_cast<int>( ( pt.x() - m_xOffset ) / m_zoomFactor ) );
p.setY( static_cast<int>( ( 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<int>(( rc.right() - m_xOffset ) / m_zoomFactor +1));
// r.setBottom( static_cast<int>(( 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<int>( pt.x() * m_zoomFactor + m_xOffset ) );
p.setY( static_cast<int>( pt.y() * m_zoomFactor + m_yOffset ) );
p.setX( static_cast<int>( pt.x() * m_zoomFactor + m_xOffset ) );
p.setY( static_cast<int>( 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);
@@ -841,9 +843,9 @@ QRect ViewArea::viewToWindow( const QRect& rc ) const
// qDebug()<<"Right = "<< r.right();
// r.setRight ( static_cast<int>(( rc.right()+1) * m_zoomFactor + m_xOffset -1) );
// r.setBottom( static_cast<int>(( rc.bottom()+1) * m_zoomFactor + m_yOffset -1));
r.setBottomRight( viewToWindow( rc.bottomRight() ) );
r.setBottomRight( viewToWindow( rc.bottomRight() ) );
return r;
return r;
}
////////////////////////////////////////////////////////////////////////////////
@@ -851,42 +853,41 @@ QRect ViewArea::viewToWindow( const QRect& rc ) const
////////////////////////////////////////////////////////////////////////////////
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
} // NameSpace plaYUVer
+25 -13
View File
@@ -809,6 +809,8 @@ Void plaYUVerApp::chageSubWindowSelection()
}
updateStreamProperties();
updateFrameProperties();
m_pcQualityMeasurement->updateCurrentWindow( m_pcCurrentSubWindow );
m_pcQualityMeasurement->updateSubWindowList();
updateMenus();
}
@@ -1311,21 +1313,31 @@ Void plaYUVerApp::createToolBars()
Void plaYUVerApp::createDockWidgets()
{
// Properties Dock Window
m_arraySideBars.resize( TOTAL_SIDEBAR );
m_arraySideBars.resize( TOTAL_DOCK );
m_pcStreamProperties = new StreamPropertiesSideBar( this );
m_arraySideBars[STREAM_SIDEBAR] = new QDockWidget( tr( "Stream Information" ), this );
m_arraySideBars[STREAM_SIDEBAR]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_arraySideBars[STREAM_SIDEBAR]->setWidget( m_pcStreamProperties );
addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[STREAM_SIDEBAR] );
connect( m_arraySideBars[STREAM_SIDEBAR], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) );
m_arraySideBars[STREAM_DOCK] = new QDockWidget( tr( "Stream Information" ), this );
m_arraySideBars[STREAM_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_arraySideBars[STREAM_DOCK]->setWidget( m_pcStreamProperties );
addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[STREAM_DOCK] );
connect( m_arraySideBars[STREAM_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) );
m_pcFrameProperties = new FramePropertiesSideBar( this, &m_bIsPlaying );
m_arraySideBars[FRAME_SIDEBAR] = new QDockWidget( tr( "Frame Information" ), this );
m_arraySideBars[FRAME_SIDEBAR]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_arraySideBars[FRAME_SIDEBAR]->setWidget( m_pcFrameProperties );
addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[FRAME_SIDEBAR] );
connect( m_arraySideBars[FRAME_SIDEBAR], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) );
m_arraySideBars[FRAME_DOCK] = new QDockWidget( tr( "Frame Information" ), this );
m_arraySideBars[FRAME_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_arraySideBars[FRAME_DOCK]->setWidget( m_pcFrameProperties );
addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[FRAME_DOCK] );
connect( m_arraySideBars[FRAME_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) );
QMainWindow::tabifyDockWidget( m_arraySideBars[FRAME_DOCK], m_arraySideBars[STREAM_DOCK] );
//QMainWindow::setTabPosition(Qt::RightDockWidgetArea, QTabWidget::North);
m_pcQualityMeasurement = new QualityMeasurementSidebar( this, mdiArea );
m_arraySideBars[QUALITY_DOCK] = new QDockWidget( tr( "Quality Measurement" ), this );
m_arraySideBars[QUALITY_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_arraySideBars[QUALITY_DOCK]->setWidget( m_pcQualityMeasurement );
addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[QUALITY_DOCK] );
}
Void plaYUVerApp::createStatusBar()
@@ -1348,9 +1360,9 @@ Void plaYUVerApp::readSettings()
Bool visibleStreamProp, visibleFrameProp;
settings.getDockVisibility( visibleStreamProp, visibleFrameProp );
if( !visibleStreamProp )
m_arraySideBars[STREAM_SIDEBAR]->close();
m_arraySideBars[STREAM_DOCK]->close();
if( !visibleFrameProp )
m_arraySideBars[FRAME_SIDEBAR]->close();
m_arraySideBars[FRAME_DOCK]->close();
}
+6 -3
View File
@@ -35,6 +35,7 @@
#include <QMainWindow>
#include "ModulesHandle.h"
#include "PropertiesSidebar.h"
#include "QualityMeasurementSidebar.h"
namespace plaYUVer
{
@@ -181,14 +182,16 @@ private:
enum SIDEBAR_LIST
{
STREAM_SIDEBAR = 0,
FRAME_SIDEBAR,
TOTAL_SIDEBAR,
STREAM_DOCK = 0,
FRAME_DOCK,
QUALITY_DOCK,
TOTAL_DOCK,
};
QVector<QDockWidget*> m_arraySideBars;
StreamPropertiesSideBar* m_pcStreamProperties;
FramePropertiesSideBar* m_pcFrameProperties;
QualityMeasurementSidebar* m_pcQualityMeasurement;
enum TOOLBAR_LIST
{