##// END OF EJS Templates
Merge pull request 146 from SCIQLOP-Initialisation develop...
leroux -
r117:27ad8f53ca07 merge
parent child
Show More
@@ -0,0 +1,20
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
4 #include <QString>
5
6 /**
7 * @brief The Variable struct represents a variable in SciQlop.
8 */
9 struct Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
12 {
13 }
14
15 QString m_Name;
16 QString m_Unit;
17 QString m_Mission;
18 };
19
20 #endif // SCIQLOP_VARIABLE_H
@@ -0,0 +1,39
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
3
4 #include <QLoggingCategory>
5 #include <QObject>
6
7 #include <Common/spimpl.h>
8
9 class Variable;
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
11
12 /**
13 * @brief The VariableController class aims to handle the variables in SciQlop.
14 */
15 class VariableController : public QObject {
16 Q_OBJECT
17 public:
18 explicit VariableController(QObject *parent = 0);
19 virtual ~VariableController();
20
21 /**
22 * Creates a new variable
23 * @param name the name of the new variable
24 * @return the variable if it was created successfully, nullptr otherwise
25 */
26 Variable *createVariable(const QString &name) noexcept;
27
28 public slots:
29 void initialize();
30 void finalize();
31
32 private:
33 void waitForFinish();
34
35 class VariableControllerPrivate;
36 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
37 };
38
39 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -0,0 +1,31
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
4 #include <Common/spimpl.h>
5
6 #include <QLoggingCategory>
7
8 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
9
10 class Variable;
11
12 /**
13 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
14 */
15 class VariableModel {
16 public:
17 explicit VariableModel();
18
19 /**
20 * Creates a new variable in the model
21 * @param name the name of the new variable
22 * @return the variable if it was created successfully, nullptr otherwise
23 */
24 Variable *createVariable(const QString &name) noexcept;
25
26 private:
27 class VariableModelPrivate;
28 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
29 };
30
31 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -0,0 +1,53
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableModel.h>
3
4 #include <QMutex>
5 #include <QThread>
6
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8
9 struct VariableController::VariableControllerPrivate {
10 explicit VariableControllerPrivate()
11 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
12 {
13 }
14
15 QMutex m_WorkingMutex;
16 std::unique_ptr<VariableModel> m_VariableModel;
17 };
18
19 VariableController::VariableController(QObject *parent)
20 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
21 {
22 qCDebug(LOG_VariableController())
23 << tr("VariableController construction") << QThread::currentThread();
24 }
25
26 VariableController::~VariableController()
27 {
28 qCDebug(LOG_VariableController())
29 << tr("VariableController destruction") << QThread::currentThread();
30 this->waitForFinish();
31 }
32
33 Variable *VariableController::createVariable(const QString &name) noexcept
34 {
35 return impl->m_VariableModel->createVariable(name);
36 }
37
38 void VariableController::initialize()
39 {
40 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
41 impl->m_WorkingMutex.lock();
42 qCDebug(LOG_VariableController()) << tr("VariableController init END");
43 }
44
45 void VariableController::finalize()
46 {
47 impl->m_WorkingMutex.unlock();
48 }
49
50 void VariableController::waitForFinish()
51 {
52 QMutexLocker locker{&impl->m_WorkingMutex};
53 }
@@ -0,0 +1,24
1 #include <Variable/VariableModel.h>
2
3 #include <Variable/Variable.h>
4
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
7 struct VariableModel::VariableModelPrivate {
8 /// Variables created in SciQlop
9 std::vector<std::unique_ptr<Variable> > m_Variables;
10 };
11
12 VariableModel::VariableModel() : impl{spimpl::make_unique_impl<VariableModelPrivate>()}
13 {
14 }
15
16 Variable *VariableModel::createVariable(const QString &name) noexcept
17 {
18 /// @todo For the moment, the other data of the variable is initialized with default values
19 auto variable
20 = std::make_unique<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
21 impl->m_Variables.push_back(std::move(variable));
22
23 return impl->m_Variables.back().get();
24 }
@@ -0,0 +1,26
1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class VariableInspectorWidget;
8 } // Ui
9
10 /**
11 * @brief The VariableInspectorWidget class representes represents the variable inspector, from
12 * which it is possible to view the loaded variables, handle them or trigger their display in
13 * visualization
14 */
15 class VariableInspectorWidget : public QWidget {
16 Q_OBJECT
17
18 public:
19 explicit VariableInspectorWidget(QWidget *parent = 0);
20 virtual ~VariableInspectorWidget();
21
22 private:
23 Ui::VariableInspectorWidget *ui;
24 };
25
26 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
@@ -0,0 +1,14
1 #include <Variable/VariableInspectorWidget.h>
2
3 #include <ui_VariableInspectorWidget.h>
4
5 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
6 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
7 {
8 ui->setupUi(this);
9 }
10
11 VariableInspectorWidget::~VariableInspectorWidget()
12 {
13 delete ui;
14 }
@@ -0,0 +1,31
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>VariableInspectorWidget</class>
4 <widget class="QWidget" name="VariableInspectorWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Variables</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QTableView" name="tableView">
19 <property name="sortingEnabled">
20 <bool>true</bool>
21 </property>
22 <attribute name="horizontalHeaderStretchLastSection">
23 <bool>true</bool>
24 </attribute>
25 </widget>
26 </item>
27 </layout>
28 </widget>
29 <resources/>
30 <connections/>
31 </ui>
@@ -77,7 +77,7
77 77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 78 </item>
79 79 <item>
80 <widget class="QWidget" name="variableInspectorWidget" native="true"/>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 81 </item>
82 82 </layout>
83 83 </widget>
@@ -126,7 +126,7
126 126 <x>0</x>
127 127 <y>0</y>
128 128 <width>800</width>
129 <height>28</height>
129 <height>26</height>
130 130 </rect>
131 131 </property>
132 132 </widget>
@@ -152,6 +152,12
152 152 <header location="global">DataSource/DataSourceWidget.h</header>
153 153 <container>1</container>
154 154 </customwidget>
155 <customwidget>
156 <class>VariableInspectorWidget</class>
157 <extends>QWidget</extends>
158 <header location="global">Variable/VariableInspectorWidget.h</header>
159 <container>1</container>
160 </customwidget>
155 161 </customwidgets>
156 162 <resources/>
157 163 <connections/>
@@ -1,10 +1,12
1 1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
2 2 #define SCIQLOP_DATASOURCEWIDGET_H
3 3
4 #include <Common/spimpl.h>
5
6 4 #include <QWidget>
7 5
6 namespace Ui {
7 class DataSourceWidget;
8 } // Ui
9
8 10 class DataSourceItem;
9 11
10 12 /**
@@ -26,8 +28,7 public slots:
26 28 void addDataSource(DataSourceItem *dataSource) noexcept;
27 29
28 30 private:
29 class DataSourceWidgetPrivate;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
31 Ui::DataSourceWidget *ui;
31 32 };
32 33
33 34 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -16,6 +16,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
16 16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17 17
18 18 class DataSourceController;
19 class VariableController;
19 20 class VisualizationController;
20 21
21 22 /**
@@ -35,8 +36,9 public:
35 36 void initialize();
36 37
37 38 /// Accessors for the differents sciqlop controllers
38 DataSourceController &dataSourceController() const noexcept;
39 VisualizationController &visualizationController() const noexcept;
39 DataSourceController &dataSourceController() noexcept;
40 VariableController &variableController() noexcept;
41 VisualizationController &visualizationController() noexcept;
40 42
41 43 private:
42 44 class SqpApplicationPrivate;
@@ -33,24 +33,13 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
33 33
34 34 } // namespace
35 35
36 class DataSourceWidget::DataSourceWidgetPrivate {
37 public:
38 explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
39 : m_Ui{std::make_unique<Ui::DataSourceWidget>()}
36 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
40 37 {
41 m_Ui->setupUi(&widget);
38 ui->setupUi(this);
42 39
43 40 // Set tree properties
44 m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
45 m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
46 }
47
48 std::unique_ptr<Ui::DataSourceWidget> m_Ui;
49 };
50
51 DataSourceWidget::DataSourceWidget(QWidget *parent)
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
53 {
41 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
42 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
54 43 }
55 44
56 45 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
@@ -58,6 +47,6 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
58 47 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 48 // takes the ownership of the item
60 49 if (dataSource) {
61 impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
50 ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
62 51 }
63 52 }
@@ -2,6 +2,7
2 2
3 3 #include <DataSource/DataSourceController.h>
4 4 #include <QThread>
5 #include <Variable/VariableController.h>
5 6 #include <Visualization/VisualizationController.h>
6 7
7 8 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
@@ -10,9 +11,11 class SqpApplication::SqpApplicationPrivate {
10 11 public:
11 12 SqpApplicationPrivate()
12 13 : m_DataSourceController{std::make_unique<DataSourceController>()},
14 m_VariableController{std::make_unique<VariableController>()},
13 15 m_VisualizationController{std::make_unique<VisualizationController>()}
14 16 {
15 17 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
18 m_VariableController->moveToThread(&m_VariableControllerThread);
16 19 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
17 20 }
18 21
@@ -22,13 +25,18 public:
22 25 m_DataSourceControllerThread.quit();
23 26 m_DataSourceControllerThread.wait();
24 27
28 m_VariableControllerThread.quit();
29 m_VariableControllerThread.wait();
30
25 31 m_VisualizationControllerThread.quit();
26 32 m_VisualizationControllerThread.wait();
27 33 }
28 34
29 35 std::unique_ptr<DataSourceController> m_DataSourceController;
36 std::unique_ptr<VariableController> m_VariableController;
30 37 std::unique_ptr<VisualizationController> m_VisualizationController;
31 38 QThread m_DataSourceControllerThread;
39 QThread m_VariableControllerThread;
32 40 QThread m_VisualizationControllerThread;
33 41 };
34 42
@@ -43,6 +51,11 SqpApplication::SqpApplication(int &argc, char **argv)
43 51 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
44 52 impl->m_DataSourceController.get(), &DataSourceController::finalize);
45 53
54 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
55 &VariableController::initialize);
56 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
57 &VariableController::finalize);
58
46 59 connect(&impl->m_VisualizationControllerThread, &QThread::started,
47 60 impl->m_VisualizationController.get(), &VisualizationController::initialize);
48 61 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
@@ -50,6 +63,7 SqpApplication::SqpApplication(int &argc, char **argv)
50 63
51 64
52 65 impl->m_DataSourceControllerThread.start();
66 impl->m_VariableControllerThread.start();
53 67 impl->m_VisualizationControllerThread.start();
54 68 }
55 69
@@ -61,12 +75,17 void SqpApplication::initialize()
61 75 {
62 76 }
63 77
64 DataSourceController &SqpApplication::dataSourceController() const noexcept
78 DataSourceController &SqpApplication::dataSourceController() noexcept
65 79 {
66 80 return *impl->m_DataSourceController;
67 81 }
68 82
69 VisualizationController &SqpApplication::visualizationController() const noexcept
83 VariableController &SqpApplication::variableController() noexcept
84 {
85 return *impl->m_VariableController;
86 }
87
88 VisualizationController &SqpApplication::visualizationController() noexcept
70 89 {
71 90 return *impl->m_VisualizationController;
72 91 }
General Comments 0
You need to be logged in to leave comments. Login now