Refactor modules ownership

This commit is contained in:
jfmcarreira committed 2021-09-19 21:50:15 +01:00
1 parent a093efce9c
commit 94444e38ec
8 files changed
+222 -168

No files matched your search

+67 -57
View File
@@ -28,6 +28,7 @@
#include <QApplication>
#include <QDockWidget>
#include "ModuleHandleDock.h"
#include "VideoSubWindow.h"
#include "lib/CalypFrame.h"
#include "lib/CalypStream.h"
@@ -36,6 +37,9 @@ CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModul
: m_pcModuleAction( action ), m_pcModule( std ::move( module ) )
{
setParent( parent );
#ifdef CALYP_THREADED_MODULES
setObjectName( m_pcModule->m_pchModuleName );
#endif
m_frameList.reserve( m_pcModule->m_uiNumberOfFrames );
m_frameListPtr.reserve( m_pcModule->m_uiNumberOfFrames );
m_pcSubWindow.resize( m_pcModule->m_uiNumberOfFrames, nullptr );
@@ -43,28 +47,30 @@ CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModul
CalypAppModuleIf::~CalypAppModuleIf()
{
while( m_bIsRunning )
#ifdef CALYP_THREADED_MODULES
wait();
#endif
if( m_pcModuleDock )
{
auto* ptr = m_pcModuleDock;
m_pcModuleDock = NULL;
ptr->close();
}
if( m_pcDisplaySubWindow )
{
auto* ptr = m_pcDisplaySubWindow;
m_pcDisplaySubWindow = NULL;
ptr->closeSubWindow();
}
if( m_pcDockWidget )
{
m_pcDockWidget->close();
}
for( auto& window : m_pcSubWindow )
{
if( window != nullptr )
window->disableModule( this );
window = nullptr;
}
if( m_pcModule )
{
m_pcModule->destroy();
m_pcModule = nullptr;
}
//assert( m_pcProcessedFrame.use_count() == 1 );
}
void CalypAppModuleIf::update( bool isPlaying )
@@ -96,11 +102,19 @@ bool CalypAppModuleIf::isRunning()
#endif
}
void CalypAppModuleIf::run()
{
bool result = process();
if( result )
{
EventData* eventData = new EventData( m_bSuccess, this );
QCoreApplication::postEvent( parent(), eventData );
}
}
bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
{
bool bRet = false;
QApplication::setOverrideCursor( Qt::WaitCursor );
bool moduleExecuted = false;
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
{
if( m_pcDisplaySubWindow )
@@ -120,6 +134,11 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
m_frameList.push_back( m_pcSubWindow[i]->getCurrFrameAsset() );
}
// Skip module is is already running
if( isRunning() )
return moduleExecuted;
moduleExecuted = true;
#ifdef CALYP_THREADED_MODULES
if( !disableThreads )
{
@@ -129,29 +148,26 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
else
#endif
{
run();
QApplication::setOverrideCursor( Qt::WaitCursor );
process();
QApplication::restoreOverrideCursor();
show();
}
}
if( m_pcDisplaySubWindow || m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
{
bRet = true;
}
}
else
{
bRet = true;
}
QApplication::restoreOverrideCursor();
return bRet;
return moduleExecuted;
}
void CalypAppModuleIf::run()
bool CalypAppModuleIf::process()
{
m_bIsRunning = true;
m_bSuccess = false;
if( m_frameList.empty() )
return false;
#ifdef CALYP_THREADED_MODULES
QMutexLocker locker( &m_Mutex );
#endif
m_frameListPtr.clear();
for( auto& frame : m_frameList )
@@ -186,58 +202,52 @@ void CalypAppModuleIf::run()
}
else
{
return;
return false;
}
#ifdef CALYP_THREADED_MODULES
EventData* eventData = new EventData( m_bSuccess, this );
if( parent() )
QCoreApplication::postEvent( parent(), eventData );
#endif
m_bSuccess = true;
m_bIsRunning = false;
return;
return true;
}
void CalypAppModuleIf::show()
{
switch( m_pcModule->m_iModuleType )
{
case CLP_FRAME_PROCESSING_MODULE:
if( m_pcDisplaySubWindow )
case CLP_FRAME_PROCESSING_MODULE: {
auto displayWindow = m_pcDisplaySubWindow;
if( displayWindow == nullptr )
displayWindow = m_pcSubWindow[0];
#ifdef CALYP_THREADED_MODULES
if( m_Mutex.try_lock() )
{
m_pcDisplaySubWindow->setFillWindow( false );
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
m_pcDisplaySubWindow->setFillWindow( isRunning() );
}
else
{
m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
m_pcSubWindow[0]->setFillWindow( isRunning() );
m_Mutex.unlock();
}
#endif
m_pcDisplaySubWindow->setFillWindow( false );
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
break;
}
case CLP_FRAME_MEASUREMENT_MODULE:
m_pcModuleDock->setModuleReturnValue( m_dMeasurementResult );
break;
}
}
void CalypAppModuleIf::destroy()
void CalypAppModuleIf::disable()
{
QApplication::setOverrideCursor( Qt::WaitCursor );
#ifdef CALYP_THREADED_MODULES
QMutexLocker locker( &m_Mutex );
QApplication::restoreOverrideCursor();
#endif
m_frameList.clear();
m_frameListPtr.clear();
if( m_pcModuleDock )
while( m_pcSubWindow.size() > 0 )
{
auto* ptr = m_pcModuleDock;
m_pcModuleDock = NULL;
ptr->close();
}
if( m_pcDisplaySubWindow )
{
auto* ptr = m_pcDisplaySubWindow;
m_pcDisplaySubWindow = NULL;
ptr->closeSubWindow();
auto window = m_pcSubWindow.back();
m_pcSubWindow.erase( m_pcSubWindow.end() - 1 );
if( window != nullptr )
window->disableModule( this );
}
QApplication::restoreOverrideCursor();
}
+11 -11
View File
@@ -26,6 +26,7 @@
#define __CALYPAPPMODULESIF_H__
#include <QEvent>
#include <QPointer>
#include <QVector>
#include <cstdio>
#include <iostream>
@@ -52,12 +53,13 @@ class CalypFrame;
class VideoSubWindow;
class CalypAppModuleIf
class CalypAppModuleIf : std::enable_shared_from_this<CalypAppModuleIf>,
#ifdef CALYP_THREADED_MODULES
: public QThread
public QThread
#else
: public QObject
public QObject
#endif
{
friend class ModulesHandle;
friend class ModuleHandleDock;
@@ -68,13 +70,11 @@ public:
{
public:
EventData( bool success, CalypAppModuleIf* module )
: QEvent( QEvent::User )
: QEvent( QEvent::User ), m_bSuccess{ success }, m_pcModule{ module }
{
m_bSuccess = success;
m_pcModule = module;
}
bool m_bSuccess;
CalypAppModuleIf* m_pcModule;
QPointer<CalypAppModuleIf> m_pcModule;
};
CalypAppModuleIf( QObject* parent, QAction* action, CalypModulePtr&& module );
@@ -87,16 +87,16 @@ public:
ClpString moduleInfo() { return m_pcModule->moduleInfo(); }
void update( bool isPlaying );
bool apply( bool isPlaying = false, bool disableThreads = false );
bool process();
void setPlaying( bool isPlaying );
bool isRunning();
void show();
void destroy();
void disable();
protected:
virtual void run();
private:
bool m_bIsRunning{ false };
bool m_bSuccess{ false };
QAction* m_pcModuleAction{ nullptr };
@@ -104,8 +104,8 @@ private:
std::vector<VideoSubWindow*> m_pcSubWindow;
// The module owns the related widgets
VideoSubWindow* m_pcDisplaySubWindow{ nullptr };
QDockWidget* m_pcDockWidget{ nullptr };
ModuleHandleDock* m_pcModuleDock{ nullptr };
@@ -118,7 +118,7 @@ private:
double m_dMeasurementResult{ 0 };
#ifdef CALYP_THREADED_MODULES
QMutex m_Mutex;
QRecursiveMutex m_Mutex;
#endif
};
+28 -38
View File
@@ -180,7 +180,7 @@ void ModulesHandle::updateMenus()
}
m_arrayActions[LOAD_EXTERNAL_ACT]->setEnabled( true );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow );
m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcCalypAppModuleIfList.size() > 0 );
m_arrayActions[DISABLE_ALL_ACT]->setEnabled( true );
if( pcSubWindow )
{
@@ -276,7 +276,7 @@ void ModulesHandle::activateModule()
QString ModuleIfName = pcAction->data().toString();
auto pcCurrModuleIf = CalypModulesFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
auto pcCurrAppModuleIf = std::make_unique<CalypAppModuleIf>( this, pcAction, std::move( pcCurrModuleIf ) );
auto pcCurrAppModuleIf = std::make_shared<CalypAppModuleIf>( this, pcAction, std::move( pcCurrModuleIf ) );
QList<VideoSubWindow*> videoSubWindowList;
int numberOfFrames = pcCurrAppModuleIf->m_pcModule->m_uiNumberOfFrames;
@@ -377,7 +377,7 @@ void ModulesHandle::activateModule()
{
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
{
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW, pcCurrAppModuleIf.get() );
windowName.append( QStringLiteral( "Module " ) );
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleLongName );
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
@@ -388,6 +388,10 @@ void ModulesHandle::activateModule()
// connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
// SLOT( moveAllScrollBars( const QPoint ) ) );
}
else
{
pcCurrAppModuleIf->m_pcSubWindow[0]->setDisplayModule( pcCurrAppModuleIf.get() );
}
}
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
{
@@ -406,7 +410,7 @@ void ModulesHandle::activateModule()
for( int i = 0; i < videoSubWindowList.size(); i++ )
{
pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf.get() );
pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf );
}
// Create Module
@@ -453,55 +457,38 @@ void ModulesHandle::activateModule()
}
// Change ownership of the module
if( !pcCurrAppModuleIf->m_pcDisplaySubWindow && !pcCurrAppModuleIf->m_pcModuleDock )
{
pcCurrAppModuleIf->m_pcSubWindow[0]->enableModule( std::move( pcCurrAppModuleIf ) );
}
else if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
{
pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( std::move( pcCurrAppModuleIf ) );
}
else if( pcCurrAppModuleIf->m_pcModuleDock )
{
pcCurrAppModuleIf->m_pcModuleDock->enableModule( std::move( pcCurrAppModuleIf ) );
}
// if( !pcCurrAppModuleIf->m_pcDisplaySubWindow && !pcCurrAppModuleIf->m_pcModuleDock )
// {
// pcCurrAppModuleIf->m_pcSubWindow[0]->enableModule( pcCurrAppModuleIf );
// }
// else if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
// {
// pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrAppModuleIf );
// }
emit changed();
}
void ModulesHandle::destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf )
{
if( pcCurrModuleIf )
{
pcCurrModuleIf->destroy();
}
}
void ModulesHandle::destroyWindowModules()
{
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
if( pcVideoSubWindow )
{
pcVideoSubWindow->disableModule();
pcVideoSubWindow->disableAllModules();
emit changed();
}
}
void ModulesHandle::destroyAllModulesIf()
{
for( int i = 0; i < m_pcCalypAppModuleIfList.size(); i++ )
bool emit_changed = false;
QList<SubWindowAbstract*> windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( auto window : windowsList )
{
destroyModuleIf( m_pcCalypAppModuleIfList.at( i ) );
}
emit changed();
}
void ModulesHandle::applyModuleIf( QList<CalypAppModuleIf*> pcCurrModuleIfList, bool isPlaying, bool disableThreads )
{
for( int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ )
{
pcCurrModuleIfList.at( i )->apply( isPlaying, disableThreads );
emit_changed |= qobject_cast<VideoSubWindow*>( window )->disableAllModules();
}
if( emit_changed )
emit changed();
}
void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
@@ -607,12 +594,15 @@ void ModulesHandle::swapModulesWindowsIf( CalypAppModuleIf* pcCurrModuleIf )
void ModulesHandle::customEvent( QEvent* event )
{
if( !event )
{
return;
}
CalypAppModuleIf::EventData* eventData = (CalypAppModuleIf::EventData*)event;
if( eventData->m_bSuccess )
{
event->accept();
// The module could be freed by the time the event is processed
if( eventData->m_pcModule.isNull() )
return;
eventData->m_pcModule->show();
}
}
-4
View File
@@ -55,10 +55,6 @@ public:
void readSettings();
void writeSettings();
static void destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf );
static void applyModuleIf( QList<CalypAppModuleIf*> pcCurrModuleIfList, bool isPlaying = false,
bool disableThreads = false );
private:
QWidget* m_pcParent;
SubWindowHandle* m_pcMainWindowManager;
+97 -41
View File
@@ -106,7 +106,6 @@ public:
m_cCenterTextFont.setPointSize( 12 );
m_pcRefreshTimer = new QTimer;
m_pcRefreshTimer->setSingleShot( true );
connect( m_pcRefreshTimer, SIGNAL( timeout() ), this, SLOT( update() ) );
}
void setInformationTopLeft( const QStringList& textLines )
{
@@ -119,6 +118,7 @@ public:
void setBusyWindow( bool bFlag )
{
m_bBusyWindow = bFlag;
// Do not show the refresh screen if it takes less than 500 ms
m_pcRefreshTimer->start( 500 );
}
@@ -136,7 +136,7 @@ protected:
topLeftCorner += QPoint( 0, 15 );
}
}
if( m_bBusyWindow )
if( m_bBusyWindow && !m_pcRefreshTimer->isActive() )
{
painter.setFont( m_cCenterTextFont );
painter.drawText( rect(), Qt::AlignHCenter | Qt::AlignVCenter, QStringLiteral( "Refreshing..." ) );
@@ -194,14 +194,15 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
m_pcVideoInfo = new VideoInformation( this );
}
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, CalypAppModuleIf* displayModule, QWidget* parent )
: VideoSubWindow( category, parent )
{
m_pcCurrentDisplayModule = displayModule;
}
VideoSubWindow::~VideoSubWindow()
{
std::vector<CalypAppModuleIf*> tmpModules = m_associatedModules;
m_associatedModules.clear();
for( auto module : tmpModules )
{
module->destroy();
}
m_pcCurrFrameAsset = nullptr;
if( m_pcResourceManager )
m_pcResourceManager->removeResource( m_uiResourceId );
delete m_pcUpdateTimer;
@@ -214,6 +215,18 @@ VideoSubWindow::~VideoSubWindow()
void VideoSubWindow::closeEvent( QCloseEvent* event )
{
//stop();
auto tmpModules = m_associatedModules;
m_associatedModules.clear();
for( auto module : tmpModules )
{
module->disable();
}
if( m_pcCurrentDisplayModule )
{
m_pcCurrentDisplayModule->disable();
event->ignore();
return;
}
SubWindowAbstract::closeEvent( event );
}
@@ -648,28 +661,67 @@ void VideoSubWindow::updateSelectedArea( QRect area )
* Functions to enable a module in the
* current SubWindow
*/
void VideoSubWindow::enableModule( std::unique_ptr<CalypAppModuleIf>&& pcModule )
// void VideoSubWindow::enableModule( std::shared_ptr<CalypAppModuleIf> pcModule )
// {
// auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
// [&]( const auto& module ) { return module.get() == pcModule.get(); } );
// if( it != m_associatedModules.end() )
// {
// m_associatedModules.erase( it );
// }
// m_pcCurrentDisplayModule = std::move( pcModule );
// updateVideoWindowInfo();
// }
bool VideoSubWindow::hasAssociatedModule()
{
auto it = std::find( m_associatedModules.begin(), m_associatedModules.end(), pcModule.get() );
if( it != m_associatedModules.end() )
if( m_pcCurrentDisplayModule == nullptr )
return !m_associatedModules.empty();
return m_associatedModules.size() > 1;
}
void VideoSubWindow::setDisplayModule( CalypAppModuleIf* pcModule )
{
if( m_pcCurrentDisplayModule != nullptr )
{
m_associatedModules.erase( it );
m_pcCurrentDisplayModule->disable();
}
m_pcCurrentDisplayModule = std::move( pcModule );
m_pcCurrentDisplayModule = pcModule;
updateVideoWindowInfo();
}
void VideoSubWindow::associateModule( std::shared_ptr<CalypAppModuleIf> pcModule )
{
auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
[&]( const auto& module ) { return module.get() == pcModule.get(); } );
if( it == m_associatedModules.end() )
{
m_associatedModules.push_back( std::move( pcModule ) );
}
}
void VideoSubWindow::disableModule( CalypAppModuleIf* pcModule )
{
if( pcModule == nullptr )
return;
bool bRefresh = false;
if( pcModule )
auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
[&]( const auto& module ) { return module.get() == pcModule; } );
if( it != m_associatedModules.end() )
{
auto it = std::find( m_associatedModules.begin(), m_associatedModules.end(), pcModule );
if( it != m_associatedModules.end() )
{
m_associatedModules.erase( it );
bRefresh |= true;
}
m_associatedModules.erase( it );
}
if( pcModule == m_pcCurrentDisplayModule )
{
bRefresh |= true;
m_pcCurrentDisplayModule = nullptr;
setWindowName( QFileInfo( m_cFilename ).fileName() );
}
if( bRefresh )
{
refreshFrame();
updateVideoWindowInfo();
}
// if( pcModule )
// {
@@ -708,25 +760,25 @@ void VideoSubWindow::disableModule( CalypAppModuleIf* pcModule )
// bRefresh |= true;
// }
// }
if( bRefresh )
{
refreshFrame();
updateVideoWindowInfo();
}
}
void VideoSubWindow::associateModule( CalypAppModuleIf* pcModule )
bool VideoSubWindow::disableAllModules()
{
m_associatedModules.push_back( pcModule );
if( m_associatedModules.empty() )
return false;
// For loop is required as we will invalidate the iterator
while( m_associatedModules.size() > 0 )
{
auto module = m_associatedModules.back();
module->disable();
m_associatedModules.pop_back();
}
return true;
}
bool VideoSubWindow::hasRunningModule()
{
bool bRet = false;
if( m_pcCurrentDisplayModule )
{
bRet |= m_pcCurrentDisplayModule->isRunning();
}
for( int i = 0; i < m_associatedModules.size() && !bRet; i++ )
{
bRet |= m_associatedModules.at( i )->isRunning();
@@ -750,8 +802,13 @@ std::shared_ptr<CalypFrame> VideoSubWindow::getCurrFrameAsset()
void VideoSubWindow::setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame )
{
m_pcCurrFrameAsset = pcCurrFrame;
m_pcCurrFrameAsset = std::move( pcCurrFrame );
m_cViewArea->setImage( m_pcCurrFrameAsset.get() );
for( auto& module : m_associatedModules )
{
if( module.get() != m_pcCurrentDisplayModule )
module->update( m_bIsPlaying );
}
}
void VideoSubWindow::refreshFrameOperation()
@@ -766,16 +823,18 @@ void VideoSubWindow::refreshFrameOperation()
if( m_pcCurrentDisplayModule )
{
m_bWindowBusy = true;
m_pcCurrentDisplayModule->apply( m_bIsPlaying, !m_bIsPlaying && m_associatedModules.size() );
bool disableThreads = !m_bIsPlaying && hasAssociatedModule();
m_pcCurrentDisplayModule->apply( m_bIsPlaying, disableThreads );
bSetFrame = false;
}
if( bSetFrame )
{
m_cViewArea->setImage( m_pcCurrFrameAsset.get() );
}
for( int i = 0; i < m_associatedModules.size(); i++ )
{
m_associatedModules.at( i )->update( m_bIsPlaying );
for( auto& module : m_associatedModules )
{
if( module.get() != m_pcCurrentDisplayModule )
module->update( m_bIsPlaying );
}
}
}
@@ -938,12 +997,9 @@ void VideoSubWindow::seekRelativeEvent( bool bIsFoward )
#ifdef CALYP_MANAGED_RESOURCES
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
#endif
refreshFrame();
}
}
if( bRefresh )
{
refreshFrame();
}
}
void VideoSubWindow::stop()
+16 -8
View File
@@ -89,8 +89,9 @@ private:
//CalypFrame* m_pcCurrFrame;
QRect m_cSelectedArea;
std::unique_ptr<CalypAppModuleIf> m_pcCurrentDisplayModule{ nullptr };
std::vector<CalypAppModuleIf*> m_associatedModules;
CalypAppModuleIf* m_pcCurrentDisplayModule{ nullptr };
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
bool m_hasAssociatedModules;
VideoSubWindow* m_pcReferenceSubWindow;
@@ -114,6 +115,7 @@ public:
MODULE_SUBWINDOW = SubWindowAbstract::MODULE_SUBWINDOW,
};
VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 );
VideoSubWindow( enum VideoSubWindowCategories category, CalypAppModuleIf* displayModule, QWidget* parent = 0 );
~VideoSubWindow();
void setResourceManaget( ResourceHandle* resourceManager ) { m_pcResourceManager = resourceManager; }
@@ -161,17 +163,23 @@ public:
* Functions to enable a module in the
* current SubWindow
*/
void enableModule( std::unique_ptr<CalypAppModuleIf>&& pcModule );
void disableModule( CalypAppModuleIf* pcModule = NULL );
void associateModule( CalypAppModuleIf* pcModule );
//void enableModule( std::shared_ptr<CalypAppModuleIf> pcModule );
bool hasAssociatedModule();
void setDisplayModule( CalypAppModuleIf* pcModule );
void associateModule( std::shared_ptr<CalypAppModuleIf> pcModule );
void disableModule( CalypAppModuleIf* pcModule );
bool disableAllModules();
CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule.get(); }
CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; }
QVector<CalypAppModuleIf*> getModuleArray()
{
QVector<CalypAppModuleIf*> apcModulesArray;
if( m_pcCurrentDisplayModule )
apcModulesArray.append( m_pcCurrentDisplayModule.get() );
apcModulesArray.append( QVector<CalypAppModuleIf*>::fromStdVector( m_associatedModules ) );
apcModulesArray.append( m_pcCurrentDisplayModule );
for( const auto& module : m_associatedModules )
{
apcModulesArray.append( module.get() );
}
return apcModulesArray;
}
+2 -7
View File
@@ -33,7 +33,7 @@
#include "ModulesHandle.h"
ModuleHandleDock::ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf )
: QWidget( parent )
: QWidget( parent ), m_pcCurrModuleIf( moduleIf )
{
// ----------------- Dock definition -----------------
@@ -60,11 +60,6 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf
ModuleHandleDock::~ModuleHandleDock() = default;
void ModuleHandleDock::enableModule( std::unique_ptr<CalypAppModuleIf>&& module )
{
m_pcCurrModuleIf = std::move( module );
}
void ModuleHandleDock::setModuleReturnValue( double value )
{
labelModulueReturnValue->clear();
@@ -76,7 +71,7 @@ void ModuleHandleDock::visibilityChangedSlot( bool visiblity )
{
if( !visiblity )
{
m_pcCurrModuleIf = nullptr;
m_pcCurrModuleIf->disable();
}
}
+1 -2
View File
@@ -42,13 +42,12 @@ public:
ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf );
~ModuleHandleDock();
void enableModule( std::unique_ptr<CalypAppModuleIf>&& module );
void setModuleReturnValue( double value );
QSize sizeHint() const;
private:
std::unique_ptr<CalypAppModuleIf> m_pcCurrModuleIf;
CalypAppModuleIf* m_pcCurrModuleIf;
bool m_bIsVisible;
QLabel* labelModulueValueLabel;