Add a option to swap frames in modules with two frames (e.g, swap left right frames)

This commit is contained in:
jfmcarreira committed 2014-05-18 18:57:12 +01:00
1 parent 150338b9ad
commit 877087ee4e
6 files changed
+90 -38

No files matched your search

+50 -25
View File
@@ -38,7 +38,7 @@ ModulesHandle::ModulesHandle( QWidget * parent, QMdiArea *mdiArea ) :
m_pcParent( parent ), m_pcParent( parent ),
m_pcMdiArea( mdiArea ), m_pcMdiArea( mdiArea ),
m_uiModulesCount( 0 ), m_uiModulesCount( 0 ),
m_uiModuleSelected( -1 ) m_iOptionSelected( INVALID_OPT )
{ {
// configure class // configure class
setParent( m_pcParent ); setParent( m_pcParent );
@@ -56,31 +56,38 @@ Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule )
m_uiModulesCount++; m_uiModulesCount++;
} }
void ModulesHandle::selectModule( int index ) Void ModulesHandle::selectModule( Int index )
{ {
m_uiModuleSelected = index; m_iOptionSelected = index;
} }
SubWindowHandle* ModulesHandle::toggleSelectedModuleIf() SubWindowHandle* ModulesHandle::processModuleHandlingOpt()
{ {
PlaYUVerModuleIf* pcCurrModuleIf = NULL; if( m_iOptionSelected >= 0 )
if( m_uiModuleSelected >= 0 )
pcCurrModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
m_uiModuleSelected = -1;
if( !pcCurrModuleIf )
return NULL;
if( pcCurrModuleIf->m_pcAction->isChecked() )
{ {
return enableModuleIf( pcCurrModuleIf ); PlaYUVerModuleIf* pcCurrModuleIf = m_pcPlaYUVerModules.at( m_iOptionSelected );
if( pcCurrModuleIf->m_pcAction->isChecked() )
{
return enableModuleIf( pcCurrModuleIf );
}
else
{
destroyModuleIf( pcCurrModuleIf );
return NULL;
}
} }
else else
{ {
destroyModuleIf( pcCurrModuleIf ); switch( m_iOptionSelected )
return NULL; {
case SWAP_FRAMES_OPT:
SubWindowHandle* pcSubWindow = qobject_cast<SubWindowHandle *>( m_pcMdiArea->activeSubWindow() );
pcSubWindow->swapModuleFrames();
break;
}
} }
m_iOptionSelected = INVALID_OPT;
return NULL; return NULL;
} }
@@ -116,18 +123,16 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf
pcCurrModuleIf->m_pcAction->setChecked( false ); pcCurrModuleIf->m_pcAction->setChecked( false );
return interfaceChild; return interfaceChild;
} }
windowName.append( " [" );
windowName.append( pcCurrModuleIf->m_cModuleDef.m_pchModuleName );
windowName.append( "]" );
} }
else else
{ {
windowName.append( pcSubWindow->userFriendlyCurrentFile() ); windowName.append( pcSubWindow->userFriendlyCurrentFile() );
windowName.append( " [" );
windowName.append( pcCurrModuleIf->m_cModuleDef.m_pchModuleName );
windowName.append( "]" );
pcCurrModuleIf->m_pcSubWindow[0] = pcSubWindow; pcCurrModuleIf->m_pcSubWindow[0] = pcSubWindow;
} }
windowName.append( " <" );
windowName.append( pcCurrModuleIf->m_cModuleDef.m_pchModuleName );
windowName.append( ">" );
pcCurrModuleIf->m_pcDisplaySubWindow = NULL; pcCurrModuleIf->m_pcDisplaySubWindow = NULL;
if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
@@ -212,6 +217,16 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Bool isPlay
return bRet; return bRet;
} }
Void ModulesHandle::swapModulesWindowsIf( PlaYUVerModuleIf *pcCurrModuleIf )
{
if( pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames == MODULE_REQUIRES_TWO_FRAMES )
{
SubWindowHandle* auxWindowHandle = pcCurrModuleIf->m_pcSubWindow[0];
pcCurrModuleIf->m_pcSubWindow[0] = pcCurrModuleIf->m_pcSubWindow[1];
pcCurrModuleIf->m_pcSubWindow[1] = auxWindowHandle;
}
}
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
{ {
PlaYUVerModuleIf* pcCurrModuleIf; PlaYUVerModuleIf* pcCurrModuleIf;
@@ -225,8 +240,6 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" );
//m_arrayModulesActions.resize( m_uiModulesCount );
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
{ {
pcCurrModuleIf = m_pcPlaYUVerModules.at( i ); pcCurrModuleIf = m_pcPlaYUVerModules.at( i );
@@ -269,10 +282,21 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() ); 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]->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_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[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_pcModulesMenu->addSeparator(); m_pcModulesMenu->addSeparator();
m_pcModulesMenu->addAction( m_arrayActions[SWAP_FRAMES_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[DISABLE_ALL_ACT] ); m_pcModulesMenu->addAction( m_arrayActions[DISABLE_ALL_ACT] );
m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] ); m_pcModulesMenu->addAction( m_arrayActions[FORCE_NEW_WINDOW_ACT] );
//m_pcModulesMenu->addAction( m_arrayActions[FORCE_PLAYING_REFRESH_ACT] );
return m_pcModulesMenu; return m_pcModulesMenu;
} }
@@ -285,6 +309,7 @@ Void ModulesHandle::updateMenus( Bool hasSubWindow )
currModuleAction = m_arrayModulesActions.at( i ); currModuleAction = m_arrayModulesActions.at( i );
currModuleAction->setEnabled( hasSubWindow ); currModuleAction->setEnabled( hasSubWindow );
} }
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( hasSubWindow );
} }
} // NAMESPACE } // NAMESPACE
+12 -3
View File
@@ -53,16 +53,23 @@ public:
QMenu* createMenus( QMenuBar* MainAppMenuBar ); QMenu* createMenus( QMenuBar* MainAppMenuBar );
Void updateMenus( Bool hasSubWindow ); Void updateMenus( Bool hasSubWindow );
SubWindowHandle* toggleSelectedModuleIf(); SubWindowHandle* processModuleHandlingOpt();
static Bool applyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf, Bool isPlaying = false );
static Void destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf ); static Void destroyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf );
static Bool applyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf, Bool isPlaying = false );
static Void swapModulesWindowsIf( PlaYUVerModuleIf *pcCurrModuleIf );
private: private:
QWidget *m_pcParent; QWidget *m_pcParent;
QMdiArea *m_pcMdiArea; QMdiArea *m_pcMdiArea;
UInt m_uiModulesCount; UInt m_uiModulesCount;
Int m_uiModuleSelected; Int m_iOptionSelected;
enum
{
INVALID_OPT = -1,
SWAP_FRAMES_OPT = -2,
};
QMenu* m_pcModulesMenu; QMenu* m_pcModulesMenu;
QList<QMenu*> m_pcModulesSubMenuList; QList<QMenu*> m_pcModulesSubMenuList;
@@ -73,7 +80,9 @@ private:
enum MODULES_ACTION_LIST enum MODULES_ACTION_LIST
{ {
FORCE_NEW_WINDOW_ACT = 0, FORCE_NEW_WINDOW_ACT = 0,
FORCE_PLAYING_REFRESH_ACT,
DISABLE_ALL_ACT, DISABLE_ALL_ACT,
SWAP_FRAMES_ACT,
MODULES_TOTAL_ACT MODULES_TOTAL_ACT
}; };
QVector<QAction*> m_arrayActions; QVector<QAction*> m_arrayActions;
+23 -5
View File
@@ -135,6 +135,16 @@ Void SubWindowHandle::disableModule()
} }
} }
Void SubWindowHandle::swapModuleFrames()
{
if( m_pcCurrentModule )
{
ModulesHandle::swapModulesWindowsIf( m_pcCurrentModule );
refreshFrame();
}
}
Void SubWindowHandle::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) Void SubWindowHandle::setCurrFrame( PlaYUVerFrame* pcCurrFrame )
{ {
m_pcCurrFrame = pcCurrFrame; m_pcCurrFrame = pcCurrFrame;
@@ -143,18 +153,26 @@ Void SubWindowHandle::setCurrFrame( PlaYUVerFrame* pcCurrFrame )
Void SubWindowHandle::refreshFrame() Void SubWindowHandle::refreshFrame()
{ {
Bool bSetFrame = true; Bool bSetFrame = false;
if( m_pCurrStream ) if( m_pCurrStream )
{ {
m_pcCurrFrame = m_pCurrStream->getCurrFrame(); m_pcCurrFrame = m_pCurrStream->getCurrFrame();
bSetFrame = true;
if( m_pcCurrentModule ) if( m_pcCurrentModule )
{ {
bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentModule, m_bIsPlaying ); bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentModule, m_bIsPlaying );
} }
if( bSetFrame ) }
{ else
m_cViewArea->setImage( m_pcCurrFrame ); {
} if( m_pcCurrentModule )
{
bSetFrame = ModulesHandle::applyModuleIf( m_pcCurrentModule, m_bIsPlaying );
}
}
if( bSetFrame )
{
m_cViewArea->setImage( m_pcCurrFrame );
} }
} }
+1 -1
View File
@@ -113,7 +113,7 @@ public:
*/ */
Void enableModule( PlaYUVerModuleIf* select_module ); Void enableModule( PlaYUVerModuleIf* select_module );
Void disableModule(); Void disableModule();
Void swapModuleFrames();
/** /**
* Show the image at its original size * Show the image at its original size
*/ */
+3 -3
View File
@@ -228,10 +228,10 @@ Void plaYUVerApp::closeAll()
// ----------------------- Modules Selection -------------------- // ----------------------- Modules Selection --------------------
Void plaYUVerApp::selectModule( QAction *curr_action ) Void plaYUVerApp::ModuleHandling( QAction *curr_action )
{ {
m_pcFrameProperties->stopHistogram(); m_pcFrameProperties->stopHistogram();
SubWindowHandle *interfaceChild = m_pcModulesHandle->toggleSelectedModuleIf(); SubWindowHandle *interfaceChild = m_pcModulesHandle->processModuleHandlingOpt();
if( interfaceChild ) if( interfaceChild )
{ {
mdiArea->addSubWindow( interfaceChild ); mdiArea->addSubWindow( interfaceChild );
@@ -1052,7 +1052,7 @@ Void plaYUVerApp::createMenus()
m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_SELECTION_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_LOCK_SELECTION_ACT] );
QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() );
connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) ); connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( ModuleHandling(QAction *) ) );
m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) ); m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) );
updateWindowMenu(); updateWindowMenu();
+1 -1
View File
@@ -74,7 +74,7 @@ private Q_SLOTS:
void lockButtonEvent(); void lockButtonEvent();
void videoSelectionButtonEvent(); void videoSelectionButtonEvent();
void selectModule( QAction * ); void ModuleHandling( QAction * );
/** /**
* Scale the image by a given factor * Scale the image by a given factor