##// END OF EJS Templates
Merge branch 'feature/SettingsWidget' into develop
Alexandre Leroux -
r472:6b7a5db1522f merge
parent child
Show More
@@ -0,0 +1,12
1 #ifndef SCIQLOP_COREGLOBAL_H
2 #define SCIQLOP_COREGLOBAL_H
3
4 #include <QtCore/QtGlobal>
5
6 #ifdef CORE_LIB
7 #define SCIQLOP_CORE_EXPORT Q_DECL_EXPORT
8 #else
9 #define SCIQLOP_CORE_EXPORT Q_DECL_IMPORT
10 #endif
11
12 #endif // SCIQLOP_COREGLOBAL_H
@@ -0,0 +1,21
1 #ifndef SCIQLOP_ISQPSETTINGSBINDABLE_H
2 #define SCIQLOP_ISQPSETTINGSBINDABLE_H
3
4 #include <QSettings>
5
6 /**
7 * @brief The ISqpSettingsBindable interface represents an object that can bind a variable
8 */
9 class ISqpSettingsBindable {
10
11 public:
12 virtual ~ISqpSettingsBindable() = default;
13
14 /// Loads settings into the object
15 virtual void loadSettings() = 0;
16
17 /// Saves settings from the object
18 virtual void saveSettings() const = 0;
19 };
20
21 #endif // SCIQLOP_ISQPSETTINGSBINDABLE_H
@@ -0,0 +1,18
1 #ifndef SCIQLOP_SQPSETTINGSDEFS_H
2 #define SCIQLOP_SQPSETTINGSDEFS_H
3
4 #include "CoreGlobal.h"
5
6 #include <QString>
7
8 // //////////////// //
9 // General settings //
10 // //////////////// //
11
12 extern SCIQLOP_CORE_EXPORT const QString GENERAL_TOLERANCE_AT_INIT_KEY;
13 extern SCIQLOP_CORE_EXPORT const double GENERAL_TOLERANCE_AT_INIT_DEFAULT_VALUE;
14
15 extern SCIQLOP_CORE_EXPORT const QString GENERAL_TOLERANCE_AT_UPDATE_KEY;
16 extern SCIQLOP_CORE_EXPORT const double GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE;
17
18 #endif // SCIQLOP_SQPSETTINGSDEFS_H
@@ -0,0 +1,7
1 #include "Settings/SqpSettingsDefs.h"
2
3 const QString GENERAL_TOLERANCE_AT_INIT_KEY = QStringLiteral("toleranceInit");
4 const double GENERAL_TOLERANCE_AT_INIT_DEFAULT_VALUE = 0.2;
5
6 const QString GENERAL_TOLERANCE_AT_UPDATE_KEY = QStringLiteral("toleranceUpdate");
7 const double GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE = 0.2;
@@ -0,0 +1,40
1 #ifndef SCIQLOP_SQPSETTINGSDIALOG_H
2 #define SCIQLOP_SQPSETTINGSDIALOG_H
3
4 #include "Settings/ISqpSettingsBindable.h"
5
6 #include <QDialog>
7
8 namespace Ui {
9 class SqpSettingsDialog;
10 } // Ui
11
12 /**
13 * @brief The SqpSettingsDialog class represents the dialog in which the parameters of SciQlop are
14 * set
15 */
16 class SqpSettingsDialog : public QDialog, public ISqpSettingsBindable {
17 Q_OBJECT
18
19 public:
20 explicit SqpSettingsDialog(QWidget *parent = 0);
21 virtual ~SqpSettingsDialog() noexcept;
22
23 /// @sa ISqpSettingsBindable::loadSettings()
24 void loadSettings() override final;
25
26 /// @sa ISqpSettingsBindable::saveSettings()
27 void saveSettings() const override final;
28
29 /**
30 * Registers a widget into the dialog
31 * @param name the name under which the widget will appear in the dialog
32 * @param widget the widget to register
33 */
34 void registerWidget(const QString &name, QWidget *widget) noexcept;
35
36 private:
37 Ui::SqpSettingsDialog *ui;
38 };
39
40 #endif // SCIQLOP_SQPSETTINGSDIALOG_H
@@ -0,0 +1,32
1 #ifndef SCIQLOP_SQPSETTINGSGENERALWIDGET_H
2 #define SCIQLOP_SQPSETTINGSGENERALWIDGET_H
3
4 #include "Settings/ISqpSettingsBindable.h"
5
6 #include <QWidget>
7
8 namespace Ui {
9 class SqpSettingsGeneralWidget;
10 } // Ui
11
12 /**
13 * @brief The SqpSettingsGeneralWidget class represents the general settings of SciQlop
14 */
15 class SqpSettingsGeneralWidget : public QWidget, public ISqpSettingsBindable {
16 Q_OBJECT
17
18 public:
19 explicit SqpSettingsGeneralWidget(QWidget *parent = 0);
20 virtual ~SqpSettingsGeneralWidget() noexcept;
21
22 /// @sa ISqpSettingsBindable::loadSettings()
23 void loadSettings() override final;
24
25 /// @sa ISqpSettingsBindable::saveSettings()
26 void saveSettings() const override final;
27
28 private:
29 Ui::SqpSettingsGeneralWidget *ui;
30 };
31
32 #endif // SCIQLOP_SQPSETTINGSGENERALWIDGET_H
@@ -0,0 +1,66
1 #include "Settings/SqpSettingsDialog.h"
2 #include "ui_SqpSettingsDialog.h"
3
4 namespace {
5
6 /**
7 * Performs a bind operation on widgets that can be binded to SciQlop settings
8 * @param widgets
9 * @param bind the bind operation
10 * @sa ISqpSettingsBindable
11 */
12 template <typename BindMethod>
13 void processBind(const QStackedWidget &widgets, BindMethod bind)
14 {
15 auto count = widgets.count();
16 for (auto i = 0; i < count; ++i) {
17 // Performs operation if widget is an ISqpSettingsBindable
18 if (auto sqpSettingsWidget = dynamic_cast<ISqpSettingsBindable *>(widgets.widget(i))) {
19 bind(*sqpSettingsWidget);
20 }
21 }
22 }
23
24 } // namespace
25
26 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
27 : QDialog{parent}, ui{new Ui::SqpSettingsDialog}
28 {
29 ui->setupUi(this);
30
31 // Connection to change the current page to the selection of an entry in the list
32 connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
33 &QStackedWidget::setCurrentIndex);
34 }
35
36 SqpSettingsDialog::~SqpSettingsDialog() noexcept
37 {
38 delete ui;
39 }
40
41 void SqpSettingsDialog::loadSettings()
42 {
43 // Performs load on all widgets that can be binded to SciQlop settings
44 processBind(*ui->stackedWidget,
45 [](ISqpSettingsBindable &bindable) { bindable.loadSettings(); });
46 }
47
48 void SqpSettingsDialog::saveSettings() const
49 {
50 // Performs save on all widgets that can be binded to SciQlop settings
51 processBind(*ui->stackedWidget,
52 [](ISqpSettingsBindable &bindable) { bindable.saveSettings(); });
53 }
54
55 void SqpSettingsDialog::registerWidget(const QString &name, QWidget *widget) noexcept
56 {
57 auto newItem = new QListWidgetItem{ui->listWidget};
58 newItem->setText(name);
59
60 ui->stackedWidget->addWidget(widget);
61
62 // Selects widget if it's the first in the dialog
63 if (ui->listWidget->count() == 1) {
64 ui->listWidget->setCurrentItem(newItem);
65 }
66 }
@@ -0,0 +1,45
1 #include "Settings/SqpSettingsGeneralWidget.h"
2
3 #include "Settings/SqpSettingsDefs.h"
4
5 #include "ui_SqpSettingsGeneralWidget.h"
6
7 SqpSettingsGeneralWidget::SqpSettingsGeneralWidget(QWidget *parent)
8 : QWidget{parent}, ui{new Ui::SqpSettingsGeneralWidget}
9 {
10 ui->setupUi(this);
11 }
12
13 SqpSettingsGeneralWidget::~SqpSettingsGeneralWidget() noexcept
14 {
15 delete ui;
16 }
17
18 void SqpSettingsGeneralWidget::loadSettings()
19 {
20 QSettings settings{};
21
22 auto loadTolerance = [&settings](const QString &key, double defaultValue) {
23 // Tolerance is converted to percent
24 auto toleranceValue = settings.value(key, defaultValue).toDouble();
25 return toleranceValue * 100.;
26 };
27
28 ui->toleranceInitSpinBox->setValue(
29 loadTolerance(GENERAL_TOLERANCE_AT_INIT_KEY, GENERAL_TOLERANCE_AT_INIT_DEFAULT_VALUE));
30 ui->toleranceUpdateSpinBox->setValue(
31 loadTolerance(GENERAL_TOLERANCE_AT_UPDATE_KEY, GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE));
32 }
33
34 void SqpSettingsGeneralWidget::saveSettings() const
35 {
36 QSettings settings{};
37
38 auto saveTolerance = [&settings](const QString &key, double value) {
39 // Tolerance is converted from percent
40 settings.setValue(key, value * 0.01);
41 };
42
43 saveTolerance(GENERAL_TOLERANCE_AT_INIT_KEY, ui->toleranceInitSpinBox->value());
44 saveTolerance(GENERAL_TOLERANCE_AT_UPDATE_KEY, ui->toleranceUpdateSpinBox->value());
45 }
@@ -0,0 +1,84
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>SqpSettingsDialog</class>
4 <widget class="QDialog" name="SqpSettingsDialog">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>572</width>
10 <height>394</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>SciQlop Settings</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QListWidget" name="listWidget">
19 <property name="sizePolicy">
20 <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
21 <horstretch>0</horstretch>
22 <verstretch>0</verstretch>
23 </sizepolicy>
24 </property>
25 </widget>
26 </item>
27 <item row="0" column="1">
28 <widget class="QStackedWidget" name="stackedWidget">
29 <property name="sizePolicy">
30 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
31 <horstretch>0</horstretch>
32 <verstretch>0</verstretch>
33 </sizepolicy>
34 </property>
35 </widget>
36 </item>
37 <item row="1" column="0" colspan="2">
38 <widget class="QDialogButtonBox" name="buttonBox">
39 <property name="orientation">
40 <enum>Qt::Horizontal</enum>
41 </property>
42 <property name="standardButtons">
43 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
44 </property>
45 </widget>
46 </item>
47 </layout>
48 </widget>
49 <resources/>
50 <connections>
51 <connection>
52 <sender>buttonBox</sender>
53 <signal>accepted()</signal>
54 <receiver>SqpSettingsDialog</receiver>
55 <slot>accept()</slot>
56 <hints>
57 <hint type="sourcelabel">
58 <x>248</x>
59 <y>254</y>
60 </hint>
61 <hint type="destinationlabel">
62 <x>157</x>
63 <y>274</y>
64 </hint>
65 </hints>
66 </connection>
67 <connection>
68 <sender>buttonBox</sender>
69 <signal>rejected()</signal>
70 <receiver>SqpSettingsDialog</receiver>
71 <slot>reject()</slot>
72 <hints>
73 <hint type="sourcelabel">
74 <x>316</x>
75 <y>260</y>
76 </hint>
77 <hint type="destinationlabel">
78 <x>286</x>
79 <y>274</y>
80 </hint>
81 </hints>
82 </connection>
83 </connections>
84 </ui>
@@ -0,0 +1,86
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>SqpSettingsGeneralWidget</class>
4 <widget class="QWidget" name="SqpSettingsGeneralWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>343</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QLabel" name="toleranceInitLabel">
19 <property name="text">
20 <string>Tolerance on first acquisition:</string>
21 </property>
22 </widget>
23 </item>
24 <item row="0" column="1">
25 <widget class="QDoubleSpinBox" name="toleranceInitSpinBox">
26 <property name="sizePolicy">
27 <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
28 <horstretch>0</horstretch>
29 <verstretch>0</verstretch>
30 </sizepolicy>
31 </property>
32 <property name="suffix">
33 <string> %</string>
34 </property>
35 <property name="minimum">
36 <double>0.000000000000000</double>
37 </property>
38 <property name="maximum">
39 <double>500.000000000000000</double>
40 </property>
41 </widget>
42 </item>
43 <item row="1" column="0">
44 <widget class="QLabel" name="toleranceUpdateLabel">
45 <property name="text">
46 <string>Tolerance when updating acquisition:</string>
47 </property>
48 </widget>
49 </item>
50 <item row="1" column="1">
51 <widget class="QDoubleSpinBox" name="toleranceUpdateSpinBox">
52 <property name="sizePolicy">
53 <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
54 <horstretch>0</horstretch>
55 <verstretch>0</verstretch>
56 </sizepolicy>
57 </property>
58 <property name="suffix">
59 <string> %</string>
60 </property>
61 <property name="minimum">
62 <double>0.000000000000000</double>
63 </property>
64 <property name="maximum">
65 <double>500.000000000000000</double>
66 </property>
67 </widget>
68 </item>
69 <item row="2" column="0">
70 <spacer name="verticalSpacer">
71 <property name="orientation">
72 <enum>Qt::Vertical</enum>
73 </property>
74 <property name="sizeHint" stdset="0">
75 <size>
76 <width>20</width>
77 <height>40</height>
78 </size>
79 </property>
80 </spacer>
81 </item>
82 </layout>
83 </widget>
84 <resources/>
85 <connections/>
86 </ui>
@@ -1,76 +1,79
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the QLop Software
2 -- This file is a part of the QLop Software
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "MainWindow.h"
22 #include "MainWindow.h"
23 #include <QProcessEnvironment>
23 #include <QProcessEnvironment>
24 #include <QThread>
24 #include <QThread>
25 #include <SqpApplication.h>
25 #include <SqpApplication.h>
26 #include <qglobal.h>
26 #include <qglobal.h>
27
27
28 #include <Plugin/PluginManager.h>
28 #include <Plugin/PluginManager.h>
29 #include <QDir>
29 #include <QDir>
30
30
31 #include <QLoggingCategory>
32
33 Q_LOGGING_CATEGORY(LOG_Main, "Main")
34
31 namespace {
35 namespace {
32
36
33 /// Name of the directory containing the plugins
37 /// Name of the directory containing the plugins
34
38
35 #if _WIN32 || _WIN64
39 #if _WIN32 || _WIN64
36 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
40 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
37 #endif
41 #endif
38
42
39 } // namespace
43 } // namespace
40
44
41 int main(int argc, char *argv[])
45 int main(int argc, char *argv[])
42 {
46 {
43 SqpApplication a{argc, argv};
47 SqpApplication a{argc, argv};
44 SqpApplication::setOrganizationName("LPP");
48 SqpApplication::setOrganizationName("LPP");
45 SqpApplication::setOrganizationDomain("lpp.fr");
49 SqpApplication::setOrganizationDomain("lpp.fr");
46 SqpApplication::setApplicationName("SciQLop");
50 SqpApplication::setApplicationName("SciQLop");
47 MainWindow w;
51 MainWindow w;
48 w.show();
52 w.show();
49
53
50 // Loads plugins
54 // Loads plugins
51 auto pluginDir = QDir{sqpApp->applicationDirPath()};
55 auto pluginDir = QDir{sqpApp->applicationDirPath()};
52 #if _WIN32 || _WIN64
56 #if _WIN32 || _WIN64
53 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
57 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
54 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
58 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
55 #endif
59 #endif
56
60
57
61
58 #if __unix || __APPLE
62 #if __unix || __APPLE
59 #if __x86_64__ || __ppc64__
63 #if __x86_64__ || __ppc64__
60 if (!pluginDir.cd("../lib64/SciQlop")) {
64 if (!pluginDir.cd("../lib64/SciQlop")) {
61 pluginDir.cd("../lib64/sciqlop");
65 pluginDir.cd("../lib64/sciqlop");
62 }
66 }
63 #else
67 #else
64 if (!pluginDir.cd("../lib/SciQlop")) {
68 if (!pluginDir.cd("../lib/SciQlop")) {
65 pluginDir.cd("../lib/sciqlop");
69 pluginDir.cd("../lib/sciqlop");
66 }
70 }
67 #endif
71 #endif
68 #endif
72 #endif
69 qCDebug(LOG_PluginManager())
73 qCDebug(LOG_Main()) << QObject::tr("Plugin directory: %1").arg(pluginDir.absolutePath());
70 << QObject::tr("Plugin directory: %1").arg(pluginDir.absolutePath());
71
74
72 PluginManager pluginManager{};
75 PluginManager pluginManager{};
73 pluginManager.loadPlugins(pluginDir);
76 pluginManager.loadPlugins(pluginDir);
74
77
75 return a.exec();
78 return a.exec();
76 }
79 }
@@ -1,269 +1,255
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SciQLop Software
2 -- This file is a part of the SciQLop Software
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "MainWindow.h"
22 #include "MainWindow.h"
23 #include "ui_MainWindow.h"
23 #include "ui_MainWindow.h"
24
24
25 #include <DataSource/DataSourceController.h>
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <Settings/SqpSettingsDialog.h>
28 #include <Settings/SqpSettingsGeneralWidget.h>
27 #include <SidePane/SqpSidePane.h>
29 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
30 #include <SqpApplication.h>
29 #include <Time/TimeController.h>
31 #include <Time/TimeController.h>
30 #include <TimeWidget/TimeWidget.h>
32 #include <TimeWidget/TimeWidget.h>
31 #include <Variable/Variable.h>
33 #include <Variable/Variable.h>
32 #include <Variable/VariableController.h>
34 #include <Variable/VariableController.h>
33 #include <Visualization/VisualizationController.h>
35 #include <Visualization/VisualizationController.h>
34
36
35 #include <QAction>
37 #include <QAction>
36 #include <QDate>
38 #include <QDate>
37 #include <QDateTime>
39 #include <QDateTime>
38 #include <QDir>
40 #include <QDir>
39 #include <QFileDialog>
41 #include <QFileDialog>
40 #include <QToolBar>
42 #include <QToolBar>
41 #include <QToolButton>
43 #include <QToolButton>
42 #include <memory.h>
44 #include <memory.h>
43
45
44 //#include <omp.h>
45 //#include <network/filedownloader.h>
46 //#include <qlopdatabase.h>
47 //#include <qlopsettings.h>
48 //#include <qlopgui.h>
49 //#include <spacedata.h>
50 //#include "qlopcore.h"
51 //#include "qlopcodecmanager.h"
52 //#include "cdfcodec.h"
53 //#include "amdatxtcodec.h"
54 //#include <qlopplotmanager.h>
55
56 #include "iostream"
46 #include "iostream"
57
47
58 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
48 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
59
49
60 namespace {
50 namespace {
61 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
51 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
62 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
52 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
63 const auto VIEWPLITTERINDEX = 2;
53 const auto VIEWPLITTERINDEX = 2;
64 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
54 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
65 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
55 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
66 }
56 }
67
57
68 class MainWindow::MainWindowPrivate {
58 class MainWindow::MainWindowPrivate {
69 public:
59 public:
60 explicit MainWindowPrivate(MainWindow *mainWindow)
61 : m_LastOpenLeftInspectorSize{},
62 m_LastOpenRightInspectorSize{},
63 m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}},
64 m_SettingsDialog{new SqpSettingsDialog{mainWindow}}
65 {
66 }
67
70 QSize m_LastOpenLeftInspectorSize;
68 QSize m_LastOpenLeftInspectorSize;
71 QSize m_LastOpenRightInspectorSize;
69 QSize m_LastOpenRightInspectorSize;
70 /// General settings widget. MainWindow has the ownership
71 SqpSettingsGeneralWidget *m_GeneralSettingsWidget;
72 /// Settings dialog. MainWindow has the ownership
73 SqpSettingsDialog *m_SettingsDialog;
72 };
74 };
73
75
74 MainWindow::MainWindow(QWidget *parent)
76 MainWindow::MainWindow(QWidget *parent)
75 : QMainWindow{parent},
77 : QMainWindow{parent},
76 m_Ui{new Ui::MainWindow},
78 m_Ui{new Ui::MainWindow},
77 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
79 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
78 {
80 {
79 m_Ui->setupUi(this);
81 m_Ui->setupUi(this);
80
82
81 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
83 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
82 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
84 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
83
85
84
86
85 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
87 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
86 auto openLeftInspectorAction = new QAction{QIcon{
88 auto openLeftInspectorAction = new QAction{QIcon{
87 ":/icones/previous.png",
89 ":/icones/previous.png",
88 },
90 },
89 tr("Show/hide the left inspector"), this};
91 tr("Show/hide the left inspector"), this};
90
92
91
93
92 auto spacerLeftTop = new QWidget{};
94 auto spacerLeftTop = new QWidget{};
93 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
94
96
95 auto spacerLeftBottom = new QWidget{};
97 auto spacerLeftBottom = new QWidget{};
96 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
98 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
97
99
98 leftSidePane->addWidget(spacerLeftTop);
100 leftSidePane->addWidget(spacerLeftTop);
99 leftSidePane->addAction(openLeftInspectorAction);
101 leftSidePane->addAction(openLeftInspectorAction);
100 leftSidePane->addWidget(spacerLeftBottom);
102 leftSidePane->addWidget(spacerLeftBottom);
101
103
102
104
103 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
105 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
104 auto openRightInspectorAction = new QAction{QIcon{
106 auto openRightInspectorAction = new QAction{QIcon{
105 ":/icones/next.png",
107 ":/icones/next.png",
106 },
108 },
107 tr("Show/hide the right inspector"), this};
109 tr("Show/hide the right inspector"), this};
108
110
109 auto spacerRightTop = new QWidget{};
111 auto spacerRightTop = new QWidget{};
110 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
111
113
112 auto spacerRightBottom = new QWidget{};
114 auto spacerRightBottom = new QWidget{};
113 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
115 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
114
116
115 rightSidePane->addWidget(spacerRightTop);
117 rightSidePane->addWidget(spacerRightTop);
116 rightSidePane->addAction(openRightInspectorAction);
118 rightSidePane->addAction(openRightInspectorAction);
117 rightSidePane->addWidget(spacerRightBottom);
119 rightSidePane->addWidget(spacerRightBottom);
118
120
119 openLeftInspectorAction->setCheckable(true);
121 openLeftInspectorAction->setCheckable(true);
120 openRightInspectorAction->setCheckable(true);
122 openRightInspectorAction->setCheckable(true);
121
123
122 auto openInspector = [this](bool checked, bool right, auto action) {
124 auto openInspector = [this](bool checked, bool right, auto action) {
123
125
124 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
126 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
125
127
126 auto &lastInspectorSize
128 auto &lastInspectorSize
127 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
129 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
128
130
129 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
131 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
130 : m_Ui->leftMainInspectorWidget->size();
132 : m_Ui->leftMainInspectorWidget->size();
131
133
132 // Update of the last opened geometry
134 // Update of the last opened geometry
133 if (checked) {
135 if (checked) {
134 lastInspectorSize = nextInspectorSize;
136 lastInspectorSize = nextInspectorSize;
135 }
137 }
136
138
137 auto startSize = lastInspectorSize;
139 auto startSize = lastInspectorSize;
138 auto endSize = startSize;
140 auto endSize = startSize;
139 endSize.setWidth(0);
141 endSize.setWidth(0);
140
142
141 auto splitterInspectorIndex
143 auto splitterInspectorIndex
142 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
144 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
143
145
144 auto currentSizes = m_Ui->splitter->sizes();
146 auto currentSizes = m_Ui->splitter->sizes();
145 if (checked) {
147 if (checked) {
146 // adjust sizes individually here, e.g.
148 // adjust sizes individually here, e.g.
147 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
149 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
148 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
149 m_Ui->splitter->setSizes(currentSizes);
151 m_Ui->splitter->setSizes(currentSizes);
150 }
152 }
151 else {
153 else {
152 // adjust sizes individually here, e.g.
154 // adjust sizes individually here, e.g.
153 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
155 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
154 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
156 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
155 m_Ui->splitter->setSizes(currentSizes);
157 m_Ui->splitter->setSizes(currentSizes);
156 }
158 }
157
159
158 };
160 };
159
161
160
162
161 connect(openLeftInspectorAction, &QAction::triggered,
163 connect(openLeftInspectorAction, &QAction::triggered,
162 [openInspector, openLeftInspectorAction](bool checked) {
164 [openInspector, openLeftInspectorAction](bool checked) {
163 openInspector(checked, false, openLeftInspectorAction);
165 openInspector(checked, false, openLeftInspectorAction);
164 });
166 });
165 connect(openRightInspectorAction, &QAction::triggered,
167 connect(openRightInspectorAction, &QAction::triggered,
166 [openInspector, openRightInspectorAction](bool checked) {
168 [openInspector, openRightInspectorAction](bool checked) {
167 openInspector(checked, true, openRightInspectorAction);
169 openInspector(checked, true, openRightInspectorAction);
168 });
170 });
169
171
172 // //// //
173 // Menu //
174 // //// //
170 this->menuBar()->addAction(tr("File"));
175 this->menuBar()->addAction(tr("File"));
176 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
177 toolsMenu->addAction(tr("Settings..."), [this]() {
178 // Loads settings
179 impl->m_SettingsDialog->loadSettings();
180
181 // Open settings dialog and save settings if the dialog is accepted
182 if (impl->m_SettingsDialog->exec() == QDialog::Accepted) {
183 impl->m_SettingsDialog->saveSettings();
184 }
185
186 });
187
171 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
188 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
172
189
173 auto timeWidget = new TimeWidget{};
190 auto timeWidget = new TimeWidget{};
174 mainToolBar->addWidget(timeWidget);
191 mainToolBar->addWidget(timeWidget);
175
192
193 // //////// //
194 // Settings //
195 // //////// //
196
197 // Registers "general settings" widget to the settings dialog
198 impl->m_SettingsDialog->registerWidget(QStringLiteral("General"),
199 impl->m_GeneralSettingsWidget);
200
201 // /////////// //
202 // Connections //
203 // /////////// //
204
176 // Controllers / controllers connections
205 // Controllers / controllers connections
177 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
206 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
178 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
207 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
179
208
180 // Widgets / controllers connections
209 // Widgets / controllers connections
181
210
182 // DataSource
211 // DataSource
183 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
212 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
184 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
213 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
185
214
186 // Time
215 // Time
187 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
216 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
188 SLOT(onTimeToUpdate(SqpDateTime)));
217 SLOT(onTimeToUpdate(SqpDateTime)));
189
218
190 // Visualization
219 // Visualization
191 connect(&sqpApp->visualizationController(),
220 connect(&sqpApp->visualizationController(),
192 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
221 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
193 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
222 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
194
223
195 connect(&sqpApp->visualizationController(),
224 connect(&sqpApp->visualizationController(),
196 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)), m_Ui->view,
225 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)), m_Ui->view,
197 SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)));
226 SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)));
198
227
199 // Widgets / widgets connections
228 // Widgets / widgets connections
200
229
201 // For the following connections, we use DirectConnection to allow each widget that can
230 // For the following connections, we use DirectConnection to allow each widget that can
202 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
231 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
203 // The order of connections is also important, since it determines the order in which each
232 // The order of connections is also important, since it determines the order in which each
204 // widget will attach its menu
233 // widget will attach its menu
205 connect(
234 connect(
206 m_Ui->variableInspectorWidget,
235 m_Ui->variableInspectorWidget,
207 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
236 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
208 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
237 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
209 Qt::DirectConnection);
238 Qt::DirectConnection);
210
211 /* QLopGUI::registerMenuBar(menuBar());
212 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
213 this->m_progressWidget = new QWidget();
214 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
215 this->m_progressWidget->setLayout(this->m_progressLayout);
216 this->m_progressWidget->setWindowModality(Qt::WindowModal);
217 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
218 for(int i=0;i<OMP_THREADS;i++)
219 {
220 this->m_progress.append(new QProgressBar(this->m_progressWidget));
221 this->m_progress.last()->setMinimum(0);
222 this->m_progress.last()->setMaximum(100);
223 this->m_progressLayout->addWidget(this->m_progress.last());
224 this->m_progressWidget->hide();
225 this->m_progressThreadIds[i] = -1;
226 }
227 this->m_progressWidget->setWindowTitle("Loading File");
228 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
229 << QLopCore::self()
230 << QLopPlotManager::self()
231 << QLopCodecManager::self()
232 << FileDownloader::self()
233 << QLopDataBase::self()
234 << SpaceData::self();
235
236 CDFCodec::registerToManager();
237 AMDATXTCodec::registerToManager();
238
239
240 for(int i=0;i<ServicesToLoad.count();i++)
241 {
242 qDebug()<<ServicesToLoad.at(i)->serviceName();
243 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
244 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
245 if(wdgt)
246 {
247 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
248 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
249 }
250 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
251 }*/
252 }
239 }
253
240
254 MainWindow::~MainWindow()
241 MainWindow::~MainWindow()
255 {
242 {
256 }
243 }
257
244
258
259 void MainWindow::changeEvent(QEvent *e)
245 void MainWindow::changeEvent(QEvent *e)
260 {
246 {
261 QMainWindow::changeEvent(e);
247 QMainWindow::changeEvent(e);
262 switch (e->type()) {
248 switch (e->type()) {
263 case QEvent::LanguageChange:
249 case QEvent::LanguageChange:
264 m_Ui->retranslateUi(this);
250 m_Ui->retranslateUi(this);
265 break;
251 break;
266 default:
252 default:
267 break;
253 break;
268 }
254 }
269 }
255 }
@@ -1,153 +1,156
1
1
2 ## core - CMakeLists.txt
2 ## core - CMakeLists.txt
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
4 SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}")
4 SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
7
7
8 # Include core directory
8 # Include core directory
9 include_directories("${INCLUDES_DIR}")
9 include_directories("${INCLUDES_DIR}")
10
10
11 # Set a variable to display a warning in the version files.
11 # Set a variable to display a warning in the version files.
12 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
12 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
13 # Generate the version file from the cmake version variables. The version
13 # Generate the version file from the cmake version variables. The version
14 # variables are defined in the cmake/sciqlop_version.cmake file.
14 # variables are defined in the cmake/sciqlop_version.cmake file.
15 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in"
15 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in"
16 "${INCLUDES_DIR}/Version.h")
16 "${INCLUDES_DIR}/Version.h")
17 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in"
17 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in"
18 "${SOURCES_DIR}/Version.cpp")
18 "${SOURCES_DIR}/Version.cpp")
19
19
20 # Find dependent modules
20 # Find dependent modules
21 find_package(sciqlop-plugin)
21 find_package(sciqlop-plugin)
22 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
22 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
23
23
24 #
24 #
25 # Find Qt modules
25 # Find Qt modules
26 #
26 #
27 SCIQLOP_FIND_QT(Core Network)
27 SCIQLOP_FIND_QT(Core Network)
28
28
29 #
29 #
30 # Compile the library library
30 # Compile the library library
31 #
31 #
32
33 ADD_DEFINITIONS(-DCORE_LIB)
34
32 FILE (GLOB_RECURSE MODULE_SOURCES
35 FILE (GLOB_RECURSE MODULE_SOURCES
33 ${INCLUDES_DIR}/*.h
36 ${INCLUDES_DIR}/*.h
34 ${SOURCES_DIR}/*.c
37 ${SOURCES_DIR}/*.c
35 ${SOURCES_DIR}/*.cpp
38 ${SOURCES_DIR}/*.cpp
36 ${SOURCES_DIR}/*.h)
39 ${SOURCES_DIR}/*.h)
37
40
38 ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES})
41 ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES})
39 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
42 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
40 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
43 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
41 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME})
44 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME})
42 qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network)
45 qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network)
43
46
44 INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME}
47 INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME}
45 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
48 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
46 LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
49 LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
47 ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR}
50 ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR}
48 )
51 )
49
52
50 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
53 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
51 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
54 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
52 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
55 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
53 IF(BUILD_SHARED_LIBS)
56 IF(BUILD_SHARED_LIBS)
54 SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
57 SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
55 ELSE()
58 ELSE()
56 TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
59 TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
57 ENDIF()
60 ENDIF()
58
61
59 # Set the variable to parent scope so that the other projects can copy the
62 # Set the variable to parent scope so that the other projects can copy the
60 # dependent shared libraries
63 # dependent shared libraries
61 SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME)
64 SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME)
62
65
63 # Copy extern shared libraries to the lib folder
66 # Copy extern shared libraries to the lib folder
64 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
67 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
65
68
66 # Add the files to the list of files to be analyzed
69 # Add the files to the list of files to be analyzed
67 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
70 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
68 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
71 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
69 # Vera++ exclusion files
72 # Vera++ exclusion files
70 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
73 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
71 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
74 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
72
75
73 #
76 #
74 # Compile the tests
77 # Compile the tests
75 #
78 #
76 IF(BUILD_TESTS)
79 IF(BUILD_TESTS)
77 INCLUDE_DIRECTORIES(${SOURCES_DIR})
80 INCLUDE_DIRECTORIES(${SOURCES_DIR})
78 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
81 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
79 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
82 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
80 SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME})
83 SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME})
81
84
82 SET(TARGETS_COV)
85 SET(TARGETS_COV)
83 FOREACH( testFile ${TESTS_SOURCES} )
86 FOREACH( testFile ${TESTS_SOURCES} )
84 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
87 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
85 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
88 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
86
89
87 # Add to the list of sources files all the sources in the same
90 # Add to the list of sources files all the sources in the same
88 # directory that aren't another test
91 # directory that aren't another test
89 FILE (GLOB currentTestSources
92 FILE (GLOB currentTestSources
90 ${testDirectory}/*.c
93 ${testDirectory}/*.c
91 ${testDirectory}/*.cpp
94 ${testDirectory}/*.cpp
92 ${testDirectory}/*.h)
95 ${testDirectory}/*.h)
93 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
96 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
94 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
97 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
95
98
96 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
99 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
97 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
100 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
98 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
101 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
99 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
102 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
100 qt5_use_modules(${testName} Test)
103 qt5_use_modules(${testName} Test)
101
104
102 ADD_TEST( NAME ${testName} COMMAND ${testName} )
105 ADD_TEST( NAME ${testName} COMMAND ${testName} )
103
106
104 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
107 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
105 set(Coverage_NAME ${testName})
108 set(Coverage_NAME ${testName})
106 if(UNIX)
109 if(UNIX)
107 SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName})
110 SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName})
108 LIST( APPEND TARGETS_COV ${testName}_coverage)
111 LIST( APPEND TARGETS_COV ${testName}_coverage)
109 endif(UNIX)
112 endif(UNIX)
110
113
111 ENDFOREACH( testFile )
114 ENDFOREACH( testFile )
112
115
113 add_custom_target(coverage)
116 add_custom_target(coverage)
114
117
115 FOREACH( target_cov ${TARGETS_COV} )
118 FOREACH( target_cov ${TARGETS_COV} )
116 add_custom_command(TARGET coverage PRE_BUILD COMMAND make ${target_cov})
119 add_custom_command(TARGET coverage PRE_BUILD COMMAND make ${target_cov})
117 ENDFOREACH( target_cov )
120 ENDFOREACH( target_cov )
118
121
119 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
122 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
120 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
123 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
121 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
124 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
122 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
125 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
123 ENDIF(BUILD_TESTS)
126 ENDIF(BUILD_TESTS)
124
127
125 #
128 #
126 # Set the files that must be formatted by clang-format.
129 # Set the files that must be formatted by clang-format.
127 #
130 #
128 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
131 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
129 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
132 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
130
133
131 #
134 #
132 # Set the directories that doxygen must browse to generate the
135 # Set the directories that doxygen must browse to generate the
133 # documentation.
136 # documentation.
134 #
137 #
135 # Source directories:
138 # Source directories:
136 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
139 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
137 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
140 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
138 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
141 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
139 # Source directories to exclude from the documentation generation
142 # Source directories to exclude from the documentation generation
140 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
143 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
141 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
144 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
142
145
143 #
146 #
144 # Set the directories with the sources to analyze and propagate the
147 # Set the directories with the sources to analyze and propagate the
145 # modification to the parent scope
148 # modification to the parent scope
146 #
149 #
147 # Source directories to analyze:
150 # Source directories to analyze:
148 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
151 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
149 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
152 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
150 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
153 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
151 # Source directories to exclude from the analysis
154 # Source directories to exclude from the analysis
152 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
155 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
153 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
156 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,72 +1,74
1 #ifndef SCIQLOP_IDATAPROVIDER_H
1 #ifndef SCIQLOP_IDATAPROVIDER_H
2 #define SCIQLOP_IDATAPROVIDER_H
2 #define SCIQLOP_IDATAPROVIDER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <memory>
6 #include <memory>
5
7
6 #include <QObject>
8 #include <QObject>
7 #include <QUuid>
9 #include <QUuid>
8
10
9 #include <Common/MetaTypes.h>
11 #include <Common/MetaTypes.h>
10
12
11 #include <Data/SqpDateTime.h>
13 #include <Data/SqpDateTime.h>
12
14
13 #include <functional>
15 #include <functional>
14
16
15 class DataProviderParameters;
17 class DataProviderParameters;
16 class IDataSeries;
18 class IDataSeries;
17 class QNetworkReply;
19 class QNetworkReply;
18 class QNetworkRequest;
20 class QNetworkRequest;
19
21
20 /**
22 /**
21 * @brief The IDataProvider interface aims to declare a data provider.
23 * @brief The IDataProvider interface aims to declare a data provider.
22 *
24 *
23 * A data provider is an entity that generates data and returns it according to various parameters
25 * A data provider is an entity that generates data and returns it according to various parameters
24 * (time interval, product to retrieve the data, etc.)
26 * (time interval, product to retrieve the data, etc.)
25 *
27 *
26 * @sa IDataSeries
28 * @sa IDataSeries
27 */
29 */
28 class IDataProvider : public QObject {
30 class SCIQLOP_CORE_EXPORT IDataProvider : public QObject {
29
31
30 Q_OBJECT
32 Q_OBJECT
31 public:
33 public:
32 virtual ~IDataProvider() noexcept = default;
34 virtual ~IDataProvider() noexcept = default;
33
35
34 /**
36 /**
35 * @brief requestDataLoading provide datas for the data identified by identifier and parameters
37 * @brief requestDataLoading provide datas for the data identified by identifier and parameters
36 */
38 */
37 virtual void requestDataLoading(QUuid identifier, const DataProviderParameters &parameters) = 0;
39 virtual void requestDataLoading(QUuid identifier, const DataProviderParameters &parameters) = 0;
38
40
39 /**
41 /**
40 * @brief requestDataAborting stop data loading of the data identified by identifier
42 * @brief requestDataAborting stop data loading of the data identified by identifier
41 */
43 */
42 virtual void requestDataAborting(QUuid identifier) = 0;
44 virtual void requestDataAborting(QUuid identifier) = 0;
43
45
44 signals:
46 signals:
45 /**
47 /**
46 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
48 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
47 * identified by identifier
49 * identified by identifier
48 */
50 */
49 void dataProvided(QUuid identifier, std::shared_ptr<IDataSeries> dateSerie,
51 void dataProvided(QUuid identifier, std::shared_ptr<IDataSeries> dateSerie,
50 const SqpDateTime &dateTime);
52 const SqpDateTime &dateTime);
51
53
52 /**
54 /**
53 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
55 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
54 * identified by identifier
56 * identified by identifier
55 */
57 */
56 void dataProvidedProgress(QUuid identifier, double progress);
58 void dataProvidedProgress(QUuid identifier, double progress);
57
59
58
60
59 /**
61 /**
60 * @brief requestConstructed send a request for the data identified by identifier
62 * @brief requestConstructed send a request for the data identified by identifier
61 * @callback is the methode call by the reply of the request when it is finished.
63 * @callback is the methode call by the reply of the request when it is finished.
62 */
64 */
63 void requestConstructed(const QNetworkRequest &request, QUuid identifier,
65 void requestConstructed(const QNetworkRequest &request, QUuid identifier,
64 std::function<void(QNetworkReply *, QUuid)> callback);
66 std::function<void(QNetworkReply *, QUuid)> callback);
65 };
67 };
66
68
67 // Required for using shared_ptr in signals/slots
69 // Required for using shared_ptr in signals/slots
68 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>)
70 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>)
69 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_FUNCTION_REGISTRY,
71 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_FUNCTION_REGISTRY,
70 std::function<void(QNetworkReply *, QUuid)>)
72 std::function<void(QNetworkReply *, QUuid)>)
71
73
72 #endif // SCIQLOP_IDATAPROVIDER_H
74 #endif // SCIQLOP_IDATAPROVIDER_H
@@ -1,23 +1,25
1 #ifndef SCIQLOP_SCALARSERIES_H
1 #ifndef SCIQLOP_SCALARSERIES_H
2 #define SCIQLOP_SCALARSERIES_H
2 #define SCIQLOP_SCALARSERIES_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Data/DataSeries.h>
6 #include <Data/DataSeries.h>
5
7
6 /**
8 /**
7 * @brief The ScalarSeries class is the implementation for a data series representing a scalar.
9 * @brief The ScalarSeries class is the implementation for a data series representing a scalar.
8 */
10 */
9 class ScalarSeries : public DataSeries<1> {
11 class SCIQLOP_CORE_EXPORT ScalarSeries : public DataSeries<1> {
10 public:
12 public:
11 /**
13 /**
12 * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no
14 * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no
13 * values will be created.
15 * values will be created.
14 * @param xAxisData x-axis data
16 * @param xAxisData x-axis data
15 * @param valuesData values data
17 * @param valuesData values data
16 */
18 */
17 explicit ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData,
19 explicit ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData,
18 const Unit &xAxisUnit, const Unit &valuesUnit);
20 const Unit &xAxisUnit, const Unit &valuesUnit);
19
21
20 std::unique_ptr<IDataSeries> clone() const;
22 std::unique_ptr<IDataSeries> clone() const;
21 };
23 };
22
24
23 #endif // SCIQLOP_SCALARSERIES_H
25 #endif // SCIQLOP_SCALARSERIES_H
@@ -1,92 +1,94
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <QLoggingCategory>
6 #include <QLoggingCategory>
5 #include <QObject>
7 #include <QObject>
6 #include <QUuid>
8 #include <QUuid>
7
9
8 #include <Common/spimpl.h>
10 #include <Common/spimpl.h>
9
11
10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
11
13
12 class DataSourceItem;
14 class DataSourceItem;
13 class IDataProvider;
15 class IDataProvider;
14
16
15 /**
17 /**
16 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
18 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
17 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
19 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
18 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
20 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
19 * source) then others specifics method will be able to access it. You can load a data source driver
21 * source) then others specifics method will be able to access it. You can load a data source driver
20 * plugin then create a data source.
22 * plugin then create a data source.
21 */
23 */
22 class DataSourceController : public QObject {
24 class SCIQLOP_CORE_EXPORT DataSourceController : public QObject {
23 Q_OBJECT
25 Q_OBJECT
24 public:
26 public:
25 explicit DataSourceController(QObject *parent = 0);
27 explicit DataSourceController(QObject *parent = 0);
26 virtual ~DataSourceController();
28 virtual ~DataSourceController();
27
29
28 /**
30 /**
29 * Registers a data source. The method delivers a unique id that can be used afterwards to
31 * Registers a data source. The method delivers a unique id that can be used afterwards to
30 * access to the data source properties (structure, connection parameters, data provider, etc.)
32 * access to the data source properties (structure, connection parameters, data provider, etc.)
31 * @param dataSourceName the name of the data source
33 * @param dataSourceName the name of the data source
32 * @return the unique id with which the data source has been registered
34 * @return the unique id with which the data source has been registered
33 */
35 */
34 QUuid registerDataSource(const QString &dataSourceName) noexcept;
36 QUuid registerDataSource(const QString &dataSourceName) noexcept;
35
37
36 /**
38 /**
37 * Sets the structure of a data source. The controller takes ownership of the structure.
39 * Sets the structure of a data source. The controller takes ownership of the structure.
38 * @param dataSourceUid the unique id with which the data source has been registered into the
40 * @param dataSourceUid the unique id with which the data source has been registered into the
39 * controller. If it is invalid, the method has no effect.
41 * controller. If it is invalid, the method has no effect.
40 * @param dataSourceItem the structure of the data source. It must be not null to be registered
42 * @param dataSourceItem the structure of the data source. It must be not null to be registered
41 * @sa registerDataSource()
43 * @sa registerDataSource()
42 */
44 */
43 void setDataSourceItem(const QUuid &dataSourceUid,
45 void setDataSourceItem(const QUuid &dataSourceUid,
44 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
46 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
45
47
46 /**
48 /**
47 * Sets the data provider used to retrieve data from of a data source. The controller takes
49 * Sets the data provider used to retrieve data from of a data source. The controller takes
48 * ownership of the provider.
50 * ownership of the provider.
49 * @param dataSourceUid the unique id with which the data source has been registered into the
51 * @param dataSourceUid the unique id with which the data source has been registered into the
50 * controller. If it is invalid, the method has no effect.
52 * controller. If it is invalid, the method has no effect.
51 * @param dataProvider the provider of the data source
53 * @param dataProvider the provider of the data source
52 * @sa registerDataSource()
54 * @sa registerDataSource()
53 */
55 */
54 void setDataProvider(const QUuid &dataSourceUid,
56 void setDataProvider(const QUuid &dataSourceUid,
55 std::unique_ptr<IDataProvider> dataProvider) noexcept;
57 std::unique_ptr<IDataProvider> dataProvider) noexcept;
56
58
57 /**
59 /**
58 * Loads an item (product) as a variable in SciQlop
60 * Loads an item (product) as a variable in SciQlop
59 * @param dataSourceUid the unique id of the data source containing the item. It is used to get
61 * @param dataSourceUid the unique id of the data source containing the item. It is used to get
60 * the data provider associated to the data source, and pass it to for the variable creation
62 * the data provider associated to the data source, and pass it to for the variable creation
61 * @param productItem the item to load
63 * @param productItem the item to load
62 */
64 */
63 void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept;
65 void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept;
64
66
65 public slots:
67 public slots:
66 /// Manage init/end of the controller
68 /// Manage init/end of the controller
67 void initialize();
69 void initialize();
68 void finalize();
70 void finalize();
69
71
70 signals:
72 signals:
71 /// Signal emitted when a structure has been set for a data source
73 /// Signal emitted when a structure has been set for a data source
72 void dataSourceItemSet(DataSourceItem *dataSourceItem);
74 void dataSourceItemSet(DataSourceItem *dataSourceItem);
73
75
74 /**
76 /**
75 * Signal emitted when a variable creation is asked for a product
77 * Signal emitted when a variable creation is asked for a product
76 * @param variableName the name of the variable
78 * @param variableName the name of the variable
77 * @param variableMetadata the metadata of the variable
79 * @param variableMetadata the metadata of the variable
78 * @param variableProvider the provider that will be used to retrieve the data of the variable
80 * @param variableProvider the provider that will be used to retrieve the data of the variable
79 * (can be null)
81 * (can be null)
80 */
82 */
81 void variableCreationRequested(const QString &variableName,
83 void variableCreationRequested(const QString &variableName,
82 const QVariantHash &variableMetadata,
84 const QVariantHash &variableMetadata,
83 std::shared_ptr<IDataProvider> variableProvider);
85 std::shared_ptr<IDataProvider> variableProvider);
84
86
85 private:
87 private:
86 void waitForFinish();
88 void waitForFinish();
87
89
88 class DataSourceControllerPrivate;
90 class DataSourceControllerPrivate;
89 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
91 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
90 };
92 };
91
93
92 #endif // SCIQLOP_DATASOURCECONTROLLER_H
94 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,94 +1,96
1 #ifndef SCIQLOP_DATASOURCEITEM_H
1 #ifndef SCIQLOP_DATASOURCEITEM_H
2 #define SCIQLOP_DATASOURCEITEM_H
2 #define SCIQLOP_DATASOURCEITEM_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Common/spimpl.h>
6 #include <Common/spimpl.h>
5
7
6 #include <QVariant>
8 #include <QVariant>
7 #include <QVector>
9 #include <QVector>
8
10
9 class DataSourceItemAction;
11 class DataSourceItemAction;
10
12
11 /**
13 /**
12 * Possible types of an item
14 * Possible types of an item
13 */
15 */
14 enum class DataSourceItemType { NODE, PRODUCT, COMPONENT };
16 enum class DataSourceItemType { NODE, PRODUCT, COMPONENT };
15
17
16 /**
18 /**
17 * @brief The DataSourceItem class aims to represent a structure element of a data source.
19 * @brief The DataSourceItem class aims to represent a structure element of a data source.
18 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
20 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
19 * containing other DataSourceItem objects (children).
21 * containing other DataSourceItem objects (children).
20 * For each DataSourceItem can be associated a set of data representing it.
22 * For each DataSourceItem can be associated a set of data representing it.
21 */
23 */
22 class DataSourceItem {
24 class SCIQLOP_CORE_EXPORT DataSourceItem {
23 public:
25 public:
24 /// Key associated with the name of the item
26 /// Key associated with the name of the item
25 static const QString NAME_DATA_KEY;
27 static const QString NAME_DATA_KEY;
26
28
27 explicit DataSourceItem(DataSourceItemType type, const QString &name);
29 explicit DataSourceItem(DataSourceItemType type, const QString &name);
28 explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {});
30 explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {});
29
31
30 /// @return the actions of the item as a vector
32 /// @return the actions of the item as a vector
31 QVector<DataSourceItemAction *> actions() const noexcept;
33 QVector<DataSourceItemAction *> actions() const noexcept;
32
34
33 /**
35 /**
34 * Adds an action to the item. The item takes ownership of the action, and the action is
36 * Adds an action to the item. The item takes ownership of the action, and the action is
35 * automatically associated to the item
37 * automatically associated to the item
36 * @param action the action to add
38 * @param action the action to add
37 */
39 */
38 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
40 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
39
41
40 /**
42 /**
41 * Adds a child to the item. The item takes ownership of the child.
43 * Adds a child to the item. The item takes ownership of the child.
42 * @param child the child to add
44 * @param child the child to add
43 */
45 */
44 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
46 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
45
47
46 /**
48 /**
47 * Returns the item's child associated to an index
49 * Returns the item's child associated to an index
48 * @param childIndex the index to search
50 * @param childIndex the index to search
49 * @return a pointer to the child if index is valid, nullptr otherwise
51 * @return a pointer to the child if index is valid, nullptr otherwise
50 */
52 */
51 DataSourceItem *child(int childIndex) const noexcept;
53 DataSourceItem *child(int childIndex) const noexcept;
52
54
53 int childCount() const noexcept;
55 int childCount() const noexcept;
54
56
55 /**
57 /**
56 * Get the data associated to a key
58 * Get the data associated to a key
57 * @param key the key to search
59 * @param key the key to search
58 * @return the data found if key is valid, default QVariant otherwise
60 * @return the data found if key is valid, default QVariant otherwise
59 */
61 */
60 QVariant data(const QString &key) const noexcept;
62 QVariant data(const QString &key) const noexcept;
61
63
62 /// Gets all data
64 /// Gets all data
63 QVariantHash data() const noexcept;
65 QVariantHash data() const noexcept;
64
66
65 bool isRoot() const noexcept;
67 bool isRoot() const noexcept;
66
68
67 QString name() const noexcept;
69 QString name() const noexcept;
68
70
69 /**
71 /**
70 * Get the item's parent
72 * Get the item's parent
71 * @return a pointer to the parent if it exists, nullptr if the item is a root
73 * @return a pointer to the parent if it exists, nullptr if the item is a root
72 */
74 */
73 DataSourceItem *parentItem() const noexcept;
75 DataSourceItem *parentItem() const noexcept;
74
76
75 /**
77 /**
76 * Sets or appends a value to a key
78 * Sets or appends a value to a key
77 * @param key the key
79 * @param key the key
78 * @param value the value
80 * @param value the value
79 * @param append if true, the value is added to the values already existing for the key,
81 * @param append if true, the value is added to the values already existing for the key,
80 * otherwise it replaces the existing values
82 * otherwise it replaces the existing values
81 */
83 */
82 void setData(const QString &key, const QVariant &value, bool append = false) noexcept;
84 void setData(const QString &key, const QVariant &value, bool append = false) noexcept;
83
85
84 DataSourceItemType type() const noexcept;
86 DataSourceItemType type() const noexcept;
85
87
86 bool operator==(const DataSourceItem &other);
88 bool operator==(const DataSourceItem &other);
87 bool operator!=(const DataSourceItem &other);
89 bool operator!=(const DataSourceItem &other);
88
90
89 private:
91 private:
90 class DataSourceItemPrivate;
92 class DataSourceItemPrivate;
91 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
93 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
92 };
94 };
93
95
94 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
96 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
@@ -1,50 +1,52
1 #ifndef SCIQLOP_DATASOURCEITEMACTION_H
1 #ifndef SCIQLOP_DATASOURCEITEMACTION_H
2 #define SCIQLOP_DATASOURCEITEMACTION_H
2 #define SCIQLOP_DATASOURCEITEMACTION_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Common/spimpl.h>
6 #include <Common/spimpl.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7 #include <QObject>
9 #include <QObject>
8
10
9 #include <functional>
11 #include <functional>
10
12
11 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceItemAction)
13 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceItemAction)
12
14
13 class DataSourceItem;
15 class DataSourceItem;
14
16
15 /**
17 /**
16 * @brief The DataSourceItemAction class represents an action on a data source item.
18 * @brief The DataSourceItemAction class represents an action on a data source item.
17 *
19 *
18 * An action is a function that will be executed when the slot execute() is called.
20 * An action is a function that will be executed when the slot execute() is called.
19 */
21 */
20 class DataSourceItemAction : public QObject {
22 class SCIQLOP_CORE_EXPORT DataSourceItemAction : public QObject {
21
23
22 Q_OBJECT
24 Q_OBJECT
23
25
24 public:
26 public:
25 /// Signature of the function associated to the action
27 /// Signature of the function associated to the action
26 using ExecuteFunction = std::function<void(DataSourceItem &dataSourceItem)>;
28 using ExecuteFunction = std::function<void(DataSourceItem &dataSourceItem)>;
27
29
28 /**
30 /**
29 * Ctor
31 * Ctor
30 * @param name the name of the action
32 * @param name the name of the action
31 * @param fun the function that will be called when the action is executed
33 * @param fun the function that will be called when the action is executed
32 * @sa execute()
34 * @sa execute()
33 */
35 */
34 explicit DataSourceItemAction(const QString &name, ExecuteFunction fun);
36 explicit DataSourceItemAction(const QString &name, ExecuteFunction fun);
35
37
36 QString name() const noexcept;
38 QString name() const noexcept;
37
39
38 /// Sets the data source item concerned by the action
40 /// Sets the data source item concerned by the action
39 void setDataSourceItem(DataSourceItem *dataSourceItem) noexcept;
41 void setDataSourceItem(DataSourceItem *dataSourceItem) noexcept;
40
42
41 public slots:
43 public slots:
42 /// Executes the action
44 /// Executes the action
43 void execute();
45 void execute();
44
46
45 private:
47 private:
46 class DataSourceItemActionPrivate;
48 class DataSourceItemActionPrivate;
47 spimpl::unique_impl_ptr<DataSourceItemActionPrivate> impl;
49 spimpl::unique_impl_ptr<DataSourceItemActionPrivate> impl;
48 };
50 };
49
51
50 #endif // SCIQLOP_DATASOURCEITEMACTION_H
52 #endif // SCIQLOP_DATASOURCEITEMACTION_H
@@ -1,46 +1,48
1 #ifndef SCIQLOP_NETWORKCONTROLLER_H
1 #ifndef SCIQLOP_NETWORKCONTROLLER_H
2 #define SCIQLOP_NETWORKCONTROLLER_H
2 #define SCIQLOP_NETWORKCONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <QLoggingCategory>
6 #include <QLoggingCategory>
5 #include <QObject>
7 #include <QObject>
6 #include <QUuid>
8 #include <QUuid>
7
9
8 #include <Common/spimpl.h>
10 #include <Common/spimpl.h>
9 #include <functional>
11 #include <functional>
10
12
11 Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController)
13 Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController)
12
14
13 class QNetworkReply;
15 class QNetworkReply;
14 class QNetworkRequest;
16 class QNetworkRequest;
15
17
16 /**
18 /**
17 * @brief The NetworkController class aims to handle all network connection of SciQlop.
19 * @brief The NetworkController class aims to handle all network connection of SciQlop.
18 */
20 */
19 class NetworkController : public QObject {
21 class SCIQLOP_CORE_EXPORT NetworkController : public QObject {
20 Q_OBJECT
22 Q_OBJECT
21 public:
23 public:
22 explicit NetworkController(QObject *parent = 0);
24 explicit NetworkController(QObject *parent = 0);
23
25
24 void initialize();
26 void initialize();
25 void finalize();
27 void finalize();
26
28
27 public slots:
29 public slots:
28 /// Execute request and call callback when the reply is finished. Identifier is attached to the
30 /// Execute request and call callback when the reply is finished. Identifier is attached to the
29 /// callback
31 /// callback
30 void onProcessRequested(const QNetworkRequest &request, QUuid identifier,
32 void onProcessRequested(const QNetworkRequest &request, QUuid identifier,
31 std::function<void(QNetworkReply *, QUuid)> callback);
33 std::function<void(QNetworkReply *, QUuid)> callback);
32 /// Cancel the request of identifier
34 /// Cancel the request of identifier
33 void onReplyCanceled(QUuid identifier);
35 void onReplyCanceled(QUuid identifier);
34
36
35 signals:
37 signals:
36 void replyFinished(QNetworkReply *reply, QUuid identifier);
38 void replyFinished(QNetworkReply *reply, QUuid identifier);
37 void replyDownloadProgress(QUuid identifier, double progress);
39 void replyDownloadProgress(QUuid identifier, double progress);
38
40
39 private:
41 private:
40 void waitForFinish();
42 void waitForFinish();
41
43
42 class NetworkControllerPrivate;
44 class NetworkControllerPrivate;
43 spimpl::unique_impl_ptr<NetworkControllerPrivate> impl;
45 spimpl::unique_impl_ptr<NetworkControllerPrivate> impl;
44 };
46 };
45
47
46 #endif // SCIQLOP_NETWORKCONTROLLER_H
48 #endif // SCIQLOP_NETWORKCONTROLLER_H
@@ -1,34 +1,36
1 #ifndef SCIQLOP_PLUGINMANAGER_H
1 #ifndef SCIQLOP_PLUGINMANAGER_H
2 #define SCIQLOP_PLUGINMANAGER_H
2 #define SCIQLOP_PLUGINMANAGER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Common/spimpl.h>
6 #include <Common/spimpl.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7
9
8 class QDir;
10 class QDir;
9
11
10 Q_DECLARE_LOGGING_CATEGORY(LOG_PluginManager)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_PluginManager)
11
13
12 /**
14 /**
13 * @brief The PluginManager class aims to handle the plugins loaded dynamically into SciQLop.
15 * @brief The PluginManager class aims to handle the plugins loaded dynamically into SciQLop.
14 */
16 */
15 class PluginManager {
17 class SCIQLOP_CORE_EXPORT PluginManager {
16 public:
18 public:
17 explicit PluginManager();
19 explicit PluginManager();
18
20
19 /**
21 /**
20 * Loads plugins into SciQlop. The loaded plugins are those located in the directory passed in
22 * Loads plugins into SciQlop. The loaded plugins are those located in the directory passed in
21 * parameter
23 * parameter
22 * @param pluginDir the directory containing the plugins
24 * @param pluginDir the directory containing the plugins
23 */
25 */
24 void loadPlugins(const QDir &pluginDir);
26 void loadPlugins(const QDir &pluginDir);
25
27
26 /// @returns the number of plugins loaded
28 /// @returns the number of plugins loaded
27 int nbPluginsLoaded() const noexcept;
29 int nbPluginsLoaded() const noexcept;
28
30
29 private:
31 private:
30 class PluginManagerPrivate;
32 class PluginManagerPrivate;
31 spimpl::unique_impl_ptr<PluginManagerPrivate> impl;
33 spimpl::unique_impl_ptr<PluginManagerPrivate> impl;
32 };
34 };
33
35
34 #endif // SCIQLOP_PLUGINMANAGER_H
36 #endif // SCIQLOP_PLUGINMANAGER_H
@@ -1,40 +1,42
1 #ifndef SCIQLOP_TIMECONTROLLER_H
1 #ifndef SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Data/SqpDateTime.h>
6 #include <Data/SqpDateTime.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7 #include <QObject>
9 #include <QObject>
8
10
9 #include <Common/spimpl.h>
11 #include <Common/spimpl.h>
10
12
11
13
12 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
14 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
13
15
14 /**
16 /**
15 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
17 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
16 */
18 */
17 class TimeController : public QObject {
19 class SCIQLOP_CORE_EXPORT TimeController : public QObject {
18 Q_OBJECT
20 Q_OBJECT
19 public:
21 public:
20 explicit TimeController(QObject *parent = 0);
22 explicit TimeController(QObject *parent = 0);
21
23
22 SqpDateTime dateTime() const noexcept;
24 SqpDateTime dateTime() const noexcept;
23
25
24 signals:
26 signals:
25 /// Signal emitted to notify that time parameters has beed updated
27 /// Signal emitted to notify that time parameters has beed updated
26 void timeUpdated(SqpDateTime time);
28 void timeUpdated(SqpDateTime time);
27
29
28 public slots:
30 public slots:
29 /// Slot called when a new dateTime has been defined.
31 /// Slot called when a new dateTime has been defined.
30 void onTimeToUpdate(SqpDateTime dateTime);
32 void onTimeToUpdate(SqpDateTime dateTime);
31
33
32 /// Slot called when the dateTime has to be notified. Call timeUpdated signal
34 /// Slot called when the dateTime has to be notified. Call timeUpdated signal
33 void onTimeNotify();
35 void onTimeNotify();
34
36
35 private:
37 private:
36 class TimeControllerPrivate;
38 class TimeControllerPrivate;
37 spimpl::unique_impl_ptr<TimeControllerPrivate> impl;
39 spimpl::unique_impl_ptr<TimeControllerPrivate> impl;
38 };
40 };
39
41
40 #endif // SCIQLOP_TIMECONTROLLER_H
42 #endif // SCIQLOP_TIMECONTROLLER_H
@@ -1,55 +1,57
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Data/SqpDateTime.h>
6 #include <Data/SqpDateTime.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7 #include <QObject>
9 #include <QObject>
8
10
9 #include <Common/MetaTypes.h>
11 #include <Common/MetaTypes.h>
10 #include <Common/spimpl.h>
12 #include <Common/spimpl.h>
11
13
12 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
14 Q_DECLARE_LOGGING_CATEGORY(LOG_Variable)
13
15
14 class IDataSeries;
16 class IDataSeries;
15 class QString;
17 class QString;
16
18
17 /**
19 /**
18 * @brief The Variable class represents a variable in SciQlop.
20 * @brief The Variable class represents a variable in SciQlop.
19 */
21 */
20 class Variable : public QObject {
22 class SCIQLOP_CORE_EXPORT Variable : public QObject {
21
23
22 Q_OBJECT
24 Q_OBJECT
23
25
24 public:
26 public:
25 explicit Variable(const QString &name, const SqpDateTime &dateTime,
27 explicit Variable(const QString &name, const SqpDateTime &dateTime,
26 const QVariantHash &metadata = {});
28 const QVariantHash &metadata = {});
27
29
28 QString name() const noexcept;
30 QString name() const noexcept;
29 SqpDateTime dateTime() const noexcept;
31 SqpDateTime dateTime() const noexcept;
30 void setDateTime(const SqpDateTime &dateTime) noexcept;
32 void setDateTime(const SqpDateTime &dateTime) noexcept;
31
33
32 /// @return the data of the variable, nullptr if there is no data
34 /// @return the data of the variable, nullptr if there is no data
33 IDataSeries *dataSeries() const noexcept;
35 IDataSeries *dataSeries() const noexcept;
34
36
35 QVariantHash metadata() const noexcept;
37 QVariantHash metadata() const noexcept;
36
38
37 bool contains(const SqpDateTime &dateTime) const noexcept;
39 bool contains(const SqpDateTime &dateTime) const noexcept;
38 bool intersect(const SqpDateTime &dateTime) const noexcept;
40 bool intersect(const SqpDateTime &dateTime) const noexcept;
39 bool isInside(const SqpDateTime &dateTime) const noexcept;
41 bool isInside(const SqpDateTime &dateTime) const noexcept;
40
42
41 public slots:
43 public slots:
42 void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
44 void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
43
45
44 signals:
46 signals:
45 void updated();
47 void updated();
46
48
47 private:
49 private:
48 class VariablePrivate;
50 class VariablePrivate;
49 spimpl::unique_impl_ptr<VariablePrivate> impl;
51 spimpl::unique_impl_ptr<VariablePrivate> impl;
50 };
52 };
51
53
52 // Required for using shared_ptr in signals/slots
54 // Required for using shared_ptr in signals/slots
53 SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>)
55 SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>)
54
56
55 #endif // SCIQLOP_VARIABLE_H
57 #endif // SCIQLOP_VARIABLE_H
@@ -1,46 +1,45
1 #ifndef SCIQLOP_VARIABLECACHECONTROLLER_H
1 #ifndef SCIQLOP_VARIABLECACHECONTROLLER_H
2 #define SCIQLOP_VARIABLECACHECONTROLLER_H
2 #define SCIQLOP_VARIABLECACHECONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <QLoggingCategory>
6 #include <QLoggingCategory>
5 #include <QObject>
7 #include <QObject>
6
8
7 #include <Data/SqpDateTime.h>
9 #include <Data/SqpDateTime.h>
8
10
9 #include <QLoggingCategory>
11 #include <QLoggingCategory>
10
12
11 #include <Common/spimpl.h>
13 #include <Common/spimpl.h>
12
14
13 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController)
15 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController)
14
16
15 class Variable;
17 class Variable;
16
18
17 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController)
18
19
20 /// This class aims to store in the cache all of the dateTime already requested to the variable.
19 /// This class aims to store in the cache all of the dateTime already requested to the variable.
21 class VariableCacheController : public QObject {
20 class SCIQLOP_CORE_EXPORT VariableCacheController : public QObject {
22 Q_OBJECT
21 Q_OBJECT
23 public:
22 public:
24 explicit VariableCacheController(QObject *parent = 0);
23 explicit VariableCacheController(QObject *parent = 0);
25
24
26
25
27 void addDateTime(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
26 void addDateTime(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
28
27
29 /// Clears cache concerning a variable
28 /// Clears cache concerning a variable
30 void clear(std::shared_ptr<Variable> variable) noexcept;
29 void clear(std::shared_ptr<Variable> variable) noexcept;
31
30
32 /// Return all of the SqpDataTime part of the dateTime whose are not in the cache
31 /// Return all of the SqpDataTime part of the dateTime whose are not in the cache
33 QVector<SqpDateTime> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
32 QVector<SqpDateTime> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
34 const SqpDateTime &dateTime);
33 const SqpDateTime &dateTime);
35
34
36
35
37 QVector<SqpDateTime> dateCacheList(std::shared_ptr<Variable> variable) const noexcept;
36 QVector<SqpDateTime> dateCacheList(std::shared_ptr<Variable> variable) const noexcept;
38
37
39 void displayCache(std::shared_ptr<Variable> variable) const;
38 void displayCache(std::shared_ptr<Variable> variable) const;
40
39
41 private:
40 private:
42 class VariableCacheControllerPrivate;
41 class VariableCacheControllerPrivate;
43 spimpl::unique_impl_ptr<VariableCacheControllerPrivate> impl;
42 spimpl::unique_impl_ptr<VariableCacheControllerPrivate> impl;
44 };
43 };
45
44
46 #endif // SCIQLOP_VARIABLECACHECONTROLLER_H
45 #endif // SCIQLOP_VARIABLECACHECONTROLLER_H
@@ -1,95 +1,97
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Data/SqpDateTime.h>
6 #include <Data/SqpDateTime.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7 #include <QObject>
9 #include <QObject>
8
10
9 #include <Common/spimpl.h>
11 #include <Common/spimpl.h>
10
12
11 class IDataProvider;
13 class IDataProvider;
12 class QItemSelectionModel;
14 class QItemSelectionModel;
13 class TimeController;
15 class TimeController;
14 class Variable;
16 class Variable;
15 class VariableModel;
17 class VariableModel;
16
18
17 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
19 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
18
20
19 /**
21 /**
20 * @brief The VariableController class aims to handle the variables in SciQlop.
22 * @brief The VariableController class aims to handle the variables in SciQlop.
21 */
23 */
22 class VariableController : public QObject {
24 class SCIQLOP_CORE_EXPORT VariableController : public QObject {
23 Q_OBJECT
25 Q_OBJECT
24 public:
26 public:
25 explicit VariableController(QObject *parent = 0);
27 explicit VariableController(QObject *parent = 0);
26 virtual ~VariableController();
28 virtual ~VariableController();
27
29
28 VariableModel *variableModel() noexcept;
30 VariableModel *variableModel() noexcept;
29 QItemSelectionModel *variableSelectionModel() noexcept;
31 QItemSelectionModel *variableSelectionModel() noexcept;
30
32
31 void setTimeController(TimeController *timeController) noexcept;
33 void setTimeController(TimeController *timeController) noexcept;
32
34
33 /**
35 /**
34 * Deletes from the controller the variable passed in parameter.
36 * Deletes from the controller the variable passed in parameter.
35 *
37 *
36 * Delete a variable includes:
38 * Delete a variable includes:
37 * - the deletion of the various references to the variable in SciQlop
39 * - the deletion of the various references to the variable in SciQlop
38 * - the deletion of the model variable
40 * - the deletion of the model variable
39 * - the deletion of the provider associated with the variable
41 * - the deletion of the provider associated with the variable
40 * - removing the cache associated with the variable
42 * - removing the cache associated with the variable
41 *
43 *
42 * @param variable the variable to delete from the controller.
44 * @param variable the variable to delete from the controller.
43 */
45 */
44 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
46 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
45
47
46 /**
48 /**
47 * Deletes from the controller the variables passed in parameter.
49 * Deletes from the controller the variables passed in parameter.
48 * @param variables the variables to delete from the controller.
50 * @param variables the variables to delete from the controller.
49 * @sa deleteVariable()
51 * @sa deleteVariable()
50 */
52 */
51 void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept;
53 void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept;
52
54
53 /**
55 /**
54 * @brief abort the variable retrieve data progression
56 * @brief abort the variable retrieve data progression
55 */
57 */
56 void abortProgress(std::shared_ptr<Variable> variable);
58 void abortProgress(std::shared_ptr<Variable> variable);
57
59
58 signals:
60 signals:
59 /// Signal emitted when a variable is about to be deleted from the controller
61 /// Signal emitted when a variable is about to be deleted from the controller
60 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
62 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
61
63
62 /// Signal emitted when a data acquisition is requested on a range for a variable
64 /// Signal emitted when a data acquisition is requested on a range for a variable
63 void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range);
65 void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range);
64
66
65 public slots:
67 public slots:
66 /// Request the data loading of the variable whithin dateTime
68 /// Request the data loading of the variable whithin dateTime
67 void onRequestDataLoading(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
69 void onRequestDataLoading(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime);
68 /**
70 /**
69 * Creates a new variable and adds it to the model
71 * Creates a new variable and adds it to the model
70 * @param name the name of the new variable
72 * @param name the name of the new variable
71 * @param metadata the metadata of the new variable
73 * @param metadata the metadata of the new variable
72 * @param provider the data provider for the new variable
74 * @param provider the data provider for the new variable
73 */
75 */
74 void createVariable(const QString &name, const QVariantHash &metadata,
76 void createVariable(const QString &name, const QVariantHash &metadata,
75 std::shared_ptr<IDataProvider> provider) noexcept;
77 std::shared_ptr<IDataProvider> provider) noexcept;
76
78
77 /// Update the temporal parameters of every selected variable to dateTime
79 /// Update the temporal parameters of every selected variable to dateTime
78 void onDateTimeOnSelection(const SqpDateTime &dateTime);
80 void onDateTimeOnSelection(const SqpDateTime &dateTime);
79
81
80
82
81 void onVariableRetrieveDataInProgress(QUuid identifier, double progress);
83 void onVariableRetrieveDataInProgress(QUuid identifier, double progress);
82
84
83 void onAbortProgressRequested(std::shared_ptr<Variable> variable);
85 void onAbortProgressRequested(std::shared_ptr<Variable> variable);
84
86
85 void initialize();
87 void initialize();
86 void finalize();
88 void finalize();
87
89
88 private:
90 private:
89 void waitForFinish();
91 void waitForFinish();
90
92
91 class VariableControllerPrivate;
93 class VariableControllerPrivate;
92 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
94 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
93 };
95 };
94
96
95 #endif // SCIQLOP_VARIABLECONTROLLER_H
97 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -1,79 +1,80
1 #ifndef SCIQLOP_VARIABLEMODEL_H
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
3
4 #include "CoreGlobal.h"
4
5
5 #include <Data/SqpDateTime.h>
6 #include <Data/SqpDateTime.h>
6
7
7 #include <QAbstractTableModel>
8 #include <QAbstractTableModel>
8 #include <QLoggingCategory>
9 #include <QLoggingCategory>
9
10
10 #include <Common/MetaTypes.h>
11 #include <Common/MetaTypes.h>
11 #include <Common/spimpl.h>
12 #include <Common/spimpl.h>
12
13
13 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
14 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
14
15
15 enum VariableRoles { ProgressRole = Qt::UserRole };
16 enum VariableRoles { ProgressRole = Qt::UserRole };
16
17
17
18
18 class IDataSeries;
19 class IDataSeries;
19 class Variable;
20 class Variable;
20
21
21 /**
22 /**
22 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
23 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
23 */
24 */
24 class VariableModel : public QAbstractTableModel {
25 class SCIQLOP_CORE_EXPORT VariableModel : public QAbstractTableModel {
25 Q_OBJECT
26 Q_OBJECT
26 public:
27 public:
27 explicit VariableModel(QObject *parent = nullptr);
28 explicit VariableModel(QObject *parent = nullptr);
28
29
29 /**
30 /**
30 * Creates a new variable in the model
31 * Creates a new variable in the model
31 * @param name the name of the new variable
32 * @param name the name of the new variable
32 * @param dateTime the dateTime of the new variable
33 * @param dateTime the dateTime of the new variable
33 * @param metadata the metadata associated to the new variable
34 * @param metadata the metadata associated to the new variable
34 * @return the pointer to the new variable
35 * @return the pointer to the new variable
35 */
36 */
36 std::shared_ptr<Variable> createVariable(const QString &name, const SqpDateTime &dateTime,
37 std::shared_ptr<Variable> createVariable(const QString &name, const SqpDateTime &dateTime,
37 const QVariantHash &metadata) noexcept;
38 const QVariantHash &metadata) noexcept;
38
39
39 /**
40 /**
40 * Deletes a variable from the model, if it exists
41 * Deletes a variable from the model, if it exists
41 * @param variable the variable to delete
42 * @param variable the variable to delete
42 */
43 */
43 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
44 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
44
45
45
46
46 std::shared_ptr<Variable> variable(int index) const;
47 std::shared_ptr<Variable> variable(int index) const;
47
48
48 void setDataProgress(std::shared_ptr<Variable> variable, double progress);
49 void setDataProgress(std::shared_ptr<Variable> variable, double progress);
49
50
50
51
51 // /////////////////////////// //
52 // /////////////////////////// //
52 // QAbstractTableModel methods //
53 // QAbstractTableModel methods //
53 // /////////////////////////// //
54 // /////////////////////////// //
54
55
55 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
56 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
56 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
57 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
57 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
58 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
58 virtual QVariant headerData(int section, Qt::Orientation orientation,
59 virtual QVariant headerData(int section, Qt::Orientation orientation,
59 int role = Qt::DisplayRole) const override;
60 int role = Qt::DisplayRole) const override;
60
61
61
62
62 void abortProgress(const QModelIndex &index);
63 void abortProgress(const QModelIndex &index);
63
64
64 signals:
65 signals:
65 void abortProgessRequested(std::shared_ptr<Variable> variable);
66 void abortProgessRequested(std::shared_ptr<Variable> variable);
66
67
67 private:
68 private:
68 class VariableModelPrivate;
69 class VariableModelPrivate;
69 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
70 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
70
71
71 private slots:
72 private slots:
72 /// Slot called when data of a variable has been updated
73 /// Slot called when data of a variable has been updated
73 void onVariableUpdated() noexcept;
74 void onVariableUpdated() noexcept;
74 };
75 };
75
76
76 // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal
77 // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal
77 SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>)
78 SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>)
78
79
79 #endif // SCIQLOP_VARIABLEMODEL_H
80 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -1,49 +1,51
1 #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H
1 #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H
2 #define SCIQLOP_VISUALIZATIONCONTROLLER_H
2 #define SCIQLOP_VISUALIZATIONCONTROLLER_H
3
3
4 #include "CoreGlobal.h"
5
4 #include <Data/SqpDateTime.h>
6 #include <Data/SqpDateTime.h>
5
7
6 #include <QLoggingCategory>
8 #include <QLoggingCategory>
7 #include <QObject>
9 #include <QObject>
8 #include <QUuid>
10 #include <QUuid>
9
11
10 #include <Common/spimpl.h>
12 #include <Common/spimpl.h>
11
13
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
14 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
13
15
14 class DataSourceItem;
16 class DataSourceItem;
15 class Variable;
17 class Variable;
16
18
17 /**
19 /**
18 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
20 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
19 * This is the intermediate class that SciQlop has to use in the way to connect a data source.
21 * This is the intermediate class that SciQlop has to use in the way to connect a data source.
20 * Please first use register method to initialize a plugin specified by its metadata name (JSON
22 * Please first use register method to initialize a plugin specified by its metadata name (JSON
21 * plugin source) then others specifics method will be able to access it. You can load a data source
23 * plugin source) then others specifics method will be able to access it. You can load a data source
22 * driver plugin then create a data source.
24 * driver plugin then create a data source.
23 */
25 */
24 class VisualizationController : public QObject {
26 class SCIQLOP_CORE_EXPORT VisualizationController : public QObject {
25 Q_OBJECT
27 Q_OBJECT
26 public:
28 public:
27 explicit VisualizationController(QObject *parent = 0);
29 explicit VisualizationController(QObject *parent = 0);
28 virtual ~VisualizationController();
30 virtual ~VisualizationController();
29
31
30 signals:
32 signals:
31 /// Signal emitted when a variable is about to be deleted from SciQlop
33 /// Signal emitted when a variable is about to be deleted from SciQlop
32 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
34 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
33
35
34 /// Signal emitted when a data acquisition is requested on a range for a variable
36 /// Signal emitted when a data acquisition is requested on a range for a variable
35 void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range);
37 void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range);
36
38
37 public slots:
39 public slots:
38 /// Manage init/end of the controller
40 /// Manage init/end of the controller
39 void initialize();
41 void initialize();
40 void finalize();
42 void finalize();
41
43
42 private:
44 private:
43 void waitForFinish();
45 void waitForFinish();
44
46
45 class VisualizationControllerPrivate;
47 class VisualizationControllerPrivate;
46 spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl;
48 spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl;
47 };
49 };
48
50
49 #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H
51 #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H
@@ -1,161 +1,161
1 #include "Visualization/VisualizationGraphHelper.h"
1 #include "Visualization/VisualizationGraphHelper.h"
2 #include "Visualization/qcustomplot.h"
2 #include "Visualization/qcustomplot.h"
3
3
4 #include <Data/ScalarSeries.h>
4 #include <Data/ScalarSeries.h>
5
5
6 #include <Variable/Variable.h>
6 #include <Variable/Variable.h>
7
7
8 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
8 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
9
9
10 namespace {
10 namespace {
11
11
12 class SqpDataContainer : public QCPGraphDataContainer {
12 class SqpDataContainer : public QCPGraphDataContainer {
13 public:
13 public:
14 void appendGraphData(const QCPGraphData &data) { mData.append(data); }
14 void appendGraphData(const QCPGraphData &data) { mData.append(data); }
15 };
15 };
16
16
17
17
18 /// Format for datetimes on a axis
18 /// Format for datetimes on a axis
19 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
19 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
20
20
21 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
21 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
22 /// non-time data
22 /// non-time data
23 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
23 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
24 {
24 {
25 if (isTimeAxis) {
25 if (isTimeAxis) {
26 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
26 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
27 dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT);
27 dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT);
28
28
29 return dateTicker;
29 return dateTicker;
30 }
30 }
31 else {
31 else {
32 // default ticker
32 // default ticker
33 return QSharedPointer<QCPAxisTicker>::create();
33 return QSharedPointer<QCPAxisTicker>::create();
34 }
34 }
35 }
35 }
36
36
37 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries,
37 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries,
38 const SqpDateTime &dateTime)
38 const SqpDateTime &dateTime)
39 {
39 {
40 qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData"
40 qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData"
41 << QThread::currentThread()->objectName();
41 << QThread::currentThread()->objectName();
42 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
42 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
43 scalarSeries.lockRead();
43 scalarSeries.lockRead();
44 {
44 {
45 const auto &xData = scalarSeries.xAxisData()->cdata();
45 const auto &xData = scalarSeries.xAxisData()->cdata();
46 const auto &valuesData = scalarSeries.valuesData()->cdata();
46 const auto &valuesData = scalarSeries.valuesData()->cdata();
47
47
48 auto xDataBegin = xData.cbegin();
48 auto xDataBegin = xData.cbegin();
49 auto xDataEnd = xData.cend();
49 auto xDataEnd = xData.cend();
50
50
51 qCInfo(LOG_VisualizationGraphHelper())
51 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache"
52 << "TORM: Current points in cache" << xData.count();
52 << xData.count();
53
53
54 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
54 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
55 qcpGraph->setData(sqpDataContainer);
55 qcpGraph->setData(sqpDataContainer);
56
56
57 auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
57 auto lowerIt = std::lower_bound(xDataBegin, xDataEnd, dateTime.m_TStart);
58 auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
58 auto upperIt = std::upper_bound(xDataBegin, xDataEnd, dateTime.m_TEnd);
59 auto distance = std::distance(xDataBegin, lowerIt);
59 auto distance = std::distance(xDataBegin, lowerIt);
60
60
61 auto valuesDataIt = valuesData.cbegin() + distance;
61 auto valuesDataIt = valuesData.cbegin() + distance;
62 for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
62 for (auto xAxisDataIt = lowerIt; xAxisDataIt != upperIt;
63 ++xAxisDataIt, ++valuesDataIt) {
63 ++xAxisDataIt, ++valuesDataIt) {
64 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
64 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
65 }
65 }
66
66
67 qCInfo(LOG_VisualizationGraphHelper())
67 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points displayed"
68 << "TORM: Current points displayed" << sqpDataContainer->size();
68 << sqpDataContainer->size();
69 }
69 }
70 scalarSeries.unlock();
70 scalarSeries.unlock();
71
71
72
72
73 // Display all data
73 // Display all data
74 component->parentPlot()->replot();
74 component->parentPlot()->replot();
75 }
75 }
76 else {
76 else {
77 /// @todo DEBUG
77 /// @todo DEBUG
78 }
78 }
79 }
79 }
80
80
81 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot,
81 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot,
82 const SqpDateTime &dateTime)
82 const SqpDateTime &dateTime)
83 {
83 {
84 auto component = plot.addGraph();
84 auto component = plot.addGraph();
85
85
86 if (component) {
86 if (component) {
87 // // Graph data
87 // // Graph data
88 component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(),
88 component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(),
89 true);
89 true);
90
90
91 updateScalarData(component, scalarSeries, dateTime);
91 updateScalarData(component, scalarSeries, dateTime);
92
92
93 // Axes properties
93 // Axes properties
94 /// @todo : for the moment, no control is performed on the axes: the units and the tickers
94 /// @todo : for the moment, no control is performed on the axes: the units and the tickers
95 /// are fixed for the default x-axis and y-axis of the plot, and according to the new graph
95 /// are fixed for the default x-axis and y-axis of the plot, and according to the new graph
96
96
97 auto setAxisProperties = [](auto axis, const auto &unit) {
97 auto setAxisProperties = [](auto axis, const auto &unit) {
98 // label (unit name)
98 // label (unit name)
99 axis->setLabel(unit.m_Name);
99 axis->setLabel(unit.m_Name);
100
100
101 // ticker (depending on the type of unit)
101 // ticker (depending on the type of unit)
102 axis->setTicker(axisTicker(unit.m_TimeUnit));
102 axis->setTicker(axisTicker(unit.m_TimeUnit));
103 };
103 };
104 setAxisProperties(plot.xAxis, scalarSeries.xAxisUnit());
104 setAxisProperties(plot.xAxis, scalarSeries.xAxisUnit());
105 setAxisProperties(plot.yAxis, scalarSeries.valuesUnit());
105 setAxisProperties(plot.yAxis, scalarSeries.valuesUnit());
106
106
107 // Display all data
107 // Display all data
108 component->rescaleAxes();
108 component->rescaleAxes();
109 plot.replot();
109 plot.replot();
110 }
110 }
111 else {
111 else {
112 qCDebug(LOG_VisualizationGraphHelper())
112 qCDebug(LOG_VisualizationGraphHelper())
113 << QObject::tr("Can't create graph for the scalar series");
113 << QObject::tr("Can't create graph for the scalar series");
114 }
114 }
115
115
116 return component;
116 return component;
117 }
117 }
118
118
119 } // namespace
119 } // namespace
120
120
121 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable,
121 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable,
122 QCustomPlot &plot) noexcept
122 QCustomPlot &plot) noexcept
123 {
123 {
124 auto result = QVector<QCPAbstractPlottable *>{};
124 auto result = QVector<QCPAbstractPlottable *>{};
125
125
126 if (variable) {
126 if (variable) {
127 // Gets the data series of the variable to call the creation of the right components
127 // Gets the data series of the variable to call the creation of the right components
128 // according to its type
128 // according to its type
129 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(variable->dataSeries())) {
129 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(variable->dataSeries())) {
130 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime()));
130 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime()));
131 }
131 }
132 else {
132 else {
133 qCDebug(LOG_VisualizationGraphHelper())
133 qCDebug(LOG_VisualizationGraphHelper())
134 << QObject::tr("Can't create graph plottables : unmanaged data series type");
134 << QObject::tr("Can't create graph plottables : unmanaged data series type");
135 }
135 }
136 }
136 }
137 else {
137 else {
138 qCDebug(LOG_VisualizationGraphHelper())
138 qCDebug(LOG_VisualizationGraphHelper())
139 << QObject::tr("Can't create graph plottables : the variable is null");
139 << QObject::tr("Can't create graph plottables : the variable is null");
140 }
140 }
141
141
142 return result;
142 return result;
143 }
143 }
144
144
145 void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect,
145 void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect,
146 IDataSeries *dataSeries, const SqpDateTime &dateTime)
146 IDataSeries *dataSeries, const SqpDateTime &dateTime)
147 {
147 {
148 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
148 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
149 if (plotableVect.size() == 1) {
149 if (plotableVect.size() == 1) {
150 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
150 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
151 }
151 }
152 else {
152 else {
153 qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr(
153 qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr(
154 "Can't update Data of a scalarSeries because there is not only one component "
154 "Can't update Data of a scalarSeries because there is not only one component "
155 "associated");
155 "associated");
156 }
156 }
157 }
157 }
158 else {
158 else {
159 /// @todo DEBUG
159 /// @todo DEBUG
160 }
160 }
161 }
161 }
@@ -1,401 +1,412
1 #include "Visualization/VisualizationGraphWidget.h"
1 #include "Visualization/VisualizationGraphWidget.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
3 #include "Visualization/VisualizationGraphHelper.h"
3 #include "Visualization/VisualizationGraphHelper.h"
4 #include "ui_VisualizationGraphWidget.h"
4 #include "ui_VisualizationGraphWidget.h"
5
5
6 #include <Data/ArrayData.h>
6 #include <Data/ArrayData.h>
7 #include <Data/IDataSeries.h>
7 #include <Data/IDataSeries.h>
8 #include <Settings/SqpSettingsDefs.h>
8 #include <SqpApplication.h>
9 #include <SqpApplication.h>
9 #include <Variable/Variable.h>
10 #include <Variable/Variable.h>
10 #include <Variable/VariableController.h>
11 #include <Variable/VariableController.h>
11
12
12 #include <unordered_map>
13 #include <unordered_map>
13
14
14 Q_LOGGING_CATEGORY(LOG_VisualizationGraphWidget, "VisualizationGraphWidget")
15 Q_LOGGING_CATEGORY(LOG_VisualizationGraphWidget, "VisualizationGraphWidget")
15
16
16 namespace {
17 namespace {
17
18
18 /// Key pressed to enable zoom on horizontal axis
19 /// Key pressed to enable zoom on horizontal axis
19 const auto HORIZONTAL_ZOOM_MODIFIER = Qt::NoModifier;
20 const auto HORIZONTAL_ZOOM_MODIFIER = Qt::NoModifier;
20
21
21 /// Key pressed to enable zoom on vertical axis
22 /// Key pressed to enable zoom on vertical axis
22 const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier;
23 const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier;
23
24
25 /// Gets a tolerance value from application settings. If the setting can't be found, the default
26 /// value passed in parameter is returned
27 double toleranceValue(const QString &key, double defaultValue) noexcept
28 {
29 return QSettings{}.value(key, defaultValue).toDouble();
30 }
31
24 } // namespace
32 } // namespace
25
33
26 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
34 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
27
35
28 explicit VisualizationGraphWidgetPrivate() : m_DoSynchronize{true}, m_IsCalibration{false} {}
36 explicit VisualizationGraphWidgetPrivate() : m_DoSynchronize{true}, m_IsCalibration{false} {}
29
37
30
38
31 // Return the operation when range changed
39 // Return the operation when range changed
32 VisualizationGraphWidgetZoomType getZoomType(const QCPRange &t1, const QCPRange &t2);
40 VisualizationGraphWidgetZoomType getZoomType(const QCPRange &t1, const QCPRange &t2);
33
41
34 // 1 variable -> n qcpplot
42 // 1 variable -> n qcpplot
35 std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap;
43 std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap;
36
44
37 bool m_DoSynchronize;
45 bool m_DoSynchronize;
38 bool m_IsCalibration;
46 bool m_IsCalibration;
39 };
47 };
40
48
41 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent)
49 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent)
42 : QWidget{parent},
50 : QWidget{parent},
43 ui{new Ui::VisualizationGraphWidget},
51 ui{new Ui::VisualizationGraphWidget},
44 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
52 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
45 {
53 {
46 ui->setupUi(this);
54 ui->setupUi(this);
47
55
48 ui->graphNameLabel->setText(name);
56 ui->graphNameLabel->setText(name);
49
57
50 // 'Close' options : widget is deleted when closed
58 // 'Close' options : widget is deleted when closed
51 setAttribute(Qt::WA_DeleteOnClose);
59 setAttribute(Qt::WA_DeleteOnClose);
52 connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationGraphWidget::close);
60 connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationGraphWidget::close);
53 ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
61 ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
54
62
55 // Set qcpplot properties :
63 // Set qcpplot properties :
56 // - Drag (on x-axis) and zoom are enabled
64 // - Drag (on x-axis) and zoom are enabled
57 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
65 // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation
58 ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
66 ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
59 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal);
67 ui->widget->axisRect()->setRangeDrag(Qt::Horizontal);
60 connect(ui->widget, &QCustomPlot::mousePress, this, &VisualizationGraphWidget::onMousePress);
68 connect(ui->widget, &QCustomPlot::mousePress, this, &VisualizationGraphWidget::onMousePress);
61 connect(ui->widget, &QCustomPlot::mouseRelease, this,
69 connect(ui->widget, &QCustomPlot::mouseRelease, this,
62 &VisualizationGraphWidget::onMouseRelease);
70 &VisualizationGraphWidget::onMouseRelease);
63 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
71 connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel);
64 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
72 connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>(
65 &QCPAxis::rangeChanged),
73 &QCPAxis::rangeChanged),
66 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
74 this, &VisualizationGraphWidget::onRangeChanged, Qt::DirectConnection);
67
75
68 // Activates menu when right clicking on the graph
76 // Activates menu when right clicking on the graph
69 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
77 ui->widget->setContextMenuPolicy(Qt::CustomContextMenu);
70 connect(ui->widget, &QCustomPlot::customContextMenuRequested, this,
78 connect(ui->widget, &QCustomPlot::customContextMenuRequested, this,
71 &VisualizationGraphWidget::onGraphMenuRequested);
79 &VisualizationGraphWidget::onGraphMenuRequested);
72
80
73 connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(),
81 connect(this, &VisualizationGraphWidget::requestDataLoading, &sqpApp->variableController(),
74 &VariableController::onRequestDataLoading);
82 &VariableController::onRequestDataLoading);
75 }
83 }
76
84
77
85
78 VisualizationGraphWidget::~VisualizationGraphWidget()
86 VisualizationGraphWidget::~VisualizationGraphWidget()
79 {
87 {
80 delete ui;
88 delete ui;
81 }
89 }
82
90
83 void VisualizationGraphWidget::enableSynchronize(bool enable)
91 void VisualizationGraphWidget::enableSynchronize(bool enable)
84 {
92 {
85 impl->m_DoSynchronize = enable;
93 impl->m_DoSynchronize = enable;
86 }
94 }
87
95
88 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
96 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
89 {
97 {
90 // Uses delegate to create the qcpplot components according to the variable
98 // Uses delegate to create the qcpplot components according to the variable
91 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
99 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
92
100
93 for (auto createdPlottable : qAsConst(createdPlottables)) {
101 for (auto createdPlottable : qAsConst(createdPlottables)) {
94 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
102 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
95 }
103 }
96
104
97 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
105 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
98 }
106 }
99 void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable)
107 void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable)
100 {
108 {
101
109
102 // when adding a variable, we need to set its time range to the current graph range
110 // when adding a variable, we need to set its time range to the current graph range
103 auto grapheRange = ui->widget->xAxis->range();
111 auto grapheRange = ui->widget->xAxis->range();
104 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
112 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
105 variable->setDateTime(dateTime);
113 variable->setDateTime(dateTime);
106
114
107 auto variableDateTimeWithTolerance = dateTime;
115 auto variableDateTimeWithTolerance = dateTime;
108
116
109 // add 20% tolerance for each side
117 // add tolerance for each side
110 auto tolerance = 0.2 * (dateTime.m_TEnd - dateTime.m_TStart);
118 auto toleranceFactor
119 = toleranceValue(GENERAL_TOLERANCE_AT_INIT_KEY, GENERAL_TOLERANCE_AT_INIT_DEFAULT_VALUE);
120 auto tolerance = toleranceFactor * (dateTime.m_TEnd - dateTime.m_TStart);
111 variableDateTimeWithTolerance.m_TStart -= tolerance;
121 variableDateTimeWithTolerance.m_TStart -= tolerance;
112 variableDateTimeWithTolerance.m_TEnd += tolerance;
122 variableDateTimeWithTolerance.m_TEnd += tolerance;
113
123
114 // Uses delegate to create the qcpplot components according to the variable
124 // Uses delegate to create the qcpplot components according to the variable
115 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
125 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
116
126
117 for (auto createdPlottable : qAsConst(createdPlottables)) {
127 for (auto createdPlottable : qAsConst(createdPlottables)) {
118 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
128 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
119 }
129 }
120
130
121 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
131 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
122
132
123 // CHangement detected, we need to ask controller to request data loading
133 // CHangement detected, we need to ask controller to request data loading
124 emit requestDataLoading(variable, variableDateTimeWithTolerance);
134 emit requestDataLoading(variable, variableDateTimeWithTolerance);
125 }
135 }
126
136
127 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept
137 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept
128 {
138 {
129 // Each component associated to the variable :
139 // Each component associated to the variable :
130 // - is removed from qcpplot (which deletes it)
140 // - is removed from qcpplot (which deletes it)
131 // - is no longer referenced in the map
141 // - is no longer referenced in the map
132 auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
142 auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
133 for (auto it = componentsIt.first; it != componentsIt.second;) {
143 for (auto it = componentsIt.first; it != componentsIt.second;) {
134 ui->widget->removePlottable(it->second);
144 ui->widget->removePlottable(it->second);
135 it = impl->m_VariableToPlotMultiMap.erase(it);
145 it = impl->m_VariableToPlotMultiMap.erase(it);
136 }
146 }
137
147
138 // Updates graph
148 // Updates graph
139 ui->widget->replot();
149 ui->widget->replot();
140 }
150 }
141
151
142 void VisualizationGraphWidget::setRange(std::shared_ptr<Variable> variable,
152 void VisualizationGraphWidget::setRange(std::shared_ptr<Variable> variable,
143 const SqpDateTime &range)
153 const SqpDateTime &range)
144 {
154 {
145 // Note: in case of different axes that depends on variable, we could start with a code like
155 // Note: in case of different axes that depends on variable, we could start with a code like
146 // that:
156 // that:
147 // auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
157 // auto componentsIt = impl->m_VariableToPlotMultiMap.equal_range(variable);
148 // for (auto it = componentsIt.first; it != componentsIt.second;) {
158 // for (auto it = componentsIt.first; it != componentsIt.second;) {
149 // }
159 // }
150 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
160 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
151 ui->widget->replot();
161 ui->widget->replot();
152 }
162 }
153
163
154 SqpDateTime VisualizationGraphWidget::graphRange() const noexcept
164 SqpDateTime VisualizationGraphWidget::graphRange() const noexcept
155 {
165 {
156 auto grapheRange = ui->widget->xAxis->range();
166 auto grapheRange = ui->widget->xAxis->range();
157 return SqpDateTime{grapheRange.lower, grapheRange.upper};
167 return SqpDateTime{grapheRange.lower, grapheRange.upper};
158 }
168 }
159
169
160 void VisualizationGraphWidget::setGraphRange(const SqpDateTime &range)
170 void VisualizationGraphWidget::setGraphRange(const SqpDateTime &range)
161 {
171 {
162 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START");
172 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange START");
163 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
173 ui->widget->xAxis->setRange(range.m_TStart, range.m_TEnd);
164 ui->widget->replot();
174 ui->widget->replot();
165 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END");
175 qCDebug(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::setGraphRange END");
166 }
176 }
167
177
168 void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor)
178 void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor)
169 {
179 {
170 if (visitor) {
180 if (visitor) {
171 visitor->visit(this);
181 visitor->visit(this);
172 }
182 }
173 else {
183 else {
174 qCCritical(LOG_VisualizationGraphWidget())
184 qCCritical(LOG_VisualizationGraphWidget())
175 << tr("Can't visit widget : the visitor is null");
185 << tr("Can't visit widget : the visitor is null");
176 }
186 }
177 }
187 }
178
188
179 bool VisualizationGraphWidget::canDrop(const Variable &variable) const
189 bool VisualizationGraphWidget::canDrop(const Variable &variable) const
180 {
190 {
181 /// @todo : for the moment, a graph can always accomodate a variable
191 /// @todo : for the moment, a graph can always accomodate a variable
182 Q_UNUSED(variable);
192 Q_UNUSED(variable);
183 return true;
193 return true;
184 }
194 }
185
195
186 bool VisualizationGraphWidget::contains(const Variable &variable) const
196 bool VisualizationGraphWidget::contains(const Variable &variable) const
187 {
197 {
188 // Finds the variable among the keys of the map
198 // Finds the variable among the keys of the map
189 auto variablePtr = &variable;
199 auto variablePtr = &variable;
190 auto findVariable
200 auto findVariable
191 = [variablePtr](const auto &entry) { return variablePtr == entry.first.get(); };
201 = [variablePtr](const auto &entry) { return variablePtr == entry.first.get(); };
192
202
193 auto end = impl->m_VariableToPlotMultiMap.cend();
203 auto end = impl->m_VariableToPlotMultiMap.cend();
194 auto it = std::find_if(impl->m_VariableToPlotMultiMap.cbegin(), end, findVariable);
204 auto it = std::find_if(impl->m_VariableToPlotMultiMap.cbegin(), end, findVariable);
195 return it != end;
205 return it != end;
196 }
206 }
197
207
198 QString VisualizationGraphWidget::name() const
208 QString VisualizationGraphWidget::name() const
199 {
209 {
200 return ui->graphNameLabel->text();
210 return ui->graphNameLabel->text();
201 }
211 }
202
212
203 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
213 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept
204 {
214 {
205 QMenu graphMenu{};
215 QMenu graphMenu{};
206
216
207 // Iterates on variables (unique keys)
217 // Iterates on variables (unique keys)
208 for (auto it = impl->m_VariableToPlotMultiMap.cbegin(),
218 for (auto it = impl->m_VariableToPlotMultiMap.cbegin(),
209 end = impl->m_VariableToPlotMultiMap.cend();
219 end = impl->m_VariableToPlotMultiMap.cend();
210 it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) {
220 it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) {
211 // 'Remove variable' action
221 // 'Remove variable' action
212 graphMenu.addAction(tr("Remove variable %1").arg(it->first->name()),
222 graphMenu.addAction(tr("Remove variable %1").arg(it->first->name()),
213 [ this, var = it->first ]() { removeVariable(var); });
223 [ this, var = it->first ]() { removeVariable(var); });
214 }
224 }
215
225
216 if (!graphMenu.isEmpty()) {
226 if (!graphMenu.isEmpty()) {
217 graphMenu.exec(mapToGlobal(pos));
227 graphMenu.exec(mapToGlobal(pos));
218 }
228 }
219 }
229 }
220
230
221 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2)
231 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2)
222 {
232 {
223 qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
233 qCInfo(LOG_VisualizationGraphWidget()) << tr("VisualizationGraphWidget::onRangeChanged")
224 << QThread::currentThread()->objectName();
234 << QThread::currentThread()->objectName();
225
235
226 auto dateTimeRange = SqpDateTime{t1.lower, t1.upper};
236 auto dateTimeRange = SqpDateTime{t1.lower, t1.upper};
227
237
228 auto zoomType = impl->getZoomType(t1, t2);
238 auto zoomType = impl->getZoomType(t1, t2);
229 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
239 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
230 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
240 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
231
241
232 auto variable = it->first;
242 auto variable = it->first;
233 auto currentDateTime = dateTimeRange;
243 auto currentDateTime = dateTimeRange;
234
244
235 auto toleranceFactor = 0.2;
245 auto toleranceFactor = toleranceValue(GENERAL_TOLERANCE_AT_UPDATE_KEY,
246 GENERAL_TOLERANCE_AT_UPDATE_DEFAULT_VALUE);
236 auto tolerance = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
247 auto tolerance = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
237 auto variableDateTimeWithTolerance = currentDateTime;
248 auto variableDateTimeWithTolerance = currentDateTime;
238 variableDateTimeWithTolerance.m_TStart -= tolerance;
249 variableDateTimeWithTolerance.m_TStart -= tolerance;
239 variableDateTimeWithTolerance.m_TEnd += tolerance;
250 variableDateTimeWithTolerance.m_TEnd += tolerance;
240
251
241 qCDebug(LOG_VisualizationGraphWidget()) << "r" << currentDateTime;
252 qCDebug(LOG_VisualizationGraphWidget()) << "r" << currentDateTime;
242 qCDebug(LOG_VisualizationGraphWidget()) << "t" << variableDateTimeWithTolerance;
253 qCDebug(LOG_VisualizationGraphWidget()) << "t" << variableDateTimeWithTolerance;
243 qCDebug(LOG_VisualizationGraphWidget()) << "v" << variable->dateTime();
254 qCDebug(LOG_VisualizationGraphWidget()) << "v" << variable->dateTime();
244 // If new range with tol is upper than variable datetime parameters. we need to request new
255 // If new range with tol is upper than variable datetime parameters. we need to request new
245 // data
256 // data
246 if (!variable->contains(variableDateTimeWithTolerance)) {
257 if (!variable->contains(variableDateTimeWithTolerance)) {
247
258
248 auto variableDateTimeWithTolerance = currentDateTime;
259 auto variableDateTimeWithTolerance = currentDateTime;
249 if (!variable->isInside(currentDateTime)) {
260 if (!variable->isInside(currentDateTime)) {
250 auto variableDateTime = variable->dateTime();
261 auto variableDateTime = variable->dateTime();
251 if (variable->contains(variableDateTimeWithTolerance)) {
262 if (variable->contains(variableDateTimeWithTolerance)) {
252 qCDebug(LOG_VisualizationGraphWidget())
263 qCDebug(LOG_VisualizationGraphWidget())
253 << tr("TORM: Detection zoom in that need request:");
264 << tr("TORM: Detection zoom in that need request:");
254 // add 10% tolerance for each side
265 // add tolerance for each side
255 tolerance
266 tolerance
256 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
267 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
257 variableDateTimeWithTolerance.m_TStart -= tolerance;
268 variableDateTimeWithTolerance.m_TStart -= tolerance;
258 variableDateTimeWithTolerance.m_TEnd += tolerance;
269 variableDateTimeWithTolerance.m_TEnd += tolerance;
259 }
270 }
260 else if (variableDateTime.m_TStart < currentDateTime.m_TStart) {
271 else if (variableDateTime.m_TStart < currentDateTime.m_TStart) {
261 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to right:");
272 qCInfo(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to right:");
262
273
263 auto diffEndToKeepDelta = currentDateTime.m_TEnd - variableDateTime.m_TEnd;
274 auto diffEndToKeepDelta = currentDateTime.m_TEnd - variableDateTime.m_TEnd;
264 currentDateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
275 currentDateTime.m_TStart = variableDateTime.m_TStart + diffEndToKeepDelta;
265 // Tolerance have to be added to the right
276 // Tolerance have to be added to the right
266 // add tolerance for right (end) side
277 // add tolerance for right (end) side
267 tolerance
278 tolerance
268 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
279 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
269 variableDateTimeWithTolerance.m_TEnd += tolerance;
280 variableDateTimeWithTolerance.m_TEnd += tolerance;
270 }
281 }
271 else if (variableDateTime.m_TEnd > currentDateTime.m_TEnd) {
282 else if (variableDateTime.m_TEnd > currentDateTime.m_TEnd) {
272 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to left: ");
283 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection pan to left: ");
273 auto diffStartToKeepDelta
284 auto diffStartToKeepDelta
274 = variableDateTime.m_TStart - currentDateTime.m_TStart;
285 = variableDateTime.m_TStart - currentDateTime.m_TStart;
275 currentDateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
286 currentDateTime.m_TEnd = variableDateTime.m_TEnd - diffStartToKeepDelta;
276 // Tolerance have to be added to the left
287 // Tolerance have to be added to the left
277 // add tolerance for left (start) side
288 // add tolerance for left (start) side
278 tolerance
289 tolerance
279 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
290 = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
280 variableDateTimeWithTolerance.m_TStart -= tolerance;
291 variableDateTimeWithTolerance.m_TStart -= tolerance;
281 }
292 }
282 else {
293 else {
283 qCCritical(LOG_VisualizationGraphWidget())
294 qCCritical(LOG_VisualizationGraphWidget())
284 << tr("Detection anormal zoom detection: ");
295 << tr("Detection anormal zoom detection: ");
285 }
296 }
286 }
297 }
287 else {
298 else {
288 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection zoom out: ");
299 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Detection zoom out: ");
289 // add 10% tolerance for each side
300 // add tolerance for each side
290 tolerance = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
301 tolerance = toleranceFactor * (currentDateTime.m_TEnd - currentDateTime.m_TStart);
291 variableDateTimeWithTolerance.m_TStart -= tolerance;
302 variableDateTimeWithTolerance.m_TStart -= tolerance;
292 variableDateTimeWithTolerance.m_TEnd += tolerance;
303 variableDateTimeWithTolerance.m_TEnd += tolerance;
293 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
304 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
294 }
305 }
295 if (!variable->contains(dateTimeRange)) {
306 if (!variable->contains(dateTimeRange)) {
296 qCDebug(LOG_VisualizationGraphWidget())
307 qCDebug(LOG_VisualizationGraphWidget())
297 << "TORM: Modif on variable datetime detected" << currentDateTime;
308 << "TORM: Modif on variable datetime detected" << currentDateTime;
298 variable->setDateTime(currentDateTime);
309 variable->setDateTime(currentDateTime);
299 }
310 }
300
311
301 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Request data detection: ");
312 qCDebug(LOG_VisualizationGraphWidget()) << tr("TORM: Request data detection: ");
302 // CHangement detected, we need to ask controller to request data loading
313 // CHangement detected, we need to ask controller to request data loading
303 emit requestDataLoading(variable, variableDateTimeWithTolerance);
314 emit requestDataLoading(variable, variableDateTimeWithTolerance);
304 }
315 }
305 else {
316 else {
306 qCInfo(LOG_VisualizationGraphWidget())
317 qCInfo(LOG_VisualizationGraphWidget())
307 << tr("TORM: Detection zoom in that doesn't need request: ");
318 << tr("TORM: Detection zoom in that doesn't need request: ");
308 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
319 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
309 }
320 }
310 }
321 }
311
322
312 if (impl->m_DoSynchronize && !impl->m_IsCalibration) {
323 if (impl->m_DoSynchronize && !impl->m_IsCalibration) {
313 auto oldDateTime = SqpDateTime{t2.lower, t2.upper};
324 auto oldDateTime = SqpDateTime{t2.lower, t2.upper};
314 qCDebug(LOG_VisualizationGraphWidget())
325 qCDebug(LOG_VisualizationGraphWidget())
315 << tr("TORM: VisualizationGraphWidget::Synchronize notify !!")
326 << tr("TORM: VisualizationGraphWidget::Synchronize notify !!")
316 << QThread::currentThread()->objectName();
327 << QThread::currentThread()->objectName();
317 emit synchronize(dateTimeRange, oldDateTime, zoomType);
328 emit synchronize(dateTimeRange, oldDateTime, zoomType);
318 }
329 }
319 }
330 }
320
331
321 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
332 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
322 {
333 {
323 auto zoomOrientations = QFlags<Qt::Orientation>{};
334 auto zoomOrientations = QFlags<Qt::Orientation>{};
324
335
325 // Lambda that enables a zoom orientation if the key modifier related to this orientation
336 // Lambda that enables a zoom orientation if the key modifier related to this orientation
326 // has
337 // has
327 // been pressed
338 // been pressed
328 auto enableOrientation
339 auto enableOrientation
329 = [&zoomOrientations, event](const auto &orientation, const auto &modifier) {
340 = [&zoomOrientations, event](const auto &orientation, const auto &modifier) {
330 auto orientationEnabled = event->modifiers().testFlag(modifier);
341 auto orientationEnabled = event->modifiers().testFlag(modifier);
331 zoomOrientations.setFlag(orientation, orientationEnabled);
342 zoomOrientations.setFlag(orientation, orientationEnabled);
332 };
343 };
333 enableOrientation(Qt::Vertical, VERTICAL_ZOOM_MODIFIER);
344 enableOrientation(Qt::Vertical, VERTICAL_ZOOM_MODIFIER);
334 enableOrientation(Qt::Horizontal, HORIZONTAL_ZOOM_MODIFIER);
345 enableOrientation(Qt::Horizontal, HORIZONTAL_ZOOM_MODIFIER);
335
346
336 ui->widget->axisRect()->setRangeZoom(zoomOrientations);
347 ui->widget->axisRect()->setRangeZoom(zoomOrientations);
337 }
348 }
338
349
339 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
350 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
340 {
351 {
341 impl->m_IsCalibration = event->modifiers().testFlag(Qt::ControlModifier);
352 impl->m_IsCalibration = event->modifiers().testFlag(Qt::ControlModifier);
342 }
353 }
343
354
344 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept
355 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept
345 {
356 {
346 impl->m_IsCalibration = false;
357 impl->m_IsCalibration = false;
347 }
358 }
348
359
349 void VisualizationGraphWidget::onDataCacheVariableUpdated()
360 void VisualizationGraphWidget::onDataCacheVariableUpdated()
350 {
361 {
351 // NOTE:
362 // NOTE:
352 // We don't want to call the method for each component of a variable unitarily, but for
363 // We don't want to call the method for each component of a variable unitarily, but for
353 // all
364 // all
354 // its components at once (eg its three components in the case of a vector).
365 // its components at once (eg its three components in the case of a vector).
355
366
356 // The unordered_multimap does not do this easily, so the question is whether to:
367 // The unordered_multimap does not do this easily, so the question is whether to:
357 // - use an ordered_multimap and the algos of std to group the values by key
368 // - use an ordered_multimap and the algos of std to group the values by key
358 // - use a map (unique keys) and store as values directly the list of components
369 // - use a map (unique keys) and store as values directly the list of components
359
370
360 auto grapheRange = ui->widget->xAxis->range();
371 auto grapheRange = ui->widget->xAxis->range();
361 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
372 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
362
373
363 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
374 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
364 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
375 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
365 auto variable = it->first;
376 auto variable = it->first;
366 qCDebug(LOG_VisualizationGraphWidget())
377 qCDebug(LOG_VisualizationGraphWidget())
367 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated S"
378 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated S"
368 << variable->dateTime();
379 << variable->dateTime();
369 qCDebug(LOG_VisualizationGraphWidget())
380 qCDebug(LOG_VisualizationGraphWidget())
370 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated E" << dateTime;
381 << "TORM: VisualizationGraphWidget::onDataCacheVariableUpdated E" << dateTime;
371 if (dateTime.contains(variable->dateTime()) || dateTime.intersect(variable->dateTime())) {
382 if (dateTime.contains(variable->dateTime()) || dateTime.intersect(variable->dateTime())) {
372
383
373 VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
384 VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
374 variable->dataSeries(), variable->dateTime());
385 variable->dataSeries(), variable->dateTime());
375 }
386 }
376 }
387 }
377 }
388 }
378
389
379 VisualizationGraphWidgetZoomType
390 VisualizationGraphWidgetZoomType
380 VisualizationGraphWidget::VisualizationGraphWidgetPrivate::getZoomType(const QCPRange &t1,
391 VisualizationGraphWidget::VisualizationGraphWidgetPrivate::getZoomType(const QCPRange &t1,
381 const QCPRange &t2)
392 const QCPRange &t2)
382 {
393 {
383 // t1.lower <= t2.lower && t2.upper <= t1.upper
394 // t1.lower <= t2.lower && t2.upper <= t1.upper
384 auto zoomType = VisualizationGraphWidgetZoomType::Unknown;
395 auto zoomType = VisualizationGraphWidgetZoomType::Unknown;
385 if (t1.lower <= t2.lower && t2.upper <= t1.upper) {
396 if (t1.lower <= t2.lower && t2.upper <= t1.upper) {
386 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
397 zoomType = VisualizationGraphWidgetZoomType::ZoomOut;
387 }
398 }
388 else if (t1.lower > t2.lower && t1.upper > t2.upper) {
399 else if (t1.lower > t2.lower && t1.upper > t2.upper) {
389 zoomType = VisualizationGraphWidgetZoomType::PanRight;
400 zoomType = VisualizationGraphWidgetZoomType::PanRight;
390 }
401 }
391 else if (t1.lower < t2.lower && t1.upper < t2.upper) {
402 else if (t1.lower < t2.lower && t1.upper < t2.upper) {
392 zoomType = VisualizationGraphWidgetZoomType::PanLeft;
403 zoomType = VisualizationGraphWidgetZoomType::PanLeft;
393 }
404 }
394 else if (t1.lower > t2.lower && t2.upper > t1.upper) {
405 else if (t1.lower > t2.lower && t2.upper > t1.upper) {
395 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
406 zoomType = VisualizationGraphWidgetZoomType::ZoomIn;
396 }
407 }
397 else {
408 else {
398 qCCritical(LOG_VisualizationGraphWidget()) << "getZoomType: Unknown type detected";
409 qCCritical(LOG_VisualizationGraphWidget()) << "getZoomType: Unknown type detected";
399 }
410 }
400 return zoomType;
411 return zoomType;
401 }
412 }
@@ -1,148 +1,147
1 #include "AmdaProvider.h"
1 #include "AmdaProvider.h"
2 #include "AmdaDefs.h"
2 #include "AmdaDefs.h"
3 #include "AmdaResultParser.h"
3 #include "AmdaResultParser.h"
4
4
5 #include <Data/DataProviderParameters.h>
5 #include <Data/DataProviderParameters.h>
6 #include <Network/NetworkController.h>
6 #include <Network/NetworkController.h>
7 #include <SqpApplication.h>
7 #include <SqpApplication.h>
8 #include <Variable/Variable.h>
8 #include <Variable/Variable.h>
9
9
10 #include <QNetworkAccessManager>
10 #include <QNetworkAccessManager>
11 #include <QNetworkReply>
11 #include <QNetworkReply>
12 #include <QTemporaryFile>
12 #include <QTemporaryFile>
13 #include <QThread>
13 #include <QThread>
14
14
15 Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider")
15 Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider")
16
16
17 namespace {
17 namespace {
18
18
19 /// URL format for a request on AMDA server. The parameters are as follows:
19 /// URL format for a request on AMDA server. The parameters are as follows:
20 /// - %1: start date
20 /// - %1: start date
21 /// - %2: end date
21 /// - %2: end date
22 /// - %3: parameter id
22 /// - %3: parameter id
23 const auto AMDA_URL_FORMAT = QStringLiteral(
23 const auto AMDA_URL_FORMAT = QStringLiteral(
24 "http://amda.irap.omp.eu/php/rest/"
24 "http://amda.irap.omp.eu/php/rest/"
25 "getParameter.php?startTime=%1&stopTime=%2&parameterID=%3&sampling=60&outputFormat=ASCII&"
25 "getParameter.php?startTime=%1&stopTime=%2&parameterID=%3&sampling=60&outputFormat=ASCII&"
26 "timeFormat=ISO8601&gzip=0");
26 "timeFormat=ISO8601&gzip=0");
27
27
28 /// Dates format passed in the URL (e.g 2013-09-23T09:00)
28 /// Dates format passed in the URL (e.g 2013-09-23T09:00)
29 const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss");
29 const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss");
30
30
31 /// Formats a time to a date that can be passed in URL
31 /// Formats a time to a date that can be passed in URL
32 QString dateFormat(double sqpDateTime) noexcept
32 QString dateFormat(double sqpDateTime) noexcept
33 {
33 {
34 auto dateTime = QDateTime::fromMSecsSinceEpoch(sqpDateTime * 1000.);
34 auto dateTime = QDateTime::fromMSecsSinceEpoch(sqpDateTime * 1000.);
35 return dateTime.toString(AMDA_TIME_FORMAT);
35 return dateTime.toString(AMDA_TIME_FORMAT);
36 }
36 }
37
37
38 } // namespace
38 } // namespace
39
39
40 AmdaProvider::AmdaProvider()
40 AmdaProvider::AmdaProvider()
41 {
41 {
42 qCDebug(LOG_NetworkController()) << tr("AmdaProvider::AmdaProvider")
42 qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::AmdaProvider") << QThread::currentThread();
43 << QThread::currentThread();
44 if (auto app = sqpApp) {
43 if (auto app = sqpApp) {
45 auto &networkController = app->networkController();
44 auto &networkController = app->networkController();
46 connect(this, SIGNAL(requestConstructed(QNetworkRequest, QUuid,
45 connect(this, SIGNAL(requestConstructed(QNetworkRequest, QUuid,
47 std::function<void(QNetworkReply *, QUuid)>)),
46 std::function<void(QNetworkReply *, QUuid)>)),
48 &networkController,
47 &networkController,
49 SLOT(onProcessRequested(QNetworkRequest, QUuid,
48 SLOT(onProcessRequested(QNetworkRequest, QUuid,
50 std::function<void(QNetworkReply *, QUuid)>)));
49 std::function<void(QNetworkReply *, QUuid)>)));
51
50
52
51
53 connect(&sqpApp->networkController(), SIGNAL(replyDownloadProgress(QUuid, double)), this,
52 connect(&sqpApp->networkController(), SIGNAL(replyDownloadProgress(QUuid, double)), this,
54 SIGNAL(dataProvidedProgress(QUuid, double)));
53 SIGNAL(dataProvidedProgress(QUuid, double)));
55 }
54 }
56 }
55 }
57
56
58 void AmdaProvider::requestDataLoading(QUuid token, const DataProviderParameters &parameters)
57 void AmdaProvider::requestDataLoading(QUuid token, const DataProviderParameters &parameters)
59 {
58 {
60 // NOTE: Try to use multithread if possible
59 // NOTE: Try to use multithread if possible
61 const auto times = parameters.m_Times;
60 const auto times = parameters.m_Times;
62 const auto data = parameters.m_Data;
61 const auto data = parameters.m_Data;
63 for (const auto &dateTime : qAsConst(times)) {
62 for (const auto &dateTime : qAsConst(times)) {
64 retrieveData(token, dateTime, data);
63 retrieveData(token, dateTime, data);
65 }
64 }
66 }
65 }
67
66
68 void AmdaProvider::requestDataAborting(QUuid identifier)
67 void AmdaProvider::requestDataAborting(QUuid identifier)
69 {
68 {
70 if (auto app = sqpApp) {
69 if (auto app = sqpApp) {
71 auto &networkController = app->networkController();
70 auto &networkController = app->networkController();
72 networkController.onReplyCanceled(identifier);
71 networkController.onReplyCanceled(identifier);
73 }
72 }
74 }
73 }
75
74
76 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data)
75 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data)
77 {
76 {
78 // Retrieves product ID from data: if the value is invalid, no request is made
77 // Retrieves product ID from data: if the value is invalid, no request is made
79 auto productId = data.value(AMDA_XML_ID_KEY).toString();
78 auto productId = data.value(AMDA_XML_ID_KEY).toString();
80 if (productId.isNull()) {
79 if (productId.isNull()) {
81 qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve data: unknown product id");
80 qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve data: unknown product id");
82 return;
81 return;
83 }
82 }
84 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime;
83 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime;
85
84
86 // /////////// //
85 // /////////// //
87 // Creates URL //
86 // Creates URL //
88 // /////////// //
87 // /////////// //
89
88
90 auto startDate = dateFormat(dateTime.m_TStart);
89 auto startDate = dateFormat(dateTime.m_TStart);
91 auto endDate = dateFormat(dateTime.m_TEnd);
90 auto endDate = dateFormat(dateTime.m_TEnd);
92
91
93 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
92 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
94 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData url:") << url;
93 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData url:") << url;
95 auto tempFile = std::make_shared<QTemporaryFile>();
94 auto tempFile = std::make_shared<QTemporaryFile>();
96
95
97 // LAMBDA
96 // LAMBDA
98 auto httpDownloadFinished
97 auto httpDownloadFinished
99 = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept {
98 = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept {
100 Q_UNUSED(dataId);
99 Q_UNUSED(dataId);
101
100
102 // Don't do anything if the reply was abort
101 // Don't do anything if the reply was abort
103 if (reply->error() != QNetworkReply::OperationCanceledError) {
102 if (reply->error() != QNetworkReply::OperationCanceledError) {
104
103
105 if (tempFile) {
104 if (tempFile) {
106 auto replyReadAll = reply->readAll();
105 auto replyReadAll = reply->readAll();
107 if (!replyReadAll.isEmpty()) {
106 if (!replyReadAll.isEmpty()) {
108 tempFile->write(replyReadAll);
107 tempFile->write(replyReadAll);
109 }
108 }
110 tempFile->close();
109 tempFile->close();
111
110
112 // Parse results file
111 // Parse results file
113 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
112 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
114 emit dataProvided(token, dataSeries, dateTime);
113 emit dataProvided(token, dataSeries, dateTime);
115 }
114 }
116 else {
115 else {
117 /// @todo ALX : debug
116 /// @todo ALX : debug
118 }
117 }
119 }
118 }
120 }
119 }
121
120
122 };
121 };
123 auto httpFinishedLambda
122 auto httpFinishedLambda
124 = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
123 = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
125
124
126 // Don't do anything if the reply was abort
125 // Don't do anything if the reply was abort
127 if (reply->error() != QNetworkReply::OperationCanceledError) {
126 if (reply->error() != QNetworkReply::OperationCanceledError) {
128 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
127 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
129
128
130
129
131 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData downloadFileUrl:")
130 qCInfo(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData downloadFileUrl:")
132 << downloadFileUrl;
131 << downloadFileUrl;
133 // Executes request for downloading file //
132 // Executes request for downloading file //
134
133
135 // Creates destination file
134 // Creates destination file
136 if (tempFile->open()) {
135 if (tempFile->open()) {
137 // Executes request
136 // Executes request
138 emit requestConstructed(QNetworkRequest{downloadFileUrl}, dataId,
137 emit requestConstructed(QNetworkRequest{downloadFileUrl}, dataId,
139 httpDownloadFinished);
138 httpDownloadFinished);
140 }
139 }
141 }
140 }
142 };
141 };
143
142
144 // //////////////// //
143 // //////////////// //
145 // Executes request //
144 // Executes request //
146 // //////////////// //
145 // //////////////// //
147 emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda);
146 emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda);
148 }
147 }
General Comments 0
You need to be logged in to leave comments. Login now