##// 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
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,12
1 #include "TimeWidget/TimeWidget.h"
2 #include "ui_TimeWidget.h"
3
4 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
5 {
6 ui->setupUi(this);
7 }
8
9 TimeWidget::~TimeWidget()
10 {
11 delete ui;
12 }
@@ -0,0 +1,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 -- This file is a part of the SciQLop Software
2 -- This file is a part of the SciQLop Software
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "MainWindow.h"
22 #include "MainWindow.h"
23 #include "ui_MainWindow.h"
23 #include "ui_MainWindow.h"
24
24
25 #include <DataSource/DataSourceController.h>
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <SidePane/SqpSidePane.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
28 #include <SqpApplication.h>
29 #include <TimeWidget/TimeWidget.h>
29
30
30 #include <QAction>
31 #include <QAction>
31 #include <QDate>
32 #include <QDate>
32 #include <QDateTime>
33 #include <QDateTime>
33 #include <QDir>
34 #include <QDir>
34 #include <QFileDialog>
35 #include <QFileDialog>
35 #include <QToolBar>
36 #include <QToolBar>
37 #include <QToolButton>
36 #include <memory.h>
38 #include <memory.h>
37
39
38 //#include <omp.h>
40 //#include <omp.h>
39 //#include <network/filedownloader.h>
41 //#include <network/filedownloader.h>
40 //#include <qlopdatabase.h>
42 //#include <qlopdatabase.h>
41 //#include <qlopsettings.h>
43 //#include <qlopsettings.h>
42 //#include <qlopgui.h>
44 //#include <qlopgui.h>
43 //#include <spacedata.h>
45 //#include <spacedata.h>
44 //#include "qlopcore.h"
46 //#include "qlopcore.h"
45 //#include "qlopcodecmanager.h"
47 //#include "qlopcodecmanager.h"
46 //#include "cdfcodec.h"
48 //#include "cdfcodec.h"
47 //#include "amdatxtcodec.h"
49 //#include "amdatxtcodec.h"
48 //#include <qlopplotmanager.h>
50 //#include <qlopplotmanager.h>
49
51
50 #include "iostream"
52 #include "iostream"
51
53
52 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53
55
54 namespace {
56 namespace {
55 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 const auto VIEWPLITTERINDEX = 2;
59 const auto VIEWPLITTERINDEX = 2;
58 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 }
62 }
61
63
62 class MainWindow::MainWindowPrivate {
64 class MainWindow::MainWindowPrivate {
63 public:
65 public:
64 QSize m_LastOpenLeftInspectorSize;
66 QSize m_LastOpenLeftInspectorSize;
65 QSize m_LastOpenRightInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
66 };
68 };
67
69
68 MainWindow::MainWindow(QWidget *parent)
70 MainWindow::MainWindow(QWidget *parent)
69 : QMainWindow{parent},
71 : QMainWindow{parent},
70 m_Ui{new Ui::MainWindow},
72 m_Ui{new Ui::MainWindow},
71 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
72 {
74 {
73 m_Ui->setupUi(this);
75 m_Ui->setupUi(this);
74
76
75 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
77
79
78 // NOTE: These lambda could be factorized. Be careful of theirs parameters
79 // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button
80 auto openLeftInspector = [this](bool checked) {
81
80
82 // Update of the last opened geometry
81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
83 if (checked) {
82 auto openLeftInspectorAction = new QAction{QIcon{
84 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
83 ":/icones/previous.png",
85 }
84 },
85 tr("Show/hide the left inspector"), this};
86
86
87 auto startSize = impl->m_LastOpenLeftInspectorSize;
88 auto endSize = startSize;
89 endSize.setWidth(0);
90
87
91 auto currentSizes = m_Ui->splitter->sizes();
88 auto spacerLeftTop = new QWidget{};
92 if (checked) {
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93 // adjust sizes individually here, e.g.
94 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
95 -= impl->m_LastOpenLeftInspectorSize.width();
96 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width();
97 m_Ui->splitter->setSizes(currentSizes);
98 }
99 else {
100 // adjust sizes individually here, e.g.
101 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
102 += impl->m_LastOpenLeftInspectorSize.width();
103 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width();
104 m_Ui->splitter->setSizes(currentSizes);
105 }
106
90
107 };
91 auto spacerLeftBottom = new QWidget{};
92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
94 leftSidePane->addWidget(spacerLeftTop);
95 leftSidePane->addAction(openLeftInspectorAction);
96 leftSidePane->addWidget(spacerLeftBottom);
97
98
99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
100 auto openRightInspectorAction = new QAction{QIcon{
101 ":/icones/next.png",
102 },
103 tr("Show/hide the right inspector"), this};
104
105 auto spacerRightTop = new QWidget{};
106 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
107
108 auto spacerRightBottom = new QWidget{};
109 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110
111 rightSidePane->addWidget(spacerRightTop);
112 rightSidePane->addAction(openRightInspectorAction);
113 rightSidePane->addWidget(spacerRightBottom);
114
115 openLeftInspectorAction->setCheckable(true);
116 openRightInspectorAction->setCheckable(true);
117
118 auto openInspector = [this](bool checked, bool right, auto action) {
119
120 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
108
121
109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
122 auto &lastInspectorSize
110 auto openRightInspector = [this](bool checked) {
123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
124
125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
126 : m_Ui->leftMainInspectorWidget->size();
111
127
112 // Update of the last opened geometry
128 // Update of the last opened geometry
113 if (checked) {
129 if (checked) {
114 impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size();
130 lastInspectorSize = nextInspectorSize;
115 }
131 }
116
132
117 auto startSize = impl->m_LastOpenRightInspectorSize;
133 auto startSize = lastInspectorSize;
118 auto endSize = startSize;
134 auto endSize = startSize;
119 endSize.setWidth(0);
135 endSize.setWidth(0);
120
136
137 auto splitterInspectorIndex
138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
139
121 auto currentSizes = m_Ui->splitter->sizes();
140 auto currentSizes = m_Ui->splitter->sizes();
122 if (checked) {
141 if (checked) {
123 // adjust sizes individually here, e.g.
142 // adjust sizes individually here, e.g.
124 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
125 -= impl->m_LastOpenRightInspectorSize.width();
144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
126 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
127 m_Ui->splitter->setSizes(currentSizes);
145 m_Ui->splitter->setSizes(currentSizes);
128 }
146 }
129 else {
147 else {
130 // adjust sizes individually here, e.g.
148 // adjust sizes individually here, e.g.
131 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
132 += impl->m_LastOpenRightInspectorSize.width();
150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
133 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
134 m_Ui->splitter->setSizes(currentSizes);
151 m_Ui->splitter->setSizes(currentSizes);
135 }
152 }
136
153
137 };
154 };
138
155
139
156
140 QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
157 connect(openLeftInspectorAction, &QAction::triggered,
141 auto openLeftInspectorAction = leftSidePane->addAction(
158 [openInspector, openLeftInspectorAction](bool checked) {
142 QIcon{
159 openInspector(checked, false, openLeftInspectorAction);
143 ":/icones/openInspector.png",
160 });
144 },
161 connect(openRightInspectorAction, &QAction::triggered,
145 tr("Show/hide the left inspector"), openLeftInspector);
162 [openInspector, openRightInspectorAction](bool checked) {
146
163 openInspector(checked, true, openRightInspectorAction);
147 openLeftInspectorAction->setCheckable(true);
164 });
148
149 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
150 auto openRightInspectorAction = rightSidePane->addAction(
151 QIcon{
152 ":/icones/openInspector.png",
153 },
154 tr("Show/hide the right inspector"), openRightInspector);
155
156 openRightInspectorAction->setCheckable(true);
157
165
158 this->menuBar()->addAction(tr("File"));
166 this->menuBar()->addAction(tr("File"));
159 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160 mainToolBar->addAction(QStringLiteral("A1"));
168
169 mainToolBar->addWidget(new TimeWidget{});
161
170
162 // Widgets / controllers connections
171 // Widgets / controllers connections
163 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
164 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
165
174
166 /* QLopGUI::registerMenuBar(menuBar());
175 /* QLopGUI::registerMenuBar(menuBar());
167 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
168 this->m_progressWidget = new QWidget();
177 this->m_progressWidget = new QWidget();
169 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
170 this->m_progressWidget->setLayout(this->m_progressLayout);
179 this->m_progressWidget->setLayout(this->m_progressLayout);
171 this->m_progressWidget->setWindowModality(Qt::WindowModal);
180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
172 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
173 for(int i=0;i<OMP_THREADS;i++)
182 for(int i=0;i<OMP_THREADS;i++)
174 {
183 {
175 this->m_progress.append(new QProgressBar(this->m_progressWidget));
184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
176 this->m_progress.last()->setMinimum(0);
185 this->m_progress.last()->setMinimum(0);
177 this->m_progress.last()->setMaximum(100);
186 this->m_progress.last()->setMaximum(100);
178 this->m_progressLayout->addWidget(this->m_progress.last());
187 this->m_progressLayout->addWidget(this->m_progress.last());
179 this->m_progressWidget->hide();
188 this->m_progressWidget->hide();
180 this->m_progressThreadIds[i] = -1;
189 this->m_progressThreadIds[i] = -1;
181 }
190 }
182 this->m_progressWidget->setWindowTitle("Loading File");
191 this->m_progressWidget->setWindowTitle("Loading File");
183 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
184 << QLopCore::self()
193 << QLopCore::self()
185 << QLopPlotManager::self()
194 << QLopPlotManager::self()
186 << QLopCodecManager::self()
195 << QLopCodecManager::self()
187 << FileDownloader::self()
196 << FileDownloader::self()
188 << QLopDataBase::self()
197 << QLopDataBase::self()
189 << SpaceData::self();
198 << SpaceData::self();
190
199
191 CDFCodec::registerToManager();
200 CDFCodec::registerToManager();
192 AMDATXTCodec::registerToManager();
201 AMDATXTCodec::registerToManager();
193
202
194
203
195 for(int i=0;i<ServicesToLoad.count();i++)
204 for(int i=0;i<ServicesToLoad.count();i++)
196 {
205 {
197 qDebug()<<ServicesToLoad.at(i)->serviceName();
206 qDebug()<<ServicesToLoad.at(i)->serviceName();
198 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
199 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
200 if(wdgt)
209 if(wdgt)
201 {
210 {
202 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
203 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
204 }
213 }
205 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
206 }*/
215 }*/
207 }
216 }
208
217
209 MainWindow::~MainWindow()
218 MainWindow::~MainWindow()
210 {
219 {
211 }
220 }
212
221
213
222
214 void MainWindow::changeEvent(QEvent *e)
223 void MainWindow::changeEvent(QEvent *e)
215 {
224 {
216 QMainWindow::changeEvent(e);
225 QMainWindow::changeEvent(e);
217 switch (e->type()) {
226 switch (e->type()) {
218 case QEvent::LanguageChange:
227 case QEvent::LanguageChange:
219 m_Ui->retranslateUi(this);
228 m_Ui->retranslateUi(this);
220 break;
229 break;
221 default:
230 default:
222 break;
231 break;
223 }
232 }
224 }
233 }
@@ -1,158 +1,164
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>MainWindow</class>
3 <class>MainWindow</class>
4 <widget class="QMainWindow" name="MainWindow">
4 <widget class="QMainWindow" name="MainWindow">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>800</width>
9 <width>800</width>
10 <height>600</height>
10 <height>600</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>QLop</string>
14 <string>QLop</string>
15 </property>
15 </property>
16 <property name="dockNestingEnabled">
16 <property name="dockNestingEnabled">
17 <bool>true</bool>
17 <bool>true</bool>
18 </property>
18 </property>
19 <widget class="QWidget" name="centralWidget">
19 <widget class="QWidget" name="centralWidget">
20 <property name="enabled">
20 <property name="enabled">
21 <bool>true</bool>
21 <bool>true</bool>
22 </property>
22 </property>
23 <property name="sizePolicy">
23 <property name="sizePolicy">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 <horstretch>0</horstretch>
25 <horstretch>0</horstretch>
26 <verstretch>0</verstretch>
26 <verstretch>0</verstretch>
27 </sizepolicy>
27 </sizepolicy>
28 </property>
28 </property>
29 <property name="maximumSize">
29 <property name="maximumSize">
30 <size>
30 <size>
31 <width>16777215</width>
31 <width>16777215</width>
32 <height>16777215</height>
32 <height>16777215</height>
33 </size>
33 </size>
34 </property>
34 </property>
35 <layout class="QHBoxLayout" name="horizontalLayout">
35 <layout class="QHBoxLayout" name="horizontalLayout">
36 <property name="spacing">
36 <property name="spacing">
37 <number>0</number>
37 <number>0</number>
38 </property>
38 </property>
39 <property name="leftMargin">
39 <property name="leftMargin">
40 <number>0</number>
40 <number>0</number>
41 </property>
41 </property>
42 <property name="topMargin">
42 <property name="topMargin">
43 <number>0</number>
43 <number>0</number>
44 </property>
44 </property>
45 <property name="rightMargin">
45 <property name="rightMargin">
46 <number>0</number>
46 <number>0</number>
47 </property>
47 </property>
48 <property name="bottomMargin">
48 <property name="bottomMargin">
49 <number>0</number>
49 <number>0</number>
50 </property>
50 </property>
51 <item>
51 <item>
52 <widget class="QSplitter" name="splitter">
52 <widget class="QSplitter" name="splitter">
53 <property name="orientation">
53 <property name="orientation">
54 <enum>Qt::Horizontal</enum>
54 <enum>Qt::Horizontal</enum>
55 </property>
55 </property>
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 <layout class="QVBoxLayout" name="verticalLayout">
57 <layout class="QVBoxLayout" name="verticalLayout">
58 <property name="spacing">
58 <property name="spacing">
59 <number>0</number>
59 <number>0</number>
60 </property>
60 </property>
61 <property name="leftMargin">
61 <property name="leftMargin">
62 <number>0</number>
62 <number>0</number>
63 </property>
63 </property>
64 <property name="topMargin">
64 <property name="topMargin">
65 <number>0</number>
65 <number>0</number>
66 </property>
66 </property>
67 <property name="rightMargin">
67 <property name="rightMargin">
68 <number>0</number>
68 <number>0</number>
69 </property>
69 </property>
70 <property name="bottomMargin">
70 <property name="bottomMargin">
71 <number>0</number>
71 <number>0</number>
72 </property>
72 </property>
73 <item>
73 <item>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 </item>
75 </item>
76 <item>
76 <item>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 </item>
78 </item>
79 <item>
79 <item>
80 <widget class="QWidget" name="variableInspectorWidget" native="true"/>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 </item>
81 </item>
82 </layout>
82 </layout>
83 </widget>
83 </widget>
84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 <widget class="VisualizationWidget" name="view" native="true">
85 <widget class="VisualizationWidget" name="view" native="true">
86 <property name="sizePolicy">
86 <property name="sizePolicy">
87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 <horstretch>0</horstretch>
88 <horstretch>0</horstretch>
89 <verstretch>0</verstretch>
89 <verstretch>0</verstretch>
90 </sizepolicy>
90 </sizepolicy>
91 </property>
91 </property>
92 </widget>
92 </widget>
93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 <layout class="QVBoxLayout" name="verticalLayout_3">
95 <layout class="QVBoxLayout" name="verticalLayout_3">
96 <property name="spacing">
96 <property name="spacing">
97 <number>0</number>
97 <number>0</number>
98 </property>
98 </property>
99 <property name="leftMargin">
99 <property name="leftMargin">
100 <number>0</number>
100 <number>0</number>
101 </property>
101 </property>
102 <property name="topMargin">
102 <property name="topMargin">
103 <number>0</number>
103 <number>0</number>
104 </property>
104 </property>
105 <property name="rightMargin">
105 <property name="rightMargin">
106 <number>0</number>
106 <number>0</number>
107 </property>
107 </property>
108 <property name="bottomMargin">
108 <property name="bottomMargin">
109 <number>0</number>
109 <number>0</number>
110 </property>
110 </property>
111 <item>
111 <item>
112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 </item>
113 </item>
114 <item>
114 <item>
115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
115 <widget class="DataSourceWidget" name="catalogWidget" native="true"/>
116 </item>
116 </item>
117 </layout>
117 </layout>
118 </widget>
118 </widget>
119 </widget>
119 </widget>
120 </item>
120 </item>
121 </layout>
121 </layout>
122 </widget>
122 </widget>
123 <widget class="QMenuBar" name="menuBar">
123 <widget class="QMenuBar" name="menuBar">
124 <property name="geometry">
124 <property name="geometry">
125 <rect>
125 <rect>
126 <x>0</x>
126 <x>0</x>
127 <y>0</y>
127 <y>0</y>
128 <width>800</width>
128 <width>800</width>
129 <height>28</height>
129 <height>26</height>
130 </rect>
130 </rect>
131 </property>
131 </property>
132 </widget>
132 </widget>
133 <widget class="QStatusBar" name="statusBar"/>
133 <widget class="QStatusBar" name="statusBar"/>
134 </widget>
134 </widget>
135 <layoutdefault spacing="6" margin="11"/>
135 <layoutdefault spacing="6" margin="11"/>
136 <customwidgets>
136 <customwidgets>
137 <customwidget>
137 <customwidget>
138 <class>VisualizationWidget</class>
138 <class>VisualizationWidget</class>
139 <extends>QWidget</extends>
139 <extends>QWidget</extends>
140 <header location="global">Visualization/VisualizationWidget.h</header>
140 <header location="global">Visualization/VisualizationWidget.h</header>
141 <container>1</container>
141 <container>1</container>
142 </customwidget>
142 </customwidget>
143 <customwidget>
143 <customwidget>
144 <class>SqpSidePane</class>
144 <class>SqpSidePane</class>
145 <extends>QWidget</extends>
145 <extends>QWidget</extends>
146 <header location="global">SidePane/SqpSidePane.h</header>
146 <header location="global">SidePane/SqpSidePane.h</header>
147 <container>1</container>
147 <container>1</container>
148 </customwidget>
148 </customwidget>
149 <customwidget>
149 <customwidget>
150 <class>DataSourceWidget</class>
150 <class>DataSourceWidget</class>
151 <extends>QWidget</extends>
151 <extends>QWidget</extends>
152 <header location="global">DataSource/DataSourceWidget.h</header>
152 <header location="global">DataSource/DataSourceWidget.h</header>
153 <container>1</container>
153 <container>1</container>
154 </customwidget>
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 </customwidgets>
161 </customwidgets>
156 <resources/>
162 <resources/>
157 <connections/>
163 <connections/>
158 </ui>
164 </ui>
@@ -1,61 +1,79
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
2 #define SCIQLOP_DATASOURCECONTROLLER_H
3
3
4 #include <QLoggingCategory>
4 #include <QLoggingCategory>
5 #include <QObject>
5 #include <QObject>
6 #include <QUuid>
6 #include <QUuid>
7
7
8 #include <Common/spimpl.h>
8 #include <Common/spimpl.h>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13 class IDataProvider;
13
14
14 /**
15 /**
15 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
16 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
16 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
17 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
17 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
18 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
18 * source) then others specifics method will be able to access it. You can load a data source driver
19 * source) then others specifics method will be able to access it. You can load a data source driver
19 * plugin then create a data source.
20 * plugin then create a data source.
20 */
21 */
21 class DataSourceController : public QObject {
22 class DataSourceController : public QObject {
22 Q_OBJECT
23 Q_OBJECT
23 public:
24 public:
24 explicit DataSourceController(QObject *parent = 0);
25 explicit DataSourceController(QObject *parent = 0);
25 virtual ~DataSourceController();
26 virtual ~DataSourceController();
26
27
27 /**
28 /**
28 * Registers a data source. The method delivers a unique id that can be used afterwards to
29 * Registers a data source. The method delivers a unique id that can be used afterwards to
29 * access to the data source properties (structure, connection parameters, data provider, etc.)
30 * access to the data source properties (structure, connection parameters, data provider, etc.)
30 * @param dataSourceName the name of the data source
31 * @param dataSourceName the name of the data source
31 * @return the unique id with which the data source has been registered
32 * @return the unique id with which the data source has been registered
32 */
33 */
33 QUuid registerDataSource(const QString &dataSourceName) noexcept;
34 QUuid registerDataSource(const QString &dataSourceName) noexcept;
34
35
35 /**
36 /**
36 * Sets the structure of a data source. The controller takes ownership of the structure.
37 * Sets the structure of a data source. The controller takes ownership of the structure.
37 * @param dataSourceUid the unique id with which the data source has been registered into the
38 * @param dataSourceUid the unique id with which the data source has been registered into the
38 * controller. If it is invalid, the method has no effect.
39 * controller. If it is invalid, the method has no effect.
39 * @param dataSourceItem the structure of the data source
40 * @param dataSourceItem the structure of the data source
40 * @sa registerDataSource()
41 * @sa registerDataSource()
41 */
42 */
42 void setDataSourceItem(const QUuid &dataSourceUid,
43 void setDataSourceItem(const QUuid &dataSourceUid,
43 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
44 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
44
45
46 /**
47 * Sets the data provider used to retrieve data from of a data source. The controller takes
48 * ownership of the provider.
49 * @param dataSourceUid the unique id with which the data source has been registered into the
50 * controller. If it is invalid, the method has no effect.
51 * @param dataProvider the provider of the data source
52 * @sa registerDataSource()
53 */
54 void setDataProvider(const QUuid &dataSourceUid,
55 std::unique_ptr<IDataProvider> dataProvider) noexcept;
56
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 public slots:
63 public slots:
46 /// Manage init/end of the controller
64 /// Manage init/end of the controller
47 void initialize();
65 void initialize();
48 void finalize();
66 void finalize();
49
67
50 signals:
68 signals:
51 /// Signal emitted when a structure has been set for a data source
69 /// Signal emitted when a structure has been set for a data source
52 void dataSourceItemSet(DataSourceItem *dataSourceItem);
70 void dataSourceItemSet(DataSourceItem *dataSourceItem);
53
71
54 private:
72 private:
55 void waitForFinish();
73 void waitForFinish();
56
74
57 class DataSourceControllerPrivate;
75 class DataSourceControllerPrivate;
58 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
76 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
59 };
77 };
60
78
61 #endif // SCIQLOP_DATASOURCECONTROLLER_H
79 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,59 +1,73
1 #ifndef SCIQLOP_DATASOURCEITEM_H
1 #ifndef SCIQLOP_DATASOURCEITEM_H
2 #define SCIQLOP_DATASOURCEITEM_H
2 #define SCIQLOP_DATASOURCEITEM_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5
5
6 #include <QVariant>
6 #include <QVariant>
7 #include <QVector>
7 #include <QVector>
8
8
9 class DataSourceItemAction;
10
9 /**
11 /**
10 * Possible types of an item
12 * Possible types of an item
11 */
13 */
12 enum class DataSourceItemType { NODE, PRODUCT };
14 enum class DataSourceItemType { NODE, PRODUCT };
13
15
14 /**
16 /**
15 * @brief The DataSourceItem class aims to represent a structure element of a data source.
17 * @brief The DataSourceItem class aims to represent a structure element of a data source.
16 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
18 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
17 * containing other DataSourceItem objects (children).
19 * containing other DataSourceItem objects (children).
18 * For each DataSourceItem can be associated a set of data representing it.
20 * For each DataSourceItem can be associated a set of data representing it.
19 */
21 */
20 class DataSourceItem {
22 class DataSourceItem {
21 public:
23 public:
22 explicit DataSourceItem(DataSourceItemType type, QVector<QVariant> data = {});
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 * Adds a child to the item. The item takes ownership of the child.
37 * Adds a child to the item. The item takes ownership of the child.
26 * @param child the child to add
38 * @param child the child to add
27 */
39 */
28 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
40 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
29
41
30 /**
42 /**
31 * Returns the item's child associated to an index
43 * Returns the item's child associated to an index
32 * @param childIndex the index to search
44 * @param childIndex the index to search
33 * @return a pointer to the child if index is valid, nullptr otherwise
45 * @return a pointer to the child if index is valid, nullptr otherwise
34 */
46 */
35 DataSourceItem *child(int childIndex) const noexcept;
47 DataSourceItem *child(int childIndex) const noexcept;
36
48
37 int childCount() const noexcept;
49 int childCount() const noexcept;
38
50
39 /**
51 /**
40 * Get the data associated to an index
52 * Get the data associated to an index
41 * @param dataIndex the index to search
53 * @param dataIndex the index to search
42 * @return the data found if index is valid, default QVariant otherwise
54 * @return the data found if index is valid, default QVariant otherwise
43 */
55 */
44 QVariant data(int dataIndex) const noexcept;
56 QVariant data(int dataIndex) const noexcept;
45
57
58 QString name() const noexcept;
59
46 /**
60 /**
47 * Get the item's parent
61 * Get the item's parent
48 * @return a pointer to the parent if it exists, nullptr if the item is a root
62 * @return a pointer to the parent if it exists, nullptr if the item is a root
49 */
63 */
50 DataSourceItem *parentItem() const noexcept;
64 DataSourceItem *parentItem() const noexcept;
51
65
52 DataSourceItemType type() const noexcept;
66 DataSourceItemType type() const noexcept;
53
67
54 private:
68 private:
55 class DataSourceItemPrivate;
69 class DataSourceItemPrivate;
56 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
70 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
57 };
71 };
58
72
59 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
73 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
@@ -1,78 +1,100
1 #include <DataSource/DataSourceController.h>
1 #include <DataSource/DataSourceController.h>
2 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItem.h>
3
3
4 #include <Data/IDataProvider.h>
5
4 #include <QMutex>
6 #include <QMutex>
5 #include <QThread>
7 #include <QThread>
6
8
7 #include <QDir>
9 #include <QDir>
8 #include <QStandardPaths>
10 #include <QStandardPaths>
9
11
10 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
12 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
11
13
12 class DataSourceController::DataSourceControllerPrivate {
14 class DataSourceController::DataSourceControllerPrivate {
13 public:
15 public:
14 QMutex m_WorkingMutex;
16 QMutex m_WorkingMutex;
15 /// Data sources registered
17 /// Data sources registered
16 QHash<QUuid, QString> m_DataSources;
18 QHash<QUuid, QString> m_DataSources;
17 /// Data sources structures
19 /// Data sources structures
18 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
20 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
21 /// Data providers registered
22 std::map<QUuid, std::unique_ptr<IDataProvider> > m_DataProviders;
19 };
23 };
20
24
21 DataSourceController::DataSourceController(QObject *parent)
25 DataSourceController::DataSourceController(QObject *parent)
22 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
26 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
23 {
27 {
24 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
28 qCDebug(LOG_DataSourceController()) << tr("DataSourceController construction")
25 << QThread::currentThread();
29 << QThread::currentThread();
26 }
30 }
27
31
28 DataSourceController::~DataSourceController()
32 DataSourceController::~DataSourceController()
29 {
33 {
30 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
34 qCDebug(LOG_DataSourceController()) << tr("DataSourceController destruction")
31 << QThread::currentThread();
35 << QThread::currentThread();
32 this->waitForFinish();
36 this->waitForFinish();
33 }
37 }
34
38
35 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
39 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
36 {
40 {
37 auto dataSourceUid = QUuid::createUuid();
41 auto dataSourceUid = QUuid::createUuid();
38 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
42 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
39
43
40 return dataSourceUid;
44 return dataSourceUid;
41 }
45 }
42
46
43 void DataSourceController::setDataSourceItem(
47 void DataSourceController::setDataSourceItem(
44 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
48 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
45 {
49 {
46 if (impl->m_DataSources.contains(dataSourceUid)) {
50 if (impl->m_DataSources.contains(dataSourceUid)) {
47 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
51 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
48
52
49 // Retrieves the data source item to emit the signal with it
53 // Retrieves the data source item to emit the signal with it
50 auto it = impl->m_DataSourceItems.find(dataSourceUid);
54 auto it = impl->m_DataSourceItems.find(dataSourceUid);
51 if (it != impl->m_DataSourceItems.end()) {
55 if (it != impl->m_DataSourceItems.end()) {
52 emit dataSourceItemSet(it->second.get());
56 emit dataSourceItemSet(it->second.get());
53 }
57 }
54 }
58 }
55 else {
59 else {
56 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
60 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
57 "data source has been registered with the uid")
61 "data source has been registered with the uid")
58 .arg(dataSourceUid.toString());
62 .arg(dataSourceUid.toString());
59 }
63 }
60 }
64 }
61
65
66 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
67 std::unique_ptr<IDataProvider> dataProvider) noexcept
68 {
69 if (impl->m_DataSources.contains(dataSourceUid)) {
70 impl->m_DataProviders.insert(std::make_pair(dataSourceUid, std::move(dataProvider)));
71 }
72 else {
73 qCWarning(LOG_DataSourceController()) << tr("Can't set data provider for uid %1 : no data "
74 "source has been registered with the uid")
75 .arg(dataSourceUid.toString());
76 }
77 }
78
79 void DataSourceController::loadProductItem(const DataSourceItem &productItem) noexcept
80 {
81 /// @todo ALX
82 }
83
62 void DataSourceController::initialize()
84 void DataSourceController::initialize()
63 {
85 {
64 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
86 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init")
65 << QThread::currentThread();
87 << QThread::currentThread();
66 impl->m_WorkingMutex.lock();
88 impl->m_WorkingMutex.lock();
67 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
89 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
68 }
90 }
69
91
70 void DataSourceController::finalize()
92 void DataSourceController::finalize()
71 {
93 {
72 impl->m_WorkingMutex.unlock();
94 impl->m_WorkingMutex.unlock();
73 }
95 }
74
96
75 void DataSourceController::waitForFinish()
97 void DataSourceController::waitForFinish()
76 {
98 {
77 QMutexLocker locker{&impl->m_WorkingMutex};
99 QMutexLocker locker{&impl->m_WorkingMutex};
78 }
100 }
@@ -1,56 +1,86
1 #include <DataSource/DataSourceItem.h>
1 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItemAction.h>
2
3
3 #include <QVector>
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 struct DataSourceItem::DataSourceItemPrivate {
13 struct DataSourceItem::DataSourceItemPrivate {
6 explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data)
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 DataSourceItem *m_Parent;
19 DataSourceItem *m_Parent;
12 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
20 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
13 DataSourceItemType m_Type;
21 DataSourceItemType m_Type;
14 QVector<QVariant> m_Data;
22 QVector<QVariant> m_Data;
23 std::vector<std::unique_ptr<DataSourceItemAction> > m_Actions;
15 };
24 };
16
25
17 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
26 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data)
18 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
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 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
47 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
23 {
48 {
24 child->impl->m_Parent = this;
49 child->impl->m_Parent = this;
25 impl->m_Children.push_back(std::move(child));
50 impl->m_Children.push_back(std::move(child));
26 }
51 }
27
52
28 DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
53 DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
29 {
54 {
30 if (childIndex < 0 || childIndex >= childCount()) {
55 if (childIndex < 0 || childIndex >= childCount()) {
31 return nullptr;
56 return nullptr;
32 }
57 }
33 else {
58 else {
34 return impl->m_Children.at(childIndex).get();
59 return impl->m_Children.at(childIndex).get();
35 }
60 }
36 }
61 }
37
62
38 int DataSourceItem::childCount() const noexcept
63 int DataSourceItem::childCount() const noexcept
39 {
64 {
40 return impl->m_Children.size();
65 return impl->m_Children.size();
41 }
66 }
42
67
43 QVariant DataSourceItem::data(int dataIndex) const noexcept
68 QVariant DataSourceItem::data(int dataIndex) const noexcept
44 {
69 {
45 return impl->m_Data.value(dataIndex);
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 DataSourceItem *DataSourceItem::parentItem() const noexcept
78 DataSourceItem *DataSourceItem::parentItem() const noexcept
49 {
79 {
50 return impl->m_Parent;
80 return impl->m_Parent;
51 }
81 }
52
82
53 DataSourceItemType DataSourceItem::type() const noexcept
83 DataSourceItemType DataSourceItem::type() const noexcept
54 {
84 {
55 return impl->m_Type;
85 return impl->m_Type;
56 }
86 }
@@ -1,6 +1,13
1 # On ignore toutes les règles vera++ pour le fichier spimpl
1 # On ignore toutes les règles vera++ pour le fichier spimpl
2 Common/spimpl\.h:\d+:.*
2 Common/spimpl\.h:\d+:.*
3
3
4 # Ignore false positive relative to two class definitions in a same file
4 # Ignore false positive relative to two class definitions in a same file
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
6
6
7 # Ignore false positive relative to a template class
8 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (D)
9 ArrayData\.h:\d+:.*IPSIS_S06.*found: (D)
10 ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim)
11
12 # Ignore false positive relative to an alias
13 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
@@ -1,32 +1,35
1 #ifndef SCIQLOP_DATASOURCETREEWIDGETITEM_H
1 #ifndef SCIQLOP_DATASOURCETREEWIDGETITEM_H
2 #define SCIQLOP_DATASOURCETREEWIDGETITEM_H
2 #define SCIQLOP_DATASOURCETREEWIDGETITEM_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7 #include <QTreeWidgetItem>
7 #include <QTreeWidgetItem>
8
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem)
9 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem)
10
10
11 class DataSourceItem;
11 class DataSourceItem;
12
12
13 /**
13 /**
14 * @brief The DataSourceTreeWidgetItem is the graphical representation of a data source item. It is
14 * @brief The DataSourceTreeWidgetItem is the graphical representation of a data source item. It is
15 * intended to be displayed in a QTreeWidget.
15 * intended to be displayed in a QTreeWidget.
16 * @sa DataSourceItem
16 * @sa DataSourceItem
17 */
17 */
18 class DataSourceTreeWidgetItem : public QTreeWidgetItem {
18 class DataSourceTreeWidgetItem : public QTreeWidgetItem {
19 public:
19 public:
20 explicit DataSourceTreeWidgetItem(const DataSourceItem *data, int type = Type);
20 explicit DataSourceTreeWidgetItem(const DataSourceItem *data, int type = Type);
21 explicit DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
21 explicit DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
22 int type = Type);
22 int type = Type);
23
23
24 virtual QVariant data(int column, int role) const override;
24 virtual QVariant data(int column, int role) const override;
25 virtual void setData(int column, int role, const QVariant &value) override;
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 private:
30 private:
28 class DataSourceTreeWidgetItemPrivate;
31 class DataSourceTreeWidgetItemPrivate;
29 spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl;
32 spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl;
30 };
33 };
31
34
32 #endif // SCIQLOP_DATASOURCETREEWIDGETITEM_H
35 #endif // SCIQLOP_DATASOURCETREEWIDGETITEM_H
@@ -1,33 +1,38
1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
1 #ifndef SCIQLOP_DATASOURCEWIDGET_H
2 #define SCIQLOP_DATASOURCEWIDGET_H
2 #define SCIQLOP_DATASOURCEWIDGET_H
3
3
4 #include <Common/spimpl.h>
5
6 #include <QWidget>
4 #include <QWidget>
7
5
6 namespace Ui {
7 class DataSourceWidget;
8 } // Ui
9
8 class DataSourceItem;
10 class DataSourceItem;
9
11
10 /**
12 /**
11 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
13 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
12 * attached to SciQlop.
14 * attached to SciQlop.
13 */
15 */
14 class DataSourceWidget : public QWidget {
16 class DataSourceWidget : public QWidget {
15 Q_OBJECT
17 Q_OBJECT
16
18
17 public:
19 public:
18 explicit DataSourceWidget(QWidget *parent = 0);
20 explicit DataSourceWidget(QWidget *parent = 0);
19
21
20 public slots:
22 public slots:
21 /**
23 /**
22 * Adds a data source. An item associated to the data source is created and then added to the
24 * Adds a data source. An item associated to the data source is created and then added to the
23 * representation tree
25 * representation tree
24 * @param dataSource the data source to add. The pointer has to be not null
26 * @param dataSource the data source to add. The pointer has to be not null
25 */
27 */
26 void addDataSource(DataSourceItem *dataSource) noexcept;
28 void addDataSource(DataSourceItem *dataSource) noexcept;
27
29
28 private:
30 private:
29 class DataSourceWidgetPrivate;
31 Ui::DataSourceWidget *ui;
30 spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl;
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 #endif // SCIQLOP_DATASOURCEWIDGET_H
38 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -1,46 +1,48
1 #ifndef SCIQLOP_SQPAPPLICATION_H
1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
3
3
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 #include <QApplication>
6 #include <QApplication>
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12
12
13 #if defined(sqpApp)
13 #if defined(sqpApp)
14 #undef sqpApp
14 #undef sqpApp
15 #endif
15 #endif
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
16 #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance()))
17
17
18 class DataSourceController;
18 class DataSourceController;
19 class VariableController;
19 class VisualizationController;
20 class VisualizationController;
20
21
21 /**
22 /**
22 * @brief The SqpApplication class aims to make the link between SciQlop
23 * @brief The SqpApplication class aims to make the link between SciQlop
23 * and its plugins. This is the intermediate class that SciQlop has to use
24 * and its plugins. This is the intermediate class that SciQlop has to use
24 * in the way to connect a data source. Please first use load method to initialize
25 * in the way to connect a data source. Please first use load method to initialize
25 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 * a plugin specified by its metadata name (JSON plugin source) then others specifics
26 * method will be able to access it.
27 * method will be able to access it.
27 * You can load a data source driver plugin then create a data source.
28 * You can load a data source driver plugin then create a data source.
28 */
29 */
29
30
30 class SqpApplication : public QApplication {
31 class SqpApplication : public QApplication {
31 Q_OBJECT
32 Q_OBJECT
32 public:
33 public:
33 explicit SqpApplication(int &argc, char **argv);
34 explicit SqpApplication(int &argc, char **argv);
34 virtual ~SqpApplication();
35 virtual ~SqpApplication();
35 void initialize();
36 void initialize();
36
37
37 /// Accessors for the differents sciqlop controllers
38 /// Accessors for the differents sciqlop controllers
38 DataSourceController &dataSourceController() const noexcept;
39 DataSourceController &dataSourceController() noexcept;
39 VisualizationController &visualizationController() const noexcept;
40 VariableController &variableController() noexcept;
41 VisualizationController &visualizationController() noexcept;
40
42
41 private:
43 private:
42 class SqpApplicationPrivate;
44 class SqpApplicationPrivate;
43 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
45 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
44 };
46 };
45
47
46 #endif // SCIQLOP_SQPAPPLICATION_H
48 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,21 +1,39
1 #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
2 #define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
2 #define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
3
3
4 #include "Visualization/IVisualizationWidget.h"
5
4 #include <QWidget>
6 #include <QWidget>
5
7
8 #include <memory>
9
10 #include <Common/spimpl.h>
11
12 class Variable;
13
6 namespace Ui {
14 namespace Ui {
7 class VisualizationGraphWidget;
15 class VisualizationGraphWidget;
8 } // namespace Ui
16 } // namespace Ui
9
17
10 class VisualizationGraphWidget : public QWidget {
18 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
11 Q_OBJECT
19 Q_OBJECT
12
20
13 public:
21 public:
14 explicit VisualizationGraphWidget(QWidget *parent = 0);
22 explicit VisualizationGraphWidget(QWidget *parent = 0);
15 virtual ~VisualizationGraphWidget();
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 private:
32 private:
18 Ui::VisualizationGraphWidget *ui;
33 Ui::VisualizationGraphWidget *ui;
34
35 class VisualizationGraphWidgetPrivate;
36 spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl;
19 };
37 };
20
38
21 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
39 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
@@ -1,21 +1,39
1 #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H
2 #define SCIQLOP_VISUALIZATIONTABWIDGET_H
2 #define SCIQLOP_VISUALIZATIONTABWIDGET_H
3
3
4 #include "Visualization/IVisualizationWidget.h"
5
4 #include <QWidget>
6 #include <QWidget>
5
7
8 class VisualizationZoneWidget;
9
6 namespace Ui {
10 namespace Ui {
7 class VisualizationTabWidget;
11 class VisualizationTabWidget;
8 } // namespace Ui
12 } // namespace Ui
9
13
10 class VisualizationTabWidget : public QWidget {
14 class VisualizationTabWidget : public QWidget, public IVisualizationWidget {
11 Q_OBJECT
15 Q_OBJECT
12
16
13 public:
17 public:
14 explicit VisualizationTabWidget(QWidget *parent = 0);
18 explicit VisualizationTabWidget(QWidget *parent = 0);
15 virtual ~VisualizationTabWidget();
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 private:
35 private:
18 Ui::VisualizationTabWidget *ui;
36 Ui::VisualizationTabWidget *ui;
19 };
37 };
20
38
21 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
39 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
@@ -1,24 +1,42
1 #ifndef SCIQLOP_VISUALIZATIONWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONWIDGET_H
2 #define SCIQLOP_VISUALIZATIONWIDGET_H
2 #define SCIQLOP_VISUALIZATIONWIDGET_H
3
3
4 #include "Visualization/IVisualizationWidget.h"
5
4 #include <QLoggingCategory>
6 #include <QLoggingCategory>
5 #include <QWidget>
7 #include <QWidget>
6
8
9 class VisualizationTabWidget;
10
7 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
8
12
9 namespace Ui {
13 namespace Ui {
10 class VisualizationWidget;
14 class VisualizationWidget;
11 } // namespace Ui
15 } // namespace Ui
12
16
13 class VisualizationWidget : public QWidget {
17 class VisualizationWidget : public QWidget, public IVisualizationWidget {
14 Q_OBJECT
18 Q_OBJECT
15
19
16 public:
20 public:
17 explicit VisualizationWidget(QWidget *parent = 0);
21 explicit VisualizationWidget(QWidget *parent = 0);
18 virtual ~VisualizationWidget();
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 private:
38 private:
21 Ui::VisualizationWidget *ui;
39 Ui::VisualizationWidget *ui;
22 };
40 };
23
41
24 #endif // VISUALIZATIONWIDGET_H
42 #endif // VISUALIZATIONWIDGET_H
@@ -1,21 +1,39
1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
3
3
4 #include "Visualization/IVisualizationWidget.h"
5
6 class VisualizationGraphWidget;
7
4 #include <QWidget>
8 #include <QWidget>
5
9
6 namespace Ui {
10 namespace Ui {
7 class VisualizationZoneWidget;
11 class VisualizationZoneWidget;
8 } // Ui
12 } // Ui
9
13
10 class VisualizationZoneWidget : public QWidget {
14 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
11 Q_OBJECT
15 Q_OBJECT
12
16
13 public:
17 public:
14 explicit VisualizationZoneWidget(QWidget *parent = 0);
18 explicit VisualizationZoneWidget(QWidget *parent = 0);
15 virtual ~VisualizationZoneWidget();
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 private:
35 private:
18 Ui::VisualizationZoneWidget *ui;
36 Ui::VisualizationZoneWidget *ui;
19 };
37 };
20
38
21 #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H
39 #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H
@@ -1,5 +1,7
1 <RCC>
1 <RCC>
2 <qresource prefix="/">
2 <qresource prefix="/">
3 <file>icones/openInspector.png</file>
3 <file>icones/openInspector.png</file>
4 <file>icones/next.png</file>
5 <file>icones/previous.png</file>
4 </qresource>
6 </qresource>
5 </RCC>
7 </RCC>
@@ -1,75 +1,101
1 #include <DataSource/DataSourceItem.h>
1 #include <DataSource/DataSourceItem.h>
2 #include <DataSource/DataSourceItemAction.h>
2 #include <DataSource/DataSourceTreeWidgetItem.h>
3 #include <DataSource/DataSourceTreeWidgetItem.h>
3
4
4 #include <SqpApplication.h>
5 #include <SqpApplication.h>
5
6
7 #include <QAction>
8
6 Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem")
9 Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem")
7
10
8 namespace {
11 namespace {
9
12
10 QIcon itemIcon(const DataSourceItem *dataSource)
13 QIcon itemIcon(const DataSourceItem *dataSource)
11 {
14 {
12 if (dataSource) {
15 if (dataSource) {
13 auto dataSourceType = dataSource->type();
16 auto dataSourceType = dataSource->type();
14 switch (dataSourceType) {
17 switch (dataSourceType) {
15 case DataSourceItemType::NODE:
18 case DataSourceItemType::NODE:
16 return sqpApp->style()->standardIcon(QStyle::SP_DirIcon);
19 return sqpApp->style()->standardIcon(QStyle::SP_DirIcon);
17 case DataSourceItemType::PRODUCT:
20 case DataSourceItemType::PRODUCT:
18 return sqpApp->style()->standardIcon(QStyle::SP_FileIcon);
21 return sqpApp->style()->standardIcon(QStyle::SP_FileIcon);
19 default:
22 default:
20 // No action
23 // No action
21 break;
24 break;
22 }
25 }
23
26
24 qCWarning(LOG_DataSourceTreeWidgetItem())
27 qCWarning(LOG_DataSourceTreeWidgetItem())
25 << QObject::tr("Can't set data source icon : unknown data source type");
28 << QObject::tr("Can't set data source icon : unknown data source type");
26 }
29 }
27 else {
30 else {
28 qCWarning(LOG_DataSourceTreeWidgetItem())
31 qCWarning(LOG_DataSourceTreeWidgetItem())
29 << QObject::tr("Can't set data source icon : the data source is null");
32 << QObject::tr("Can't set data source icon : the data source is null");
30 }
33 }
31
34
32 // Default cases
35 // Default cases
33 return QIcon{};
36 return QIcon{};
34 }
37 }
35
38
36 } // namespace
39 } // namespace
37
40
38 struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate {
41 struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate {
39 explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {}
42 explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {}
40
43
41 /// Model used to retrieve data source information
44 /// Model used to retrieve data source information
42 const DataSourceItem *m_Data;
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 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type)
51 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type)
46 : DataSourceTreeWidgetItem{nullptr, data, type}
52 : DataSourceTreeWidgetItem{nullptr, data, type}
47 {
53 {
48 }
54 }
49
55
50 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
56 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data,
51 int type)
57 int type)
52 : QTreeWidgetItem{parent, type},
58 : QTreeWidgetItem{parent, type},
53 impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)}
59 impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)}
54 {
60 {
55 // Sets the icon depending on the data source
61 // Sets the icon depending on the data source
56 setIcon(0, itemIcon(impl->m_Data));
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 QVariant DataSourceTreeWidgetItem::data(int column, int role) const
80 QVariant DataSourceTreeWidgetItem::data(int column, int role) const
60 {
81 {
61 if (role == Qt::DisplayRole) {
82 if (role == Qt::DisplayRole) {
62 return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{};
83 return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{};
63 }
84 }
64 else {
85 else {
65 return QTreeWidgetItem::data(column, role);
86 return QTreeWidgetItem::data(column, role);
66 }
87 }
67 }
88 }
68
89
69 void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value)
90 void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value)
70 {
91 {
71 // Data can't be changed by edition
92 // Data can't be changed by edition
72 if (role != Qt::EditRole) {
93 if (role != Qt::EditRole) {
73 QTreeWidgetItem::setData(column, role, value);
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 #include <DataSource/DataSourceWidget.h>
1 #include <DataSource/DataSourceWidget.h>
2
2
3 #include <ui_DataSourceWidget.h>
3 #include <ui_DataSourceWidget.h>
4
4
5 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/DataSourceItem.h>
6 #include <DataSource/DataSourceTreeWidgetItem.h>
6 #include <DataSource/DataSourceTreeWidgetItem.h>
7
7
8 #include <QMenu>
9
8 namespace {
10 namespace {
9
11
10 /// Number of columns displayed in the tree
12 /// Number of columns displayed in the tree
11 const auto TREE_NB_COLUMNS = 1;
13 const auto TREE_NB_COLUMNS = 1;
12
14
13 /// Header labels for the tree
15 /// Header labels for the tree
14 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
16 const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")};
15
17
16 /**
18 /**
17 * Creates the item associated to a data source
19 * Creates the item associated to a data source
18 * @param dataSource the data source for which to create the item
20 * @param dataSource the data source for which to create the item
19 * @return the new item
21 * @return the new item
20 */
22 */
21 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
23 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
22 {
24 {
23 // Creates item for the data source
25 // Creates item for the data source
24 auto item = new DataSourceTreeWidgetItem{dataSource};
26 auto item = new DataSourceTreeWidgetItem{dataSource};
25
27
26 // Generates items for the children of the data source
28 // Generates items for the children of the data source
27 for (auto i = 0; i < dataSource->childCount(); ++i) {
29 for (auto i = 0; i < dataSource->childCount(); ++i) {
28 item->addChild(createTreeWidgetItem(dataSource->child(i)));
30 item->addChild(createTreeWidgetItem(dataSource->child(i)));
29 }
31 }
30
32
31 return item;
33 return item;
32 }
34 }
33
35
34 } // namespace
36 } // namespace
35
37
36 class DataSourceWidget::DataSourceWidgetPrivate {
38 DataSourceWidget::DataSourceWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::DataSourceWidget}
37 public:
39 {
38 explicit DataSourceWidgetPrivate(DataSourceWidget &widget)
40 ui->setupUi(this);
39 : m_Ui{std::make_unique<Ui::DataSourceWidget>()}
40 {
41 m_Ui->setupUi(&widget);
42
43 // Set tree properties
44 m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
45 m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
46 }
47
41
48 std::unique_ptr<Ui::DataSourceWidget> m_Ui;
42 // Set tree properties
49 };
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)
47 // Connection to show a menu when right clicking on the tree
52 : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)}
48 connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this,
53 {
49 &DataSourceWidget::onTreeMenuRequested);
54 }
50 }
55
51
56 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
52 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
57 {
53 {
58 // Creates the item associated to the source and adds it to the tree widget. The tree widget
54 // Creates the item associated to the source and adds it to the tree widget. The tree widget
59 // takes the ownership of the item
55 // takes the ownership of the item
60 if (dataSource) {
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 #include "SidePane/SqpSidePane.h"
1 #include "SidePane/SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
3
3
4 #include <QAction>
4 #include <QAction>
5 #include <QLayout>
5 #include <QLayout>
6 #include <QToolBar>
6 #include <QToolBar>
7
7
8 namespace {
8 namespace {
9 static const QString SQPSIDEPANESTYLESHEET
9 static const QString SQPSIDEPANESTYLESHEET
10 = "QToolBar {"
10 = "QToolBar {"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
12 " stop: 0.0 #5a5a5a,"
12 " stop: 0.0 #5a5a5a,"
13 " stop: 1.0 #414141);"
13 " stop: 1.0 #414141);"
14 " border: none;"
14 " border: none;"
15 " border-left: 1px solid #424242;"
15 " border-left: 1px solid #424242;"
16 "border-right: 1px solid #393939;"
16 "border-right: 1px solid #393939;"
17 " }"
17 " }"
18
18
19 " QToolButton {"
19 " QToolButton {"
20 "background: none;"
20 "background: none;"
21 "border: none;"
21 "border: none;"
22 " }";
22 " }";
23 }
23 }
24
24
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
26 {
26 {
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
29 // this->setLayout(sidePaneLayout);
29 // this->setLayout(sidePaneLayout);
30
30
31 ui->setupUi(this);
31 ui->setupUi(this);
32 m_SidePaneToolbar = new QToolBar();
32 m_SidePaneToolbar = new QToolBar();
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
34 this->layout()->addWidget(m_SidePaneToolbar);
34 this->layout()->addWidget(m_SidePaneToolbar);
35
35
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
37
38 this->setStyleSheet(
39 " QWidget {"
40 "background: red;"
41
42 "border: 1px;"
43 " }");
44 }
37 }
45
38
46 SqpSidePane::~SqpSidePane()
39 SqpSidePane::~SqpSidePane()
47 {
40 {
48 delete ui;
41 delete ui;
49 }
42 }
50
43
51 QToolBar *SqpSidePane::sidePane()
44 QToolBar *SqpSidePane::sidePane()
52 {
45 {
53 return m_SidePaneToolbar;
46 return m_SidePaneToolbar;
54 }
47 }
@@ -1,72 +1,91
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <DataSource/DataSourceController.h>
3 #include <DataSource/DataSourceController.h>
4 #include <QThread>
4 #include <QThread>
5 #include <Variable/VariableController.h>
5 #include <Visualization/VisualizationController.h>
6 #include <Visualization/VisualizationController.h>
6
7
7 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
8
9
9 class SqpApplication::SqpApplicationPrivate {
10 class SqpApplication::SqpApplicationPrivate {
10 public:
11 public:
11 SqpApplicationPrivate()
12 SqpApplicationPrivate()
12 : m_DataSourceController{std::make_unique<DataSourceController>()},
13 : m_DataSourceController{std::make_unique<DataSourceController>()},
14 m_VariableController{std::make_unique<VariableController>()},
13 m_VisualizationController{std::make_unique<VisualizationController>()}
15 m_VisualizationController{std::make_unique<VisualizationController>()}
14 {
16 {
15 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
17 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
18 m_VariableController->moveToThread(&m_VariableControllerThread);
16 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
19 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
17 }
20 }
18
21
19 virtual ~SqpApplicationPrivate()
22 virtual ~SqpApplicationPrivate()
20 {
23 {
21 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
24 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
22 m_DataSourceControllerThread.quit();
25 m_DataSourceControllerThread.quit();
23 m_DataSourceControllerThread.wait();
26 m_DataSourceControllerThread.wait();
24
27
28 m_VariableControllerThread.quit();
29 m_VariableControllerThread.wait();
30
25 m_VisualizationControllerThread.quit();
31 m_VisualizationControllerThread.quit();
26 m_VisualizationControllerThread.wait();
32 m_VisualizationControllerThread.wait();
27 }
33 }
28
34
29 std::unique_ptr<DataSourceController> m_DataSourceController;
35 std::unique_ptr<DataSourceController> m_DataSourceController;
36 std::unique_ptr<VariableController> m_VariableController;
30 std::unique_ptr<VisualizationController> m_VisualizationController;
37 std::unique_ptr<VisualizationController> m_VisualizationController;
31 QThread m_DataSourceControllerThread;
38 QThread m_DataSourceControllerThread;
39 QThread m_VariableControllerThread;
32 QThread m_VisualizationControllerThread;
40 QThread m_VisualizationControllerThread;
33 };
41 };
34
42
35
43
36 SqpApplication::SqpApplication(int &argc, char **argv)
44 SqpApplication::SqpApplication(int &argc, char **argv)
37 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
45 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
38 {
46 {
39 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
47 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
40
48
41 connect(&impl->m_DataSourceControllerThread, &QThread::started,
49 connect(&impl->m_DataSourceControllerThread, &QThread::started,
42 impl->m_DataSourceController.get(), &DataSourceController::initialize);
50 impl->m_DataSourceController.get(), &DataSourceController::initialize);
43 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
51 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
44 impl->m_DataSourceController.get(), &DataSourceController::finalize);
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 connect(&impl->m_VisualizationControllerThread, &QThread::started,
59 connect(&impl->m_VisualizationControllerThread, &QThread::started,
47 impl->m_VisualizationController.get(), &VisualizationController::initialize);
60 impl->m_VisualizationController.get(), &VisualizationController::initialize);
48 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
61 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
49 impl->m_VisualizationController.get(), &VisualizationController::finalize);
62 impl->m_VisualizationController.get(), &VisualizationController::finalize);
50
63
51
64
52 impl->m_DataSourceControllerThread.start();
65 impl->m_DataSourceControllerThread.start();
66 impl->m_VariableControllerThread.start();
53 impl->m_VisualizationControllerThread.start();
67 impl->m_VisualizationControllerThread.start();
54 }
68 }
55
69
56 SqpApplication::~SqpApplication()
70 SqpApplication::~SqpApplication()
57 {
71 {
58 }
72 }
59
73
60 void SqpApplication::initialize()
74 void SqpApplication::initialize()
61 {
75 {
62 }
76 }
63
77
64 DataSourceController &SqpApplication::dataSourceController() const noexcept
78 DataSourceController &SqpApplication::dataSourceController() noexcept
65 {
79 {
66 return *impl->m_DataSourceController;
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 return *impl->m_VisualizationController;
90 return *impl->m_VisualizationController;
72 }
91 }
@@ -1,13 +1,47
1 #include "Visualization/VisualizationGraphWidget.h"
1 #include "Visualization/VisualizationGraphWidget.h"
2 #include "ui_VisualizationGraphWidget.h"
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 VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent)
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 ui->setupUi(this);
20 ui->setupUi(this);
8 }
21 }
9
22
10 VisualizationGraphWidget::~VisualizationGraphWidget()
23 VisualizationGraphWidget::~VisualizationGraphWidget()
11 {
24 {
12 delete ui;
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 #include "Visualization/VisualizationTabWidget.h"
1 #include "Visualization/VisualizationTabWidget.h"
2 #include "ui_VisualizationTabWidget.h"
2 #include "ui_VisualizationTabWidget.h"
3
3
4 #include "Visualization/VisualizationZoneWidget.h"
5
6
4 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
7 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
5 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
8 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
6 {
9 {
7 ui->setupUi(this);
10 ui->setupUi(this);
8 }
11 }
9
12
10 VisualizationTabWidget::~VisualizationTabWidget()
13 VisualizationTabWidget::~VisualizationTabWidget()
11 {
14 {
12 delete ui;
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 #include "Visualization/VisualizationWidget.h"
1 #include "Visualization/VisualizationWidget.h"
2 #include "Visualization/VisualizationTabWidget.h"
2 #include "Visualization/VisualizationTabWidget.h"
3 #include "Visualization/qcustomplot.h"
4
3 #include "ui_VisualizationWidget.h"
5 #include "ui_VisualizationWidget.h"
4
6
5 #include <QDebug>
6 #include <QToolButton>
7 #include <QToolButton>
7
8
8 #include "iostream"
9
10 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
9 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
11
10
12 VisualizationWidget::VisualizationWidget(QWidget *parent)
11 VisualizationWidget::VisualizationWidget(QWidget *parent)
13 : QWidget{parent}, ui{new Ui::VisualizationWidget}
12 : QWidget{parent}, ui{new Ui::VisualizationWidget}
14 {
13 {
15 ui->setupUi(this);
14 ui->setupUi(this);
16
15
17 auto addTabViewButton = new QToolButton{ui->tabWidget};
16 auto addTabViewButton = new QToolButton{ui->tabWidget};
18 addTabViewButton->setText(tr("Add View"));
17 addTabViewButton->setText(tr("Add View"));
19 addTabViewButton->setCursor(Qt::ArrowCursor);
18 addTabViewButton->setCursor(Qt::ArrowCursor);
20 addTabViewButton->setAutoRaise(true);
19 addTabViewButton->setAutoRaise(true);
21 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
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 auto addTabView = [&]() {
28 auto addTabView = [&]() {
24 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
29 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
25 QString("View %1").arg(ui->tabWidget->count() + 1));
30 QString("View %1").arg(ui->tabWidget->count() + 1));
26 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
31 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
27 };
32 };
28
33
29 auto removeTabView = [&](int index) {
34 auto removeTabView = [&](int index) {
30 ui->tabWidget->removeTab(index);
35 ui->tabWidget->removeTab(index);
31 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
36 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
32 };
37 };
33
38
34 ui->tabWidget->setTabsClosable(true);
39 ui->tabWidget->setTabsClosable(true);
35
40
36 connect(addTabViewButton, &QToolButton::clicked, addTabView);
41 connect(addTabViewButton, &QToolButton::clicked, addTabView);
37 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
42 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
38 }
43 }
39
44
40 VisualizationWidget::~VisualizationWidget()
45 VisualizationWidget::~VisualizationWidget()
41 {
46 {
42 delete ui;
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 #include "Visualization/VisualizationZoneWidget.h"
1 #include "Visualization/VisualizationZoneWidget.h"
2 #include "ui_VisualizationZoneWidget.h"
2 #include "ui_VisualizationZoneWidget.h"
3
3
4 #include "Visualization/VisualizationGraphWidget.h"
5
4 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
6 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
5 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
7 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
6 {
8 {
7 ui->setupUi(this);
9 ui->setupUi(this);
8 }
10 }
9
11
10 VisualizationZoneWidget::~VisualizationZoneWidget()
12 VisualizationZoneWidget::~VisualizationZoneWidget()
11 {
13 {
12 delete ui;
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
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 <ui version="4.0">
2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 <class>VisualizationGraphWidget</class>
3 <class>VisualizationGraphWidget</class>
6 <widget name="VisualizationGraphWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationGraphWidget">
7 <property name="geometry">
5 <property name="geometry">
8 <rect>
6 <rect>
9 <x>0</x>
7 <x>0</x>
10 <y>0</y>
8 <y>0</y>
11 <width>400</width>
9 <width>400</width>
12 <height>300</height>
10 <height>300</height>
13 </rect>
11 </rect>
14 </property>
12 </property>
15 <property name="windowTitle">
13 <property name="windowTitle">
16 <string>Form</string>
14 <string>Form</string>
17 </property>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QCustomPlot" name="widget" native="true"/>
19 </item>
20 </layout>
18 </widget>
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 <connections/>
31 <connections/>
21 </ui>
32 </ui>
@@ -1,21 +1,20
1 <?xml version="1.0" encoding="UTF-8"?>
1 <ui version="4.0">
2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 <class>VisualizationTabWidget</class>
3 <class>VisualizationTabWidget</class>
6 <widget name="VisualizationTabWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationTabWidget">
7 <property name="geometry">
5 <property name="geometry">
8 <rect>
6 <rect>
9 <x>0</x>
7 <x>0</x>
10 <y>0</y>
8 <y>0</y>
11 <width>400</width>
9 <width>400</width>
12 <height>300</height>
10 <height>300</height>
13 </rect>
11 </rect>
14 </property>
12 </property>
15 <property name="windowTitle">
13 <property name="windowTitle">
16 <string>Form</string>
14 <string>Form</string>
17 </property>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout"/>
18 </widget>
17 </widget>
19 <pixmapfunction/>
18 <resources/>
20 <connections/>
19 <connections/>
21 </ui>
20 </ui>
1 NO CONTENT: file renamed from gui/ui/visualization/VisualizationWidget.ui to gui/ui/Visualization/VisualizationWidget.ui
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 <ui version="4.0">
2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 <class>VisualizationZoneWidget</class>
3 <class>VisualizationZoneWidget</class>
6 <widget name="VisualizationZoneWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationZoneWidget">
7 <property name="geometry">
5 <property name="geometry">
8 <rect>
6 <rect>
9 <x>0</x>
7 <x>0</x>
10 <y>0</y>
8 <y>0</y>
11 <width>400</width>
9 <width>400</width>
12 <height>300</height>
10 <height>300</height>
13 </rect>
11 </rect>
14 </property>
12 </property>
15 <property name="windowTitle">
13 <property name="windowTitle">
16 <string>Form</string>
14 <string>Form</string>
17 </property>
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 </widget>
29 </widget>
19 <pixmapfunction/>
30 <resources/>
20 <connections/>
31 <connections/>
21 </ui>
32 </ui>
@@ -1,147 +1,153
1 ## mockplugin - CMakeLists.txt
1 ## mockplugin - CMakeLists.txt
2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7
7
8 # Include mockplugin directory
8 # Include mockplugin directory
9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11
11
12 #
12 #
13 # Find Qt modules
13 # Find Qt modules
14 #
14 #
15 SCIQLOP_FIND_QT(Core Widgets)
15 SCIQLOP_FIND_QT(Core Widgets)
16
16
17 #
17 #
18 # Find dependent libraries
18 # Find dependent libraries
19 # ========================
19 # ========================
20
20
21 # sciqlop plugin
21 # sciqlop plugin
22 find_package(sciqlop-plugin)
22 find_package(sciqlop-plugin)
23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24
24
25 # sciqlop core
25 # sciqlop core
26 find_package(sciqlop-core)
26 find_package(sciqlop-core)
27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29
29
30 # sciqlop gui
30 # sciqlop gui
31 find_package(sciqlop-gui)
31 find_package(sciqlop-gui)
32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34
34
35 # Resources files
35 # Resources files
36 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json)
36 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json)
37
37
38 #
38 #
39 # Compile the library
39 # Compile the library
40 #
40 #
41 FILE (GLOB_RECURSE MODULE_SOURCES
41 FILE (GLOB_RECURSE MODULE_SOURCES
42 ${INCLUDES_DIR}/*.h
42 ${INCLUDES_DIR}/*.h
43 ${SOURCES_DIR}/*.c
43 ${SOURCES_DIR}/*.c
44 ${SOURCES_DIR}/*.cpp
44 ${SOURCES_DIR}/*.cpp
45 ${SOURCES_DIR}/*.h
45 ${SOURCES_DIR}/*.h
46 ${PROJECT_RESOURCES})
46 ${PROJECT_RESOURCES})
47
47
48 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
48 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
49 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
49 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
50 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
50 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
51
51
52 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
52 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
53 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
53 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
54
54
55 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
55 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
56
56
57 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
57 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
58 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
58 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
59 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
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 IF(BUILD_SHARED_LIBS)
60 IF(BUILD_SHARED_LIBS)
61 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
61 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
62 ELSE()
62 ELSE()
63 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
63 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
64 ENDIF()
64 ENDIF()
65
65
66 # Set the variable to parent scope so that the other projects can copy the
66 # Set the variable to parent scope so that the other projects can copy the
67 # dependent shared libraries
67 # dependent shared libraries
68 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
68 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
69
69
70 # Copy extern shared libraries to the lib folder
70 # Copy extern shared libraries to the lib folder
71 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
71 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
72
72
73 # Add the files to the list of files to be analyzed
73 # Add the files to the list of files to be analyzed
74 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
74 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
75 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
75 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
76 # Vera++ exclusion files
76 # Vera++ exclusion files
77 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
77 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
78 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
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 # Compile the tests
87 # Compile the tests
82 #
88 #
83 IF(BUILD_TESTS)
89 IF(BUILD_TESTS)
84 INCLUDE_DIRECTORIES(${SOURCES_DIR})
90 INCLUDE_DIRECTORIES(${SOURCES_DIR})
85 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
91 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
86 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
92 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
87 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
93 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
88
94
89 FOREACH( testFile ${TESTS_SOURCES} )
95 FOREACH( testFile ${TESTS_SOURCES} )
90 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
96 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
91 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
97 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
92
98
93 # Add to the list of sources files all the sources in the same
99 # Add to the list of sources files all the sources in the same
94 # directory that aren't another test
100 # directory that aren't another test
95 FILE (GLOB currentTestSources
101 FILE (GLOB currentTestSources
96 ${testDirectory}/*.c
102 ${testDirectory}/*.c
97 ${testDirectory}/*.cpp
103 ${testDirectory}/*.cpp
98 ${testDirectory}/*.h)
104 ${testDirectory}/*.h)
99 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
105 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
100 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
106 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
101
107
102 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
108 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
103 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
109 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
104 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
110 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
105 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
111 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
106 qt5_use_modules(${testName} Test)
112 qt5_use_modules(${testName} Test)
107
113
108 ADD_TEST( NAME ${testName} COMMAND ${testName} )
114 ADD_TEST( NAME ${testName} COMMAND ${testName} )
109
115
110 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
116 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
111 ENDFOREACH( testFile )
117 ENDFOREACH( testFile )
112
118
113 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
119 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
114 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
120 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
115 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
121 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
116 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
122 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
117 ENDIF(BUILD_TESTS)
123 ENDIF(BUILD_TESTS)
118
124
119 #
125 #
120 # Set the files that must be formatted by clang-format.
126 # Set the files that must be formatted by clang-format.
121 #
127 #
122 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
128 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
123 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
129 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
124
130
125 #
131 #
126 # Set the directories that doxygen must browse to generate the
132 # Set the directories that doxygen must browse to generate the
127 # documentation.
133 # documentation.
128 #
134 #
129 # Source directories:
135 # Source directories:
130 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
136 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
131 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
137 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
132 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
138 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
133 # Source directories to exclude from the documentation generation
139 # Source directories to exclude from the documentation generation
134 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
140 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
135 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
141 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
136
142
137 #
143 #
138 # Set the directories with the sources to analyze and propagate the
144 # Set the directories with the sources to analyze and propagate the
139 # modification to the parent scope
145 # modification to the parent scope
140 #
146 #
141 # Source directories to analyze:
147 # Source directories to analyze:
142 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
148 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
143 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
149 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
144 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
150 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
145 # Source directories to exclude from the analysis
151 # Source directories to exclude from the analysis
146 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
152 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
147 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
153 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,21 +1,22
1 # - Try to find sciqlop-mockplugin
1 # - Try to find sciqlop-mockplugin
2 # Once done this will define
2 # Once done this will define
3 # SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin
3 # SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin
4 # SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories
4 # SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories
5 # SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin
5 # SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin
6
6
7 if(SCIQLOP-MOCKPLUGIN_FOUND)
7 if(SCIQLOP-MOCKPLUGIN_FOUND)
8 return()
8 return()
9 endif(SCIQLOP-MOCKPLUGIN_FOUND)
9 endif(SCIQLOP-MOCKPLUGIN_FOUND)
10
10
11 set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include)
11 set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include)
12
12
13 set (OS_LIB_EXTENSION "so")
13 set (OS_LIB_EXTENSION "so")
14
14
15 if(WIN32)
15 if(WIN32)
16 set (OS_LIB_EXTENSION "dll")
16 set (OS_LIB_EXTENSION "dll")
17 endif(WIN32)
17 endif(WIN32)
18 # TODO: Add Mac Support
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 set(SCIQLOP-MOCKPLUGIN_FOUND TRUE)
22 set(SCIQLOP-MOCKPLUGIN_FOUND TRUE)
@@ -1,27 +1,23
1 #ifndef SCIQLOP_MOCKPLUGIN_H
1 #ifndef SCIQLOP_MOCKPLUGIN_H
2 #define SCIQLOP_MOCKPLUGIN_H
2 #define SCIQLOP_MOCKPLUGIN_H
3
3
4 #include <Plugin/IPlugin.h>
4 #include <Plugin/IPlugin.h>
5
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7
7
8 #include <memory>
8 #include <memory>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13
13
14 class MockPlugin : public QObject, public IPlugin {
14 class MockPlugin : public QObject, public IPlugin {
15 Q_OBJECT
15 Q_OBJECT
16 Q_INTERFACES(IPlugin)
16 Q_INTERFACES(IPlugin)
17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
18 public:
18 public:
19 /// @sa IPlugin::initialize()
19 /// @sa IPlugin::initialize()
20 void initialize() override;
20 void initialize() override;
21
22 private:
23 /// Creates the data source item relative to the plugin
24 std::unique_ptr<DataSourceItem> createDataSourceItem() const noexcept;
25 };
21 };
26
22
27 #endif // SCIQLOP_MOCKPLUGIN_H
23 #endif // SCIQLOP_MOCKPLUGIN_H
@@ -1,55 +1,79
1 #include <MockPlugin.h>
1 #include "MockPlugin.h"
2 #include "CosinusProvider.h"
2
3
3 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/DataSourceItem.h>
6 #include <DataSource/DataSourceItemAction.h>
5
7
6 #include <SqpApplication.h>
8 #include <SqpApplication.h>
7
9
8 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
10 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9
11
10 namespace {
12 namespace {
11
13
12 /// Name of the data source
14 /// Name of the data source
13 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
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) {
25 auto result = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
20 // Registers to the data source controller
26 QVector<QVariant>{productName});
21 auto &dataSourceController = app->dataSourceController();
22 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
23
27
24 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
28 // Add action to load product from DataSourceController
25 }
29 result->addAction(std::make_unique<DataSourceItemAction>(
26 else {
30 QObject::tr("Load %1 product").arg(productName), [productName](DataSourceItem &item) {
27 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
31 if (auto app = sqpApp) {
28 }
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 // Magnetic field products
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 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
43 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
40 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
44 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
41 magneticFieldFolder->appendChild(std::move(fgmProduct));
45 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("FGM")));
42 magneticFieldFolder->appendChild(std::move(scProduct));
46 magneticFieldFolder->appendChild(createProductItem(QStringLiteral("SC")));
43
47
44 // Electric field products
48 // Electric field products
45 auto electricFieldFolder = std::make_unique<DataSourceItem>(
49 auto electricFieldFolder = std::make_unique<DataSourceItem>(
46 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
50 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
47
51
48 // Root
52 // Root
49 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
53 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
50 QVector<QVariant>{DATA_SOURCE_NAME});
54 QVector<QVariant>{DATA_SOURCE_NAME});
51 root->appendChild(std::move(magneticFieldFolder));
55 root->appendChild(std::move(magneticFieldFolder));
52 root->appendChild(std::move(electricFieldFolder));
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