Merge branch 'dev_modules_api' into jc-dev

This commit is contained in:
jfmcarreira committed 2014-04-24 03:36:58 +01:00
commit 38aed21a8a
7 files changed
+148 -103

No files matched your search

+2
View File
@@ -399,6 +399,8 @@ cv::Mat InputStream::getFrameCvMat()
Void InputStream::seekInput( UInt64 new_frame_num )
{
if( !m_pFile )
return;
if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum )
return;
#ifdef USE_FFMPEG
+54 -12
View File
@@ -25,6 +25,9 @@
#include <cstdio>
#include "ModulesHandle.h"
#include "SubWindowHandle.h"
// List of modules includes
#include "FilterFrame.h"
namespace plaYUVer
@@ -32,20 +35,22 @@ namespace plaYUVer
Void ModulesHandle::ModulesList( Bool bCreate )
{
// Register Modules
REGISTER_MODULE( FilterFrame );
}
ModulesHandle::ModulesHandle( QWidget * parent )
{
ModulesList( true );
m_pcParent = parent;
// configure class
setParent( parent );
setParent( m_pcParent );
m_uiModulesCount = 0;
m_uiModuleSelected= -1;
m_uiModuleSelected = -1;
m_bShowModulesNewWindow = false;
ModulesList( true );
}
ModulesHandle::~ModulesHandle()
@@ -63,16 +68,55 @@ void ModulesHandle::selectModule( int index )
m_uiModuleSelected = index;
}
PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf()
SubWindowHandle* ModulesHandle::toggleSelectedModuleIf( SubWindowHandle* pcSubWindow )
{
SubWindowHandle* interfaceChild = NULL;
PlaYUVerModuleIf* currModuleIf = NULL;
if( m_uiModuleSelected >= 0 )
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
m_uiModuleSelected = -1;
return currModuleIf;
if( currModuleIf->m_pcAction->isChecked() )
{
currModuleIf->m_pcDisplaySubWindow = NULL;
if( currModuleIf->m_cModuleDef.m_bRequiresNewWindow || m_bShowModulesNewWindow )
{
QString windowName;
interfaceChild = new SubWindowHandle( m_pcParent );
pcSubWindow->setModuleSubWindow( interfaceChild );
pcSubWindow->enableModule( currModuleIf );
windowName.append( pcSubWindow->userFriendlyCurrentFile() );
windowName.append( " - " );
windowName.append( currModuleIf->m_cModuleDef.m_pchModuleName );
interfaceChild->setWindowName( windowName );
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this,
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
currModuleIf->m_pcDisplaySubWindow = interfaceChild;
}
else
{
pcSubWindow->enableModule( currModuleIf );
}
currModuleIf->m_pcSubWindow = pcSubWindow;
}
else
{
currModuleIf->m_pcSubWindow->disableModule();
}
return interfaceChild;
}
Void ModulesHandle::destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf )
{
pcCurrModuleIf->m_pcAction->setChecked( false );
if( pcCurrModuleIf->m_pcDisplaySubWindow )
{
pcCurrModuleIf->m_pcDisplaySubWindow->close();
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
}
pcCurrModuleIf->m_pcSubWindow = NULL;
pcCurrModuleIf->destroy();
}
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
@@ -88,8 +132,6 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
//m_arrayModulesActions.resize( m_uiModulesCount );
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
{
currModuleIf = m_pcPlaYUVerModules.at( i );
+10 -3
View File
@@ -42,18 +42,24 @@
namespace plaYUVer
{
class ModulesHandle : public QObject
class SubWindowHandle;
class ModulesHandle: public QObject
{
Q_OBJECT
Q_OBJECT
public:
ModulesHandle( QWidget * parent = 0 );
~ModulesHandle();
QMenu* createMenus( QMenuBar *MainAppMenuBar );
Void updateMenus( Bool hasSubWindow );
PlaYUVerModuleIf* getSelectedModuleIf();
SubWindowHandle* toggleSelectedModuleIf( SubWindowHandle* pcSubWindow );
static Void destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf );
private:
QWidget *m_pcParent;
Bool m_bShowModulesNewWindow;
UInt m_uiModulesCount;
Int m_uiModuleSelected;
QMenu* m_pcModulesMenu;
@@ -64,6 +70,7 @@ private:
Void appendModule( PlaYUVerModuleIf* );
Void ModulesList( Bool bCreate );
private Q_SLOTS:
void selectModule( int index );
};
+7 -2
View File
@@ -73,9 +73,16 @@ typedef struct __PlaYUVerModuleDefinition
bool m_bRequiresNewWindow;
}PlaYUVerModuleDefinition;
class SubWindowHandle;
class PlaYUVerModuleIf
{
friend class ModulesHandle;
private:
QAction* m_pcAction;
SubWindowHandle* m_pcSubWindow;
SubWindowHandle* m_pcDisplaySubWindow;
public:
PlaYUVerModuleIf()
{
@@ -85,8 +92,6 @@ public:
{
}
QAction* m_pcAction;
PlaYUVerModuleDefinition m_cModuleDef;
virtual Void create() {};
+20 -19
View File
@@ -52,8 +52,9 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
m_cScrollArea->setWidget( m_cViewArea );
m_cScrollArea->setWidgetResizable( true );
m_pCurrStream = NULL;
m_pCurrStream = new InputStream;
m_pcCurrFrame = NULL;
m_pcCurrentModule = NULL;
m_pcModuleSubWindow = NULL;
@@ -64,15 +65,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
SubWindowHandle::~SubWindowHandle()
{
disableModule();
delete m_cViewArea;
delete m_cScrollArea;
delete m_pCurrStream;
if( m_pcCurrentModule )
{
m_pcCurrentModule->m_pcAction->setChecked( false );
m_pcCurrentModule->destroy();
m_pcCurrentModule = NULL;
}
if( m_pCurrStream )
delete m_pCurrStream;
}
Bool SubWindowHandle::loadFile( const QString &fileName )
@@ -80,6 +77,9 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
UInt Width = 0, Height = 0, FrameRate = 30;
Int InputFormat = -1;
if( !m_pCurrStream )
m_pCurrStream = new InputStream;
m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate );
if( m_pCurrStream->guessFormat( fileName, Width, Height, InputFormat, FrameRate ) )
@@ -102,7 +102,6 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
QApplication::restoreOverrideCursor();
refreshFrame();
//normalSize();
m_cCurrFileName = fileName;
m_cWindowName = m_pCurrStream->getStreamInformationString();
@@ -116,11 +115,6 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
*/
Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module )
{
if( m_pcCurrentModule == select_module )
{
disableModule();
return;
}
m_pcCurrentModule = select_module;
m_pcCurrentModule->create( m_pCurrStream->getCurrFrame() );
refreshFrame();
@@ -130,10 +124,9 @@ Void SubWindowHandle::disableModule()
{
if( !m_pcCurrentModule )
return;
m_pcCurrentModule->m_pcAction->setCheckable( false );
m_pcCurrentModule->destroy();
ModulesHandle::destroyModuleIf( m_pcCurrentModule );
m_pcCurrentModule = NULL;
m_pcModuleSubWindow = NULL;
refreshFrame();
}
@@ -268,7 +261,11 @@ Void SubWindowHandle::scaleView( Int width, Int height )
Void SubWindowHandle::scaleView( const QSize & size )
{
QSize imgViewSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
QSize imgViewSize;
if( m_pcCurrFrame )
imgViewSize = QSize( m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight() );
else
imgViewSize = QSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
@@ -361,7 +358,11 @@ QSize SubWindowHandle::sizeHint() const
maxSize = p->size();
}
QSize isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
QSize isize;
if( m_pcCurrFrame )
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
else
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.
+12 -1
View File
@@ -36,7 +36,7 @@
#include "TypeDef.h"
#include "InputStream.h"
#include "ViewArea.h"
#include "PlaYUVerModuleIf.h"
#include "ModulesHandle.h"
namespace plaYUVer
{
@@ -94,6 +94,11 @@ public:
return m_pCurrStream;
}
PlaYUVerFrame* getCurrFrame()
{
return m_pcCurrFrame;
}
ViewArea* getViewArea()
{
return m_cViewArea;
@@ -146,6 +151,12 @@ public:
QSize sizeHint() const;
Void setWindowName( QString name )
{
m_cWindowName = name;
setWindowTitle( m_cWindowName );
}
QString userFriendlyCurrentFile()
{
return m_cWindowName;
+43 -66
View File
@@ -49,7 +49,6 @@ plaYUVerApp::plaYUVerApp()
//mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( chageSubWindowSelection() ) );
//connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateMenus() ) );
mapperWindow = new QSignalMapper( this );
connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
@@ -221,32 +220,13 @@ void plaYUVerApp::closeAll()
void plaYUVerApp::selectModule( QAction *curr_action )
{
//emit curr_action->triggered();
if( m_pcCurrentSubWindow )
SubWindowHandle *interfaceChild = m_pcModulesHandle->toggleSelectedModuleIf( m_pcCurrentSubWindow );
if( interfaceChild )
{
PlaYUVerModuleIf* pcCurrMod = m_pcModulesHandle->getSelectedModuleIf();
if( pcCurrMod )
{
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
{
m_pcCurrentSubWindow->enableModule( pcCurrMod );
}
}
mdiArea->addSubWindow( interfaceChild );
interfaceChild->show();
interfaceChild->zoomToFit();
interfaceChild->getViewArea()->setTool( m_appTool );
}
return;
}
@@ -269,7 +249,7 @@ Void plaYUVerApp::updateFrameProperties()
{
if( m_pcCurrentSubWindow )
{
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getCurrFrame() );
//m_pcFrameProperties->setSelection( m_pcCurrentSubWindow->getViewArea()->selectedArea() );
}
else
@@ -319,47 +299,51 @@ Void plaYUVerApp::setTimerStatus()
void plaYUVerApp::play()
{
if( m_pcCurrentSubWindow )
if( !m_pcCurrentSubWindow )
return;
if( !m_pcCurrentSubWindow->getInputStream() )
return;
if( actionVideoLock->isChecked() && m_acPlayingSubWindows.size() )
{
if( actionVideoLock->isChecked() && m_acPlayingSubWindows.size() )
Bool bFind = false;
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
Bool bFind = false;
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
if( m_acPlayingSubWindows.at( i ) == m_pcCurrentSubWindow )
{
if( m_acPlayingSubWindows.at( i ) == m_pcCurrentSubWindow )
{
bFind = true;
break;
}
}
if( !bFind )
{
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
m_pcCurrentSubWindow->play();
m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )m_pcCurrentSubWindow->getInputStream()->getFrameNum() - 1 ) );
bFind = true;
break;
}
}
else
if( !bFind )
{
playingTimer->stop();
m_acPlayingSubWindows.clear();
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
m_pcCurrentSubWindow->play();
m_uiAveragePlayInterval = 0;
m_bIsPlaying = false;
}
if( !m_bIsPlaying )
{
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
qDebug( ) << "Desired frame rate: "
<< QString::number( 1000 / timeInterval )
<< " fps";
playingTimer->start( timeInterval );
m_cTimer.start();
m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )m_pcCurrentSubWindow->getInputStream()->getFrameNum() - 1 ) );
}
}
else
{
playingTimer->stop();
m_acPlayingSubWindows.clear();
m_acPlayingSubWindows.append( m_pcCurrentSubWindow );
m_pcCurrentSubWindow->play();
m_uiAveragePlayInterval = 0;
m_bIsPlaying = false;
}
if( !m_bIsPlaying )
{
UInt frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
qDebug( ) << "Desired frame rate: "
<< QString::number( 1000 / timeInterval )
<< " fps";
playingTimer->start( timeInterval );
m_cTimer.start();
}
}
void plaYUVerApp::pause()
@@ -475,7 +459,6 @@ void plaYUVerApp::seekEvent( int direction )
else
{
m_pcCurrentSubWindow->seekRelativeEvent( direction > 0 ? true : false );
}
updateFrameProperties();
updateCurrFrameNum();
@@ -555,15 +538,9 @@ void plaYUVerApp::chageSubWindowSelection()
SubWindowHandle *new_window = activeSubWindow();
if( activeSubWindow() != m_pcCurrentSubWindow )
{
if( activeSubWindow() )
if( activeSubWindow() )
{
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();