##// END OF EJS Templates
Merge pull request 149 from SCIQLOP-Initialisation develop...
perrinel -
r141:c468e470fe0c merge
parent child
Show More
@@ -0,0 +1,56
1 #ifndef SCIQLOP_ARRAYDATA_H
2 #define SCIQLOP_ARRAYDATA_H
3
4 #include <QVector>
5
6 /**
7 * @brief The ArrayData class represents a dataset for a data series.
8 *
9 * A dataset can be unidimensional or two-dimensional. This property is determined by the Dim
10 * template-parameter.
11 *
12 * @tparam Dim the dimension of the ArrayData (one or two)
13 * @sa IDataSeries
14 */
15 template <int Dim>
16 class ArrayData {
17 public:
18 /**
19 * Ctor for a unidimensional ArrayData
20 * @param nbColumns the number of values the ArrayData will hold
21 */
22 template <int D = Dim, typename = std::enable_if_t<D == 1> >
23 explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}}
24 {
25 m_Data[0].resize(nbColumns);
26 }
27
28 /**
29 * Sets a data at a specified index. The index has to be valid to be effective
30 * @param index the index to which the data will be set
31 * @param data the data to set
32 * @remarks this method is only available for a unidimensional ArrayData
33 */
34 template <int D = Dim, typename = std::enable_if_t<D == 1> >
35 void setData(int index, double data) noexcept
36 {
37 if (index >= 0 && index < m_Data.at(0).size()) {
38 m_Data[0].replace(index, data);
39 }
40 }
41
42 /**
43 * @return the data as a vector
44 * @remarks this method is only available for a unidimensional ArrayData
45 */
46 template <int D = Dim, typename = std::enable_if_t<D == 1> >
47 QVector<double> data() const noexcept
48 {
49 return m_Data.at(0);
50 }
51
52 private:
53 QVector<QVector<double> > m_Data;
54 };
55
56 #endif // SCIQLOP_ARRAYDATA_H
@@ -0,0 +1,16
1 #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H
2 #define SCIQLOP_DATAPROVIDERPARAMETERS_H
3
4 /**
5 * @brief The DataProviderParameters struct holds the information needed to retrieve data from a
6 * data provider
7 * @sa IDataProvider
8 */
9 struct DataProviderParameters {
10 /// Start time
11 double m_TStart;
12 /// End time
13 double m_TEnd;
14 };
15
16 #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H
@@ -0,0 +1,50
1 #ifndef SCIQLOP_DATASERIES_H
2 #define SCIQLOP_DATASERIES_H
3
4 #include <Data/ArrayData.h>
5 #include <Data/IDataSeries.h>
6
7 #include <memory>
8
9 /**
10 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
11 *
12 * It proposes to set a dimension for the values ​​data
13 *
14 * @tparam Dim The dimension of the values data
15 *
16 */
17 template <int Dim>
18 class DataSeries : public IDataSeries {
19 public:
20 /// @sa IDataSeries::xAxisData()
21 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
22
23 /// @sa IDataSeries::xAxisUnit()
24 QString xAxisUnit() const override { return m_XAxisUnit; }
25
26 /// @return the values dataset
27 std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; }
28
29 /// @sa IDataSeries::valuesUnit()
30 QString valuesUnit() const override { return m_ValuesUnit; }
31
32 protected:
33 /// Protected ctor (DataSeries is abstract)
34 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const QString &xAxisUnit,
35 std::shared_ptr<ArrayData<Dim> > valuesData, const QString &valuesUnit)
36 : m_XAxisData{xAxisData},
37 m_XAxisUnit{xAxisUnit},
38 m_ValuesData{valuesData},
39 m_ValuesUnit{valuesUnit}
40 {
41 }
42
43 private:
44 std::shared_ptr<ArrayData<1> > m_XAxisData;
45 QString m_XAxisUnit;
46 std::shared_ptr<ArrayData<Dim> > m_ValuesData;
47 QString m_ValuesUnit;
48 };
49
50 #endif // SCIQLOP_DATASERIES_H
@@ -0,0 +1,25
1 #ifndef SCIQLOP_IDATAPROVIDER_H
2 #define SCIQLOP_IDATAPROVIDER_H
3
4 #include <memory>
5
6 class DataProviderParameters;
7 class IDataSeries;
8
9 /**
10 * @brief The IDataProvider interface aims to declare a data provider.
11 *
12 * A data provider is an entity that generates data and returns it according to various parameters
13 * (time interval, product to retrieve the data, etc.)
14 *
15 * @sa IDataSeries
16 */
17 class IDataProvider {
18 public:
19 virtual ~IDataProvider() noexcept = default;
20
21 virtual std::unique_ptr<IDataSeries>
22 retrieveData(const DataProviderParameters &parameters) const = 0;
23 };
24
25 #endif // SCIQLOP_IDATAPROVIDER_H
@@ -0,0 +1,37
1 #ifndef SCIQLOP_IDATASERIES_H
2 #define SCIQLOP_IDATASERIES_H
3
4 #include <QString>
5
6 #include <memory>
7
8 template <int Dim>
9 class ArrayData;
10
11 /**
12 * @brief The IDataSeries aims to declare a data series.
13 *
14 * A data series is an entity that contains at least :
15 * - one dataset representing the x-axis
16 * - one dataset representing the values
17 *
18 * Each dataset is represented by an ArrayData, and is associated with a unit.
19 *
20 * An ArrayData can be unidimensional or two-dimensional, depending on the implementation of the
21 * IDataSeries. The x-axis dataset is always unidimensional.
22 *
23 * @sa ArrayData
24 */
25 class IDataSeries {
26 public:
27 virtual ~IDataSeries() noexcept = default;
28
29 /// Returns the x-axis dataset
30 virtual std::shared_ptr<ArrayData<1> > xAxisData() = 0;
31
32 virtual QString xAxisUnit() const = 0;
33
34 virtual QString valuesUnit() const = 0;
35 };
36
37 #endif // SCIQLOP_IDATASERIES_H
@@ -0,0 +1,28
1 #ifndef SCIQLOP_SCALARSERIES_H
2 #define SCIQLOP_SCALARSERIES_H
3
4 #include <Data/DataSeries.h>
5
6 /**
7 * @brief The ScalarSeries class is the implementation for a data series representing a scalar.
8 */
9 class ScalarSeries : public DataSeries<1> {
10 public:
11 /**
12 * Ctor
13 * @param size the number of data the series will hold
14 * @param xAxisUnit x-axis unit
15 * @param valuesUnit values unit
16 */
17 explicit ScalarSeries(int size, const QString &xAxisUnit, const QString &valuesUnit);
18
19 /**
20 * Sets data for a specific index. The index has to be valid to be effective
21 * @param index the index to which the data will be set
22 * @param x the x-axis data
23 * @param value the value data
24 */
25 void setData(int index, double x, double value) noexcept;
26 };
27
28 #endif // SCIQLOP_SCALARSERIES_H
@@ -0,0 +1,13
1 #include <Data/ScalarSeries.h>
2
3 ScalarSeries::ScalarSeries(int size, const QString &xAxisUnit, const QString &valuesUnit)
4 : DataSeries{std::make_shared<ArrayData<1> >(size), xAxisUnit,
5 std::make_shared<ArrayData<1> >(size), valuesUnit}
6 {
7 }
8
9 void ScalarSeries::setData(int index, double x, double value) noexcept
10 {
11 xAxisData()->setData(index, x);
12 valuesData()->setData(index, value);
13 }
@@ -0,0 +1,21
1 #ifndef SCIQLOP_TIMEWIDGET_H
2 #define SCIQLOP_TIMEWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class TimeWidget;
8 } // Ui
9
10 class TimeWidget : public QWidget {
11 Q_OBJECT
12
13 public:
14 explicit TimeWidget(QWidget *parent = 0);
15 virtual ~TimeWidget();
16
17 private:
18 Ui::TimeWidget *ui;
19 };
20
21 #endif // SCIQLOP_ SQPSIDEPANE_H
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,12
1 #include "TimeWidget/TimeWidget.h"
2 #include "ui_TimeWidget.h"
3
4 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
5 {
6 ui->setupUi(this);
7 }
8
9 TimeWidget::~TimeWidget()
10 {
11 delete ui;
12 }
@@ -0,0 +1,85
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>TimeWidget</class>
4 <widget class="QWidget" name="TimeWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>716</width>
10 <height>48</height>
11 </rect>
12 </property>
13 <property name="sizePolicy">
14 <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
15 <horstretch>0</horstretch>
16 <verstretch>0</verstretch>
17 </sizepolicy>
18 </property>
19 <property name="windowTitle">
20 <string>Form</string>
21 </property>
22 <layout class="QHBoxLayout" name="horizontalLayout_2">
23 <item>
24 <widget class="QLabel" name="label">
25 <property name="sizePolicy">
26 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
27 <horstretch>0</horstretch>
28 <verstretch>0</verstretch>
29 </sizepolicy>
30 </property>
31 <property name="text">
32 <string>TStart :</string>
33 </property>
34 </widget>
35 </item>
36 <item>
37 <widget class="QDateTimeEdit" name="startDateTimeEdit">
38 <property name="sizePolicy">
39 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
40 <horstretch>0</horstretch>
41 <verstretch>0</verstretch>
42 </sizepolicy>
43 </property>
44 <property name="displayFormat">
45 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
46 </property>
47 <property name="calendarPopup">
48 <bool>true</bool>
49 </property>
50 </widget>
51 </item>
52 <item>
53 <widget class="QLabel" name="label_2">
54 <property name="sizePolicy">
55 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
56 <horstretch>0</horstretch>
57 <verstretch>0</verstretch>
58 </sizepolicy>
59 </property>
60 <property name="text">
61 <string>TEnd :</string>
62 </property>
63 </widget>
64 </item>
65 <item>
66 <widget class="QDateTimeEdit" name="endDateTimeEdit">
67 <property name="sizePolicy">
68 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
69 <horstretch>0</horstretch>
70 <verstretch>0</verstretch>
71 </sizepolicy>
72 </property>
73 <property name="displayFormat">
74 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
75 </property>
76 <property name="calendarPopup">
77 <bool>true</bool>
78 </property>
79 </widget>
80 </item>
81 </layout>
82 </widget>
83 <resources/>
84 <connections/>
85 </ui>
@@ -0,0 +1,16
1 #ifndef SCIQLOP_COSINUSPROVIDER_H
2 #define SCIQLOP_COSINUSPROVIDER_H
3
4 #include <Data/IDataProvider.h>
5
6 /**
7 * @brief The CosinusProvider class is an example of how a data provider can generate data
8 */
9 class CosinusProvider : public IDataProvider {
10 public:
11 /// @sa IDataProvider::retrieveData()
12 std::unique_ptr<IDataSeries>
13 retrieveData(const DataProviderParameters &parameters) const override;
14 };
15
16 #endif // SCIQLOP_COSINUSPROVIDER_H
@@ -0,0 +1,30
1 #include "CosinusProvider.h"
2
3 #include <Data/DataProviderParameters.h>
4 #include <Data/ScalarSeries.h>
5
6 #include <cmath>
7
8 std::unique_ptr<IDataSeries>
9 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
10 {
11 // Gets the timerange from the parameters
12 auto start = parameters.m_TStart;
13 auto end = parameters.m_TEnd;
14
15 // We assure that timerange is valid
16 if (end < start) {
17 std::swap(start, end);
18 }
19
20 // Generates scalar series containing cosinus values (one value per second)
21 auto scalarSeries
22 = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral(""));
23
24 auto dataIndex = 0;
25 for (auto time = start; time < end; ++time, ++dataIndex) {
26 scalarSeries->setData(dataIndex, time, std::cos(time));
27 }
28
29 return scalarSeries;
30 }
@@ -1,224 +1,233
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 <SidePane/SqpSidePane.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
28 #include <SqpApplication.h>
29 #include <TimeWidget/TimeWidget.h>
29
30
30 #include <QAction>
31 #include <QAction>
31 #include <QDate>
32 #include <QDate>
32 #include <QDateTime>
33 #include <QDateTime>
33 #include <QDir>
34 #include <QDir>
34 #include <QFileDialog>
35 #include <QFileDialog>
35 #include <QToolBar>
36 #include <QToolBar>
37 #include <QToolButton>
36 #include <memory.h>
38 #include <memory.h>
37
39
38 //#include <omp.h>
40 //#include <omp.h>
39 //#include <network/filedownloader.h>
41 //#include <network/filedownloader.h>
40 //#include <qlopdatabase.h>
42 //#include <qlopdatabase.h>
41 //#include <qlopsettings.h>
43 //#include <qlopsettings.h>
42 //#include <qlopgui.h>
44 //#include <qlopgui.h>
43 //#include <spacedata.h>
45 //#include <spacedata.h>
44 //#include "qlopcore.h"
46 //#include "qlopcore.h"
45 //#include "qlopcodecmanager.h"
47 //#include "qlopcodecmanager.h"
46 //#include "cdfcodec.h"
48 //#include "cdfcodec.h"
47 //#include "amdatxtcodec.h"
49 //#include "amdatxtcodec.h"
48 //#include <qlopplotmanager.h>
50 //#include <qlopplotmanager.h>
49
51
50 #include "iostream"
52 #include "iostream"
51
53
52 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53
55
54 namespace {
56 namespace {
55 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 const auto VIEWPLITTERINDEX = 2;
59 const auto VIEWPLITTERINDEX = 2;
58 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 }
62 }
61
63
62 class MainWindow::MainWindowPrivate {
64 class MainWindow::MainWindowPrivate {
63 public:
65 public:
64 QSize m_LastOpenLeftInspectorSize;
66 QSize m_LastOpenLeftInspectorSize;
65 QSize m_LastOpenRightInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
66 };
68 };
67
69
68 MainWindow::MainWindow(QWidget *parent)
70 MainWindow::MainWindow(QWidget *parent)
69 : QMainWindow{parent},
71 : QMainWindow{parent},
70 m_Ui{new Ui::MainWindow},
72 m_Ui{new Ui::MainWindow},
71 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
72 {
74 {
73 m_Ui->setupUi(this);
75 m_Ui->setupUi(this);
74
76
75 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
77
79
78 // NOTE: These lambda could be factorized. Be careful of theirs parameters
79 // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button
80 auto openLeftInspector = [this](bool checked) {
81
80
82 // Update of the last opened geometry
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
83 if (checked) {
82 auto openLeftInspectorAction = new QAction{QIcon{
84 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
83 ":/icones/previous.png",
85 }
84 },
85 tr("Show/hide the left inspector"), this};
86
86
87 auto startSize = impl->m_LastOpenLeftInspectorSize;
88 auto endSize = startSize;
89 endSize.setWidth(0);
90
87
91 auto currentSizes = m_Ui->splitter->sizes();
88 auto spacerLeftTop = new QWidget{};
92 if (checked) {
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93 // adjust sizes individually here, e.g.
94 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
95 -= impl->m_LastOpenLeftInspectorSize.width();
96 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width();
97 m_Ui->splitter->setSizes(currentSizes);
98 }
99 else {
100 // adjust sizes individually here, e.g.
101 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
102 += impl->m_LastOpenLeftInspectorSize.width();
103 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width();
104 m_Ui->splitter->setSizes(currentSizes);
105 }
106
90
107 };
91 auto spacerLeftBottom = new QWidget{};
92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
94 leftSidePane->addWidget(spacerLeftTop);
95 leftSidePane->addAction(openLeftInspectorAction);
96 leftSidePane->addWidget(spacerLeftBottom);
97
98
99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
100 auto openRightInspectorAction = new QAction{QIcon{
101 ":/icones/next.png",
102 },
103 tr("Show/hide the right inspector"), this};
104
105 auto spacerRightTop = new QWidget{};
106 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
107
108 auto spacerRightBottom = new QWidget{};
109 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110
111 rightSidePane->addWidget(spacerRightTop);
112 rightSidePane->addAction(openRightInspectorAction);
113 rightSidePane->addWidget(spacerRightBottom);
114
115 openLeftInspectorAction->setCheckable(true);
116 openRightInspectorAction->setCheckable(true);
117
118 auto openInspector = [this](bool checked, bool right, auto action) {
119
120 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
108
121
109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
122 auto &lastInspectorSize
110 auto openRightInspector = [this](bool checked) {
123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
124
125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
126 : m_Ui->leftMainInspectorWidget->size();
111
127
112 // Update of the last opened geometry
128 // Update of the last opened geometry
113 if (checked) {
129 if (checked) {
114 impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size();
130 lastInspectorSize = nextInspectorSize;
115 }
131 }
116
132
117 auto startSize = impl->m_LastOpenRightInspectorSize;
133 auto startSize = lastInspectorSize;
118 auto endSize = startSize;
134 auto endSize = startSize;
119 endSize.setWidth(0);
135 endSize.setWidth(0);
120
136
137 auto splitterInspectorIndex
138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
139
121 auto currentSizes = m_Ui->splitter->sizes();
140 auto currentSizes = m_Ui->splitter->sizes();
122 if (checked) {
141 if (checked) {
123 // adjust sizes individually here, e.g.
142 // adjust sizes individually here, e.g.
124 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
125 -= impl->m_LastOpenRightInspectorSize.width();
144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
126 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
127 m_Ui->splitter->setSizes(currentSizes);
145 m_Ui->splitter->setSizes(currentSizes);
128 }
146 }
129 else {
147 else {
130 // adjust sizes individually here, e.g.
148 // adjust sizes individually here, e.g.
131 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
132 += impl->m_LastOpenRightInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
133 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
134 m_Ui->splitter->setSizes(currentSizes);
151 m_Ui->splitter->setSizes(currentSizes);
135 }
152 }
136
153
137 };
154 };
138
155
139
156
140 QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
157 connect(openLeftInspectorAction, &QAction::triggered,
141 auto openLeftInspectorAction = leftSidePane->addAction(
158 [openInspector, openLeftInspectorAction](bool checked) {
142 QIcon{
159 openInspector(checked, false, openLeftInspectorAction);
143 ":/icones/openInspector.png",
160 });
144 },
161 connect(openRightInspectorAction, &QAction::triggered,
145 tr("Show/hide the left inspector"), openLeftInspector);
162 [openInspector, openRightInspectorAction](bool checked) {
146
163 openInspector(checked, true, openRightInspectorAction);
147 openLeftInspectorAction->setCheckable(true);
164 });
148
149 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
150 auto openRightInspectorAction = rightSidePane->addAction(
151 QIcon{
152 ":/icones/openInspector.png",
153 },
154 tr("Show/hide the right inspector"), openRightInspector);
155
156 openRightInspectorAction->setCheckable(true);
157
165
158 this->menuBar()->addAction(tr("File"));
166 this->menuBar()->addAction(tr("File"));
159 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160 mainToolBar->addAction(QStringLiteral("A1"));
168
169 mainToolBar->addWidget(new TimeWidget{});
161
170
162 // Widgets / controllers connections
171 // Widgets / controllers connections
163 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
164 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
165
174
166 /* QLopGUI::registerMenuBar(menuBar());
175 /* QLopGUI::registerMenuBar(menuBar());
167 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
168 this->m_progressWidget = new QWidget();
177 this->m_progressWidget = new QWidget();
169 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
170 this->m_progressWidget->setLayout(this->m_progressLayout);
179 this->m_progressWidget->setLayout(this->m_progressLayout);
171 this->m_progressWidget->setWindowModality(Qt::WindowModal);
180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
172 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
173 for(int i=0;i<OMP_THREADS;i++)
182 for(int i=0;i<OMP_THREADS;i++)
174 {
183 {
175 this->m_progress.append(new QProgressBar(this->m_progressWidget));
184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
176 this->m_progress.last()->setMinimum(0);
185 this->m_progress.last()->setMinimum(0);
177 this->m_progress.last()->setMaximum(100);
186 this->m_progress.last()->setMaximum(100);
178 this->m_progressLayout->addWidget(this->m_progress.last());
187 this->m_progressLayout->addWidget(this->m_progress.last());
179 this->m_progressWidget->hide();
188 this->m_progressWidget->hide();
180 this->m_progressThreadIds[i] = -1;
189 this->m_progressThreadIds[i] = -1;
181 }
190 }
182 this->m_progressWidget->setWindowTitle("Loading File");
191 this->m_progressWidget->setWindowTitle("Loading File");
183 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
184 << QLopCore::self()
193 << QLopCore::self()
185 << QLopPlotManager::self()
194 << QLopPlotManager::self()
186 << QLopCodecManager::self()
195 << QLopCodecManager::self()
187 << FileDownloader::self()
196 << FileDownloader::self()
188 << QLopDataBase::self()
197 << QLopDataBase::self()
189 << SpaceData::self();
198 << SpaceData::self();
190
199
191 CDFCodec::registerToManager();
200 CDFCodec::registerToManager();
192 AMDATXTCodec::registerToManager();
201 AMDATXTCodec::registerToManager();
193
202
194
203
195 for(int i=0;i<ServicesToLoad.count();i++)
204 for(int i=0;i<ServicesToLoad.count();i++)
196 {
205 {
197 qDebug()<<ServicesToLoad.at(i)->serviceName();
206 qDebug()<<ServicesToLoad.at(i)->serviceName();
198 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
199 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
200 if(wdgt)
209 if(wdgt)
201 {
210 {
202 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
203 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
204 }
213 }
205 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
206 }*/
215 }*/
207 }
216 }
208
217
209 MainWindow::~MainWindow()
218 MainWindow::~MainWindow()
210 {
219 {
211 }
220 }
212
221
213
222
214 void MainWindow::changeEvent(QEvent *e)
223 void MainWindow::changeEvent(QEvent *e)
215 {
224 {
216 QMainWindow::changeEvent(e);
225 QMainWindow::changeEvent(e);
217 switch (e->type()) {
226 switch (e->type()) {
218 case QEvent::LanguageChange:
227 case QEvent::LanguageChange:
219 m_Ui->retranslateUi(this);
228 m_Ui->retranslateUi(this);
220 break;
229 break;
221 default:
230 default:
222 break;
231 break;
223 }
232 }
224 }
233 }
@@ -1,61 +1,73
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
3
3
4 #include <QLoggingCategory>
4 #include <QLoggingCategory>
5 #include <QObject>
5 #include <QObject>
6 #include <QUuid>
6 #include <QUuid>
7
7
8 #include <Common/spimpl.h>
8 #include <Common/spimpl.h>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13 class IDataProvider;
13
14
14 /**
15 /**
15 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
16 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
16 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
17 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
17 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
18 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
18 * source) then others specifics method will be able to access it. You can load a data source driver
19 * source) then others specifics method will be able to access it. You can load a data source driver
19 * plugin then create a data source.
20 * plugin then create a data source.
20 */
21 */
21 class DataSourceController : public QObject {
22 class DataSourceController : public QObject {
22 Q_OBJECT
23 Q_OBJECT
23 public:
24 public:
24 explicit DataSourceController(QObject *parent = 0);
25 explicit DataSourceController(QObject *parent = 0);
25 virtual ~DataSourceController();
26 virtual ~DataSourceController();
26
27
27 /**
28 /**
28 * Registers a data source. The method delivers a unique id that can be used afterwards to
29 * Registers a data source. The method delivers a unique id that can be used afterwards to
29 * access to the data source properties (structure, connection parameters, data provider, etc.)
30 * access to the data source properties (structure, connection parameters, data provider, etc.)
30 * @param dataSourceName the name of the data source
31 * @param dataSourceName the name of the data source
31 * @return the unique id with which the data source has been registered
32 * @return the unique id with which the data source has been registered
32 */
33 */
33 QUuid registerDataSource(const QString &dataSourceName) noexcept;
34 QUuid registerDataSource(const QString &dataSourceName) noexcept;
34
35
35 /**
36 /**
36 * Sets the structure of a data source. The controller takes ownership of the structure.
37 * Sets the structure of a data source. The controller takes ownership of the structure.
37 * @param dataSourceUid the unique id with which the data source has been registered into the
38 * @param dataSourceUid the unique id with which the data source has been registered into the
38 * controller. If it is invalid, the method has no effect.
39 * controller. If it is invalid, the method has no effect.
39 * @param dataSourceItem the structure of the data source
40 * @param dataSourceItem the structure of the data source
40 * @sa registerDataSource()
41 * @sa registerDataSource()
41 */
42 */
42 void setDataSourceItem(const QUuid &dataSourceUid,
43 void setDataSourceItem(const QUuid &dataSourceUid,
43 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
44 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
44
45
46 /**
47 * Sets the data provider used to retrieve data from of a data source. The controller takes
48 * ownership of the provider.
49 * @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.
51 * @param dataProvider the provider of the data source
52 * @sa registerDataSource()
53 */
54 void setDataProvider(const QUuid &dataSourceUid,
55 std::unique_ptr<IDataProvider> dataProvider) noexcept;
56
45 public slots:
57 public slots:
46 /// Manage init/end of the controller
58 /// Manage init/end of the controller
47 void initialize();
59 void initialize();
48 void finalize();
60 void finalize();
49
61
50 signals:
62 signals:
51 /// Signal emitted when a structure has been set for a data source
63 /// Signal emitted when a structure has been set for a data source
52 void dataSourceItemSet(DataSourceItem *dataSourceItem);
64 void dataSourceItemSet(DataSourceItem *dataSourceItem);
53
65
54 private:
66 private:
55 void waitForFinish();
67 void waitForFinish();
56
68
57 class DataSourceControllerPrivate;
69 class DataSourceControllerPrivate;
58 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
70 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
59 };
71 };
60
72
61 #endif // SCIQLOP_DATASOURCECONTROLLER_H
73 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,78 +1,95
1 #include <DataSource/DataSourceController.h>
1 #include <DataSource/DataSourceController.h>
2 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItem.h>
3
3
4 #include <Data/IDataProvider.h>
5
4 #include <QMutex>
6 #include <QMutex>
5 #include <QThread>
7 #include <QThread>
6
8
7 #include <QDir>
9 #include <QDir>
8 #include <QStandardPaths>
10 #include <QStandardPaths>
9
11
10 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
12 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
11
13
12 class DataSourceController::DataSourceControllerPrivate {
14 class DataSourceController::DataSourceControllerPrivate {
13 public:
15 public:
14 QMutex m_WorkingMutex;
16 QMutex m_WorkingMutex;
15 /// Data sources registered
17 /// Data sources registered
16 QHash<QUuid, QString> m_DataSources;
18 QHash<QUuid, QString> m_DataSources;
17 /// Data sources structures
19 /// Data sources structures
18 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
20 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
21 /// Data providers registered
22 std::map<QUuid, std::unique_ptr<IDataProvider> > m_DataProviders;
19 };
23 };
20
24
21 DataSourceController::DataSourceController(QObject *parent)
25 DataSourceController::DataSourceController(QObject *parent)
22 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
26 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
23 {
27 {
24 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
28 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
25 << QThread::currentThread();
29 << QThread::currentThread();
26 }
30 }
27
31
28 DataSourceController::~DataSourceController()
32 DataSourceController::~DataSourceController()
29 {
33 {
30 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
34 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
31 << QThread::currentThread();
35 << QThread::currentThread();
32 this->waitForFinish();
36 this->waitForFinish();
33 }
37 }
34
38
35 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
39 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
36 {
40 {
37 auto dataSourceUid = QUuid::createUuid();
41 auto dataSourceUid = QUuid::createUuid();
38 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
42 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
39
43
40 return dataSourceUid;
44 return dataSourceUid;
41 }
45 }
42
46
43 void DataSourceController::setDataSourceItem(
47 void DataSourceController::setDataSourceItem(
44 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
48 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
45 {
49 {
46 if (impl->m_DataSources.contains(dataSourceUid)) {
50 if (impl->m_DataSources.contains(dataSourceUid)) {
47 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
51 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
48
52
49 // Retrieves the data source item to emit the signal with it
53 // Retrieves the data source item to emit the signal with it
50 auto it = impl->m_DataSourceItems.find(dataSourceUid);
54 auto it = impl->m_DataSourceItems.find(dataSourceUid);
51 if (it != impl->m_DataSourceItems.end()) {
55 if (it != impl->m_DataSourceItems.end()) {
52 emit dataSourceItemSet(it->second.get());
56 emit dataSourceItemSet(it->second.get());
53 }
57 }
54 }
58 }
55 else {
59 else {
56 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
60 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
57 "data source has been registered with the uid")
61 "data source has been registered with the uid")
58 .arg(dataSourceUid.toString());
62 .arg(dataSourceUid.toString());
59 }
63 }
60 }
64 }
61
65
66 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
67 std::unique_ptr<IDataProvider> dataProvider) noexcept
68 {
69 if (impl->m_DataSources.contains(dataSourceUid)) {
70 impl->m_DataProviders.insert(std::make_pair(dataSourceUid, std::move(dataProvider)));
71 }
72 else {
73 qCWarning(LOG_DataSourceController()) << tr("Can't set data provider for uid %1 : no data "
74 "source has been registered with the uid")
75 .arg(dataSourceUid.toString());
76 }
77 }
78
62 void DataSourceController::initialize()
79 void DataSourceController::initialize()
63 {
80 {
64 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
81 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
65 << QThread::currentThread();
82 << QThread::currentThread();
66 impl->m_WorkingMutex.lock();
83 impl->m_WorkingMutex.lock();
67 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
84 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
68 }
85 }
69
86
70 void DataSourceController::finalize()
87 void DataSourceController::finalize()
71 {
88 {
72 impl->m_WorkingMutex.unlock();
89 impl->m_WorkingMutex.unlock();
73 }
90 }
74
91
75 void DataSourceController::waitForFinish()
92 void DataSourceController::waitForFinish()
76 {
93 {
77 QMutexLocker locker{&impl->m_WorkingMutex};
94 QMutexLocker locker{&impl->m_WorkingMutex};
78 }
95 }
@@ -1,53 +1,53
1 #include <Variable/VariableController.h>
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableModel.h>
2 #include <Variable/VariableModel.h>
3
3
4 #include <QMutex>
4 #include <QMutex>
5 #include <QThread>
5 #include <QThread>
6
6
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8
8
9 struct VariableController::VariableControllerPrivate {
9 struct VariableController::VariableControllerPrivate {
10 explicit VariableControllerPrivate()
10 explicit VariableControllerPrivate()
11 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
11 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
12 {
12 {
13 }
13 }
14
14
15 QMutex m_WorkingMutex;
15 QMutex m_WorkingMutex;
16 std::unique_ptr<VariableModel> m_VariableModel;
16 std::unique_ptr<VariableModel> m_VariableModel;
17 };
17 };
18
18
19 VariableController::VariableController(QObject *parent)
19 VariableController::VariableController(QObject *parent)
20 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
20 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
21 {
21 {
22 qCDebug(LOG_VariableController())
22 qCDebug(LOG_VariableController()) << tr("VariableController construction")
23 << tr("VariableController construction") << QThread::currentThread();
23 << QThread::currentThread();
24 }
24 }
25
25
26 VariableController::~VariableController()
26 VariableController::~VariableController()
27 {
27 {
28 qCDebug(LOG_VariableController())
28 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
29 << tr("VariableController destruction") << QThread::currentThread();
29 << QThread::currentThread();
30 this->waitForFinish();
30 this->waitForFinish();
31 }
31 }
32
32
33 Variable *VariableController::createVariable(const QString &name) noexcept
33 Variable *VariableController::createVariable(const QString &name) noexcept
34 {
34 {
35 return impl->m_VariableModel->createVariable(name);
35 return impl->m_VariableModel->createVariable(name);
36 }
36 }
37
37
38 void VariableController::initialize()
38 void VariableController::initialize()
39 {
39 {
40 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
40 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
41 impl->m_WorkingMutex.lock();
41 impl->m_WorkingMutex.lock();
42 qCDebug(LOG_VariableController()) << tr("VariableController init END");
42 qCDebug(LOG_VariableController()) << tr("VariableController init END");
43 }
43 }
44
44
45 void VariableController::finalize()
45 void VariableController::finalize()
46 {
46 {
47 impl->m_WorkingMutex.unlock();
47 impl->m_WorkingMutex.unlock();
48 }
48 }
49
49
50 void VariableController::waitForFinish()
50 void VariableController::waitForFinish()
51 {
51 {
52 QMutexLocker locker{&impl->m_WorkingMutex};
52 QMutexLocker locker{&impl->m_WorkingMutex};
53 }
53 }
@@ -1,6 +1,10
1 # On ignore toutes les règles vera++ pour le fichier spimpl
1 # On ignore toutes les règles vera++ pour le fichier spimpl
2 Common/spimpl\.h:\d+:.*
2 Common/spimpl\.h:\d+:.*
3
3
4 # Ignore false positive relative to two class definitions in a same file
4 # Ignore false positive relative to two class definitions in a same file
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
6
6
7 # Ignore false positive relative to a template class
8 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (D)
9 ArrayData\.h:\d+:.*IPSIS_S06.*found: (D)
10 ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim)
@@ -1,5 +1,7
1 <RCC>
1 <RCC>
2 <qresource prefix="/">
2 <qresource prefix="/">
3 <file>icones/openInspector.png</file>
3 <file>icones/openInspector.png</file>
4 <file>icones/next.png</file>
5 <file>icones/previous.png</file>
4 </qresource>
6 </qresource>
5 </RCC>
7 </RCC>
@@ -1,54 +1,47
1 #include "SidePane/SqpSidePane.h"
1 #include "SidePane/SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
3
3
4 #include <QAction>
4 #include <QAction>
5 #include <QLayout>
5 #include <QLayout>
6 #include <QToolBar>
6 #include <QToolBar>
7
7
8 namespace {
8 namespace {
9 static const QString SQPSIDEPANESTYLESHEET
9 static const QString SQPSIDEPANESTYLESHEET
10 = "QToolBar {"
10 = "QToolBar {"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
12 " stop: 0.0 #5a5a5a,"
12 " stop: 0.0 #5a5a5a,"
13 " stop: 1.0 #414141);"
13 " stop: 1.0 #414141);"
14 " border: none;"
14 " border: none;"
15 " border-left: 1px solid #424242;"
15 " border-left: 1px solid #424242;"
16 "border-right: 1px solid #393939;"
16 "border-right: 1px solid #393939;"
17 " }"
17 " }"
18
18
19 " QToolButton {"
19 " QToolButton {"
20 "background: none;"
20 "background: none;"
21 "border: none;"
21 "border: none;"
22 " }";
22 " }";
23 }
23 }
24
24
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
26 {
26 {
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
29 // this->setLayout(sidePaneLayout);
29 // this->setLayout(sidePaneLayout);
30
30
31 ui->setupUi(this);
31 ui->setupUi(this);
32 m_SidePaneToolbar = new QToolBar();
32 m_SidePaneToolbar = new QToolBar();
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
34 this->layout()->addWidget(m_SidePaneToolbar);
34 this->layout()->addWidget(m_SidePaneToolbar);
35
35
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
37
38 this->setStyleSheet(
39 " QWidget {"
40 "background: red;"
41
42 "border: 1px;"
43 " }");
44 }
37 }
45
38
46 SqpSidePane::~SqpSidePane()
39 SqpSidePane::~SqpSidePane()
47 {
40 {
48 delete ui;
41 delete ui;
49 }
42 }
50
43
51 QToolBar *SqpSidePane::sidePane()
44 QToolBar *SqpSidePane::sidePane()
52 {
45 {
53 return m_SidePaneToolbar;
46 return m_SidePaneToolbar;
54 }
47 }
1 NO CONTENT: file renamed from gui/ui/Sidepane/SqpSidePane.ui to gui/ui/SidePane/SqpSidePane.ui
NO CONTENT: file renamed from gui/ui/Sidepane/SqpSidePane.ui to gui/ui/SidePane/SqpSidePane.ui
@@ -1,27 +1,23
1 #ifndef SCIQLOP_MOCKPLUGIN_H
1 #ifndef SCIQLOP_MOCKPLUGIN_H
2 #define SCIQLOP_MOCKPLUGIN_H
2 #define SCIQLOP_MOCKPLUGIN_H
3
3
4 #include <Plugin/IPlugin.h>
4 #include <Plugin/IPlugin.h>
5
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7
7
8 #include <memory>
8 #include <memory>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13
13
14 class MockPlugin : public QObject, public IPlugin {
14 class MockPlugin : public QObject, public IPlugin {
15 Q_OBJECT
15 Q_OBJECT
16 Q_INTERFACES(IPlugin)
16 Q_INTERFACES(IPlugin)
17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
18 public:
18 public:
19 /// @sa IPlugin::initialize()
19 /// @sa IPlugin::initialize()
20 void initialize() override;
20 void initialize() override;
21
22 private:
23 /// Creates the data source item relative to the plugin
24 std::unique_ptr<DataSourceItem> createDataSourceItem() const noexcept;
25 };
21 };
26
22
27 #endif // SCIQLOP_MOCKPLUGIN_H
23 #endif // SCIQLOP_MOCKPLUGIN_H
@@ -1,55 +1,67
1 #include <MockPlugin.h>
1 #include "MockPlugin.h"
2 #include "CosinusProvider.h"
2
3
3 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/DataSourceItem.h>
5
6
6 #include <SqpApplication.h>
7 #include <SqpApplication.h>
7
8
8 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9
10
10 namespace {
11 namespace {
11
12
12 /// Name of the data source
13 /// Name of the data source
13 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
14 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
14
15
15 } // namespace
16 /// Creates the data provider relative to the plugin
16
17 std::unique_ptr<IDataProvider> createDataProvider() noexcept
17 void MockPlugin::initialize()
18 {
18 {
19 if (auto app = sqpApp) {
19 return std::make_unique<CosinusProvider>();
20 // Registers to the data source controller
21 auto &dataSourceController = app->dataSourceController();
22 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
23
24 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
25 }
26 else {
27 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
28 }
29 }
20 }
30
21
31 std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcept
22 /// Creates the data source item relative to the plugin
23 std::unique_ptr<DataSourceItem> createDataSourceItem() noexcept
32 {
24 {
33 // Magnetic field products
25 // Magnetic field products
34 auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
26 auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
35 QVector<QVariant>{QStringLiteral("FGM")});
27 QVector<QVariant>{QStringLiteral("FGM")});
36 auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
28 auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
37 QVector<QVariant>{QStringLiteral("SC")});
29 QVector<QVariant>{QStringLiteral("SC")});
38
30
39 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
31 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
40 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
32 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
41 magneticFieldFolder->appendChild(std::move(fgmProduct));
33 magneticFieldFolder->appendChild(std::move(fgmProduct));
42 magneticFieldFolder->appendChild(std::move(scProduct));
34 magneticFieldFolder->appendChild(std::move(scProduct));
43
35
44 // Electric field products
36 // Electric field products
45 auto electricFieldFolder = std::make_unique<DataSourceItem>(
37 auto electricFieldFolder = std::make_unique<DataSourceItem>(
46 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
38 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
47
39
48 // Root
40 // Root
49 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
41 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
50 QVector<QVariant>{DATA_SOURCE_NAME});
42 QVector<QVariant>{DATA_SOURCE_NAME});
51 root->appendChild(std::move(magneticFieldFolder));
43 root->appendChild(std::move(magneticFieldFolder));
52 root->appendChild(std::move(electricFieldFolder));
44 root->appendChild(std::move(electricFieldFolder));
53
45
54 return std::move(root);
46 return root;
47 }
48
49 } // namespace
50
51 void MockPlugin::initialize()
52 {
53 if (auto app = sqpApp) {
54 // Registers to the data source controller
55 auto &dataSourceController = app->dataSourceController();
56 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
57
58 // Sets data source tree
59 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
60
61 // Sets data provider
62 dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
63 }
64 else {
65 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
66 }
55 }
67 }
General Comments 0
You need to be logged in to leave comments. Login now