Merge branch 'dev_modules_api'

This commit is contained in:
jfmcarreira committed 2014-04-17 21:59:08 +01:00
commit 4d50b0e173
6 files changed
+86 -54

No files matched your search

+30 -22
View File
@@ -45,8 +45,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
m_cViewArea = new ViewArea( m_cScrollArea );
connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( adjustScrollBarByZoom(double, QPoint) ) );
connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SLOT( adjustScrollBarByOffset(QPoint) ) );
connect( m_cScrollArea->horizontalScrollBar() , SIGNAL( actionTriggered( int ) ), this, SLOT ( updateLastScrollValue() ) );
connect( m_cScrollArea->verticalScrollBar() , SIGNAL( actionTriggered( int ) ), this, SLOT ( updateLastScrollValue() ) );
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
m_cScrollArea->setWidget( m_cViewArea );
@@ -55,6 +55,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
m_pCurrStream = new InputStream;
m_pcCurrentModule = NULL;
m_pcModuleSubWindow = NULL;
m_cWindowName = QString( " " );
m_bIsPlaying = false;
@@ -130,26 +131,33 @@ Void SubWindowHandle::disableModule()
if( !m_pcCurrentModule )
return;
m_pcCurrentModule->m_pcAction->setCheckable(false);
m_pcCurrentModule->m_pcAction->setCheckable( false );
m_pcCurrentModule->destroy();
m_pcCurrentModule = NULL;
refreshFrame();
}
Void SubWindowHandle::setCurrFrame( PlaYUVerFrame* pcCurrFrame )
{
m_pcCurrFrame = pcCurrFrame;
m_cViewArea->setImage( m_pcCurrFrame );
}
Void SubWindowHandle::refreshFrame()
{
PlaYUVerFrame* currFrame;
m_pcCurrFrame = m_pCurrStream->getCurrFrame();
if( m_pcCurrentModule )
{
currFrame = m_pcCurrentModule->process( m_pCurrStream->getCurrFrame() );
if( m_pcModuleSubWindow )
{
m_pcModuleSubWindow->setCurrFrame( m_pcCurrentModule->process( m_pCurrStream->getCurrFrame() ) );
}
else
{
m_pcCurrFrame = m_pcCurrentModule->process( m_pCurrStream->getCurrFrame() );
}
}
else
{
currFrame = m_pCurrStream->getCurrFrame();
}
currFrame->FrametoRGB8();
QImage qimg = QImage( currFrame->getQImageBuffer(), currFrame->getWidth(), currFrame->getHeight(), QImage::Format_RGB888 );
m_cViewArea->setImage( QPixmap::fromImage( qimg ) );
m_cViewArea->setImage( m_pcCurrFrame );
}
Bool SubWindowHandle::save()
@@ -169,7 +177,8 @@ Bool SubWindowHandle::save()
QApplication::setOverrideCursor( Qt::WaitCursor );
m_pCurrStream->getCurrFrame()->FrametoRGB8();
QImage qimg = QImage( m_pCurrStream->getCurrFrame()->getQImageBuffer(), m_pCurrStream->getCurrFrame()->getWidth(), m_pCurrStream->getCurrFrame()->getHeight(), QImage::Format_RGB888 );
QImage qimg = QImage( m_pCurrStream->getCurrFrame()->getQImageBuffer(), m_pCurrStream->getCurrFrame()->getWidth(), m_pCurrStream->getCurrFrame()->getHeight(),
QImage::Format_RGB888 );
if( qimg.save( fileName ) )
{
QApplication::restoreOverrideCursor();
@@ -279,13 +288,13 @@ Void SubWindowHandle::scaleView( const QSize & size )
Void SubWindowHandle::scaleViewByRatio( Double ratio )
{
Q_ASSERT( m_cViewArea->image() );
m_cViewArea->zoomChangeEvent( ratio , QPoint() );
m_cViewArea->zoomChangeEvent( ratio, QPoint() );
}
void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
{
QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar();
scrollBar->setValue( int( scrollBar->value() + Offset.x() ) );
scrollBar->setValue( int( scrollBar->value() + Offset.x() ) );
m_cLastScroll.setX( scrollBar->value() );
scrollBar = m_cScrollArea->verticalScrollBar();
scrollBar->setValue( int( scrollBar->value() + Offset.y() ) );
@@ -296,7 +305,7 @@ void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
// This function was developed with help of the schematics presented in
// http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position
void SubWindowHandle::adjustScrollBarByZoom( double factor , QPoint center )
void SubWindowHandle::adjustScrollBarByZoom( double factor, QPoint center )
{
QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar();
if( center.isNull() )
@@ -307,9 +316,9 @@ void SubWindowHandle::adjustScrollBarByZoom( double factor , QPoint center )
{
Int x = center.x() - m_cLastScroll.x();
Int value = int( factor * m_cLastScroll.x() + ( ( factor - 1 ) * x ) );
if ( value > scrollBar->maximum() )
if( value > scrollBar->maximum() )
value = scrollBar->maximum();
if ( value < scrollBar->minimum() )
if( value < scrollBar->minimum() )
value = scrollBar->minimum();
scrollBar->setValue( value );
}
@@ -323,9 +332,9 @@ void SubWindowHandle::adjustScrollBarByZoom( double factor , QPoint center )
{
Int y = center.y() - m_cLastScroll.y();
Int value = int( factor * m_cLastScroll.y() + ( ( factor - 1 ) * y ) );
if ( value > scrollBar->maximum() )
if( value > scrollBar->maximum() )
value = scrollBar->maximum();
if ( value < scrollBar->minimum() )
if( value < scrollBar->minimum() )
value = scrollBar->minimum();
scrollBar->setValue( value );
}
@@ -333,7 +342,7 @@ void SubWindowHandle::adjustScrollBarByZoom( double factor , QPoint center )
updateLastScrollValue();
}
void SubWindowHandle::updateLastScrollValue( )
void SubWindowHandle::updateLastScrollValue()
{
QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar();
m_cLastScroll.setX( scrollBar->value() );
@@ -341,7 +350,6 @@ void SubWindowHandle::updateLastScrollValue( )
m_cLastScroll.setY( scrollBar->value() );
}
QSize SubWindowHandle::sizeHint() const
{
QSize maxSize; // The size of the parent (viewport widget
+7
View File
@@ -51,8 +51,10 @@ private:
ViewArea* m_cViewArea;
PlaYUVerModuleIf* m_pcCurrentModule;
SubWindowHandle* m_pcModuleSubWindow;
InputStream* m_pCurrStream;
PlaYUVerFrame* m_pcCurrFrame;
QString m_cWindowName;
QString m_cCurrFileName;
@@ -85,6 +87,7 @@ public:
QImage* FrameToQImage( PlaYUVerFrame* curr_frame );
Void refreshFrame();
Void setCurrFrame( PlaYUVerFrame* pcCurrFrame );
InputStream* getInputStream()
{
@@ -95,6 +98,10 @@ public:
{
return m_cViewArea;
}
Void setModuleSubWindow( SubWindowHandle* pcWindow )
{
m_pcModuleSubWindow = pcWindow;
}
/**
* Functions to enable a module in the
+11 -4
View File
@@ -37,7 +37,6 @@
#include "ViewArea.h"
#include "GridManager.h"
#include "PlaYUVerFrame.h"
#include "InputStream.h"
namespace plaYUVer
@@ -54,6 +53,7 @@ ViewArea::ViewArea( QWidget *parent ) :
// setAttribute( Qt::WA_NoBackground );
setMouseTracking( true );
m_pcCurrFrame = NULL;
m_pixmap = QPixmap();
m_grid = GridManager();
m_mask = QBitmap();
@@ -69,6 +69,14 @@ ViewArea::ViewArea( QWidget *parent ) :
m_pStream = NULL;
}
void ViewArea::setImage( PlaYUVerFrame* pcFrame )
{
m_pcCurrFrame = pcFrame;
m_pcCurrFrame->FrametoRGB8();
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
setImage( QPixmap::fromImage( qimg ) );
}
void ViewArea::setImage( const QPixmap &pixmap )
{
m_pixmap = pixmap;
@@ -357,7 +365,6 @@ void ViewArea::paintEvent( QPaintEvent *event )
{
Int imageWidth = m_pixmap.width();
Int imageHeight = m_pixmap.height();
PlaYUVerFrame *curFrame = getInputStream()->getCurrFrame();
Pixel sPixelValue;
QFont font("Helvetica");
@@ -372,7 +379,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
for(Int j=vr.y() ; j<=vr.bottom() ; j++)
{
QPoint pixelTopLeft(i,j);
sPixelValue = curFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV );
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV );
QRect pixelRect(viewToWindow(pixelTopLeft), QSize(m_zoomFactor,m_zoomFactor));
if( sPixelValue.Luma < 128 )
@@ -605,7 +612,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
QPoint actualPos = windowToView( event->pos() );
QRect updateRect;
emit positionChanged( actualPos , getInputStream() );
emit positionChanged( actualPos , m_pcCurrFrame );
// If mouse left button pressed
if( event->buttons() == Qt::LeftButton && m_lastPos != QPoint( -1, -1 ) )
+4 -1
View File
@@ -33,6 +33,7 @@
#include "TypeDef.h"
#include "GridManager.h"
#include "PlaYUVerFrame.h"
namespace plaYUVer
{
@@ -55,6 +56,7 @@ public:
ViewArea( QWidget *parent = 0 );
void setImage( PlaYUVerFrame* pcFrame );
void setImage( const QPixmap &pixmap );
void setMode( ViewMode mode );
void setMaskColor( const QColor &color = QColor() );
@@ -108,7 +110,7 @@ public:
signals:
void selectionChanged( const QRect &rect );
void positionChanged( const QPoint &pos, InputStream *stream );
void positionChanged( const QPoint &pos, PlaYUVerFrame *frame );
void moveScroll( QPoint offset );
void zoomFactorChanged( double factor , QPoint center);
@@ -146,6 +148,7 @@ private:
QPoint viewToWindow( const QPoint& pt ) const;
QRect viewToWindow( const QRect& rc ) const;
PlaYUVerFrame *m_pcCurrFrame;
QPixmap m_pixmap;
QBitmap m_mask;
QRect m_selectedArea;
+33 -26
View File
@@ -147,10 +147,10 @@ Void plaYUVerApp::loadFile( QString fileName )
mdiArea->addSubWindow( interfaceChild );
statusBar()->showMessage( tr( "File loaded" ), 2000 );
interfaceChild->show();
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this,
SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) );
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this,
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
// connect( interfaceChild->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this,
// SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) );
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
interfaceChild->zoomToFit();
interfaceChild->getViewArea()->setTool( m_appTool );
@@ -229,7 +229,18 @@ void plaYUVerApp::selectModule( QAction *curr_action )
{
if( pcCurrMod->m_cModuleDef.m_bRequiresNewWindow )
{
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow();
mdiArea->addSubWindow( interfaceChild );
// connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this,
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
// connect( interfaceChild->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this,
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
m_pcCurrentSubWindow->setModuleSubWindow( interfaceChild );
m_pcCurrentSubWindow->enableModule( pcCurrMod );
interfaceChild->show();
interfaceChild->zoomToFit();
interfaceChild->getViewArea()->setTool( m_appTool );
}
else
{
@@ -541,47 +552,43 @@ void plaYUVerApp::about()
void plaYUVerApp::chageSubWindowSelection()
{
if( activeSubWindow() )
SubWindowHandle *new_window = activeSubWindow();
if( activeSubWindow() != m_pcCurrentSubWindow )
{
if( m_pcCurrentSubWindow )
if( activeSubWindow() )
{
m_pcCurrentSubWindow->disableModule();
if( m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow->disableModule();
}
m_pcCurrentSubWindow = new_window;
m_pcStreamProperties->setData( m_pcCurrentSubWindow->getInputStream() );
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );
updateCurrFrameNum();
updateTotalFrameNum();
updateStreamProperties();
updateFrameProperties();
}
// if( m_acPlayingSubWindows.size() < 2 )
// {
// playingTimer->stop();
// }
m_pcCurrentSubWindow = activeSubWindow();
m_pcStreamProperties->setData( m_pcCurrentSubWindow->getInputStream() );
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );
updateCurrFrameNum();
updateTotalFrameNum();
updateStreamProperties();
updateFrameProperties();
}
else
{
m_pcCurrentSubWindow = NULL;
m_pcCurrentSubWindow = new_window;
}
updateStreamProperties();
updateFrameProperties();
updateMenus();
createStatusBar();
}
// ----------------------- Status bar Functions -----------------------
void plaYUVerApp::updatePixelValueStatusBar( const QPoint & pos, InputStream* stream )
void plaYUVerApp::updatePixelValueStatusBar( const QPoint & pos, PlaYUVerFrame* frame )
{
Pixel sPixelValue;
Int iWidth, iHeight;
Int posX = pos.x(), posY = pos.y();
QString strPixel;
QString strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
PlaYUVerFrame *curFrame = stream->getCurrFrame();
PlaYUVerFrame *curFrame = frame;
iWidth = stream->getWidth();
iHeight = stream->getHeight();
iWidth = frame->getWidth();
iHeight = frame->getHeight();
if( ( posX < iWidth ) && ( posX >= 0 ) && ( posY < iHeight ) && ( posY >= 0 ) )
{
+1 -1
View File
@@ -97,7 +97,7 @@ private Q_SLOTS:
void setActiveSubWindow( QWidget *window );
void updatePixelValueStatusBar(const QPoint & pos, InputStream* stream);
void updatePixelValueStatusBar( const QPoint & pos, PlaYUVerFrame* frame );
void updatePropertiesSelectedArea( QRect area );