##// END OF EJS Templates
@@ -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,48
1 #ifndef SCIQLOP_DATASOURCEITEMACTION_H
2 #define SCIQLOP_DATASOURCEITEMACTION_H
3
4 #include <Common/spimpl.h>
5
6 #include <QLoggingCategory>
7 #include <QObject>
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceItemAction)
10
11 class DataSourceItem;
12
13 /**
14 * @brief The DataSourceItemAction class represents an action on a data source item.
15 *
16 * An action is a function that will be executed when the slot execute() is called.
17 */
18 class DataSourceItemAction : public QObject {
19
20 Q_OBJECT
21
22 public:
23 /// Signature of the function associated to the action
24 using ExecuteFunction = std::function<void(DataSourceItem &dataSourceItem)>;
25
26 /**
27 * Ctor
28 * @param name the name of the action
29 * @param fun the function that will be called when the action is executed
30 * @sa execute()
31 */
32 explicit DataSourceItemAction(const QString &name, ExecuteFunction fun);
33
34 QString name() const noexcept;
35
36 /// Sets the data source item concerned by the action
37 void setDataSourceItem(DataSourceItem *dataSourceItem) noexcept;
38
39 public slots:
40 /// Executes the action
41 void execute();
42
43 private:
44 class DataSourceItemActionPrivate;
45 spimpl::unique_impl_ptr<DataSourceItemActionPrivate> impl;
46 };
47
48 #endif // SCIQLOP_DATASOURCEITEMACTION_H
@@ -0,0 +1,20
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
4 #include <QString>
5
6 /**
7 * @brief The Variable struct represents a variable in SciQlop.
8 */
9 struct Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
12 {
13 }
14
15 QString m_Name;
16 QString m_Unit;
17 QString m_Mission;
18 };
19
20 #endif // SCIQLOP_VARIABLE_H
@@ -0,0 +1,43
1 #ifndef SCIQLOP_VARIABLECONTROLLER_H
2 #define SCIQLOP_VARIABLECONTROLLER_H
3
4 #include <QLoggingCategory>
5 #include <QObject>
6
7 #include <Common/spimpl.h>
8
9 class Variable;
10 class VariableModel;
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController)
13
14 /**
15 * @brief The VariableController class aims to handle the variables in SciQlop.
16 */
17 class VariableController : public QObject {
18 Q_OBJECT
19 public:
20 explicit VariableController(QObject *parent = 0);
21 virtual ~VariableController();
22
23 /**
24 * Creates a new variable
25 * @param name the name of the new variable
26 * @return the variable if it was created successfully, nullptr otherwise
27 */
28 Variable *createVariable(const QString &name) noexcept;
29
30 VariableModel *variableModel() noexcept;
31
32 public slots:
33 void initialize();
34 void finalize();
35
36 private:
37 void waitForFinish();
38
39 class VariableControllerPrivate;
40 spimpl::unique_impl_ptr<VariableControllerPrivate> impl;
41 };
42
43 #endif // SCIQLOP_VARIABLECONTROLLER_H
@@ -0,0 +1,41
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
4 #include <Common/spimpl.h>
5
6 #include <QAbstractTableModel>
7 #include <QLoggingCategory>
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
10
11 class Variable;
12
13 /**
14 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
15 */
16 class VariableModel : public QAbstractTableModel {
17 public:
18 explicit VariableModel(QObject *parent = nullptr);
19
20 /**
21 * Creates a new variable in the model
22 * @param name the name of the new variable
23 * @return the variable if it was created successfully, nullptr otherwise
24 */
25 Variable *createVariable(const QString &name) noexcept;
26
27 // /////////////////////////// //
28 // QAbstractTableModel methods //
29 // /////////////////////////// //
30 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
31 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
32 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
33 virtual QVariant headerData(int section, Qt::Orientation orientation,
34 int role = Qt::DisplayRole) const override;
35
36 private:
37 class VariableModelPrivate;
38 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
39 };
40
41 #endif // SCIQLOP_VARIABLEMODEL_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,42
1 #include <DataSource/DataSourceItemAction.h>
2
3 Q_LOGGING_CATEGORY(LOG_DataSourceItemAction, "DataSourceItemAction")
4
5 struct DataSourceItemAction::DataSourceItemActionPrivate {
6 explicit DataSourceItemActionPrivate(const QString &name,
7 DataSourceItemAction::ExecuteFunction fun)
8 : m_Name{name}, m_Fun{std::move(fun)}, m_DataSourceItem{nullptr}
9 {
10 }
11
12 QString m_Name;
13 DataSourceItemAction::ExecuteFunction m_Fun;
14 /// Item associated to the action (can be null, in which case the action will not be executed)
15 DataSourceItem *m_DataSourceItem;
16 };
17
18 DataSourceItemAction::DataSourceItemAction(const QString &name, ExecuteFunction fun)
19 : impl{spimpl::make_unique_impl<DataSourceItemActionPrivate>(name, std::move(fun))}
20 {
21 }
22
23 QString DataSourceItemAction::name() const noexcept
24 {
25 return impl->m_Name;
26 }
27
28 void DataSourceItemAction::setDataSourceItem(DataSourceItem *dataSourceItem) noexcept
29 {
30 impl->m_DataSourceItem = dataSourceItem;
31 }
32
33 void DataSourceItemAction::execute()
34 {
35 if (impl->m_DataSourceItem) {
36 impl->m_Fun(*impl->m_DataSourceItem);
37 }
38 else {
39 qCDebug(LOG_DataSourceItemAction())
40 << tr("Can't execute action : no item has been associated");
41 }
42 }
@@ -0,0 +1,59
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableModel.h>
3
4 #include <QMutex>
5 #include <QThread>
6
7 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
8
9 struct VariableController::VariableControllerPrivate {
10 explicit VariableControllerPrivate(VariableController *parent)
11 : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
12 {
13 }
14
15 QMutex m_WorkingMutex;
16 /// Variable model. The VariableController has the ownership
17 VariableModel *m_VariableModel;
18 };
19
20 VariableController::VariableController(QObject *parent)
21 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
22 {
23 qCDebug(LOG_VariableController()) << tr("VariableController construction")
24 << QThread::currentThread();
25 }
26
27 VariableController::~VariableController()
28 {
29 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
30 << QThread::currentThread();
31 this->waitForFinish();
32 }
33
34 Variable *VariableController::createVariable(const QString &name) noexcept
35 {
36 return impl->m_VariableModel->createVariable(name);
37 }
38
39 VariableModel *VariableController::variableModel() noexcept
40 {
41 return impl->m_VariableModel;
42 }
43
44 void VariableController::initialize()
45 {
46 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
47 impl->m_WorkingMutex.lock();
48 qCDebug(LOG_VariableController()) << tr("VariableController init END");
49 }
50
51 void VariableController::finalize()
52 {
53 impl->m_WorkingMutex.unlock();
54 }
55
56 void VariableController::waitForFinish()
57 {
58 QMutexLocker locker{&impl->m_WorkingMutex};
59 }
@@ -0,0 +1,115
1 #include <Variable/VariableModel.h>
2
3 #include <Variable/Variable.h>
4
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
7 namespace {
8
9 // Column indexes
10 const auto NAME_COLUMN = 0;
11 const auto UNIT_COLUMN = 1;
12 const auto MISSION_COLUMN = 2;
13 const auto NB_COLUMNS = 3;
14
15 } // namespace
16
17 struct VariableModel::VariableModelPrivate {
18 /// Variables created in SciQlop
19 std::vector<std::unique_ptr<Variable> > m_Variables;
20 };
21
22 VariableModel::VariableModel(QObject *parent)
23 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
24 {
25 }
26
27 Variable *VariableModel::createVariable(const QString &name) noexcept
28 {
29 auto insertIndex = rowCount();
30 beginInsertRows({}, insertIndex, insertIndex);
31
32 /// @todo For the moment, the other data of the variable is initialized with default values
33 auto variable
34 = std::make_unique<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
35 impl->m_Variables.push_back(std::move(variable));
36
37 endInsertRows();
38
39 return impl->m_Variables.at(insertIndex).get();
40 }
41
42 int VariableModel::columnCount(const QModelIndex &parent) const
43 {
44 Q_UNUSED(parent);
45
46 return NB_COLUMNS;
47 }
48
49 int VariableModel::rowCount(const QModelIndex &parent) const
50 {
51 Q_UNUSED(parent);
52
53 return impl->m_Variables.size();
54 }
55
56 QVariant VariableModel::data(const QModelIndex &index, int role) const
57 {
58 if (!index.isValid()) {
59 return QVariant{};
60 }
61
62 if (index.row() < 0 || index.row() >= rowCount()) {
63 return QVariant{};
64 }
65
66 if (role == Qt::DisplayRole) {
67 if (auto variable = impl->m_Variables.at(index.row()).get()) {
68 switch (index.column()) {
69 case NAME_COLUMN:
70 return variable->m_Name;
71 case UNIT_COLUMN:
72 return variable->m_Unit;
73 case MISSION_COLUMN:
74 return variable->m_Mission;
75 default:
76 // No action
77 break;
78 }
79
80 qWarning(LOG_VariableModel())
81 << tr("Can't get data (unknown column %1)").arg(index.column());
82 }
83 else {
84 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
85 }
86 }
87
88 return QVariant{};
89 }
90
91 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
92 {
93 if (role != Qt::DisplayRole) {
94 return QVariant{};
95 }
96
97 if (orientation == Qt::Horizontal) {
98 switch (section) {
99 case NAME_COLUMN:
100 return tr("Name");
101 case UNIT_COLUMN:
102 return tr("Unit");
103 case MISSION_COLUMN:
104 return tr("Mission");
105 default:
106 // No action
107 break;
108 }
109
110 qWarning(LOG_VariableModel())
111 << tr("Can't get header data (unknown column %1)").arg(section);
112 }
113
114 return QVariant{};
115 }
@@ -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
@@ -0,0 +1,26
1 #ifndef SCIQLOP_VARIABLEINSPECTORWIDGET_H
2 #define SCIQLOP_VARIABLEINSPECTORWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class VariableInspectorWidget;
8 } // Ui
9
10 /**
11 * @brief The VariableInspectorWidget class representes represents the variable inspector, from
12 * which it is possible to view the loaded variables, handle them or trigger their display in
13 * visualization
14 */
15 class VariableInspectorWidget : public QWidget {
16 Q_OBJECT
17
18 public:
19 explicit VariableInspectorWidget(QWidget *parent = 0);
20 virtual ~VariableInspectorWidget();
21
22 private:
23 Ui::VariableInspectorWidget *ui;
24 };
25
26 #endif // SCIQLOP_VARIABLEINSPECTORWIDGET_H
@@ -0,0 +1,24
1 #ifndef SCIQLOP_IVISUALIZATIONWIDGET_H
2 #define SCIQLOP_IVISUALIZATIONWIDGET_H
3
4 #include "Visualization/IVisualizationWidgetVisitor.h"
5
6 #include <QString>
7 #include <memory>
8
9 /**
10 * @brief The IVisualizationWidget handles the visualization widget.
11 */
12 class IVisualizationWidget {
13
14 public:
15 virtual ~IVisualizationWidget() = default;
16
17 /// Initializes the plugin
18 virtual void accept(IVisualizationWidget *visitor) = 0;
19 virtual void close() = 0;
20 virtual QString name() const = 0;
21 };
22
23
24 #endif // SCIQLOP_IVISUALIZATIONWIDGET_H
@@ -0,0 +1,25
1 #ifndef SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H
2 #define SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H
3
4
5 class VisualizationWidget;
6 class VisualizationTabWidget;
7 class VisualizationZoneWidget;
8 class VisualizationGraphWidget;
9
10 /**
11 * @brief The IVisualizationWidgetVisitor handles the visualization widget vistor pattern.
12 */
13 class IVisualizationWidgetVisitor {
14
15 public:
16 virtual ~IVisualizationWidgetVisitor() = default;
17
18 virtual void visit(VisualizationWidget *widget) = 0;
19 virtual void visit(VisualizationTabWidget *tabWidget) = 0;
20 virtual void visit(VisualizationZoneWidget *zoneWidget) = 0;
21 virtual void visit(VisualizationGraphWidget *graphWidget) = 0;
22 };
23
24
25 #endif // SCIQLOP_IVISUALIZATIONWIDGETVISITOR_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,26
1 #include <Variable/VariableController.h>
2 #include <Variable/VariableInspectorWidget.h>
3 #include <Variable/VariableModel.h>
4
5 #include <ui_VariableInspectorWidget.h>
6
7 #include <QSortFilterProxyModel>
8
9 #include <SqpApplication.h>
10
11 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
12 : QWidget{parent}, ui{new Ui::VariableInspectorWidget}
13 {
14 ui->setupUi(this);
15
16 // Sets model for table
17 auto sortFilterModel = new QSortFilterProxyModel{this};
18 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
19
20 ui->tableView->setModel(sortFilterModel);
21 }
22
23 VariableInspectorWidget::~VariableInspectorWidget()
24 {
25 delete ui;
26 }
@@ -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,31
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>VariableInspectorWidget</class>
4 <widget class="QWidget" name="VariableInspectorWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Variables</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QTableView" name="tableView">
19 <property name="sortingEnabled">
20 <bool>true</bool>
21 </property>
22 <attribute name="horizontalHeaderStretchLastSection">
23 <bool>true</bool>
24 </attribute>
25 </widget>
26 </item>
27 </layout>
28 </widget>
29 <resources/>
30 <connections/>
31 </ui>
@@ -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"});
108 121
109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
110 auto openRightInspector = [this](bool checked) {
122 auto &lastInspectorSize
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 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,158 +1,164
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>MainWindow</class>
4 4 <widget class="QMainWindow" name="MainWindow">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>800</width>
10 10 <height>600</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>QLop</string>
15 15 </property>
16 16 <property name="dockNestingEnabled">
17 17 <bool>true</bool>
18 18 </property>
19 19 <widget class="QWidget" name="centralWidget">
20 20 <property name="enabled">
21 21 <bool>true</bool>
22 22 </property>
23 23 <property name="sizePolicy">
24 24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 25 <horstretch>0</horstretch>
26 26 <verstretch>0</verstretch>
27 27 </sizepolicy>
28 28 </property>
29 29 <property name="maximumSize">
30 30 <size>
31 31 <width>16777215</width>
32 32 <height>16777215</height>
33 33 </size>
34 34 </property>
35 35 <layout class="QHBoxLayout" name="horizontalLayout">
36 36 <property name="spacing">
37 37 <number>0</number>
38 38 </property>
39 39 <property name="leftMargin">
40 40 <number>0</number>
41 41 </property>
42 42 <property name="topMargin">
43 43 <number>0</number>
44 44 </property>
45 45 <property name="rightMargin">
46 46 <number>0</number>
47 47 </property>
48 48 <property name="bottomMargin">
49 49 <number>0</number>
50 50 </property>
51 51 <item>
52 52 <widget class="QSplitter" name="splitter">
53 53 <property name="orientation">
54 54 <enum>Qt::Horizontal</enum>
55 55 </property>
56 56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 57 <layout class="QVBoxLayout" name="verticalLayout">
58 58 <property name="spacing">
59 59 <number>0</number>
60 60 </property>
61 61 <property name="leftMargin">
62 62 <number>0</number>
63 63 </property>
64 64 <property name="topMargin">
65 65 <number>0</number>
66 66 </property>
67 67 <property name="rightMargin">
68 68 <number>0</number>
69 69 </property>
70 70 <property name="bottomMargin">
71 71 <number>0</number>
72 72 </property>
73 73 <item>
74 74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 75 </item>
76 76 <item>
77 77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 78 </item>
79 79 <item>
80 <widget class="QWidget" name="variableInspectorWidget" native="true"/>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 81 </item>
82 82 </layout>
83 83 </widget>
84 84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 85 <widget class="VisualizationWidget" name="view" native="true">
86 86 <property name="sizePolicy">
87 87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 88 <horstretch>0</horstretch>
89 89 <verstretch>0</verstretch>
90 90 </sizepolicy>
91 91 </property>
92 92 </widget>
93 93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 95 <layout class="QVBoxLayout" name="verticalLayout_3">
96 96 <property name="spacing">
97 97 <number>0</number>
98 98 </property>
99 99 <property name="leftMargin">
100 100 <number>0</number>
101 101 </property>
102 102 <property name="topMargin">
103 103 <number>0</number>
104 104 </property>
105 105 <property name="rightMargin">
106 106 <number>0</number>
107 107 </property>
108 108 <property name="bottomMargin">
109 109 <number>0</number>
110 110 </property>
111 111 <item>
112 112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 113 </item>
114 114 <item>
115 115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
116 116 </item>
117 117 </layout>
118 118 </widget>
119 119 </widget>
120 120 </item>
121 121 </layout>
122 122 </widget>
123 123 <widget class="QMenuBar" name="menuBar">
124 124 <property name="geometry">
125 125 <rect>
126 126 <x>0</x>
127 127 <y>0</y>
128 128 <width>800</width>
129 <height>28</height>
129 <height>26</height>
130 130 </rect>
131 131 </property>
132 132 </widget>
133 133 <widget class="QStatusBar" name="statusBar"/>
134 134 </widget>
135 135 <layoutdefault spacing="6" margin="11"/>
136 136 <customwidgets>
137 137 <customwidget>
138 138 <class>VisualizationWidget</class>
139 139 <extends>QWidget</extends>
140 140 <header location="global">Visualization/VisualizationWidget.h</header>
141 141 <container>1</container>
142 142 </customwidget>
143 143 <customwidget>
144 144 <class>SqpSidePane</class>
145 145 <extends>QWidget</extends>
146 146 <header location="global">SidePane/SqpSidePane.h</header>
147 147 <container>1</container>
148 148 </customwidget>
149 149 <customwidget>
150 150 <class>DataSourceWidget</class>
151 151 <extends>QWidget</extends>
152 152 <header location="global">DataSource/DataSourceWidget.h</header>
153 153 <container>1</container>
154 154 </customwidget>
155 <customwidget>
156 <class>VariableInspectorWidget</class>
157 <extends>QWidget</extends>
158 <header location="global">Variable/VariableInspectorWidget.h</header>
159 <container>1</container>
160 </customwidget>
155 161 </customwidgets>
156 162 <resources/>
157 163 <connections/>
158 164 </ui>
@@ -1,61 +1,79
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
57 /**
58 * Loads an item (product) as a variable in SciQlop
59 * @param productItem the item to load
60 */
61 void loadProductItem(const DataSourceItem &productItem) noexcept;
62
45 63 public slots:
46 64 /// Manage init/end of the controller
47 65 void initialize();
48 66 void finalize();
49 67
50 68 signals:
51 69 /// Signal emitted when a structure has been set for a data source
52 70 void dataSourceItemSet(DataSourceItem *dataSourceItem);
53 71
54 72 private:
55 73 void waitForFinish();
56 74
57 75 class DataSourceControllerPrivate;
58 76 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
59 77 };
60 78
61 79 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,59 +1,73
1 1 #ifndef SCIQLOP_DATASOURCEITEM_H
2 2 #define SCIQLOP_DATASOURCEITEM_H
3 3
4 4 #include <Common/spimpl.h>
5 5
6 6 #include <QVariant>
7 7 #include <QVector>
8 8
9 class DataSourceItemAction;
10
9 11 /**
10 12 * Possible types of an item
11 13 */
12 14 enum class DataSourceItemType { NODE, PRODUCT };
13 15
14 16 /**
15 17 * @brief The DataSourceItem class aims to represent a structure element of a data source.
16 18 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
17 19 * containing other DataSourceItem objects (children).
18 20 * For each DataSourceItem can be associated a set of data representing it.
19 21 */
20 22 class DataSourceItem {
21 23 public:
22 24 explicit DataSourceItem(DataSourceItemType type, QVector<QVariant> data = {});
23 25
26 /// @return the actions of the item as a vector
27 QVector<DataSourceItemAction *> actions() const noexcept;
28
29 /**
30 * Adds an action to the item. The item takes ownership of the action, and the action is
31 * automatically associated to the item
32 * @param action the action to add
33 */
34 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
35
24 36 /**
25 37 * Adds a child to the item. The item takes ownership of the child.
26 38 * @param child the child to add
27 39 */
28 40 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
29 41
30 42 /**
31 43 * Returns the item's child associated to an index
32 44 * @param childIndex the index to search
33 45 * @return a pointer to the child if index is valid, nullptr otherwise
34 46 */
35 47 DataSourceItem *child(int childIndex) const noexcept;
36 48
37 49 int childCount() const noexcept;
38 50
39 51 /**
40 52 * Get the data associated to an index
41 53 * @param dataIndex the index to search
42 54 * @return the data found if index is valid, default QVariant otherwise
43 55 */
44 56 QVariant data(int dataIndex) const noexcept;
45 57
58 QString name() const noexcept;
59
46 60 /**
47 61 * Get the item's parent
48 62 * @return a pointer to the parent if it exists, nullptr if the item is a root
49 63 */
50 64 DataSourceItem *parentItem() const noexcept;
51 65
52 66 DataSourceItemType type() const noexcept;
53 67
54 68 private:
55 69 class DataSourceItemPrivate;
56 70 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
57 71 };
58 72
59 73 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
@@ -1,78 +1,100
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
79 void DataSourceController::loadProductItem(const DataSourceItem &productItem) noexcept
80 {
81 /// @todo ALX
82 }
83
62 84 void DataSourceController::initialize()
63 85 {
64 86 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
65 87 << QThread::currentThread();
66 88 impl->m_WorkingMutex.lock();
67 89 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
68 90 }
69 91
70 92 void DataSourceController::finalize()
71 93 {
72 94 impl->m_WorkingMutex.unlock();
73 95 }
74 96
75 97 void DataSourceController::waitForFinish()
76 98 {
77 99 QMutexLocker locker{&impl->m_WorkingMutex};
78 100 }
@@ -1,56 +1,86
1 1 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItemAction.h>
2 3
3 4 #include <QVector>
4 5
6 namespace {
7
8 /// Index of the 'name' value in the item
9 const auto NAME_INDEX = 0;
10
11 } // namespace
12
5 13 struct DataSourceItem::DataSourceItemPrivate {
6 14 explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data)
7 : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}
15 : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}, m_Actions{}
8 16 {
9 17 }
10 18
11 19 DataSourceItem *m_Parent;
12 20 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
13 21 DataSourceItemType m_Type;
14 22 QVector<QVariant> m_Data;
23 std::vector<std::unique_ptr<DataSourceItemAction> > m_Actions;
15 24 };
16 25
17 26 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
18 27 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
19 28 {
20 29 }
21 30
31 QVector<DataSourceItemAction *> DataSourceItem::actions() const noexcept
32 {
33 QVector<DataSourceItemAction *> result{};
34
35 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
36 std::back_inserter(result), [](const auto &action) { return action.get(); });
37
38 return result;
39 }
40
41 void DataSourceItem::addAction(std::unique_ptr<DataSourceItemAction> action) noexcept
42 {
43 action->setDataSourceItem(this);
44 impl->m_Actions.push_back(std::move(action));
45 }
46
22 47 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
23 48 {
24 49 child->impl->m_Parent = this;
25 50 impl->m_Children.push_back(std::move(child));
26 51 }
27 52
28 53 DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
29 54 {
30 55 if (childIndex < 0 || childIndex >= childCount()) {
31 56 return nullptr;
32 57 }
33 58 else {
34 59 return impl->m_Children.at(childIndex).get();
35 60 }
36 61 }
37 62
38 63 int DataSourceItem::childCount() const noexcept
39 64 {
40 65 return impl->m_Children.size();
41 66 }
42 67
43 68 QVariant DataSourceItem::data(int dataIndex) const noexcept
44 69 {
45 70 return impl->m_Data.value(dataIndex);
46 71 }
47 72
73 QString DataSourceItem::name() const noexcept
74 {
75 return data(NAME_INDEX).toString();
76 }
77
48 78 DataSourceItem *DataSourceItem::parentItem() const noexcept
49 79 {
50 80 return impl->m_Parent;
51 81 }
52 82
53 83 DataSourceItemType DataSourceItem::type() const noexcept
54 84 {
55 85 return impl->m_Type;
56 86 }
@@ -1,6 +1,13
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)
11
12 # Ignore false positive relative to an alias
13 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
@@ -1,32 +1,35
1 1 #ifndef SCIQLOP_DATASOURCETREEWIDGETITEM_H
2 2 #define SCIQLOP_DATASOURCETREEWIDGETITEM_H
3 3
4 4 #include <Common/spimpl.h>
5 5
6 6 #include <QLoggingCategory>
7 7 #include <QTreeWidgetItem>
8 8
9 9 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem)
10 10
11 11 class DataSourceItem;
12 12
13 13 /**
14 14 * @brief The DataSourceTreeWidgetItem is the graphical representation of a data source item. It is
15 15 * intended to be displayed in a QTreeWidget.
16 16 * @sa DataSourceItem
17 17 */
18 18 class DataSourceTreeWidgetItem : public QTreeWidgetItem {
19 19 public:
20 20 explicit DataSourceTreeWidgetItem(const DataSourceItem *data, int type = Type);
21 21 explicit DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
22 22 int type = Type);
23 23
24 24 virtual QVariant data(int column, int role) const override;
25 25 virtual void setData(int column, int role, const QVariant &value) override;
26 26
27 /// @return the actions associated to the item
28 QList<QAction *> actions() const noexcept;
29
27 30 private:
28 31 class DataSourceTreeWidgetItemPrivate;
29 32 spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl;
30 33 };
31 34
32 35 #endif // SCIQLOP_DATASOURCETREEWIDGETITEM_H
@@ -1,33 +1,38
1 1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
2 2 #define SCIQLOP_DATASOURCEWIDGET_H
3 3
4 #include <Common/spimpl.h>
5
6 4 #include <QWidget>
7 5
6 namespace Ui {
7 class DataSourceWidget;
8 } // Ui
9
8 10 class DataSourceItem;
9 11
10 12 /**
11 13 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
12 14 * attached to SciQlop.
13 15 */
14 16 class DataSourceWidget : public QWidget {
15 17 Q_OBJECT
16 18
17 19 public:
18 20 explicit DataSourceWidget(QWidget *parent = 0);
19 21
20 22 public slots:
21 23 /**
22 24 * Adds a data source. An item associated to the data source is created and then added to the
23 25 * representation tree
24 26 * @param dataSource the data source to add. The pointer has to be not null
25 27 */
26 28 void addDataSource(DataSourceItem *dataSource) noexcept;
27 29
28 30 private:
29 class DataSourceWidgetPrivate;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
31 Ui::DataSourceWidget *ui;
32
33 private slots:
34 /// Slot called when right clicking on an item in the tree (displays a menu)
35 void onTreeMenuRequested(const QPoint &pos) noexcept;
31 36 };
32 37
33 38 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -1,46 +1,48
1 1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 2 #define SCIQLOP_SQPAPPLICATION_H
3 3
4 4 #include "SqpApplication.h"
5 5
6 6 #include <QApplication>
7 7 #include <QLoggingCategory>
8 8
9 9 #include <Common/spimpl.h>
10 10
11 11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12 12
13 13 #if defined(sqpApp)
14 14 #undef sqpApp
15 15 #endif
16 16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17 17
18 18 class DataSourceController;
19 class VariableController;
19 20 class VisualizationController;
20 21
21 22 /**
22 23 * @brief The SqpApplication class aims to make the link between SciQlop
23 24 * and its plugins. This is the intermediate class that SciQlop has to use
24 25 * in the way to connect a data source. Please first use load method to initialize
25 26 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 27 * method will be able to access it.
27 28 * You can load a data source driver plugin then create a data source.
28 29 */
29 30
30 31 class SqpApplication : public QApplication {
31 32 Q_OBJECT
32 33 public:
33 34 explicit SqpApplication(int &argc, char **argv);
34 35 virtual ~SqpApplication();
35 36 void initialize();
36 37
37 38 /// Accessors for the differents sciqlop controllers
38 DataSourceController &dataSourceController() const noexcept;
39 VisualizationController &visualizationController() const noexcept;
39 DataSourceController &dataSourceController() noexcept;
40 VariableController &variableController() noexcept;
41 VisualizationController &visualizationController() noexcept;
40 42
41 43 private:
42 44 class SqpApplicationPrivate;
43 45 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
44 46 };
45 47
46 48 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QWidget>
5 7
8 #include <memory>
9
10 #include <Common/spimpl.h>
11
12 class Variable;
13
6 14 namespace Ui {
7 15 class VisualizationGraphWidget;
8 16 } // namespace Ui
9 17
10 class VisualizationGraphWidget : public QWidget {
18 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
11 19 Q_OBJECT
12 20
13 21 public:
14 22 explicit VisualizationGraphWidget(QWidget *parent = 0);
15 23 virtual ~VisualizationGraphWidget();
16 24
25 void addVariable(std::shared_ptr<Variable> variable);
26
27 // IVisualizationWidget interface
28 void accept(IVisualizationWidget *visitor) override;
29 void close() override;
30 QString name() const;
31
17 32 private:
18 33 Ui::VisualizationGraphWidget *ui;
34
35 class VisualizationGraphWidgetPrivate;
36 spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONTABWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QWidget>
5 7
8 class VisualizationZoneWidget;
9
6 10 namespace Ui {
7 11 class VisualizationTabWidget;
8 12 } // namespace Ui
9 13
10 class VisualizationTabWidget : public QWidget {
14 class VisualizationTabWidget : public QWidget, public IVisualizationWidget {
11 15 Q_OBJECT
12 16
13 17 public:
14 18 explicit VisualizationTabWidget(QWidget *parent = 0);
15 19 virtual ~VisualizationTabWidget();
16 20
21 /// Add a zone widget
22 void addZone(VisualizationZoneWidget *zoneWidget);
23
24 /// Create a zone using a Variable
25 VisualizationZoneWidget *createZone();
26
27 /// Remove a zone
28 void removeZone(VisualizationZoneWidget *zone);
29
30 // IVisualizationWidget interface
31 void accept(IVisualizationWidget *visitor) override;
32 void close() override;
33 QString name() const override;
34
17 35 private:
18 36 Ui::VisualizationTabWidget *ui;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
@@ -1,24 +1,42
1 1 #ifndef SCIQLOP_VISUALIZATIONWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QLoggingCategory>
5 7 #include <QWidget>
6 8
9 class VisualizationTabWidget;
10
7 11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
8 12
9 13 namespace Ui {
10 14 class VisualizationWidget;
11 15 } // namespace Ui
12 16
13 class VisualizationWidget : public QWidget {
17 class VisualizationWidget : public QWidget, public IVisualizationWidget {
14 18 Q_OBJECT
15 19
16 20 public:
17 21 explicit VisualizationWidget(QWidget *parent = 0);
18 22 virtual ~VisualizationWidget();
19 23
24 /// Add a zone widget
25 virtual void addTab(VisualizationTabWidget *tabWidget);
26
27 /// Create a tab using a Variable
28 VisualizationTabWidget *createTab();
29
30 /// Remove a tab
31 void removeTab(VisualizationTabWidget *tab);
32
33 // IVisualizationWidget interface
34 void accept(IVisualizationWidget *visitor) override;
35 void close() override;
36 QString name() const;
37
20 38 private:
21 39 Ui::VisualizationWidget *ui;
22 40 };
23 41
24 42 #endif // VISUALIZATIONWIDGET_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
6 class VisualizationGraphWidget;
7
4 8 #include <QWidget>
5 9
6 10 namespace Ui {
7 11 class VisualizationZoneWidget;
8 12 } // Ui
9 13
10 class VisualizationZoneWidget : public QWidget {
14 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
11 15 Q_OBJECT
12 16
13 17 public:
14 18 explicit VisualizationZoneWidget(QWidget *parent = 0);
15 19 virtual ~VisualizationZoneWidget();
16 20
21 /// Add a graph widget
22 void addGraph(VisualizationGraphWidget *graphWidget);
23
24 /// Create a graph using a Variable
25 VisualizationGraphWidget *createGraph();
26
27 /// Remove a graph
28 void removeGraph(VisualizationGraphWidget *graph);
29
30 // IVisualizationWidget interface
31 void accept(IVisualizationWidget *visitor) override;
32 void close() override;
33 QString name() const override;
34
17 35 private:
18 36 Ui::VisualizationZoneWidget *ui;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H
@@ -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,75 +1,101
1 1 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItemAction.h>
2 3 #include <DataSource/DataSourceTreeWidgetItem.h>
3 4
4 5 #include <SqpApplication.h>
5 6
7 #include <QAction>
8
6 9 Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem")
7 10
8 11 namespace {
9 12
10 13 QIcon itemIcon(const DataSourceItem *dataSource)
11 14 {
12 15 if (dataSource) {
13 16 auto dataSourceType = dataSource->type();
14 17 switch (dataSourceType) {
15 18 case DataSourceItemType::NODE:
16 19 return sqpApp->style()->standardIcon(QStyle::SP_DirIcon);
17 20 case DataSourceItemType::PRODUCT:
18 21 return sqpApp->style()->standardIcon(QStyle::SP_FileIcon);
19 22 default:
20 23 // No action
21 24 break;
22 25 }
23 26
24 27 qCWarning(LOG_DataSourceTreeWidgetItem())
25 28 << QObject::tr("Can't set data source icon : unknown data source type");
26 29 }
27 30 else {
28 31 qCWarning(LOG_DataSourceTreeWidgetItem())
29 32 << QObject::tr("Can't set data source icon : the data source is null");
30 33 }
31 34
32 35 // Default cases
33 36 return QIcon{};
34 37 }
35 38
36 39 } // namespace
37 40
38 41 struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate {
39 42 explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {}
40 43
41 44 /// Model used to retrieve data source information
42 45 const DataSourceItem *m_Data;
46 /// Actions associated to the item. The parent of the item (QTreeWidget) takes the ownership of
47 /// the actions
48 QList<QAction *> m_Actions;
43 49 };
44 50
45 51 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type)
46 52 : DataSourceTreeWidgetItem{nullptr, data, type}
47 53 {
48 54 }
49 55
50 56 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
51 57 int type)
52 58 : QTreeWidgetItem{parent, type},
53 59 impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)}
54 60 {
55 61 // Sets the icon depending on the data source
56 62 setIcon(0, itemIcon(impl->m_Data));
63
64 // Generates tree actions based on the item actions
65 auto createTreeAction = [this, &parent](const auto &itemAction) {
66 auto treeAction = new QAction{itemAction->name(), parent};
67
68 // Executes item action when tree action is triggered
69 QObject::connect(treeAction, &QAction::triggered, itemAction,
70 &DataSourceItemAction::execute);
71
72 return treeAction;
73 };
74
75 auto itemActions = impl->m_Data->actions();
76 std::transform(std::cbegin(itemActions), std::cend(itemActions),
77 std::back_inserter(impl->m_Actions), createTreeAction);
57 78 }
58 79
59 80 QVariant DataSourceTreeWidgetItem::data(int column, int role) const
60 81 {
61 82 if (role == Qt::DisplayRole) {
62 83 return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{};
63 84 }
64 85 else {
65 86 return QTreeWidgetItem::data(column, role);
66 87 }
67 88 }
68 89
69 90 void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value)
70 91 {
71 92 // Data can't be changed by edition
72 93 if (role != Qt::EditRole) {
73 94 QTreeWidgetItem::setData(column, role, value);
74 95 }
75 96 }
97
98 QList<QAction *> DataSourceTreeWidgetItem::actions() const noexcept
99 {
100 return impl->m_Actions;
101 }
@@ -1,63 +1,72
1 1 #include <DataSource/DataSourceWidget.h>
2 2
3 3 #include <ui_DataSourceWidget.h>
4 4
5 5 #include <DataSource/DataSourceItem.h>
6 6 #include <DataSource/DataSourceTreeWidgetItem.h>
7 7
8 #include <QMenu>
9
8 10 namespace {
9 11
10 12 /// Number of columns displayed in the tree
11 13 const auto TREE_NB_COLUMNS = 1;
12 14
13 15 /// Header labels for the tree
14 16 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
15 17
16 18 /**
17 19 * Creates the item associated to a data source
18 20 * @param dataSource the data source for which to create the item
19 21 * @return the new item
20 22 */
21 23 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
22 24 {
23 25 // Creates item for the data source
24 26 auto item = new DataSourceTreeWidgetItem{dataSource};
25 27
26 28 // Generates items for the children of the data source
27 29 for (auto i = 0; i < dataSource->childCount(); ++i) {
28 30 item->addChild(createTreeWidgetItem(dataSource->child(i)));
29 31 }
30 32
31 33 return item;
32 34 }
33 35
34 36 } // namespace
35 37
36 class DataSourceWidget::DataSourceWidgetPrivate {
37 public:
38 explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
39 : m_Ui{std::make_unique<Ui::DataSourceWidget>()}
40 {
41 m_Ui->setupUi(&widget);
42
43 // Set tree properties
44 m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
45 m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
46 }
38 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
39 {
40 ui->setupUi(this);
47 41
48 std::unique_ptr<Ui::DataSourceWidget> m_Ui;
49 };
42 // Set tree properties
43 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
44 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
45 ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
50 46
51 DataSourceWidget::DataSourceWidget(QWidget *parent)
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
53 {
47 // Connection to show a menu when right clicking on the tree
48 connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this,
49 &DataSourceWidget::onTreeMenuRequested);
54 50 }
55 51
56 52 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
57 53 {
58 54 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 55 // takes the ownership of the item
60 56 if (dataSource) {
61 impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
57 ui->treeWidget->addTopLevelItem(createTreeWidgetItem(dataSource));
58 }
59 }
60
61 void DataSourceWidget::onTreeMenuRequested(const QPoint &pos) noexcept
62 {
63 // Retrieves the selected item in the tree, and build the menu from its actions
64 if (auto selectedItem = dynamic_cast<DataSourceTreeWidgetItem *>(ui->treeWidget->itemAt(pos))) {
65 QMenu treeMenu{};
66 treeMenu.addActions(selectedItem->actions());
67
68 if (!treeMenu.isEmpty()) {
69 treeMenu.exec(mapToGlobal(pos));
70 }
62 71 }
63 72 }
@@ -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,72 +1,91
1 1 #include "SqpApplication.h"
2 2
3 3 #include <DataSource/DataSourceController.h>
4 4 #include <QThread>
5 #include <Variable/VariableController.h>
5 6 #include <Visualization/VisualizationController.h>
6 7
7 8 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8 9
9 10 class SqpApplication::SqpApplicationPrivate {
10 11 public:
11 12 SqpApplicationPrivate()
12 13 : m_DataSourceController{std::make_unique<DataSourceController>()},
14 m_VariableController{std::make_unique<VariableController>()},
13 15 m_VisualizationController{std::make_unique<VisualizationController>()}
14 16 {
15 17 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
18 m_VariableController->moveToThread(&m_VariableControllerThread);
16 19 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
17 20 }
18 21
19 22 virtual ~SqpApplicationPrivate()
20 23 {
21 24 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
22 25 m_DataSourceControllerThread.quit();
23 26 m_DataSourceControllerThread.wait();
24 27
28 m_VariableControllerThread.quit();
29 m_VariableControllerThread.wait();
30
25 31 m_VisualizationControllerThread.quit();
26 32 m_VisualizationControllerThread.wait();
27 33 }
28 34
29 35 std::unique_ptr<DataSourceController> m_DataSourceController;
36 std::unique_ptr<VariableController> m_VariableController;
30 37 std::unique_ptr<VisualizationController> m_VisualizationController;
31 38 QThread m_DataSourceControllerThread;
39 QThread m_VariableControllerThread;
32 40 QThread m_VisualizationControllerThread;
33 41 };
34 42
35 43
36 44 SqpApplication::SqpApplication(int &argc, char **argv)
37 45 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
38 46 {
39 47 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
40 48
41 49 connect(&impl->m_DataSourceControllerThread, &QThread::started,
42 50 impl->m_DataSourceController.get(), &DataSourceController::initialize);
43 51 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
44 52 impl->m_DataSourceController.get(), &DataSourceController::finalize);
45 53
54 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
55 &VariableController::initialize);
56 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
57 &VariableController::finalize);
58
46 59 connect(&impl->m_VisualizationControllerThread, &QThread::started,
47 60 impl->m_VisualizationController.get(), &VisualizationController::initialize);
48 61 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
49 62 impl->m_VisualizationController.get(), &VisualizationController::finalize);
50 63
51 64
52 65 impl->m_DataSourceControllerThread.start();
66 impl->m_VariableControllerThread.start();
53 67 impl->m_VisualizationControllerThread.start();
54 68 }
55 69
56 70 SqpApplication::~SqpApplication()
57 71 {
58 72 }
59 73
60 74 void SqpApplication::initialize()
61 75 {
62 76 }
63 77
64 DataSourceController &SqpApplication::dataSourceController() const noexcept
78 DataSourceController &SqpApplication::dataSourceController() noexcept
65 79 {
66 80 return *impl->m_DataSourceController;
67 81 }
68 82
69 VisualizationController &SqpApplication::visualizationController() const noexcept
83 VariableController &SqpApplication::variableController() noexcept
84 {
85 return *impl->m_VariableController;
86 }
87
88 VisualizationController &SqpApplication::visualizationController() noexcept
70 89 {
71 90 return *impl->m_VisualizationController;
72 91 }
@@ -1,13 +1,47
1 1 #include "Visualization/VisualizationGraphWidget.h"
2 2 #include "ui_VisualizationGraphWidget.h"
3 3
4 #include <Variable/Variable.h>
5
6 #include <unordered_map>
7
8 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
9
10 // 1 variable -> n qcpplot
11 std::unordered_map<std::shared_ptr<Variable>, std::unique_ptr<QCPAbstractPlottable> >
12 m_VariableToPlotMap;
13 };
14
4 15 VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent)
5 : QWidget(parent), ui(new Ui::VisualizationGraphWidget)
16 : QWidget{parent},
17 ui{new Ui::VisualizationGraphWidget},
18 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
6 19 {
7 20 ui->setupUi(this);
8 21 }
9 22
10 23 VisualizationGraphWidget::~VisualizationGraphWidget()
11 24 {
12 25 delete ui;
13 26 }
27
28 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
29 {
30 // todo: first check is variable contains data then check how many plot have to be created
31 }
32
33 void VisualizationGraphWidget::accept(IVisualizationWidget *visitor)
34 {
35 // TODO: manage the visitor
36 }
37
38 void VisualizationGraphWidget::close()
39 {
40 // The main view cannot be directly closed.
41 return;
42 }
43
44 QString VisualizationGraphWidget::name() const
45 {
46 return QStringLiteral("MainView");
47 }
@@ -1,13 +1,49
1 1 #include "Visualization/VisualizationTabWidget.h"
2 2 #include "ui_VisualizationTabWidget.h"
3 3
4 #include "Visualization/VisualizationZoneWidget.h"
5
6
4 7 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
5 8 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
6 9 {
7 10 ui->setupUi(this);
8 11 }
9 12
10 13 VisualizationTabWidget::~VisualizationTabWidget()
11 14 {
12 15 delete ui;
13 16 }
17
18 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
19 {
20 this->layout()->addWidget(zoneWidget);
21 }
22
23 VisualizationZoneWidget *VisualizationTabWidget::createZone()
24 {
25 auto zoneWidget = new VisualizationZoneWidget{this};
26 this->addZone(zoneWidget);
27
28 return zoneWidget;
29 }
30
31 void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone)
32 {
33 }
34
35 void VisualizationTabWidget::accept(IVisualizationWidget *visitor)
36 {
37 // TODO: manage the visitor
38 }
39
40 void VisualizationTabWidget::close()
41 {
42 // The main view cannot be directly closed.
43 return;
44 }
45
46 QString VisualizationTabWidget::name() const
47 {
48 return QStringLiteral("MainView");
49 }
@@ -1,43 +1,80
1 1 #include "Visualization/VisualizationWidget.h"
2 2 #include "Visualization/VisualizationTabWidget.h"
3 #include "Visualization/qcustomplot.h"
4
3 5 #include "ui_VisualizationWidget.h"
4 6
5 #include <QDebug>
6 7 #include <QToolButton>
7 8
8 #include "iostream"
9
10 9 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
11 10
12 11 VisualizationWidget::VisualizationWidget(QWidget *parent)
13 12 : QWidget{parent}, ui{new Ui::VisualizationWidget}
14 13 {
15 14 ui->setupUi(this);
16 15
17 16 auto addTabViewButton = new QToolButton{ui->tabWidget};
18 17 addTabViewButton->setText(tr("Add View"));
19 18 addTabViewButton->setCursor(Qt::ArrowCursor);
20 19 addTabViewButton->setAutoRaise(true);
21 20 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
21 auto width = ui->tabWidget->cornerWidget()->width();
22 auto height = ui->tabWidget->cornerWidget()->height();
23 addTabViewButton->setMinimumHeight(height);
24 addTabViewButton->setMinimumWidth(width);
25 ui->tabWidget->setMinimumHeight(height);
26 ui->tabWidget->setMinimumWidth(width);
22 27
23 28 auto addTabView = [&]() {
24 29 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
25 30 QString("View %1").arg(ui->tabWidget->count() + 1));
26 31 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
27 32 };
28 33
29 34 auto removeTabView = [&](int index) {
30 35 ui->tabWidget->removeTab(index);
31 36 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
32 37 };
33 38
34 39 ui->tabWidget->setTabsClosable(true);
35 40
36 41 connect(addTabViewButton, &QToolButton::clicked, addTabView);
37 42 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
38 43 }
39 44
40 45 VisualizationWidget::~VisualizationWidget()
41 46 {
42 47 delete ui;
43 48 }
49
50 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
51 {
52 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
53 // lambda function (in the constructor)
54 }
55
56 VisualizationTabWidget *VisualizationWidget::createTab()
57 {
58 }
59
60 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
61 {
62 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
63 // lambda function (in the constructor)
64 }
65
66 void VisualizationWidget::accept(IVisualizationWidget *visitor)
67 {
68 // TODO: manage the visitor
69 }
70
71 void VisualizationWidget::close()
72 {
73 // The main view cannot be directly closed.
74 return;
75 }
76
77 QString VisualizationWidget::name() const
78 {
79 return QStringLiteral("MainView");
80 }
@@ -1,13 +1,48
1 1 #include "Visualization/VisualizationZoneWidget.h"
2 2 #include "ui_VisualizationZoneWidget.h"
3 3
4 #include "Visualization/VisualizationGraphWidget.h"
5
4 6 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
5 7 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
6 8 {
7 9 ui->setupUi(this);
8 10 }
9 11
10 12 VisualizationZoneWidget::~VisualizationZoneWidget()
11 13 {
12 14 delete ui;
13 15 }
16
17 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
18 {
19 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
20 }
21
22 VisualizationGraphWidget *VisualizationZoneWidget::createGraph()
23 {
24 auto graphWidget = new VisualizationGraphWidget{this};
25 this->addGraph(graphWidget);
26
27 return graphWidget;
28 }
29
30 void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph)
31 {
32 }
33
34 void VisualizationZoneWidget::accept(IVisualizationWidget *visitor)
35 {
36 // TODO: manage the visitor
37 }
38
39 void VisualizationZoneWidget::close()
40 {
41 // The main view cannot be directly closed.
42 return;
43 }
44
45 QString VisualizationZoneWidget::name() const
46 {
47 return QStringLiteral("MainView");
48 }
1 NO CONTENT: file renamed from gui/ui/sidepane/SqpSidePane.ui to gui/ui/SidePane/SqpSidePane.ui
@@ -1,21 +1,32
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationGraphWidget</class>
6 <widget name="VisualizationGraphWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationGraphWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QCustomPlot" name="widget" native="true"/>
19 </item>
20 </layout>
18 21 </widget>
19 <pixmapfunction/>
22 <customwidgets>
23 <customwidget>
24 <class>QCustomPlot</class>
25 <extends>QWidget</extends>
26 <header>Visualization/qcustomplot.h</header>
27 <container>1</container>
28 </customwidget>
29 </customwidgets>
30 <resources/>
20 31 <connections/>
21 32 </ui>
@@ -1,21 +1,20
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationTabWidget</class>
6 <widget name="VisualizationTabWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationTabWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout"/>
18 17 </widget>
19 <pixmapfunction/>
18 <resources/>
20 19 <connections/>
21 20 </ui>
1 NO CONTENT: file renamed from gui/ui/visualization/VisualizationWidget.ui to gui/ui/Visualization/VisualizationWidget.ui
@@ -1,21 +1,32
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationZoneWidget</class>
6 <widget name="VisualizationZoneWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationZoneWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <item>
18 <widget class="QFrame" name="visualizationZoneFrame">
19 <property name="frameShape">
20 <enum>QFrame::StyledPanel</enum>
21 </property>
22 <property name="frameShadow">
23 <enum>QFrame::Raised</enum>
24 </property>
25 <layout class="QVBoxLayout" name="verticalLayout"/>
26 </widget>
27 </item>
28 </layout>
18 29 </widget>
19 <pixmapfunction/>
30 <resources/>
20 31 <connections/>
21 32 </ui>
@@ -1,147 +1,153
1 1 ## mockplugin - CMakeLists.txt
2 2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
4 4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7 7
8 8 # Include mockplugin directory
9 9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11 11
12 12 #
13 13 # Find Qt modules
14 14 #
15 15 SCIQLOP_FIND_QT(Core Widgets)
16 16
17 17 #
18 18 # Find dependent libraries
19 19 # ========================
20 20
21 21 # sciqlop plugin
22 22 find_package(sciqlop-plugin)
23 23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24 24
25 25 # sciqlop core
26 26 find_package(sciqlop-core)
27 27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29 29
30 30 # sciqlop gui
31 31 find_package(sciqlop-gui)
32 32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34 34
35 35 # Resources files
36 36 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json)
37 37
38 38 #
39 39 # Compile the library
40 40 #
41 41 FILE (GLOB_RECURSE MODULE_SOURCES
42 42 ${INCLUDES_DIR}/*.h
43 43 ${SOURCES_DIR}/*.c
44 44 ${SOURCES_DIR}/*.cpp
45 45 ${SOURCES_DIR}/*.h
46 46 ${PROJECT_RESOURCES})
47 47
48 48 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
49 49 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
50 50 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
51 51
52 52 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
53 53 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
54 54
55 55 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
56 56
57 57 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
58 58 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
59 59 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
60 60 IF(BUILD_SHARED_LIBS)
61 61 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
62 62 ELSE()
63 63 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
64 64 ENDIF()
65 65
66 66 # Set the variable to parent scope so that the other projects can copy the
67 67 # dependent shared libraries
68 68 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
69 69
70 70 # Copy extern shared libraries to the lib folder
71 71 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
72 72
73 73 # Add the files to the list of files to be analyzed
74 74 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
75 75 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
76 76 # Vera++ exclusion files
77 77 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
78 78 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
79 79
80 # Temporary target to copy to plugins dir
81 find_package(sciqlop-mockplugin)
82 ADD_CUSTOM_TARGET(plugins
83 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-MOCKPLUGIN_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}"
84 )
85
80 86 #
81 87 # Compile the tests
82 88 #
83 89 IF(BUILD_TESTS)
84 90 INCLUDE_DIRECTORIES(${SOURCES_DIR})
85 91 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
86 92 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
87 93 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
88 94
89 95 FOREACH( testFile ${TESTS_SOURCES} )
90 96 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
91 97 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
92 98
93 99 # Add to the list of sources files all the sources in the same
94 100 # directory that aren't another test
95 101 FILE (GLOB currentTestSources
96 102 ${testDirectory}/*.c
97 103 ${testDirectory}/*.cpp
98 104 ${testDirectory}/*.h)
99 105 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
100 106 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
101 107
102 108 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
103 109 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
104 110 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
105 111 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
106 112 qt5_use_modules(${testName} Test)
107 113
108 114 ADD_TEST( NAME ${testName} COMMAND ${testName} )
109 115
110 116 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
111 117 ENDFOREACH( testFile )
112 118
113 119 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
114 120 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
115 121 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
116 122 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
117 123 ENDIF(BUILD_TESTS)
118 124
119 125 #
120 126 # Set the files that must be formatted by clang-format.
121 127 #
122 128 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
123 129 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
124 130
125 131 #
126 132 # Set the directories that doxygen must browse to generate the
127 133 # documentation.
128 134 #
129 135 # Source directories:
130 136 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
131 137 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
132 138 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
133 139 # Source directories to exclude from the documentation generation
134 140 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
135 141 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
136 142
137 143 #
138 144 # Set the directories with the sources to analyze and propagate the
139 145 # modification to the parent scope
140 146 #
141 147 # Source directories to analyze:
142 148 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
143 149 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
144 150 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
145 151 # Source directories to exclude from the analysis
146 152 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
147 153 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,21 +1,22
1 1 # - Try to find sciqlop-mockplugin
2 2 # Once done this will define
3 3 # SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin
4 4 # SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories
5 5 # SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin
6 6
7 7 if(SCIQLOP-MOCKPLUGIN_FOUND)
8 8 return()
9 9 endif(SCIQLOP-MOCKPLUGIN_FOUND)
10 10
11 11 set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include)
12 12
13 13 set (OS_LIB_EXTENSION "so")
14 14
15 15 if(WIN32)
16 16 set (OS_LIB_EXTENSION "dll")
17 17 endif(WIN32)
18 18 # TODO: Add Mac Support
19 set(SCIQLOP-MOCKPLUGIN_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION})
19 set(SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME "libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION}")
20 set(SCIQLOP-MOCKPLUGIN_LIBRARIES "${LIBRARY_OUTPUT_PATH}/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}")
20 21
21 22 set(SCIQLOP-MOCKPLUGIN_FOUND TRUE)
@@ -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,79
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>
6 #include <DataSource/DataSourceItemAction.h>
5 7
6 8 #include <SqpApplication.h>
7 9
8 10 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9 11
10 12 namespace {
11 13
12 14 /// Name of the data source
13 15 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
14 16
15 } // namespace
17 /// Creates the data provider relative to the plugin
18 std::unique_ptr<IDataProvider> createDataProvider() noexcept
19 {
20 return std::make_unique<CosinusProvider>();
21 }
16 22
17 void MockPlugin::initialize()
23 std::unique_ptr<DataSourceItem> createProductItem(const QString &productName)
18 24 {
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);
25 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
26 QVector<QVariant>{productName});
23 27
24 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
25 }
26 else {
27 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
28 }
28 // Add action to load product from DataSourceController
29 result->addAction(std::make_unique<DataSourceItemAction>(
30 QObject::tr("Load %1 product").arg(productName), [productName](DataSourceItem &item) {
31 if (auto app = sqpApp) {
32 app->dataSourceController().loadProductItem(item);
33 }
34 }));
35
36 return result;
29 37 }
30 38
31 std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcept
39 /// Creates the data source item relative to the plugin
40 std::unique_ptr<DataSourceItem> createDataSourceItem() noexcept
32 41 {
33 42 // Magnetic field products
34 auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
35 QVector<QVariant>{QStringLiteral("FGM")});
36 auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
37 QVector<QVariant>{QStringLiteral("SC")});
38
39 43 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
40 44 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
41 magneticFieldFolder->appendChild(std::move(fgmProduct));
42 magneticFieldFolder->appendChild(std::move(scProduct));
45 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM")));
46 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC")));
43 47
44 48 // Electric field products
45 49 auto electricFieldFolder = std::make_unique<DataSourceItem>(
46 50 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
47 51
48 52 // Root
49 53 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
50 54 QVector<QVariant>{DATA_SOURCE_NAME});
51 55 root->appendChild(std::move(magneticFieldFolder));
52 56 root->appendChild(std::move(electricFieldFolder));
53 57
54 return std::move(root);
58 return root;
59 }
60
61 } // namespace
62
63 void MockPlugin::initialize()
64 {
65 if (auto app = sqpApp) {
66 // Registers to the data source controller
67 auto &dataSourceController = app->dataSourceController();
68 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
69
70 // Sets data source tree
71 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
72
73 // Sets data provider
74 dataSourceController.setDataProvider(dataSourceUid, createDataProvider());
75 }
76 else {
77 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
78 }
55 79 }
General Comments 0
You need to be logged in to leave comments. Login now