Improve Modules Interface

Now the modules are created using a factory instead of static allocated.
  The same module can be applied to different sequences.
  Pain in the ass memory free
This commit is contained in:
jfmcarreira committed 2014-12-27 21:52:56 +00:00
1 parent bec150f705
commit 73bf370e6e
18 files changed
+432 -210

No files matched your search

+214 -157
View File
@@ -27,6 +27,7 @@
#include "ModulesHandle.h"
#include "ModulesListHeader.h"
#include "ModulesListMacro.h"
#include "PlaYUVerModuleFactory.h"
#include "DialogSubWindowSelector.h"
#include "SubWindowHandle.h"
#include "VideoSubWindow.h"
@@ -35,55 +36,179 @@ namespace plaYUVer
{
ModulesHandle::ModulesHandle( QMainWindow * parent, QMdiArea *mdiArea ) :
QObject( parent ),
QWidget( parent ),
m_pcParent( parent ),
m_pcMdiArea( mdiArea ),
m_uiModulesCount( 0 ),
m_iOptionSelected( INVALID_OPT )
{
// configure class
setParent( m_pcParent );
// Register Modules
REGISTER_ALL_MODULES
}
ModulesHandle::~ModulesHandle()
{
}
Void ModulesHandle::appendModule( PlaYUVerModuleIf* pModuleIf )
Void ModulesHandle::createActions()
{
m_pcPlaYUVerModulesIf.append( pModuleIf );
PlaYUVerAppModuleIf* pcAppModuleIf = new PlaYUVerAppModuleIf;
pcAppModuleIf->m_pcModule = pModuleIf;
pcAppModuleIf->setParent( this );
m_pcPlaYUVerModules.append( pcAppModuleIf );
m_uiModulesCount++;
m_arrayActions.resize( MODULES_TOTAL_ACT );
m_pcActionMapper = new QSignalMapper( this );
connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( processOpt(int) ) );
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip( "Show module result in a new window. Some modules already force this feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while playing", parent() );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module refreshing while playing" );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
connect( m_arrayActions[APPLY_ALL_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[APPLY_ALL_ACT], APPLY_ALL_OPT );
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_OPT );
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
}
Void ModulesHandle::selectModule( Int index )
QMenu* ModulesHandle::createMenu()
{
m_iOptionSelected = index;
}
PlaYUVerModuleIf* pcCurrModuleIf;
QString ModuleIfInternalName;
QAction* currAction;
QMenu* currSubMenu;
SubWindowHandle* ModulesHandle::processModuleHandlingOpt()
{
if( m_iOptionSelected >= 0 )
m_pcModulesMenu = new QMenu( "&Modules", this );
m_pcModulesActionMapper = new QSignalMapper( this );
connect( m_pcModulesActionMapper, SIGNAL( mapped(int) ), this, SLOT( activateModule(int) ) );
UInt i = 0;
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
for( ; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ )
{
PlaYUVerAppModuleIf* pcCurrModuleIf = m_pcPlaYUVerModules.at( m_iOptionSelected );
m_iOptionSelected = INVALID_OPT;
if( pcCurrModuleIf->m_pcAction->isChecked() )
pcCurrModuleIf = it->second();
ModuleIfInternalName = QString::fromLocal8Bit( it->first );
currSubMenu = NULL;
if( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory )
{
return enableModuleIf( pcCurrModuleIf );
for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ )
{
if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory ) )
{
currSubMenu = m_pcModulesSubMenuList.at( j );
break;
}
}
if( !currSubMenu )
{
currSubMenu = m_pcModulesMenu->addMenu( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory );
m_pcModulesSubMenuList.append( currSubMenu );
}
}
currAction = new QAction( pcCurrModuleIf->m_cModuleDef.m_pchModuleName, parent() );
currAction->setStatusTip( pcCurrModuleIf->m_cModuleDef.m_pchModuleTooltip );
currAction->setData( ModuleIfInternalName );
currAction->setCheckable( true );
connect( currAction, SIGNAL( triggered() ), this, SLOT( activateModule() ) );
//connect( currAction, SIGNAL( triggered() ), m_pcModulesActionMapper, SLOT( map() ) );
m_pcModulesActionMapper->setMapping( currAction, i );
m_arrayModulesActions.append( currAction );
if( currSubMenu )
currSubMenu->addAction( currAction );
else
m_pcModulesMenu->addAction( currAction );
}
// for( Int i = 0; i < m_pcPlaYUVerModulesIf.size(); i++ )
// {
// pcCurrModuleIf = m_pcPlaYUVerModulesIf.at( i );
//
// currSubMenu = NULL;
// if( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory )
// {
// for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ )
// {
// if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory ) )
// {
// currSubMenu = m_pcModulesSubMenuList.at( j );
// break;
// }
// }
// if( !currSubMenu )
// {
// currSubMenu = m_pcModulesMenu->addMenu( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory );
// m_pcModulesSubMenuList.append( currSubMenu );
// }
// }
//
// currAction = new QAction( pcCurrModuleIf->m_cModuleDef.m_pchModuleName, parent() );
// currAction->setStatusTip( pcCurrModuleIf->m_cModuleDef.m_pchModuleTooltip );
// currAction->setCheckable( true );
// connect( currAction, SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
// m_pcActionMapper->setMapping( currAction, i );
// m_arrayModulesActions.append( currAction );
//
// if( currSubMenu )
// currSubMenu->addAction( currAction );
// else
// m_pcModulesMenu->addAction( currAction );
//
// m_pcPlaYUVerModules.at( i )->m_pcAction = currAction;
// }
m_pcModulesMenu->addSeparator();
m_pcModulesMenu->addAction( m_arrayActions[APPLY_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[SWAP_FRAMES_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[DISABLE_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] );
return m_pcModulesMenu;
}
Void ModulesHandle::updateMenus()
{
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow *>( m_pcMdiArea->activeSubWindow() );
Bool hasSubWindow = pcSubWindow ? true : false;
QAction* currModuleAction;
for( Int i = 0; i < m_arrayModulesActions.size(); i++ )
{
currModuleAction = m_arrayModulesActions.at( i );
currModuleAction->setEnabled( hasSubWindow );
currModuleAction->setChecked( false );
}
for( Int i = 0; i < m_arrayActions.size(); i++ )
{
m_arrayActions.at( i )->setEnabled( hasSubWindow );
}
if( pcSubWindow )
{
if( pcSubWindow->getModule() )
{
destroyModuleIf( pcCurrModuleIf );
currModuleAction = pcSubWindow->getModule()->m_pcModuleAction;
currModuleAction->setChecked( true );
}
}
else
}
Void ModulesHandle::processOpt( Int index )
{
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow *>( m_pcMdiArea->activeSubWindow() );
if( pcSubWindow )
{
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow *>( m_pcMdiArea->activeSubWindow() );
switch( m_iOptionSelected )
{
case INVALID_OPT:
@@ -99,11 +224,34 @@ SubWindowHandle* ModulesHandle::processModuleHandlingOpt()
Q_ASSERT( 0 );
}
}
m_iOptionSelected = INVALID_OPT;
return NULL;
}
SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
Void ModulesHandle::activateModule()
{
QAction *pcAction = qobject_cast<QAction *>( sender() );
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow *>( m_pcMdiArea->activeSubWindow() );
if( pcVideoSubWindow )
{
if( pcAction->isChecked() )
{
QString ModuleIfName = pcAction->data().toString();
PlaYUVerModuleIf* pcCurrModuleIf = PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
PlaYUVerAppModuleIf* pcCurrAppModuleIf = new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf );
enableModuleIf( pcCurrAppModuleIf );
m_pcPlaYUVerAppModuleIfList.append( pcCurrAppModuleIf );
}
else
{
pcVideoSubWindow->disableModule();
}
m_iOptionSelected = INVALID_OPT;
}
}
Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
{
Bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked();
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow *>( m_pcMdiArea->activeSubWindow() );
@@ -136,7 +284,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul
// Check for same fmt in more than one frame modules
for( Int i = 1; i < subWindowList.size(); i++ )
{
if( !subWindowList.at( i )->getCurrFrame()->haveSameFmt( subWindowList.at( 0 )->getCurrFrame()) )
if( !subWindowList.at( i )->getCurrFrame()->haveSameFmt( subWindowList.at( 0 )->getCurrFrame() ) )
{
subWindowList.clear();
break;
@@ -151,9 +299,9 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul
if( subWindowList.size() == 0 )
{
pcCurrModuleIf->m_pcAction->setChecked( false );
m_pcParent->statusBar()->showMessage( "Error! Module cannot be applied", 2000 );
return NULL;
destroyModuleIf( pcCurrModuleIf );
return;
}
windowName.append( " <" );
@@ -168,22 +316,19 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
VideoSubWindow* interfaceChild = NULL;
if( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_iModuleType == FRAME_PROCESSING_MODULE )
{
if( ( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
{
interfaceChild = new VideoSubWindow( m_pcParent, true );
VideoSubWindow* interfaceChild = new VideoSubWindow( m_pcParent, true );
interfaceChild->setWindowName( windowName );
// connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent,
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
connect( interfaceChild, SIGNAL( updateStatusBar( const QString& ) ), m_pcParent, SLOT( updateStatusBar( const QString& ) ) );
connect( interfaceChild, SIGNAL( zoomChanged() ), m_pcParent, SLOT( updateZoomFactorSBox() ) );
pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild;
pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf );
m_pcMdiArea->addSubWindow( interfaceChild );
}
}
else if( pcCurrModuleIf->m_pcModule->m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE )
@@ -212,48 +357,51 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModul
}
applyModuleIf( pcCurrModuleIf, false );
return interfaceChild;
return;
}
Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
{
if( pcCurrModuleIf->m_pcModuleDock )
if( pcCurrModuleIf )
{
pcCurrModuleIf->m_pcModuleDock->close();
pcCurrModuleIf->m_pcModuleDock = NULL;
}
if( pcCurrModuleIf->m_pcDockWidget )
{
pcCurrModuleIf->m_pcDockWidget->close();
pcCurrModuleIf->m_pcDockWidget = NULL;
}
if( pcCurrModuleIf->m_pcDisplaySubWindow )
pcCurrModuleIf->m_pcDisplaySubWindow->close();
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
for( Int i = 0; i < MAX_NUMBER_FRAMES; i++ )
{
if( pcCurrModuleIf->m_pcSubWindow[i] )
if( pcCurrModuleIf->m_pcModuleDock )
{
pcCurrModuleIf->m_pcSubWindow[i]->disableModule();
pcCurrModuleIf->m_pcSubWindow[i] = NULL;
pcCurrModuleIf->m_pcModuleDock->close();
pcCurrModuleIf->m_pcModuleDock = NULL;
}
if( pcCurrModuleIf->m_pcDockWidget )
{
pcCurrModuleIf->m_pcDockWidget->close();
pcCurrModuleIf->m_pcDockWidget = NULL;
}
if( pcCurrModuleIf->m_pcDisplaySubWindow )
pcCurrModuleIf->m_pcDisplaySubWindow->close();
pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
for( Int i = 0; i < MAX_NUMBER_FRAMES; i++ )
{
if( pcCurrModuleIf->m_pcSubWindow[i] )
{
pcCurrModuleIf->m_pcSubWindow[i]->disableModule();
pcCurrModuleIf->m_pcSubWindow[i] = NULL;
}
}
if( pcCurrModuleIf->m_pcModuleStream )
{
pcCurrModuleIf->m_pcModuleStream->close();
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
}
pcCurrModuleIf->m_pcModule->destroy();
//pcCurrModuleIf->m_pcModule->Delete();
}
if( pcCurrModuleIf->m_pcModuleStream )
{
pcCurrModuleIf->m_pcModuleStream->close();
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
}
pcCurrModuleIf->m_pcAction->setChecked( false );
pcCurrModuleIf->m_pcModule->destroy();
}
Void ModulesHandle::destroyAllModulesIf()
{
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
for( Int i = 0; i < m_pcPlaYUVerAppModuleIfList.size(); i++ )
{
destroyModuleIf( m_pcPlaYUVerModules.at( i ) );
destroyModuleIf( m_pcPlaYUVerAppModuleIfList.at( i ) );
}
}
@@ -264,10 +412,10 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isP
{
#ifdef PLAYUVER_THREADED_MODULES
if( !disableThreads )
pcCurrModuleIf->start();
pcCurrModuleIf->start();
else
#endif
pcCurrModuleIf->run();
pcCurrModuleIf->run();
if( pcCurrModuleIf->m_pcDisplaySubWindow || pcCurrModuleIf->m_pcModule->m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE )
{
@@ -421,96 +569,5 @@ Void ModulesHandle::customEvent( QEvent *event )
}
}
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
{
PlaYUVerModuleIf* pcCurrModuleIf;
QAction* currAction;
QMenu* currSubMenu;
m_arrayActions.resize( MODULES_TOTAL_ACT );
m_pcActionMapper = new QSignalMapper( this );
connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) );
m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" );
for( Int i = 0; i < m_pcPlaYUVerModulesIf.size(); i++ )
{
pcCurrModuleIf = m_pcPlaYUVerModulesIf.at( i );
currSubMenu = NULL;
if( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory )
{
for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ )
{
if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory ) )
{
currSubMenu = m_pcModulesSubMenuList.at( j );
break;
}
}
if( !currSubMenu )
{
currSubMenu = m_pcModulesMenu->addMenu( pcCurrModuleIf->m_cModuleDef.m_pchModuleCategory );
m_pcModulesSubMenuList.append( currSubMenu );
}
}
currAction = new QAction( pcCurrModuleIf->m_cModuleDef.m_pchModuleName, parent() );
currAction->setStatusTip( pcCurrModuleIf->m_cModuleDef.m_pchModuleTooltip );
currAction->setCheckable( true );
connect( currAction, SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( currAction, i );
m_arrayModulesActions.append( currAction );
if( currSubMenu )
currSubMenu->addAction( currAction );
else
m_pcModulesMenu->addAction( currAction );
m_pcPlaYUVerModules.at( i )->m_pcAction = currAction;
}
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip( "Show module result in a new window. Some modules already force this feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while playing", parent() );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module refreshing while playing" );
m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
connect( m_arrayActions[APPLY_ALL_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[APPLY_ALL_ACT], APPLY_ALL_OPT );
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_OPT );
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
m_pcModulesMenu->addSeparator();
m_pcModulesMenu->addAction( m_arrayActions[APPLY_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[SWAP_FRAMES_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[DISABLE_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] );
return m_pcModulesMenu;
}
Void ModulesHandle::updateMenus( Bool hasSubWindow )
{
QAction* currModuleAction;
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
{
currModuleAction = m_arrayModulesActions.at( i );
currModuleAction->setEnabled( hasSubWindow );
}
m_arrayActions[APPLY_ALL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( hasSubWindow );
}
} // NAMESPACE
+16 -9
View File
@@ -45,17 +45,21 @@ namespace plaYUVer
class PlaYUVerAppModuleIf;
class SubWindowHandle;
class ModulesHandle: public QObject
class ModulesHandle: public QWidget
{
Q_OBJECT
public:
ModulesHandle( QMainWindow* parent = 0, QMdiArea *mdiArea = 0 );
~ModulesHandle();
QMenu* createMenus( QMenuBar* MainAppMenuBar );
Void updateMenus( Bool hasSubWindow );
Void createActions();
QMenu* createMenu();
//QDockWidget* createDock();
Void updateMenus( );
SubWindowHandle* processModuleHandlingOpt();
static Void destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
static Bool applyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf, Bool isPlaying, Bool disableThreads = false );
static Void swapModulesWindowsIf( PlaYUVerAppModuleIf *pcCurrModuleIf );
@@ -66,6 +70,7 @@ public:
private:
QMainWindow *m_pcParent;
QMdiArea *m_pcMdiArea;
UInt m_uiModulesCount;
Int m_iOptionSelected;
@@ -78,10 +83,11 @@ private:
QMenu* m_pcModulesMenu;
QList<QMenu*> m_pcModulesSubMenuList;
QList<PlaYUVerModuleIf*> m_pcPlaYUVerModulesIf;
QList<PlaYUVerAppModuleIf*> m_pcPlaYUVerModules;
QSignalMapper* m_pcActionMapper;
QList<PlaYUVerModuleIf*> m_pcPlaYUVerModulesIfList;
QList<PlaYUVerAppModuleIf*> m_pcPlaYUVerAppModuleIfList;
QVector<QAction*> m_arrayModulesActions;
QSignalMapper* m_pcModulesActionMapper;
enum MODULES_ACTION_LIST
{
@@ -93,15 +99,16 @@ private:
MODULES_TOTAL_ACT
};
QVector<QAction*> m_arrayActions;
QSignalMapper* m_pcActionMapper;
Void appendModule( PlaYUVerModuleIf* pModuleIf );
SubWindowHandle* enableModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
Void enableModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf );
Void openModuleIfStream( PlaYUVerAppModuleIf *pcCurrModuleIf );
Void customEvent( QEvent *event );
private Q_SLOTS:
void selectModule( int index );
void activateModule();
void processOpt( int index );
void destroyAllModulesIf();
};
+4 -2
View File
@@ -28,8 +28,9 @@
namespace plaYUVer
{
PlaYUVerAppModuleIf::PlaYUVerAppModuleIf() :
m_pcAction( NULL ),
PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ) :
m_pcModuleAction( action ),
m_pcModule( module ),
m_pcDisplaySubWindow( NULL ),
m_pcDockWidget( NULL ),
m_pcModuleDock( NULL ),
@@ -37,6 +38,7 @@ PlaYUVerAppModuleIf::PlaYUVerAppModuleIf() :
m_pcProcessedFrame( NULL ),
m_dMeasurementResult( 0 )
{
setParent( parent );
for( Int i = 0; i < MAX_NUMBER_FRAMES; i++ )
{
m_pcSubWindow[i] = NULL;
+3 -2
View File
@@ -53,9 +53,10 @@ class PlaYUVerAppModuleIf
private:
QAction* m_pcModuleAction;
PlaYUVerModuleIf* m_pcModule;
QAction* m_pcAction;
VideoSubWindow* m_pcSubWindow[MAX_NUMBER_FRAMES];
VideoSubWindow* m_pcDisplaySubWindow;
@@ -82,7 +83,7 @@ public:
PlaYUVerAppModuleIf* m_pcModule;
};
PlaYUVerAppModuleIf();
PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
virtual ~PlaYUVerAppModuleIf() {}
protected:
+7 -24
View File
@@ -55,9 +55,8 @@ plaYUVerApp::plaYUVerApp()
mapperWindow = new QSignalMapper( this );
connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
m_pcModulesHandle = new ModulesHandle( this, mdiArea );
m_appModuleQuality = new QualityMeasurement( this, mdiArea );
m_appModuleExtensions = new ModulesHandle( this, mdiArea );
createActions();
createToolBars();
@@ -412,24 +411,6 @@ Void plaYUVerApp::closeAll()
mdiArea->closeAllSubWindows();
}
// ----------------------- Modules Selection --------------------
Void plaYUVerApp::ModuleHandling( QAction *curr_action )
{
m_pcFrameProperties->stopHistogram();
SubWindowHandle *interfaceChild = m_pcModulesHandle->processModuleHandlingOpt();
if( interfaceChild )
{
mdiArea->addSubWindow( interfaceChild );
//interfaceChild->getViewArea()->setTool( m_appTool );
}
if( activeSubWindow() )
m_pcCurrentSubWindow = activeSubWindow();
updateStreamProperties();
return;
}
// ----------------------- Update Properties --------------------
UInt64 plaYUVerApp::getMaxFrameNumber()
@@ -956,7 +937,8 @@ Void plaYUVerApp::updateMenus()
m_arrayActions[NAVIGATION_TOOL_ACT]->setEnabled( hasSubWindow );
m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
m_pcModulesHandle->updateMenus( hasSubWindow );
m_appModuleQuality->updateMenus();
m_appModuleExtensions->updateMenus();
}
Void plaYUVerApp::updateWindowMenu()
@@ -1189,6 +1171,7 @@ Void plaYUVerApp::createActions()
m_mapperTools->setMapping( m_arrayActions[SELECTION_TOOL_ACT], ViewArea::NormalSelectionTool );
m_appModuleQuality->createActions();
m_appModuleExtensions->createActions();
// ------------ Window ------------
@@ -1292,9 +1275,9 @@ Void plaYUVerApp::createMenus()
QMenu* QualityMenu = m_appModuleQuality->createMenu();
menuBar()->addMenu( QualityMenu );
QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() );
connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( ModuleHandling(QAction *) ) );
QMenu* ModuleMenu = m_appModuleExtensions->createMenu();
menuBar()->addMenu( ModuleMenu );
//connect( ModuleMenu, SIGNAL( triggered(QAction *) ), this, SLOT( ModuleHandling(QAction *) ) );
m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) );
updateWindowMenu();
+2 -4
View File
@@ -88,8 +88,6 @@ private Q_SLOTS:
void videoSelectionButtonEvent();
void ModuleHandling( QAction * );
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 120 scale the image up by 20% and
@@ -156,8 +154,6 @@ private:
SubWindowHandle* m_pcCurrentSubWindow; //!< General always set
VideoSubWindow* m_pcCurrentVideoSubWindow;
ModulesHandle *m_pcModulesHandle;
QString m_cLastOpenPath;
QTimer *m_pcPlayingTimer;
Bool m_bIsPlaying;
@@ -214,6 +210,8 @@ private:
* Modules
*/
QualityMeasurement* m_appModuleQuality;
ModulesHandle *m_appModuleExtensions;
/**
* Array of menus for the main app
+1 -1
View File
@@ -2,7 +2,7 @@
### CMakeLists for playuver lib component
###
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
set(plaYUver_Lib_SRCS
# Frame
+16 -8
View File
@@ -29,17 +29,25 @@ namespace plaYUVer
static PlaYUVerModuleDefinition AbsoluteFrameDifferenceDef =
{
FRAME_PROCESSING_MODULE,
"Measurements",
"AbsoluteFrameDifference",
"Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )",
MODULE_REQUIRES_TWO_FRAMES,
MODULE_REQUIRES_NEW_WINDOW,
APPLY_WHILE_PLAYING,
};
FRAME_PROCESSING_MODULE,
"Measurements",
"AbsoluteFrameDifference",
"Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )",
MODULE_REQUIRES_TWO_FRAMES,
MODULE_REQUIRES_NEW_WINDOW,
APPLY_WHILE_PLAYING, };
AbsoluteFrameDifference::AbsoluteFrameDifference()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Measurements";
m_pchModuleName = "AbsoluteFrameDifference";
m_pchModuleTooltip = "Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )";
m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW;
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING;
m_pcFrameDifference = NULL;
setModuleDefinition( AbsoluteFrameDifferenceDef );
}
+2
View File
@@ -34,6 +34,8 @@ namespace plaYUVer
class AbsoluteFrameDifference: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( AbsoluteFrameDifference )
private:
PlaYUVerFrame* m_pcFrameDifference;
+5 -1
View File
@@ -2,7 +2,11 @@
### CMakeLists for playuver modules component
###
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
set(plaYUver_Mod_SRCS
PlaYUVerModuleFactory.cpp
)
MACRO(ADD_MODULE name file )
set(__modulename "Module${name}")
+2
View File
@@ -36,6 +36,8 @@ namespace plaYUVer
class DisparityStereoVar: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( DisparityStereoVar )
private:
PlaYUVerFrame* m_pcDisparityFrame;
cv::StereoVar m_cStereoVar;
+3
View File
@@ -46,6 +46,7 @@ public:
class FilterComponentLuma: public FilterComponent, public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FilterComponentLuma )
public:
FilterComponentLuma();
virtual ~FilterComponentLuma()
@@ -57,6 +58,7 @@ public:
class FilterComponentChromaU: public FilterComponent, public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FilterComponentChromaU )
public:
FilterComponentChromaU();
virtual ~FilterComponentChromaU()
@@ -68,6 +70,7 @@ public:
class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FilterComponentChromaV )
public:
FilterComponentChromaV();
virtual ~FilterComponentChromaV()
+9
View File
@@ -41,6 +41,15 @@ static PlaYUVerModuleDefinition FrameDifferenceDef =
FrameDifference::FrameDifference()
{
/* Module Definition */
m_iModuleType = FRAME_PROCESSING_MODULE;
m_pchModuleCategory = "Measurements";
m_pchModuleName = "FrameDifference";
m_pchModuleTooltip = "Measure the difference between two images (Y plane), Y1 - Y2, with max absolute diff of 128";
m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW;
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
m_bApplyWhilePlaying = APPLY_WHILE_PLAYING;
m_pcFrameDifference = NULL;
setModuleDefinition( FrameDifferenceDef );
}
+2
View File
@@ -34,6 +34,8 @@ namespace plaYUVer
class FrameDifference: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( FrameDifference )
private:
PlaYUVerFrame* m_pcFrameDifference;
+2
View File
@@ -32,6 +32,8 @@ namespace plaYUVer
class MeasurePSNR: public PlaYUVerModuleIf
{
REGISTER_CLASS_FACTORY( MeasurePSNR )
private:
public:
MeasurePSNR();
+67
View File
@@ -0,0 +1,67 @@
/* 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 PlaYUVerModuleFactory.cpp
* \brief PlaYUVer modules factory
*/
#include <functional>
#include <cstring>
#include "PlaYUVerModuleFactory.h"
#include "ModulesListHeader.h"
#include "ModulesListMacro.h"
namespace plaYUVer
{
PlaYUVerModuleFactory::PlaYUVerModuleFactory()
{
Register( "FilterComponentLuma", &FilterComponentLuma::Create );
Register( "FilterComponentChromaU", &FilterComponentChromaU::Create );
Register( "FilterComponentChromaV", &FilterComponentChromaV::Create );
Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create );
Register( "FrameDifference", &FrameDifference::Create );
}
PlaYUVerModuleFactory::~PlaYUVerModuleFactory()
{
m_FactoryMap.clear();
}
Void PlaYUVerModuleFactory::Register( const char* moduleName, CreateModuleFn pfnCreate )
{
m_FactoryMap[moduleName] = pfnCreate;
}
PlaYUVerModuleIf *PlaYUVerModuleFactory::CreateModule( const char* moduleName )
{
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
for( ; it != PlaYUVerModuleFactoryMap.end(); ++it)
{
if( !strcmp( it->first, moduleName ) )
{
return it->second();
}
}
return NULL;
}
} // NAMESPACE
+67
View File
@@ -0,0 +1,67 @@
/* 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 PlaYUVerModuleFactory.h
* \brief PlaYUVer modules factory
*/
#ifndef __PLAYUVERMODULESFACTORY_H__
#define __PLAYUVERMODULESFACTORY_H__
#include <functional>
#include "PlaYUVerModuleIf.h"
namespace plaYUVer
{
typedef PlaYUVerModuleIf* (*CreateModuleFn)( void );
typedef std::map<const char *, CreateModuleFn> PlaYUVerModuleFactoryMap;
// Factory for creating instances of IAnimal
class PlaYUVerModuleFactory
{
private:
PlaYUVerModuleFactory();
PlaYUVerModuleFactory &operator=( const PlaYUVerModuleFactory & ) { return *this; }
PlaYUVerModuleFactoryMap m_FactoryMap;
public:
~PlaYUVerModuleFactory();
static PlaYUVerModuleFactory *Get()
{
static PlaYUVerModuleFactory instance;
return &instance;
}
Void Register( const char* moduleName, CreateModuleFn pfnCreate );
PlaYUVerModuleIf *CreateModule( const char *animalName );
PlaYUVerModuleFactoryMap& getMap(){ return m_FactoryMap; }
};
//// typedef to make it easier to set up our factory
//typedef PlaYUVerModuleIf *PlaYUVerModuleMaker();
//// our global factory
//extern std::map<std::string, PlaYUVerModuleMaker *, std::less<std::string> > PlaYUVerModuleFactory;
}// NAMESPACE
#endif // __PLAYUVERMODULESFACTORY_H__
+10 -2
View File
@@ -32,10 +32,16 @@
namespace plaYUVer
{
#define REGISTER_CLASS_FACTORY(X) \
public: \
static PlaYUVerModuleIf* Create() { return new X(); } \
void Delete() { delete this; }
#define REGISTER_MODULE(X) \
{ \
X *pMod = new X(); \
appendModule( pMod ); \
X *pMod = new X(); \
appendModule( pMod ); \
}
enum // Module type
@@ -90,6 +96,8 @@ public:
PlaYUVerModuleIf() {}
virtual ~PlaYUVerModuleIf() {}
virtual void Delete() = 0;
virtual Void create() {}
virtual Void create( PlaYUVerFrame* ) {}