From 468d525b165a2090a3a64e5cc302ea28f52bd25d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 21 Feb 2014 18:58:07 +0000 Subject: [PATCH] Add feature to disable current module --- source/ModulesHandle.cpp | 7 ++++++- source/SubWindowHandle.cpp | 7 +++++++ source/modules/FilterFrame.cpp | 8 ++++++-- source/modules/PlaYUVerModuleIf.h | 5 +++++ source/plaYUVerApp.cpp | 8 ++++---- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index fac9a67..68fd201 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -62,8 +62,11 @@ void ModulesHandle::selectModule( int index ) PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf() { PlaYUVerModuleIf* currModuleIf = NULL; + if( m_uiModuleSelected >= 0 ) - return m_pcPlaYUVerModules.at( m_uiModuleSelected ); + //if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() ) + currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected ); + m_uiModuleSelected = -1; return currModuleIf; } @@ -92,6 +95,8 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) m_arrayModulesActions.append( currAction ); m_pcModulesMenu->addAction( currAction ); + + currModuleIf->m_pcAction = currAction; } return m_pcModulesMenu; //MainAppMenuBar-> diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 47281f8..f780d61 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -115,6 +115,11 @@ 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->getFrame( m_pcCurrentModule->getModImage() ) ); refreshFrame(); @@ -122,6 +127,8 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) Void SubWindowHandle::disableModule() { + if( !m_pcCurrentModule ) + return; m_pcCurrentModule->destroy(); m_pcCurrentModule = NULL; refreshFrame(); diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 8aa66b3..ec1ea51 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -31,6 +31,8 @@ namespace plaYUVer Void FilterFrame::create( PlaYUVerFrame* InputFrame ) { + if( m_pcFilteredFrame ) + delete m_pcFilteredFrame; m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), InputFrame->getPelFormat() ); } @@ -48,13 +50,15 @@ PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) pppPelYUV[2][y][x] = 128; } } - m_pcFilteredFrame->YUV420toRGB(); + //m_pcFilteredFrame->YUV420toRGB(); return m_pcFilteredFrame; } Void FilterFrame::destroy() { - delete m_pcFilteredFrame; + if( m_pcFilteredFrame ) + delete m_pcFilteredFrame; + m_pcFilteredFrame = NULL; } } // NAMESPACE diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 86ebd56..21677cd 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -33,6 +33,7 @@ #include "PlaYUVerFrame.h" class QImage; +class QAction; namespace plaYUVer { @@ -54,6 +55,8 @@ public: { } + QAction* m_pcAction; + const Char* m_pchModuleType; const Char* m_pchModuleName; const Char* m_pchModuleTooltip; @@ -65,6 +68,8 @@ public: virtual PlaYUVerFrame* process( PlaYUVerFrame* ) {}; virtual PlaYUVerFrame* getModImage() {}; + virtual QImage* process( QImage* ) {}; + virtual Void destroy() {}; }; diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 9401a07..dafb56d 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -140,12 +140,12 @@ void plaYUVerApp::save() void plaYUVerApp::selectModule( QAction *curr_action ) { //emit curr_action->triggered(); - - if( m_pcModulesHandle->getSelectedModuleIf() ) + if( activeSubWindow() ) { - if( activeSubWindow() ) + PlaYUVerModuleIf* pcCurrMod = m_pcModulesHandle->getSelectedModuleIf(); + if( pcCurrMod ) { - activeSubWindow()->enableModule( m_pcModulesHandle->getSelectedModuleIf() ); + activeSubWindow()->enableModule( pcCurrMod ); } } return;