##// 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>
@@ -1,158 +1,164
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>MainWindow</class>
4 4 <widget class="QMainWindow" name="MainWindow">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>800</width>
10 10 <height>600</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>QLop</string>
15 15 </property>
16 16 <property name="dockNestingEnabled">
17 17 <bool>true</bool>
18 18 </property>
19 19 <widget class="QWidget" name="centralWidget">
20 20 <property name="enabled">
21 21 <bool>true</bool>
22 22 </property>
23 23 <property name="sizePolicy">
24 24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 25 <horstretch>0</horstretch>
26 26 <verstretch>0</verstretch>
27 27 </sizepolicy>
28 28 </property>
29 29 <property name="maximumSize">
30 30 <size>
31 31 <width>16777215</width>
32 32 <height>16777215</height>
33 33 </size>
34 34 </property>
35 35 <layout class="QHBoxLayout" name="horizontalLayout">
36 36 <property name="spacing">
37 37 <number>0</number>
38 38 </property>
39 39 <property name="leftMargin">
40 40 <number>0</number>
41 41 </property>
42 42 <property name="topMargin">
43 43 <number>0</number>
44 44 </property>
45 45 <property name="rightMargin">
46 46 <number>0</number>
47 47 </property>
48 48 <property name="bottomMargin">
49 49 <number>0</number>
50 50 </property>
51 51 <item>
52 52 <widget class="QSplitter" name="splitter">
53 53 <property name="orientation">
54 54 <enum>Qt::Horizontal</enum>
55 55 </property>
56 56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 57 <layout class="QVBoxLayout" name="verticalLayout">
58 58 <property name="spacing">
59 59 <number>0</number>
60 60 </property>
61 61 <property name="leftMargin">
62 62 <number>0</number>
63 63 </property>
64 64 <property name="topMargin">
65 65 <number>0</number>
66 66 </property>
67 67 <property name="rightMargin">
68 68 <number>0</number>
69 69 </property>
70 70 <property name="bottomMargin">
71 71 <number>0</number>
72 72 </property>
73 73 <item>
74 74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 75 </item>
76 76 <item>
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>
84 84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 85 <widget class="VisualizationWidget" name="view" native="true">
86 86 <property name="sizePolicy">
87 87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 88 <horstretch>0</horstretch>
89 89 <verstretch>0</verstretch>
90 90 </sizepolicy>
91 91 </property>
92 92 </widget>
93 93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 95 <layout class="QVBoxLayout" name="verticalLayout_3">
96 96 <property name="spacing">
97 97 <number>0</number>
98 98 </property>
99 99 <property name="leftMargin">
100 100 <number>0</number>
101 101 </property>
102 102 <property name="topMargin">
103 103 <number>0</number>
104 104 </property>
105 105 <property name="rightMargin">
106 106 <number>0</number>
107 107 </property>
108 108 <property name="bottomMargin">
109 109 <number>0</number>
110 110 </property>
111 111 <item>
112 112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 113 </item>
114 114 <item>
115 115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
116 116 </item>
117 117 </layout>
118 118 </widget>
119 119 </widget>
120 120 </item>
121 121 </layout>
122 122 </widget>
123 123 <widget class="QMenuBar" name="menuBar">
124 124 <property name="geometry">
125 125 <rect>
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>
133 133 <widget class="QStatusBar" name="statusBar"/>
134 134 </widget>
135 135 <layoutdefault spacing="6" margin="11"/>
136 136 <customwidgets>
137 137 <customwidget>
138 138 <class>VisualizationWidget</class>
139 139 <extends>QWidget</extends>
140 140 <header location="global">Visualization/VisualizationWidget.h</header>
141 141 <container>1</container>
142 142 </customwidget>
143 143 <customwidget>
144 144 <class>SqpSidePane</class>
145 145 <extends>QWidget</extends>
146 146 <header location="global">SidePane/SqpSidePane.h</header>
147 147 <container>1</container>
148 148 </customwidget>
149 149 <customwidget>
150 150 <class>DataSourceWidget</class>
151 151 <extends>QWidget</extends>
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/>
158 164 </ui>
@@ -1,33 +1,34
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 /**
11 13 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
12 14 * attached to SciQlop.
13 15 */
14 16 class DataSourceWidget : public QWidget {
15 17 Q_OBJECT
16 18
17 19 public:
18 20 explicit DataSourceWidget(QWidget *parent = 0);
19 21
20 22 public slots:
21 23 /**
22 24 * Adds a data source. An item associated to the data source is created and then added to the
23 25 * representation tree
24 26 * @param dataSource the data source to add. The pointer has to be not null
25 27 */
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
@@ -1,46 +1,48
1 1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 2 #define SCIQLOP_SQPAPPLICATION_H
3 3
4 4 #include "SqpApplication.h"
5 5
6 6 #include <QApplication>
7 7 #include <QLoggingCategory>
8 8
9 9 #include <Common/spimpl.h>
10 10
11 11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12 12
13 13 #if defined(sqpApp)
14 14 #undef sqpApp
15 15 #endif
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 /**
22 23 * @brief The SqpApplication class aims to make the link between SciQlop
23 24 * and its plugins. This is the intermediate class that SciQlop has to use
24 25 * in the way to connect a data source. Please first use load method to initialize
25 26 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 27 * method will be able to access it.
27 28 * You can load a data source driver plugin then create a data source.
28 29 */
29 30
30 31 class SqpApplication : public QApplication {
31 32 Q_OBJECT
32 33 public:
33 34 explicit SqpApplication(int &argc, char **argv);
34 35 virtual ~SqpApplication();
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;
43 45 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
44 46 };
45 47
46 48 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,63 +1,52
1 1 #include <DataSource/DataSourceWidget.h>
2 2
3 3 #include <ui_DataSourceWidget.h>
4 4
5 5 #include <DataSource/DataSourceItem.h>
6 6 #include <DataSource/DataSourceTreeWidgetItem.h>
7 7
8 8 namespace {
9 9
10 10 /// Number of columns displayed in the tree
11 11 const auto TREE_NB_COLUMNS = 1;
12 12
13 13 /// Header labels for the tree
14 14 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
15 15
16 16 /**
17 17 * Creates the item associated to a data source
18 18 * @param dataSource the data source for which to create the item
19 19 * @return the new item
20 20 */
21 21 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
22 22 {
23 23 // Creates item for the data source
24 24 auto item = new DataSourceTreeWidgetItem{dataSource};
25 25
26 26 // Generates items for the children of the data source
27 27 for (auto i = 0; i < dataSource->childCount(); ++i) {
28 28 item->addChild(createTreeWidgetItem(dataSource->child(i)));
29 29 }
30 30
31 31 return item;
32 32 }
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>()}
40 {
41 m_Ui->setupUi(&widget);
42
43 // 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)}
36 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
53 37 {
38 ui->setupUi(this);
39
40 // Set tree properties
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
57 46 {
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 }
@@ -1,72 +1,91
1 1 #include "SqpApplication.h"
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")
8 9
9 10 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
19 22 virtual ~SqpApplicationPrivate()
20 23 {
21 24 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
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
35 43
36 44 SqpApplication::SqpApplication(int &argc, char **argv)
37 45 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
38 46 {
39 47 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
40 48
41 49 connect(&impl->m_DataSourceControllerThread, &QThread::started,
42 50 impl->m_DataSourceController.get(), &DataSourceController::initialize);
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,
49 62 impl->m_VisualizationController.get(), &VisualizationController::finalize);
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
56 70 SqpApplication::~SqpApplication()
57 71 {
58 72 }
59 73
60 74 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