SqpApplication.cpp
193 lines
| 6.9 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> | |||
r1348 | #include <Variable/VariableController2.h> | |||
#include <Variable/VariableModel2.h> | ||||
r53 | #include <Visualization/VisualizationController.h> | |||
r21 | ||||
Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | ||||
r1406 | class SqpApplication::SqpApplicationPrivate | |||
{ | ||||
r21 | public: | |||
r55 | SqpApplicationPrivate() | |||
r1406 | : m_VariableController { std::make_shared<VariableController2>() } | |||
, m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None) | ||||
, m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) | ||||
Alexandre Leroux
|
r32 | { | ||
Alexandre Leroux
|
r169 | // /////////////////////////////// // | ||
// Connections between controllers // | ||||
// /////////////////////////////// // | ||||
// VariableController <-> DataSourceController | ||||
r1406 | connect(&m_DataSourceController, &DataSourceController::createVariable, | |||
[](const QString& variableName, const QVariantHash& variableMetadata, | ||||
std::shared_ptr<IDataProvider> variableProvider) { | ||||
sqpApp->variableController().createVariable(variableName, variableMetadata, | ||||
variableProvider, sqpApp->timeController().dateTime()); | ||||
}); | ||||
Alexandre Leroux
|
r169 | |||
Alexandre Leroux
|
r170 | // VariableController <-> VisualizationController | ||
r1406 | // connect(m_VariableController.get(), | |||
// SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | ||||
// m_VisualizationController.get(), | ||||
// SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | ||||
// Qt::DirectConnection); | ||||
Alexandre Leroux
|
r170 | |||
r1406 | // connect(m_VariableController.get(), | |||
// SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), | ||||
// m_VisualizationController.get(), | ||||
// SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); | ||||
r437 | ||||
r193 | ||||
r1348 | m_DataSourceController.moveToThread(&m_DataSourceControllerThread); | |||
r429 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | |||
r1348 | m_NetworkController.moveToThread(&m_NetworkControllerThread); | |||
r429 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); | |||
r1348 | m_VisualizationController.moveToThread(&m_VisualizationControllerThread); | |||
r429 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |||
r374 | ||||
r193 | // Additionnal init | |||
r1406 | // 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(); | ||||
r55 | m_VisualizationControllerThread.quit(); | |||
m_VisualizationControllerThread.wait(); | ||||
r22 | } | |||
r21 | ||||
r1348 | DataSourceController m_DataSourceController; | |||
std::shared_ptr<VariableController2> m_VariableController; | ||||
TimeController m_TimeController; | ||||
NetworkController m_NetworkController; | ||||
VisualizationController m_VisualizationController; | ||||
CatalogueController m_CatalogueController; | ||||
r1076 | ||||
r21 | QThread m_DataSourceControllerThread; | |||
r339 | QThread m_NetworkControllerThread; | |||
r55 | QThread m_VisualizationControllerThread; | |||
r837 | ||||
r1348 | DragDropGuiController m_DragDropGuiController; | |||
ActionsGuiController m_ActionsGuiController; | ||||
r957 | ||||
SqpApplication::PlotsInteractionMode m_PlotInterractionMode; | ||||
SqpApplication::PlotsCursorMode m_PlotCursorMode; | ||||
r21 | }; | |||
r1406 | SqpApplication::SqpApplication(int& argc, char** argv) | |||
: QApplication { argc, argv }, impl { spimpl::make_unique_impl<SqpApplicationPrivate>() } | ||||
r21 | { | |||
r1462 | this->setStyle(new MyProxyStyle(this->style())); | |||
r389 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); | |||
r21 | ||||
r1320 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | |||
r1406 | connect(&impl->m_DataSourceControllerThread, &QThread::started, &impl->m_DataSourceController, | |||
&DataSourceController::initialize); | ||||
connect(&impl->m_DataSourceControllerThread, &QThread::finished, &impl->m_DataSourceController, | ||||
&DataSourceController::finalize); | ||||
r21 | ||||
r1348 | connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController, | |||
r1406 | &NetworkController::initialize); | |||
r1348 | connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController, | |||
r1406 | &NetworkController::finalize); | |||
r339 | ||||
r55 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |||
r1406 | &impl->m_VisualizationController, &VisualizationController::initialize); | |||
r55 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |||
r1406 | &impl->m_VisualizationController, &VisualizationController::finalize); | |||
r53 | ||||
r21 | impl->m_DataSourceControllerThread.start(); | |||
r339 | impl->m_NetworkControllerThread.start(); | |||
r55 | impl->m_VisualizationControllerThread.start(); | |||
r1406 | // impl->m_CatalogueController.initialize(); | |||
r21 | } | |||
r1406 | SqpApplication::~SqpApplication() {} | |||
r21 | ||||
r1406 | void SqpApplication::initialize() {} | |||
Alexandre Leroux
|
r33 | |||
r1406 | DataSourceController& SqpApplication::dataSourceController() noexcept | |||
Alexandre Leroux
|
r33 | { | ||
r1348 | return impl->m_DataSourceController; | |||
Alexandre Leroux
|
r33 | } | ||
r53 | ||||
r1406 | NetworkController& SqpApplication::networkController() noexcept | |||
r339 | { | |||
r1348 | return impl->m_NetworkController; | |||
r339 | } | |||
r1406 | TimeController& SqpApplication::timeController() noexcept | |||
r193 | { | |||
r1348 | return impl->m_TimeController; | |||
r193 | } | |||
r1406 | VariableController2& SqpApplication::variableController() noexcept | |||
Alexandre Leroux
|
r111 | { | ||
return *impl->m_VariableController; | ||||
} | ||||
r1348 | std::shared_ptr<VariableController2> SqpApplication::variableControllerOwner() noexcept | |||
{ | ||||
return impl->m_VariableController; | ||||
} | ||||
r1406 | // VariableModel2 &SqpApplication::variableModel() noexcept | |||
r1348 | //{ | |||
// return impl->m_VariableModel; | ||||
//} | ||||
r1406 | VisualizationController& SqpApplication::visualizationController() noexcept | |||
r53 | { | |||
r1348 | return impl->m_VisualizationController; | |||
r53 | } | |||
r837 | ||||
r1406 | CatalogueController& SqpApplication::catalogueController() noexcept | |||
r1144 | { | |||
r1348 | return impl->m_CatalogueController; | |||
r1144 | } | |||
r1406 | DragDropGuiController& SqpApplication::dragDropGuiController() noexcept | |||
r837 | { | |||
r1348 | return impl->m_DragDropGuiController; | |||
r837 | } | |||
r957 | ||||
r1406 | ActionsGuiController& SqpApplication::actionsGuiController() noexcept | |||
r1076 | { | |||
r1348 | return impl->m_ActionsGuiController; | |||
r1076 | } | |||
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; | ||||
} | ||||