@@ -1,43 +1,44 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H | |
2 | #define SCIQLOP_VISUALIZATIONCONTROLLER_H |
|
2 | #define SCIQLOP_VISUALIZATIONCONTROLLER_H | |
3 |
|
3 | |||
4 | #include <QLoggingCategory> |
|
4 | #include <QLoggingCategory> | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QUuid> |
|
6 | #include <QUuid> | |
7 |
|
7 | |||
8 | #include <Common/spimpl.h> |
|
8 | #include <Common/spimpl.h> | |
9 |
|
9 | |||
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController) |
|
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController) | |
11 |
|
11 | |||
12 | class DataSourceItem; |
|
12 | class DataSourceItem; | |
13 | class Variable; |
|
13 | class Variable; | |
14 |
|
14 | |||
15 | /** |
|
15 | /** | |
16 | * @brief The VisualizationController class aims to make the link between SciQlop and its plugins. |
|
16 | * @brief The VisualizationController class aims to make the link between SciQlop and its plugins. | |
17 | * This is the intermediate class that SciQlop has to use in the way to connect a data source. |
|
17 | * This is the intermediate class that SciQlop has to use in the way to connect a data source. | |
18 | * Please first use register method to initialize a plugin specified by its metadata name (JSON |
|
18 | * Please first use register method to initialize a plugin specified by its metadata name (JSON | |
19 | * plugin source) then others specifics method will be able to access it. You can load a data source |
|
19 | * plugin source) then others specifics method will be able to access it. You can load a data source | |
20 | * driver plugin then create a data source. |
|
20 | * driver plugin then create a data source. | |
21 | */ |
|
21 | */ | |
22 | class VisualizationController : public QObject { |
|
22 | class VisualizationController : public QObject { | |
23 | Q_OBJECT |
|
23 | Q_OBJECT | |
24 | public: |
|
24 | public: | |
25 | explicit VisualizationController(QObject *parent = 0); |
|
25 | explicit VisualizationController(QObject *parent = 0); | |
26 | virtual ~VisualizationController(); |
|
26 | virtual ~VisualizationController(); | |
27 |
|
27 | |||
28 | public slots: |
|
28 | signals: | |
29 |
/// S |
|
29 | /// Signal emitted when a variable has been created in SciQlop | |
30 |
void |
|
30 | void variableCreated(std::shared_ptr<Variable> variable); | |
31 |
|
31 | |||
|
32 | public slots: | |||
32 | /// Manage init/end of the controller |
|
33 | /// Manage init/end of the controller | |
33 | void initialize(); |
|
34 | void initialize(); | |
34 | void finalize(); |
|
35 | void finalize(); | |
35 |
|
36 | |||
36 | private: |
|
37 | private: | |
37 | void waitForFinish(); |
|
38 | void waitForFinish(); | |
38 |
|
39 | |||
39 | class VisualizationControllerPrivate; |
|
40 | class VisualizationControllerPrivate; | |
40 | spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl; |
|
41 | spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl; | |
41 | }; |
|
42 | }; | |
42 |
|
43 | |||
43 | #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H |
|
44 | #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H |
@@ -1,54 +1,48 | |||||
1 | #include <Visualization/VisualizationController.h> |
|
1 | #include <Visualization/VisualizationController.h> | |
2 |
|
2 | |||
3 | #include <Variable/Variable.h> |
|
3 | #include <Variable/Variable.h> | |
4 |
|
4 | |||
5 | #include <QMutex> |
|
5 | #include <QMutex> | |
6 | #include <QThread> |
|
6 | #include <QThread> | |
7 |
|
7 | |||
8 | #include <QDir> |
|
8 | #include <QDir> | |
9 | #include <QStandardPaths> |
|
9 | #include <QStandardPaths> | |
10 |
|
10 | |||
11 | Q_LOGGING_CATEGORY(LOG_VisualizationController, "VisualizationController") |
|
11 | Q_LOGGING_CATEGORY(LOG_VisualizationController, "VisualizationController") | |
12 |
|
12 | |||
13 | class VisualizationController::VisualizationControllerPrivate { |
|
13 | class VisualizationController::VisualizationControllerPrivate { | |
14 | public: |
|
14 | public: | |
15 | QMutex m_WorkingMutex; |
|
15 | QMutex m_WorkingMutex; | |
16 | }; |
|
16 | }; | |
17 |
|
17 | |||
18 | VisualizationController::VisualizationController(QObject *parent) |
|
18 | VisualizationController::VisualizationController(QObject *parent) | |
19 | : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()} |
|
19 | : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()} | |
20 | { |
|
20 | { | |
21 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController construction") |
|
21 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController construction") | |
22 | << QThread::currentThread(); |
|
22 | << QThread::currentThread(); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | VisualizationController::~VisualizationController() |
|
25 | VisualizationController::~VisualizationController() | |
26 | { |
|
26 | { | |
27 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController destruction") |
|
27 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController destruction") | |
28 | << QThread::currentThread(); |
|
28 | << QThread::currentThread(); | |
29 | this->waitForFinish(); |
|
29 | this->waitForFinish(); | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | void VisualizationController::onVariableCreated(std::shared_ptr<Variable> variable) noexcept |
|
|||
33 | { |
|
|||
34 | /// @todo ALX : make new graph for the variable |
|
|||
35 | qCDebug(LOG_VisualizationController()) << "new variable to display"; |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | void VisualizationController::initialize() |
|
32 | void VisualizationController::initialize() | |
39 | { |
|
33 | { | |
40 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init") |
|
34 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init") | |
41 | << QThread::currentThread(); |
|
35 | << QThread::currentThread(); | |
42 | impl->m_WorkingMutex.lock(); |
|
36 | impl->m_WorkingMutex.lock(); | |
43 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END"); |
|
37 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END"); | |
44 | } |
|
38 | } | |
45 |
|
39 | |||
46 | void VisualizationController::finalize() |
|
40 | void VisualizationController::finalize() | |
47 | { |
|
41 | { | |
48 | impl->m_WorkingMutex.unlock(); |
|
42 | impl->m_WorkingMutex.unlock(); | |
49 | } |
|
43 | } | |
50 |
|
44 | |||
51 | void VisualizationController::waitForFinish() |
|
45 | void VisualizationController::waitForFinish() | |
52 | { |
|
46 | { | |
53 | QMutexLocker locker{&impl->m_WorkingMutex}; |
|
47 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
54 | } |
|
48 | } |
@@ -1,109 +1,109 | |||||
1 | #include "SqpApplication.h" |
|
1 | #include "SqpApplication.h" | |
2 |
|
2 | |||
3 | #include <Data/IDataProvider.h> |
|
3 | #include <Data/IDataProvider.h> | |
4 | #include <DataSource/DataSourceController.h> |
|
4 | #include <DataSource/DataSourceController.h> | |
5 | #include <QThread> |
|
5 | #include <QThread> | |
6 | #include <Variable/Variable.h> |
|
6 | #include <Variable/Variable.h> | |
7 | #include <Variable/VariableController.h> |
|
7 | #include <Variable/VariableController.h> | |
8 | #include <Visualization/VisualizationController.h> |
|
8 | #include <Visualization/VisualizationController.h> | |
9 |
|
9 | |||
10 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
10 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
11 |
|
11 | |||
12 | class SqpApplication::SqpApplicationPrivate { |
|
12 | class SqpApplication::SqpApplicationPrivate { | |
13 | public: |
|
13 | public: | |
14 | SqpApplicationPrivate() |
|
14 | SqpApplicationPrivate() | |
15 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
15 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
16 | m_VariableController{std::make_unique<VariableController>()}, |
|
16 | m_VariableController{std::make_unique<VariableController>()}, | |
17 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
17 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
18 | { |
|
18 | { | |
19 | // /////////////////////////////// // |
|
19 | // /////////////////////////////// // | |
20 | // Connections between controllers // |
|
20 | // Connections between controllers // | |
21 | // /////////////////////////////// // |
|
21 | // /////////////////////////////// // | |
22 |
|
22 | |||
23 | // VariableController <-> DataSourceController |
|
23 | // VariableController <-> DataSourceController | |
24 | qRegisterMetaType<std::shared_ptr<IDataProvider> >(); |
|
24 | qRegisterMetaType<std::shared_ptr<IDataProvider> >(); | |
25 | connect(m_DataSourceController.get(), |
|
25 | connect(m_DataSourceController.get(), | |
26 | SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)), |
|
26 | SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)), | |
27 | m_VariableController.get(), |
|
27 | m_VariableController.get(), | |
28 | SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>))); |
|
28 | SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>))); | |
29 |
|
29 | |||
30 | // VariableController <-> VisualizationController |
|
30 | // VariableController <-> VisualizationController | |
31 | qRegisterMetaType<std::shared_ptr<Variable> >(); |
|
31 | qRegisterMetaType<std::shared_ptr<Variable> >(); | |
32 | connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), |
|
32 | connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), | |
33 | m_VisualizationController.get(), |
|
33 | m_VisualizationController.get(), | |
34 |
SL |
|
34 | SIGNAL(variableCreated(std::shared_ptr<Variable>))); | |
35 |
|
35 | |||
36 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
36 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
37 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
37 | m_VariableController->moveToThread(&m_VariableControllerThread); | |
38 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
38 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | virtual ~SqpApplicationPrivate() |
|
41 | virtual ~SqpApplicationPrivate() | |
42 | { |
|
42 | { | |
43 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); |
|
43 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | |
44 | m_DataSourceControllerThread.quit(); |
|
44 | m_DataSourceControllerThread.quit(); | |
45 | m_DataSourceControllerThread.wait(); |
|
45 | m_DataSourceControllerThread.wait(); | |
46 |
|
46 | |||
47 | m_VariableControllerThread.quit(); |
|
47 | m_VariableControllerThread.quit(); | |
48 | m_VariableControllerThread.wait(); |
|
48 | m_VariableControllerThread.wait(); | |
49 |
|
49 | |||
50 | m_VisualizationControllerThread.quit(); |
|
50 | m_VisualizationControllerThread.quit(); | |
51 | m_VisualizationControllerThread.wait(); |
|
51 | m_VisualizationControllerThread.wait(); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
54 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
55 | std::unique_ptr<VariableController> m_VariableController; |
|
55 | std::unique_ptr<VariableController> m_VariableController; | |
56 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
56 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
57 | QThread m_DataSourceControllerThread; |
|
57 | QThread m_DataSourceControllerThread; | |
58 | QThread m_VariableControllerThread; |
|
58 | QThread m_VariableControllerThread; | |
59 | QThread m_VisualizationControllerThread; |
|
59 | QThread m_VisualizationControllerThread; | |
60 | }; |
|
60 | }; | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
63 | SqpApplication::SqpApplication(int &argc, char **argv) | |
64 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
64 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
65 | { |
|
65 | { | |
66 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); |
|
66 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); | |
67 |
|
67 | |||
68 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
68 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
69 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
69 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
70 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
70 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
71 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
71 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
72 |
|
72 | |||
73 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
73 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |
74 | &VariableController::initialize); |
|
74 | &VariableController::initialize); | |
75 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
75 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |
76 | &VariableController::finalize); |
|
76 | &VariableController::finalize); | |
77 |
|
77 | |||
78 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
78 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
79 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
79 | impl->m_VisualizationController.get(), &VisualizationController::initialize); | |
80 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
80 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
81 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
81 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
82 |
|
82 | |||
83 | impl->m_DataSourceControllerThread.start(); |
|
83 | impl->m_DataSourceControllerThread.start(); | |
84 | impl->m_VariableControllerThread.start(); |
|
84 | impl->m_VariableControllerThread.start(); | |
85 | impl->m_VisualizationControllerThread.start(); |
|
85 | impl->m_VisualizationControllerThread.start(); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | SqpApplication::~SqpApplication() |
|
88 | SqpApplication::~SqpApplication() | |
89 | { |
|
89 | { | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | void SqpApplication::initialize() |
|
92 | void SqpApplication::initialize() | |
93 | { |
|
93 | { | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | DataSourceController &SqpApplication::dataSourceController() noexcept |
|
96 | DataSourceController &SqpApplication::dataSourceController() noexcept | |
97 | { |
|
97 | { | |
98 | return *impl->m_DataSourceController; |
|
98 | return *impl->m_DataSourceController; | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | VariableController &SqpApplication::variableController() noexcept |
|
101 | VariableController &SqpApplication::variableController() noexcept | |
102 | { |
|
102 | { | |
103 | return *impl->m_VariableController; |
|
103 | return *impl->m_VariableController; | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | VisualizationController &SqpApplication::visualizationController() noexcept |
|
106 | VisualizationController &SqpApplication::visualizationController() noexcept | |
107 | { |
|
107 | { | |
108 | return *impl->m_VisualizationController; |
|
108 | return *impl->m_VisualizationController; | |
109 | } |
|
109 | } |
General Comments 0
You need to be logged in to leave comments.
Login now