SqpApplication.cpp
217 lines
| 8.5 KiB
| text/x-c
|
CppLexer
r21 | #include "SqpApplication.h" | |||
r1076 | #include <Actions/ActionsGuiController.h> | |||
Thibaud Rabillard
|
r1087 | #include <Catalogue/CatalogueController.h> | ||
Alexandre Leroux
|
r169 | #include <Data/IDataProvider.h> | ||
r21 | #include <DataSource/DataSourceController.h> | |||
r1075 | #include <DragAndDrop/DragDropGuiController.h> | |||
r339 | #include <Network/NetworkController.h> | |||
r21 | #include <QThread> | |||
r193 | #include <Time/TimeController.h> | |||
Alexandre Leroux
|
r170 | #include <Variable/Variable.h> | ||
Alexandre Leroux
|
r111 | #include <Variable/VariableController.h> | ||
r870 | #include <Variable/VariableModel.h> | |||
r53 | #include <Visualization/VisualizationController.h> | |||
r21 | ||||
Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | ||||
class SqpApplication::SqpApplicationPrivate { | ||||
public: | ||||
r55 | SqpApplicationPrivate() | |||
: m_DataSourceController{std::make_unique<DataSourceController>()}, | ||||
Alexandre Leroux
|
r111 | m_VariableController{std::make_unique<VariableController>()}, | ||
Alexandre Leroux
|
r961 | m_TimeController{std::make_unique<TimeController>()}, | ||
m_NetworkController{std::make_unique<NetworkController>()}, | ||||
r837 | m_VisualizationController{std::make_unique<VisualizationController>()}, | |||
r1075 | m_DragDropGuiController{std::make_unique<DragDropGuiController>()}, | |||
r1059 | m_CatalogueController{std::make_unique<CatalogueController>()}, | |||
r1076 | m_ActionsGuiController{std::make_unique<ActionsGuiController>()}, | |||
r957 | m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None), | |||
m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) | ||||
Alexandre Leroux
|
r32 | { | ||
Alexandre Leroux
|
r169 | // /////////////////////////////// // | ||
// Connections between controllers // | ||||
// /////////////////////////////// // | ||||
// VariableController <-> DataSourceController | ||||
connect(m_DataSourceController.get(), | ||||
Alexandre Leroux
|
r410 | SIGNAL(variableCreationRequested(const QString &, const QVariantHash &, | ||
std::shared_ptr<IDataProvider>)), | ||||
Alexandre Leroux
|
r169 | m_VariableController.get(), | ||
Alexandre Leroux
|
r410 | SLOT(createVariable(const QString &, const QVariantHash &, | ||
std::shared_ptr<IDataProvider>))); | ||||
Alexandre Leroux
|
r169 | |||
r870 | connect(m_VariableController->variableModel(), &VariableModel::requestVariable, | |||
m_DataSourceController.get(), &DataSourceController::requestVariable); | ||||
Alexandre Leroux
|
r170 | // VariableController <-> VisualizationController | ||
Alexandre Leroux
|
r336 | connect(m_VariableController.get(), | ||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | ||||
m_VisualizationController.get(), | ||||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | ||||
Alexandre Leroux
|
r170 | |||
r437 | connect(m_VariableController.get(), | |||
r512 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)), | |||
r437 | m_VisualizationController.get(), | |||
r512 | SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &))); | |||
r437 | ||||
r193 | ||||
Alexandre Leroux
|
r32 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | ||
r429 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | |||
r339 | m_NetworkController->moveToThread(&m_NetworkControllerThread); | |||
r429 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); | |||
Alexandre Leroux
|
r111 | m_VariableController->moveToThread(&m_VariableControllerThread); | ||
r429 | m_VariableControllerThread.setObjectName("VariableControllerThread"); | |||
r55 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |||
r429 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |||
Thibaud Rabillard
|
r1087 | m_CatalogueController->moveToThread(&m_CatalogueControllerThread); | ||
m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); | ||||
r193 | ||||
r374 | ||||
r193 | // Additionnal init | |||
m_VariableController->setTimeController(m_TimeController.get()); | ||||
Alexandre Leroux
|
r32 | } | ||
r24 | virtual ~SqpApplicationPrivate() | |||
r22 | { | |||
m_DataSourceControllerThread.quit(); | ||||
m_DataSourceControllerThread.wait(); | ||||
r53 | ||||
r339 | m_NetworkControllerThread.quit(); | |||
m_NetworkControllerThread.wait(); | ||||
Alexandre Leroux
|
r111 | m_VariableControllerThread.quit(); | ||
m_VariableControllerThread.wait(); | ||||
r55 | m_VisualizationControllerThread.quit(); | |||
m_VisualizationControllerThread.wait(); | ||||
Thibaud Rabillard
|
r1087 | |||
m_CatalogueControllerThread.quit(); | ||||
m_CatalogueControllerThread.wait(); | ||||
r22 | } | |||
r21 | ||||
std::unique_ptr<DataSourceController> m_DataSourceController; | ||||
Alexandre Leroux
|
r111 | std::unique_ptr<VariableController> m_VariableController; | ||
r193 | std::unique_ptr<TimeController> m_TimeController; | |||
r339 | std::unique_ptr<NetworkController> m_NetworkController; | |||
r53 | std::unique_ptr<VisualizationController> m_VisualizationController; | |||
Thibaud Rabillard
|
r1087 | std::unique_ptr<CatalogueController> m_CatalogueController; | ||
r1076 | ||||
r21 | QThread m_DataSourceControllerThread; | |||
r339 | QThread m_NetworkControllerThread; | |||
Alexandre Leroux
|
r111 | QThread m_VariableControllerThread; | ||
r55 | QThread m_VisualizationControllerThread; | |||
Thibaud Rabillard
|
r1087 | QThread m_CatalogueControllerThread; | ||
r837 | ||||
r1075 | std::unique_ptr<DragDropGuiController> m_DragDropGuiController; | |||
r1076 | std::unique_ptr<ActionsGuiController> m_ActionsGuiController; | |||
r957 | ||||
SqpApplication::PlotsInteractionMode m_PlotInterractionMode; | ||||
SqpApplication::PlotsCursorMode m_PlotCursorMode; | ||||
r21 | }; | |||
SqpApplication::SqpApplication(int &argc, char **argv) | ||||
Alexandre Leroux
|
r32 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | ||
r21 | { | |||
r389 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); | |||
r21 | ||||
connect(&impl->m_DataSourceControllerThread, &QThread::started, | ||||
impl->m_DataSourceController.get(), &DataSourceController::initialize); | ||||
connect(&impl->m_DataSourceControllerThread, &QThread::finished, | ||||
impl->m_DataSourceController.get(), &DataSourceController::finalize); | ||||
r339 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), | |||
&NetworkController::initialize); | ||||
connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), | ||||
&NetworkController::finalize); | ||||
Alexandre Leroux
|
r111 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | ||
&VariableController::initialize); | ||||
connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | ||||
&VariableController::finalize); | ||||
r55 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |||
impl->m_VisualizationController.get(), &VisualizationController::initialize); | ||||
connect(&impl->m_VisualizationControllerThread, &QThread::finished, | ||||
impl->m_VisualizationController.get(), &VisualizationController::finalize); | ||||
r53 | ||||
Thibaud Rabillard
|
r1087 | connect(&impl->m_CatalogueControllerThread, &QThread::started, | ||
impl->m_CatalogueController.get(), &CatalogueController::initialize); | ||||
connect(&impl->m_CatalogueControllerThread, &QThread::finished, | ||||
impl->m_CatalogueController.get(), &CatalogueController::finalize); | ||||
r21 | impl->m_DataSourceControllerThread.start(); | |||
r339 | impl->m_NetworkControllerThread.start(); | |||
Alexandre Leroux
|
r111 | impl->m_VariableControllerThread.start(); | ||
r55 | impl->m_VisualizationControllerThread.start(); | |||
Thibaud Rabillard
|
r1087 | impl->m_CatalogueControllerThread.start(); | ||
r21 | } | |||
r845 | SqpApplication::~SqpApplication() | |||
{ | ||||
} | ||||
r21 | ||||
r845 | void SqpApplication::initialize() | |||
{ | ||||
} | ||||
Alexandre Leroux
|
r33 | |||
Alexandre Leroux
|
r116 | DataSourceController &SqpApplication::dataSourceController() noexcept | ||
Alexandre Leroux
|
r33 | { | ||
return *impl->m_DataSourceController; | ||||
} | ||||
r53 | ||||
r339 | NetworkController &SqpApplication::networkController() noexcept | |||
{ | ||||
return *impl->m_NetworkController; | ||||
} | ||||
r193 | TimeController &SqpApplication::timeController() noexcept | |||
{ | ||||
return *impl->m_TimeController; | ||||
} | ||||
Alexandre Leroux
|
r116 | VariableController &SqpApplication::variableController() noexcept | ||
Alexandre Leroux
|
r111 | { | ||
return *impl->m_VariableController; | ||||
} | ||||
Alexandre Leroux
|
r116 | VisualizationController &SqpApplication::visualizationController() noexcept | ||
r53 | { | |||
return *impl->m_VisualizationController; | ||||
} | ||||
r837 | ||||
r1144 | CatalogueController &SqpApplication::catalogueController() noexcept | |||
{ | ||||
return *impl->m_CatalogueController; | ||||
} | ||||
r1075 | DragDropGuiController &SqpApplication::dragDropGuiController() noexcept | |||
r837 | { | |||
r1075 | return *impl->m_DragDropGuiController; | |||
r837 | } | |||
r957 | ||||
r1076 | ActionsGuiController &SqpApplication::actionsGuiController() noexcept | |||
{ | ||||
return *impl->m_ActionsGuiController; | ||||
} | ||||
r957 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const | |||
{ | ||||
return impl->m_PlotInterractionMode; | ||||
} | ||||
void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) | ||||
{ | ||||
impl->m_PlotInterractionMode = mode; | ||||
} | ||||
SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const | ||||
{ | ||||
return impl->m_PlotCursorMode; | ||||
} | ||||
void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) | ||||
{ | ||||
impl->m_PlotCursorMode = mode; | ||||
} | ||||