Change the behaviour of ViewArea to support the input of a PlaYUVerFrame
This commit is contained in:
1 parent
cb12f3710f
commit
9e666117b2
5 files changed
+57
-23
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include "ViewArea.h"
|
||||
#include "GridManager.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
#include "InputStream.h"
|
||||
|
||||
namespace plaYUVer
|
||||
@@ -69,6 +68,13 @@ ViewArea::ViewArea( QWidget *parent ) :
|
||||
m_pStream = NULL;
|
||||
}
|
||||
|
||||
void ViewArea::setImage( PlaYUVerFrame* pcFrame )
|
||||
{
|
||||
pcFrame->FrametoRGB8();
|
||||
QImage qimg = QImage( pcFrame->getQImageBuffer(), pcFrame->getWidth(), pcFrame->getHeight(), QImage::Format_RGB888 );
|
||||
setImage( QPixmap::fromImage( qimg ) );
|
||||
}
|
||||
|
||||
void ViewArea::setImage( const QPixmap &pixmap )
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
|
||||
@@ -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() );
|
||||
|
||||
@@ -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 &, InputStream *) ) );
|
||||
// connect( interfaceChild->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this,
|
||||
// SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) );
|
||||
m_pcCurrentSubWindow->setModuleSubWindow( interfaceChild );
|
||||
m_pcCurrentSubWindow->enableModule( pcCurrMod );
|
||||
interfaceChild->show();
|
||||
interfaceChild->zoomToFit();
|
||||
interfaceChild->getViewArea()->setTool( m_appTool );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user