Fix pixel value and position tracking in statusbar.

This commit is contained in:
Luis Lucas committed 2014-03-22 20:20:28 +00:00
1 parent 9c5cc4d1a6
commit 1976bb5a08
5 files changed
+45 -20

No files matched your search

+1
View File
@@ -98,6 +98,7 @@ bool SubWindowHandle::loadFile( const QString &fileName )
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( fileName ) );
return false;
}
m_cViewArea->setInputStream(m_pCurrStream);
QApplication::restoreOverrideCursor();
+14 -1
View File
@@ -62,6 +62,7 @@ ViewArea::ViewArea( QWidget *parent ) :
m_gridVisible = false;
m_snapToGrid = false;
m_blockTrackEnable = false;
m_pStream = NULL;
}
void ViewArea::setImage( const QPixmap &pixmap )
@@ -500,7 +501,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
QPoint actualPos = windowToView( event->pos() );
QRect updateRect;
emit positionChanged( actualPos );
emit positionChanged( actualPos , getInputStream() );
// If mouse left button pressed
if( event->buttons() == Qt::LeftButton && m_lastPos != QPoint( -1, -1 ) )
@@ -749,4 +750,16 @@ void ViewArea::updateMask( const QRect &rect )
}
}
void ViewArea::setInputStream( InputStream *stream )
{
m_pStream = stream;
}
InputStream* ViewArea::getInputStream()
{
return m_pStream;
}
} // NameSpace plaYUVer
+8 -2
View File
@@ -34,6 +34,8 @@
namespace plaYUVer
{
class InputStream;
/**
*
*/
@@ -98,12 +100,14 @@ public:
return m_maskColor;
}
void setInputStream( InputStream *stream );
InputStream* getInputStream();
// QSize sizeHint() const;
signals:
void selectionChanged( const QRect &rect );
void positionChanged( const QPoint &pos );
void updateStatusBar( const QPoint &actualPos, int &luma, int &chromaU, int &chromaV );
void positionChanged( const QPoint &pos, InputStream *stream );
void zoomFactorChanged( double );
public slots:
@@ -157,6 +161,8 @@ private:
bool m_snapToGrid;
bool m_cursorInGrid;
InputStream *m_pStream;
};
} // NameSpace plaYUVer
+20 -16
View File
@@ -123,7 +123,7 @@ void plaYUVerApp::open()
addSubWindow( interfaceChild );
statusBar()->showMessage( tr( "File loaded" ), 2000 );
interfaceChild->show();
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &) ), this, SLOT( updatePixelValueStatusBar(const QPoint &) ) );
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this, SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) );
}
else
@@ -626,27 +626,31 @@ void plaYUVerApp::setActiveSubWindow( QWidget *window )
mdiArea->setActiveSubWindow( qobject_cast<QMdiSubWindow *>( window ) );
}
void plaYUVerApp::updatePixelValueStatusBar(const QPoint & pos)
void plaYUVerApp::updatePixelValueStatusBar(const QPoint & pos, InputStream* stream)
{
Pel pixel;
Pel luma, chromaU, chromaV;
Int iWidth, iHeight;
Int posX = pos.x(), posY = pos.y();
QString strStatus = QString("X=%1 Y=%2 ").arg(posX).arg(posY);
QString strPixel;
QString strStatus = QString("(%1,%2) ").arg(posX).arg(posY);
PlaYUVerFrame *curFrame = stream->getCurrentFrame();
SubWindowHandle *currentSubWindow = m_pcCurrentSubWindow;
if(currentSubWindow)
iWidth = stream->getWidth();
iHeight = stream->getHeight();
if( (posX<iWidth) && (posX>=0) && (posY<iHeight) && (posY>=0) )
{
iWidth = currentSubWindow->getInputStream()->getWidth();
iHeight = currentSubWindow->getInputStream()->getHeight();
if( (posX<iWidth) && (posX>=0) && (posY<iHeight) && (posY>=0) )
{
pixel = currentSubWindow->getInputStream()->getCurrentFrame()->getPixelValueFromYUV(pos, LUMA);
QString strAux = QString("Luma= %1").arg(pixel);
strStatus.append(strAux);
statusBar()->showMessage( strStatus , 0 );
}
luma = curFrame->getPixelValueFromYUV(pos, LUMA);
chromaU = curFrame->getPixelValueFromYUV(pos, CHROMA_U);
chromaV = curFrame->getPixelValueFromYUV(pos, CHROMA_V);
strPixel = QString("Y: %1 U: %2 V: %3").arg(luma).arg(chromaU).arg(chromaV);
}
else
{
strPixel = QString("Y: U: V: ");
}
strStatus.append(strPixel);
statusBar()->showMessage( strStatus , 0 );
}
} // NAMESPACE
+2 -1
View File
@@ -40,6 +40,7 @@ namespace plaYUVer
{
class SubWindowHandle;
class InputStream;
class plaYUVerApp: public QMainWindow
{
@@ -89,7 +90,7 @@ private Q_SLOTS:
void dropEvent( QDropEvent *event );
void setActiveSubWindow( QWidget *window );
void updatePixelValueStatusBar(const QPoint & pos);
void updatePixelValueStatusBar(const QPoint & pos, InputStream* stream);
private:
QMdiArea *mdiArea;