##// 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
1 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 2 -- This file is a part of the SciQLop Software
3 3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "MainWindow.h"
23 23 #include "ui_MainWindow.h"
24 24
25 25 #include <DataSource/DataSourceController.h>
26 26 #include <DataSource/DataSourceWidget.h>
27 27 #include <SidePane/SqpSidePane.h>
28 28 #include <SqpApplication.h>
29 #include <TimeWidget/TimeWidget.h>
29 30
30 31 #include <QAction>
31 32 #include <QDate>
32 33 #include <QDateTime>
33 34 #include <QDir>
34 35 #include <QFileDialog>
35 36 #include <QToolBar>
37 #include <QToolButton>
36 38 #include <memory.h>
37 39
38 40 //#include <omp.h>
39 41 //#include <network/filedownloader.h>
40 42 //#include <qlopdatabase.h>
41 43 //#include <qlopsettings.h>
42 44 //#include <qlopgui.h>
43 45 //#include <spacedata.h>
44 46 //#include "qlopcore.h"
45 47 //#include "qlopcodecmanager.h"
46 48 //#include "cdfcodec.h"
47 49 //#include "amdatxtcodec.h"
48 50 //#include <qlopplotmanager.h>
49 51
50 52 #include "iostream"
51 53
52 54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53 55
54 56 namespace {
55 57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 59 const auto VIEWPLITTERINDEX = 2;
58 60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 62 }
61 63
62 64 class MainWindow::MainWindowPrivate {
63 65 public:
64 66 QSize m_LastOpenLeftInspectorSize;
65 67 QSize m_LastOpenRightInspectorSize;
66 68 };
67 69
68 70 MainWindow::MainWindow(QWidget *parent)
69 71 : QMainWindow{parent},
70 72 m_Ui{new Ui::MainWindow},
71 73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
72 74 {
73 75 m_Ui->setupUi(this);
74 76
75 77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 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
83 if (checked) {
84 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
85 }
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
82 auto openLeftInspectorAction = new QAction{QIcon{
83 ":/icones/previous.png",
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();
92 if (checked) {
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 }
88 auto spacerLeftTop = new QWidget{};
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
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"});
121
122 auto &lastInspectorSize
123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
108 124
109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
110 auto openRightInspector = [this](bool checked) {
125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
126 : m_Ui->leftMainInspectorWidget->size();
111 127
112 128 // Update of the last opened geometry
113 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 134 auto endSize = startSize;
119 135 endSize.setWidth(0);
120 136
137 auto splitterInspectorIndex
138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
139
121 140 auto currentSizes = m_Ui->splitter->sizes();
122 141 if (checked) {
123 142 // adjust sizes individually here, e.g.
124 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
125 -= impl->m_LastOpenRightInspectorSize.width();
126 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
127 145 m_Ui->splitter->setSizes(currentSizes);
128 146 }
129 147 else {
130 148 // adjust sizes individually here, e.g.
131 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
132 += impl->m_LastOpenRightInspectorSize.width();
133 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
134 151 m_Ui->splitter->setSizes(currentSizes);
135 152 }
136 153
137 154 };
138 155
139 156
140 QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
141 auto openLeftInspectorAction = leftSidePane->addAction(
142 QIcon{
143 ":/icones/openInspector.png",
144 },
145 tr("Show/hide the left inspector"), openLeftInspector);
146
147 openLeftInspectorAction->setCheckable(true);
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 connect(openLeftInspectorAction, &QAction::triggered,
158 [openInspector, openLeftInspectorAction](bool checked) {
159 openInspector(checked, false, openLeftInspectorAction);
160 });
161 connect(openRightInspectorAction, &QAction::triggered,
162 [openInspector, openRightInspectorAction](bool checked) {
163 openInspector(checked, true, openRightInspectorAction);
164 });
157 165
158 166 this->menuBar()->addAction(tr("File"));
159 167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160 mainToolBar->addAction(QStringLiteral("A1"));
168
169 mainToolBar->addWidget(new TimeWidget{});
161 170
162 171 // Widgets / controllers connections
163 172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
164 173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
165 174
166 175 /* QLopGUI::registerMenuBar(menuBar());
167 176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
168 177 this->m_progressWidget = new QWidget();
169 178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
170 179 this->m_progressWidget->setLayout(this->m_progressLayout);
171 180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
172 181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
173 182 for(int i=0;i<OMP_THREADS;i++)
174 183 {
175 184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
176 185 this->m_progress.last()->setMinimum(0);
177 186 this->m_progress.last()->setMaximum(100);
178 187 this->m_progressLayout->addWidget(this->m_progress.last());
179 188 this->m_progressWidget->hide();
180 189 this->m_progressThreadIds[i] = -1;
181 190 }
182 191 this->m_progressWidget->setWindowTitle("Loading File");
183 192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
184 193 << QLopCore::self()
185 194 << QLopPlotManager::self()
186 195 << QLopCodecManager::self()
187 196 << FileDownloader::self()
188 197 << QLopDataBase::self()
189 198 << SpaceData::self();
190 199
191 200 CDFCodec::registerToManager();
192 201 AMDATXTCodec::registerToManager();
193 202
194 203
195 204 for(int i=0;i<ServicesToLoad.count();i++)
196 205 {
197 206 qDebug()<<ServicesToLoad.at(i)->serviceName();
198 207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
199 208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
200 209 if(wdgt)
201 210 {
202 211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
203 212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
204 213 }
205 214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
206 215 }*/
207 216 }
208 217
209 218 MainWindow::~MainWindow()
210 219 {
211 220 }
212 221
213 222
214 223 void MainWindow::changeEvent(QEvent *e)
215 224 {
216 225 QMainWindow::changeEvent(e);
217 226 switch (e->type()) {
218 227 case QEvent::LanguageChange:
219 228 m_Ui->retranslateUi(this);
220 229 break;
221 230 default:
222 231 break;
223 232 }
224 233 }
@@ -1,61 +1,73
1 1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 2 #define SCIQLOP_DATASOURCECONTROLLER_H
3 3
4 4 #include <QLoggingCategory>
5 5 #include <QObject>
6 6 #include <QUuid>
7 7
8 8 #include <Common/spimpl.h>
9 9
10 10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
11 11
12 12 class DataSourceItem;
13 class IDataProvider;
13 14
14 15 /**
15 16 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
16 17 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
17 18 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
18 19 * source) then others specifics method will be able to access it. You can load a data source driver
19 20 * plugin then create a data source.
20 21 */
21 22 class DataSourceController : public QObject {
22 23 Q_OBJECT
23 24 public:
24 25 explicit DataSourceController(QObject *parent = 0);
25 26 virtual ~DataSourceController();
26 27
27 28 /**
28 29 * Registers a data source. The method delivers a unique id that can be used afterwards to
29 30 * access to the data source properties (structure, connection parameters, data provider, etc.)
30 31 * @param dataSourceName the name of the data source
31 32 * @return the unique id with which the data source has been registered
32 33 */
33 34 QUuid registerDataSource(const QString &dataSourceName) noexcept;
34 35
35 36 /**
36 37 * Sets the structure of a data source. The controller takes ownership of the structure.
37 38 * @param dataSourceUid the unique id with which the data source has been registered into the
38 39 * controller. If it is invalid, the method has no effect.
39 40 * @param dataSourceItem the structure of the data source
40 41 * @sa registerDataSource()
41 42 */
42 43 void setDataSourceItem(const QUuid &dataSourceUid,
43 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 57 public slots:
46 58 /// Manage init/end of the controller
47 59 void initialize();
48 60 void finalize();
49 61
50 62 signals:
51 63 /// Signal emitted when a structure has been set for a data source
52 64 void dataSourceItemSet(DataSourceItem *dataSourceItem);
53 65
54 66 private:
55 67 void waitForFinish();
56 68
57 69 class DataSourceControllerPrivate;
58 70 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
59 71 };
60 72
61 73 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,78 +1,95
1 1 #include <DataSource/DataSourceController.h>
2 2 #include <DataSource/DataSourceItem.h>
3 3
4 #include <Data/IDataProvider.h>
5
4 6 #include <QMutex>
5 7 #include <QThread>
6 8
7 9 #include <QDir>
8 10 #include <QStandardPaths>
9 11
10 12 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
11 13
12 14 class DataSourceController::DataSourceControllerPrivate {
13 15 public:
14 16 QMutex m_WorkingMutex;
15 17 /// Data sources registered
16 18 QHash<QUuid, QString> m_DataSources;
17 19 /// Data sources structures
18 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 25 DataSourceController::DataSourceController(QObject *parent)
22 26 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
23 27 {
24 28 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
25 29 << QThread::currentThread();
26 30 }
27 31
28 32 DataSourceController::~DataSourceController()
29 33 {
30 34 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
31 35 << QThread::currentThread();
32 36 this->waitForFinish();
33 37 }
34 38
35 39 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
36 40 {
37 41 auto dataSourceUid = QUuid::createUuid();
38 42 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
39 43
40 44 return dataSourceUid;
41 45 }
42 46
43 47 void DataSourceController::setDataSourceItem(
44 48 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
45 49 {
46 50 if (impl->m_DataSources.contains(dataSourceUid)) {
47 51 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
48 52
49 53 // Retrieves the data source item to emit the signal with it
50 54 auto it = impl->m_DataSourceItems.find(dataSourceUid);
51 55 if (it != impl->m_DataSourceItems.end()) {
52 56 emit dataSourceItemSet(it->second.get());
53 57 }
54 58 }
55 59 else {
56 60 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
57 61 "data source has been registered with the uid")
58 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 79 void DataSourceController::initialize()
63 80 {
64 81 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
65 82 << QThread::currentThread();
66 83 impl->m_WorkingMutex.lock();
67 84 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
68 85 }
69 86
70 87 void DataSourceController::finalize()
71 88 {
72 89 impl->m_WorkingMutex.unlock();
73 90 }
74 91
75 92 void DataSourceController::waitForFinish()
76 93 {
77 94 QMutexLocker locker{&impl->m_WorkingMutex};
78 95 }
@@ -1,53 +1,53
1 1 #include <Variable/VariableController.h>
2 2 #include <Variable/VariableModel.h>
3 3
4 4 #include <QMutex>
5 5 #include <QThread>
6 6
7 7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8 8
9 9 struct VariableController::VariableControllerPrivate {
10 10 explicit VariableControllerPrivate()
11 11 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
12 12 {
13 13 }
14 14
15 15 QMutex m_WorkingMutex;
16 16 std::unique_ptr<VariableModel> m_VariableModel;
17 17 };
18 18
19 19 VariableController::VariableController(QObject *parent)
20 20 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
21 21 {
22 qCDebug(LOG_VariableController())
23 << tr("VariableController construction") << QThread::currentThread();
22 qCDebug(LOG_VariableController()) << tr("VariableController construction")
23 << QThread::currentThread();
24 24 }
25 25
26 26 VariableController::~VariableController()
27 27 {
28 qCDebug(LOG_VariableController())
29 << tr("VariableController destruction") << QThread::currentThread();
28 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
29 << QThread::currentThread();
30 30 this->waitForFinish();
31 31 }
32 32
33 33 Variable *VariableController::createVariable(const QString &name) noexcept
34 34 {
35 35 return impl->m_VariableModel->createVariable(name);
36 36 }
37 37
38 38 void VariableController::initialize()
39 39 {
40 40 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
41 41 impl->m_WorkingMutex.lock();
42 42 qCDebug(LOG_VariableController()) << tr("VariableController init END");
43 43 }
44 44
45 45 void VariableController::finalize()
46 46 {
47 47 impl->m_WorkingMutex.unlock();
48 48 }
49 49
50 50 void VariableController::waitForFinish()
51 51 {
52 52 QMutexLocker locker{&impl->m_WorkingMutex};
53 53 }
@@ -1,6 +1,10
1 1 # On ignore toutes les règles vera++ pour le fichier spimpl
2 2 Common/spimpl\.h:\d+:.*
3 3
4 4 # Ignore false positive relative to two class definitions in a same file
5 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 1 <RCC>
2 2 <qresource prefix="/">
3 3 <file>icones/openInspector.png</file>
4 <file>icones/next.png</file>
5 <file>icones/previous.png</file>
4 6 </qresource>
5 7 </RCC>
@@ -1,54 +1,47
1 1 #include "SidePane/SqpSidePane.h"
2 2 #include "ui_SqpSidePane.h"
3 3
4 4 #include <QAction>
5 5 #include <QLayout>
6 6 #include <QToolBar>
7 7
8 8 namespace {
9 9 static const QString SQPSIDEPANESTYLESHEET
10 10 = "QToolBar {"
11 11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
12 12 " stop: 0.0 #5a5a5a,"
13 13 " stop: 1.0 #414141);"
14 14 " border: none;"
15 15 " border-left: 1px solid #424242;"
16 16 "border-right: 1px solid #393939;"
17 17 " }"
18 18
19 19 " QToolButton {"
20 20 "background: none;"
21 21 "border: none;"
22 22 " }";
23 23 }
24 24
25 25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
26 26 {
27 27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
28 28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
29 29 // this->setLayout(sidePaneLayout);
30 30
31 31 ui->setupUi(this);
32 32 m_SidePaneToolbar = new QToolBar();
33 33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
34 34 this->layout()->addWidget(m_SidePaneToolbar);
35 35
36 36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
37
38 this->setStyleSheet(
39 " QWidget {"
40 "background: red;"
41
42 "border: 1px;"
43 " }");
44 37 }
45 38
46 39 SqpSidePane::~SqpSidePane()
47 40 {
48 41 delete ui;
49 42 }
50 43
51 44 QToolBar *SqpSidePane::sidePane()
52 45 {
53 46 return m_SidePaneToolbar;
54 47 }
1 NO CONTENT: file renamed from gui/ui/Sidepane/SqpSidePane.ui to gui/ui/SidePane/SqpSidePane.ui
@@ -1,27 +1,23
1 1 #ifndef SCIQLOP_MOCKPLUGIN_H
2 2 #define SCIQLOP_MOCKPLUGIN_H
3 3
4 4 #include <Plugin/IPlugin.h>
5 5
6 6 #include <QLoggingCategory>
7 7
8 8 #include <memory>
9 9
10 10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
11 11
12 12 class DataSourceItem;
13 13
14 14 class MockPlugin : public QObject, public IPlugin {
15 15 Q_OBJECT
16 16 Q_INTERFACES(IPlugin)
17 17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
18 18 public:
19 19 /// @sa IPlugin::initialize()
20 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 23 #endif // SCIQLOP_MOCKPLUGIN_H
@@ -1,55 +1,67
1 #include <MockPlugin.h>
1 #include "MockPlugin.h"
2 #include "CosinusProvider.h"
2 3
3 4 #include <DataSource/DataSourceController.h>
4 5 #include <DataSource/DataSourceItem.h>
5 6
6 7 #include <SqpApplication.h>
7 8
8 9 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9 10
10 11 namespace {
11 12
12 13 /// Name of the data source
13 14 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
14 15
15 } // namespace
16
17 void MockPlugin::initialize()
16 /// Creates the data provider relative to the plugin
17 std::unique_ptr<IDataProvider> createDataProvider() noexcept
18 18 {
19 if (auto app = sqpApp) {
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 }
19 return std::make_unique<CosinusProvider>();
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 25 // Magnetic field products
34 26 auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
35 27 QVector<QVariant>{QStringLiteral("FGM")});
36 28 auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
37 29 QVector<QVariant>{QStringLiteral("SC")});
38 30
39 31 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
40 32 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
41 33 magneticFieldFolder->appendChild(std::move(fgmProduct));
42 34 magneticFieldFolder->appendChild(std::move(scProduct));
43 35
44 36 // Electric field products
45 37 auto electricFieldFolder = std::make_unique<DataSourceItem>(
46 38 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
47 39
48 40 // Root
49 41 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
50 42 QVector<QVariant>{DATA_SOURCE_NAME});
51 43 root->appendChild(std::move(magneticFieldFolder));
52 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