##// 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 }
@@ -26,6 +26,7
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>
@@ -33,6 +34,7
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>
@@ -75,89 +77,96 MainWindow::MainWindow(QWidget *parent)
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 *)),
@@ -77,7 +77,7
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>
@@ -126,7 +126,7
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>
@@ -152,6 +152,12
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/>
@@ -10,6 +10,7
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
@@ -42,6 +43,23 public:
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();
@@ -6,6 +6,8
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 */
@@ -21,6 +23,16 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
@@ -43,6 +55,8 public:
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
@@ -1,6 +1,8
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
@@ -16,6 +18,8 public:
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)
@@ -59,6 +63,24 void DataSourceController::setDataSourceItem(
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")
@@ -1,10 +1,18
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
@@ -12,6 +20,7 struct DataSourceItem::DataSourceItemPrivate {
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)
@@ -19,6 +28,22 DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> 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;
@@ -45,6 +70,11 QVariant DataSourceItem::data(int dataIndex) const noexcept
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;
@@ -4,3 +4,10 Common/spimpl\.h:\d+:.*
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)
@@ -24,6 +24,9 public:
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;
@@ -1,10 +1,12
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 /**
@@ -26,8 +28,11 public slots:
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
@@ -16,6 +16,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
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 /**
@@ -35,8 +36,9 public:
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;
@@ -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,19 +1,37
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 };
@@ -1,22 +1,40
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 };
@@ -1,19 +1,37
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 };
@@ -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,8 +1,11
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 {
@@ -40,6 +43,9 struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate {
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)
@@ -54,6 +60,21 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const Da
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
@@ -73,3 +94,8 void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &val
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 }
@@ -5,6 +5,8
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
@@ -33,24 +35,18 DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource)
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
@@ -58,6 +54,19 void DataSourceWidget::addDataSource(DataSourceItem *dataSource) noexcept
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 }
@@ -34,13 +34,6 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSideP
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()
@@ -2,6 +2,7
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")
@@ -10,9 +11,11 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
@@ -22,13 +25,18 public:
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
@@ -43,6 +51,11 SqpApplication::SqpApplication(int &argc, char **argv)
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,
@@ -50,6 +63,7 SqpApplication::SqpApplication(int &argc, char **argv)
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
@@ -61,12 +75,17 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,8 +1,21
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 }
@@ -11,3 +24,24 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,6 +1,9
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 {
@@ -11,3 +14,36 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,12 +1,11
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)
@@ -19,6 +18,12 VisualizationWidget::VisualizationWidget(QWidget *parent)
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),
@@ -41,3 +46,35 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,6 +1,8
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 {
@@ -11,3 +13,36 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,9 +1,7
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>
@@ -15,7 +13,20
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,9 +1,7
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>
@@ -15,7 +13,8
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,9 +1,7
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>
@@ -15,7 +13,20
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>
@@ -77,6 +77,12 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_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 #
@@ -16,6 +16,7 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)
@@ -18,10 +18,6 class MockPlugin : public QObject, public IPlugin {
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,7 +1,9
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
@@ -12,34 +14,36 namespace {
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>(
@@ -51,5 +55,25 std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcep
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