@@ -1,44 +1,47 | |||||
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" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
|
6 | #include <QLoggingCategory> | |||
6 | #include <QWidget> |
|
7 | #include <QWidget> | |
7 |
|
8 | |||
8 | #include <memory> |
|
9 | #include <memory> | |
9 |
|
10 | |||
10 | #include <Common/spimpl.h> |
|
11 | #include <Common/spimpl.h> | |
11 |
|
12 | |||
|
13 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphWidget) | |||
|
14 | ||||
12 | class Variable; |
|
15 | class Variable; | |
13 |
|
16 | |||
14 | namespace Ui { |
|
17 | namespace Ui { | |
15 | class VisualizationGraphWidget; |
|
18 | class VisualizationGraphWidget; | |
16 | } // namespace Ui |
|
19 | } // namespace Ui | |
17 |
|
20 | |||
18 | class VisualizationGraphWidget : public QWidget, public IVisualizationWidget { |
|
21 | class VisualizationGraphWidget : public QWidget, public IVisualizationWidget { | |
19 | Q_OBJECT |
|
22 | Q_OBJECT | |
20 |
|
23 | |||
21 | public: |
|
24 | public: | |
22 | explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0); |
|
25 | explicit VisualizationGraphWidget(const QString &name = {}, QWidget *parent = 0); | |
23 | virtual ~VisualizationGraphWidget(); |
|
26 | virtual ~VisualizationGraphWidget(); | |
24 |
|
27 | |||
25 | void addVariable(std::shared_ptr<Variable> variable); |
|
28 | void addVariable(std::shared_ptr<Variable> variable); | |
26 |
|
29 | |||
27 | // IVisualizationWidget interface |
|
30 | // IVisualizationWidget interface | |
28 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
31 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
29 | bool canDrop(const Variable &variable) const override; |
|
32 | bool canDrop(const Variable &variable) const override; | |
30 | void close() override; |
|
33 | void close() override; | |
31 | QString name() const override; |
|
34 | QString name() const override; | |
32 |
|
35 | |||
33 | private: |
|
36 | private: | |
34 | Ui::VisualizationGraphWidget *ui; |
|
37 | Ui::VisualizationGraphWidget *ui; | |
35 |
|
38 | |||
36 | class VisualizationGraphWidgetPrivate; |
|
39 | class VisualizationGraphWidgetPrivate; | |
37 | spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl; |
|
40 | spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl; | |
38 |
|
41 | |||
39 | private slots: |
|
42 | private slots: | |
40 | /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done |
|
43 | /// Slot called when a mouse wheel was made, to perform some processing before the zoom is done | |
41 | void onMouseWheel(QWheelEvent *event) noexcept; |
|
44 | void onMouseWheel(QWheelEvent *event) noexcept; | |
42 | }; |
|
45 | }; | |
43 |
|
46 | |||
44 | #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H |
|
47 | #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H |
@@ -1,51 +1,54 | |||||
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" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
6 | #include <Common/spimpl.h> |
|
6 | #include <Common/spimpl.h> | |
7 |
|
7 | |||
|
8 | #include <QLoggingCategory> | |||
8 | #include <QWidget> |
|
9 | #include <QWidget> | |
9 |
|
10 | |||
|
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationTabWidget) | |||
|
12 | ||||
10 | class Variable; |
|
13 | class Variable; | |
11 | class VisualizationZoneWidget; |
|
14 | class VisualizationZoneWidget; | |
12 |
|
15 | |||
13 | namespace Ui { |
|
16 | namespace Ui { | |
14 | class VisualizationTabWidget; |
|
17 | class VisualizationTabWidget; | |
15 | } // namespace Ui |
|
18 | } // namespace Ui | |
16 |
|
19 | |||
17 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { |
|
20 | class VisualizationTabWidget : public QWidget, public IVisualizationWidget { | |
18 | Q_OBJECT |
|
21 | Q_OBJECT | |
19 |
|
22 | |||
20 | public: |
|
23 | public: | |
21 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); |
|
24 | explicit VisualizationTabWidget(const QString &name = {}, QWidget *parent = 0); | |
22 | virtual ~VisualizationTabWidget(); |
|
25 | virtual ~VisualizationTabWidget(); | |
23 |
|
26 | |||
24 | /// Add a zone widget |
|
27 | /// Add a zone widget | |
25 | void addZone(VisualizationZoneWidget *zoneWidget); |
|
28 | void addZone(VisualizationZoneWidget *zoneWidget); | |
26 |
|
29 | |||
27 | /** |
|
30 | /** | |
28 | * Creates a zone using a variable. The variable will be displayed in a new graph of the new |
|
31 | * Creates a zone using a variable. The variable will be displayed in a new graph of the new | |
29 | * zone. |
|
32 | * zone. | |
30 | * @param variable the variable for which to create the zone |
|
33 | * @param variable the variable for which to create the zone | |
31 | * @return the pointer to the created zone |
|
34 | * @return the pointer to the created zone | |
32 | */ |
|
35 | */ | |
33 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); |
|
36 | VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable); | |
34 |
|
37 | |||
35 | /// Remove a zone |
|
38 | /// Remove a zone | |
36 | void removeZone(VisualizationZoneWidget *zone); |
|
39 | void removeZone(VisualizationZoneWidget *zone); | |
37 |
|
40 | |||
38 | // IVisualizationWidget interface |
|
41 | // IVisualizationWidget interface | |
39 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
42 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
40 | bool canDrop(const Variable &variable) const override; |
|
43 | bool canDrop(const Variable &variable) const override; | |
41 | void close() override; |
|
44 | void close() override; | |
42 | QString name() const override; |
|
45 | QString name() const override; | |
43 |
|
46 | |||
44 | private: |
|
47 | private: | |
45 | Ui::VisualizationTabWidget *ui; |
|
48 | Ui::VisualizationTabWidget *ui; | |
46 |
|
49 | |||
47 | class VisualizationTabWidgetPrivate; |
|
50 | class VisualizationTabWidgetPrivate; | |
48 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; |
|
51 | spimpl::unique_impl_ptr<VisualizationTabWidgetPrivate> impl; | |
49 | }; |
|
52 | }; | |
50 |
|
53 | |||
51 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
|
54 | #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H |
@@ -1,53 +1,53 | |||||
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" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
6 | #include <QLoggingCategory> |
|
6 | #include <QLoggingCategory> | |
7 | #include <QWidget> |
|
7 | #include <QWidget> | |
8 |
|
8 | |||
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) | |||
|
10 | ||||
9 | class Variable; |
|
11 | class Variable; | |
10 | class VisualizationTabWidget; |
|
12 | class VisualizationTabWidget; | |
11 |
|
13 | |||
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) |
|
|||
13 |
|
||||
14 | namespace Ui { |
|
14 | namespace Ui { | |
15 | class VisualizationWidget; |
|
15 | class VisualizationWidget; | |
16 | } // namespace Ui |
|
16 | } // namespace Ui | |
17 |
|
17 | |||
18 | class VisualizationWidget : public QWidget, public IVisualizationWidget { |
|
18 | class VisualizationWidget : public QWidget, public IVisualizationWidget { | |
19 | Q_OBJECT |
|
19 | Q_OBJECT | |
20 |
|
20 | |||
21 | public: |
|
21 | public: | |
22 | explicit VisualizationWidget(QWidget *parent = 0); |
|
22 | explicit VisualizationWidget(QWidget *parent = 0); | |
23 | virtual ~VisualizationWidget(); |
|
23 | virtual ~VisualizationWidget(); | |
24 |
|
24 | |||
25 | /// Add a zone widget |
|
25 | /// Add a zone widget | |
26 | virtual void addTab(VisualizationTabWidget *tabWidget); |
|
26 | virtual void addTab(VisualizationTabWidget *tabWidget); | |
27 |
|
27 | |||
28 | /// Create a tab using a Variable |
|
28 | /// Create a tab using a Variable | |
29 | VisualizationTabWidget *createTab(); |
|
29 | VisualizationTabWidget *createTab(); | |
30 |
|
30 | |||
31 | /// Remove a tab |
|
31 | /// Remove a tab | |
32 | void removeTab(VisualizationTabWidget *tab); |
|
32 | void removeTab(VisualizationTabWidget *tab); | |
33 |
|
33 | |||
34 | // IVisualizationWidget interface |
|
34 | // IVisualizationWidget interface | |
35 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
35 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
36 | bool canDrop(const Variable &variable) const override; |
|
36 | bool canDrop(const Variable &variable) const override; | |
37 | void close() override; |
|
37 | void close() override; | |
38 | QString name() const override; |
|
38 | QString name() const override; | |
39 |
|
39 | |||
40 | public slots: |
|
40 | public slots: | |
41 | /** |
|
41 | /** | |
42 | * Displays a variable in a new graph of a new zone of the current tab |
|
42 | * Displays a variable in a new graph of a new zone of the current tab | |
43 | * @param variable the variable to display |
|
43 | * @param variable the variable to display | |
44 | * @todo this is a temporary method that will be replaced by own actions for each type of |
|
44 | * @todo this is a temporary method that will be replaced by own actions for each type of | |
45 | * visualization widget |
|
45 | * visualization widget | |
46 | */ |
|
46 | */ | |
47 | void displayVariable(std::shared_ptr<Variable> variable) noexcept; |
|
47 | void displayVariable(std::shared_ptr<Variable> variable) noexcept; | |
48 |
|
48 | |||
49 | private: |
|
49 | private: | |
50 | Ui::VisualizationWidget *ui; |
|
50 | Ui::VisualizationWidget *ui; | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | #endif // VISUALIZATIONWIDGET_H |
|
53 | #endif // VISUALIZATIONWIDGET_H |
@@ -1,45 +1,48 | |||||
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" |
|
4 | #include "Visualization/IVisualizationWidget.h" | |
5 |
|
5 | |||
|
6 | #include <QLoggingCategory> | |||
6 | #include <QWidget> |
|
7 | #include <QWidget> | |
7 |
|
8 | |||
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationZoneWidget) | |||
|
10 | ||||
8 | namespace Ui { |
|
11 | namespace Ui { | |
9 | class VisualizationZoneWidget; |
|
12 | class VisualizationZoneWidget; | |
10 | } // Ui |
|
13 | } // Ui | |
11 |
|
14 | |||
12 | class Variable; |
|
15 | class Variable; | |
13 | class VisualizationGraphWidget; |
|
16 | class VisualizationGraphWidget; | |
14 |
|
17 | |||
15 | class VisualizationZoneWidget : public QWidget, public IVisualizationWidget { |
|
18 | class VisualizationZoneWidget : public QWidget, public IVisualizationWidget { | |
16 | Q_OBJECT |
|
19 | Q_OBJECT | |
17 |
|
20 | |||
18 | public: |
|
21 | public: | |
19 | explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0); |
|
22 | explicit VisualizationZoneWidget(const QString &name = {}, QWidget *parent = 0); | |
20 | virtual ~VisualizationZoneWidget(); |
|
23 | virtual ~VisualizationZoneWidget(); | |
21 |
|
24 | |||
22 | /// Add a graph widget |
|
25 | /// Add a graph widget | |
23 | void addGraph(VisualizationGraphWidget *graphWidget); |
|
26 | void addGraph(VisualizationGraphWidget *graphWidget); | |
24 |
|
27 | |||
25 | /** |
|
28 | /** | |
26 | * Creates a graph using a variable. The variable will be displayed in the new graph. |
|
29 | * Creates a graph using a variable. The variable will be displayed in the new graph. | |
27 | * @param variable the variable for which to create the graph |
|
30 | * @param variable the variable for which to create the graph | |
28 | * @return the pointer to the created graph |
|
31 | * @return the pointer to the created graph | |
29 | */ |
|
32 | */ | |
30 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable); |
|
33 | VisualizationGraphWidget *createGraph(std::shared_ptr<Variable> variable); | |
31 |
|
34 | |||
32 | /// Remove a graph |
|
35 | /// Remove a graph | |
33 | void removeGraph(VisualizationGraphWidget *graph); |
|
36 | void removeGraph(VisualizationGraphWidget *graph); | |
34 |
|
37 | |||
35 | // IVisualizationWidget interface |
|
38 | // IVisualizationWidget interface | |
36 | void accept(IVisualizationWidgetVisitor *visitor) override; |
|
39 | void accept(IVisualizationWidgetVisitor *visitor) override; | |
37 | bool canDrop(const Variable &variable) const override; |
|
40 | bool canDrop(const Variable &variable) const override; | |
38 | void close() override; |
|
41 | void close() override; | |
39 | QString name() const override; |
|
42 | QString name() const override; | |
40 |
|
43 | |||
41 | private: |
|
44 | private: | |
42 | Ui::VisualizationZoneWidget *ui; |
|
45 | Ui::VisualizationZoneWidget *ui; | |
43 | }; |
|
46 | }; | |
44 |
|
47 | |||
45 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
|
48 | #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H |
@@ -1,105 +1,111 | |||||
1 | #include "Visualization/VisualizationGraphWidget.h" |
|
1 | #include "Visualization/VisualizationGraphWidget.h" | |
2 | #include "Visualization/GraphPlottablesFactory.h" |
|
2 | #include "Visualization/GraphPlottablesFactory.h" | |
3 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
3 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
4 | #include "ui_VisualizationGraphWidget.h" |
|
4 | #include "ui_VisualizationGraphWidget.h" | |
5 |
|
5 | |||
6 | #include <Variable/Variable.h> |
|
6 | #include <Variable/Variable.h> | |
7 |
|
7 | |||
8 | #include <unordered_map> |
|
8 | #include <unordered_map> | |
9 |
|
9 | |||
|
10 | Q_LOGGING_CATEGORY(LOG_VisualizationGraphWidget, "VisualizationGraphWidget") | |||
|
11 | ||||
10 | namespace { |
|
12 | namespace { | |
11 |
|
13 | |||
12 | /// Key pressed to enable zoom on horizontal axis |
|
14 | /// Key pressed to enable zoom on horizontal axis | |
13 | const auto HORIZONTAL_ZOOM_MODIFIER = Qt::NoModifier; |
|
15 | const auto HORIZONTAL_ZOOM_MODIFIER = Qt::NoModifier; | |
14 |
|
16 | |||
15 | /// Key pressed to enable zoom on vertical axis |
|
17 | /// Key pressed to enable zoom on vertical axis | |
16 | const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier; |
|
18 | const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier; | |
17 |
|
19 | |||
18 | } // namespace |
|
20 | } // namespace | |
19 |
|
21 | |||
20 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { |
|
22 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { | |
21 |
|
23 | |||
22 | // 1 variable -> n qcpplot |
|
24 | // 1 variable -> n qcpplot | |
23 | std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap; |
|
25 | std::unordered_map<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMap; | |
24 | }; |
|
26 | }; | |
25 |
|
27 | |||
26 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) |
|
28 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) | |
27 | : QWidget{parent}, |
|
29 | : QWidget{parent}, | |
28 | ui{new Ui::VisualizationGraphWidget}, |
|
30 | ui{new Ui::VisualizationGraphWidget}, | |
29 | impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()} |
|
31 | impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()} | |
30 | { |
|
32 | { | |
31 | ui->setupUi(this); |
|
33 | ui->setupUi(this); | |
32 |
|
34 | |||
33 | // qcpplot title |
|
35 | // qcpplot title | |
34 | ui->widget->plotLayout()->insertRow(0); |
|
36 | ui->widget->plotLayout()->insertRow(0); | |
35 | ui->widget->plotLayout()->addElement(0, 0, new QCPTextElement{ui->widget, name}); |
|
37 | ui->widget->plotLayout()->addElement(0, 0, new QCPTextElement{ui->widget, name}); | |
36 |
|
38 | |||
37 | // Set qcpplot properties : |
|
39 | // Set qcpplot properties : | |
38 | // - Drag (on x-axis) and zoom are enabled |
|
40 | // - Drag (on x-axis) and zoom are enabled | |
39 | // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation |
|
41 | // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation | |
40 | ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); |
|
42 | ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); | |
41 | ui->widget->axisRect()->setRangeDrag(Qt::Horizontal); |
|
43 | ui->widget->axisRect()->setRangeDrag(Qt::Horizontal); | |
42 | connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel); |
|
44 | connect(ui->widget, &QCustomPlot::mouseWheel, this, &VisualizationGraphWidget::onMouseWheel); | |
43 | } |
|
45 | } | |
44 |
|
46 | |||
45 | VisualizationGraphWidget::~VisualizationGraphWidget() |
|
47 | VisualizationGraphWidget::~VisualizationGraphWidget() | |
46 | { |
|
48 | { | |
47 | delete ui; |
|
49 | delete ui; | |
48 | } |
|
50 | } | |
49 |
|
51 | |||
50 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) |
|
52 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) | |
51 | { |
|
53 | { | |
52 | // Uses delegate to create the qcpplot components according to the variable |
|
54 | // Uses delegate to create the qcpplot components according to the variable | |
53 | auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget); |
|
55 | auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget); | |
54 |
|
56 | |||
55 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
57 | for (auto createdPlottable : qAsConst(createdPlottables)) { | |
56 | impl->m_VariableToPlotMap.insert({variable, createdPlottable}); |
|
58 | impl->m_VariableToPlotMap.insert({variable, createdPlottable}); | |
57 | } |
|
59 | } | |
58 | } |
|
60 | } | |
59 |
|
61 | |||
60 | void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
62 | void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor) | |
61 | { |
|
63 | { | |
62 | if (visitor) { |
|
64 | if (visitor) { | |
63 | visitor->visit(this); |
|
65 | visitor->visit(this); | |
64 | } |
|
66 | } | |
|
67 | else { | |||
|
68 | qCCritical(LOG_VisualizationGraphWidget()) | |||
|
69 | << tr("Can't visit widget : the visitor is null"); | |||
|
70 | } | |||
65 | } |
|
71 | } | |
66 |
|
72 | |||
67 | bool VisualizationGraphWidget::canDrop(const Variable &variable) const |
|
73 | bool VisualizationGraphWidget::canDrop(const Variable &variable) const | |
68 | { |
|
74 | { | |
69 | /// @todo : for the moment, a graph can always accomodate a variable |
|
75 | /// @todo : for the moment, a graph can always accomodate a variable | |
70 | Q_UNUSED(variable); |
|
76 | Q_UNUSED(variable); | |
71 | return true; |
|
77 | return true; | |
72 | } |
|
78 | } | |
73 |
|
79 | |||
74 | void VisualizationGraphWidget::close() |
|
80 | void VisualizationGraphWidget::close() | |
75 | { |
|
81 | { | |
76 | // The main view cannot be directly closed. |
|
82 | // The main view cannot be directly closed. | |
77 | return; |
|
83 | return; | |
78 | } |
|
84 | } | |
79 |
|
85 | |||
80 | QString VisualizationGraphWidget::name() const |
|
86 | QString VisualizationGraphWidget::name() const | |
81 | { |
|
87 | { | |
82 | if (auto title = dynamic_cast<QCPTextElement *>(ui->widget->plotLayout()->elementAt(0))) { |
|
88 | if (auto title = dynamic_cast<QCPTextElement *>(ui->widget->plotLayout()->elementAt(0))) { | |
83 | return title->text(); |
|
89 | return title->text(); | |
84 | } |
|
90 | } | |
85 | else { |
|
91 | else { | |
86 | return QString{}; |
|
92 | return QString{}; | |
87 | } |
|
93 | } | |
88 | } |
|
94 | } | |
89 |
|
95 | |||
90 | void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept |
|
96 | void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept | |
91 | { |
|
97 | { | |
92 | auto zoomOrientations = QFlags<Qt::Orientation>{}; |
|
98 | auto zoomOrientations = QFlags<Qt::Orientation>{}; | |
93 |
|
99 | |||
94 | // Lambda that enables a zoom orientation if the key modifier related to this orientation has |
|
100 | // Lambda that enables a zoom orientation if the key modifier related to this orientation has | |
95 | // been pressed |
|
101 | // been pressed | |
96 | auto enableOrientation |
|
102 | auto enableOrientation | |
97 | = [&zoomOrientations, event](const auto &orientation, const auto &modifier) { |
|
103 | = [&zoomOrientations, event](const auto &orientation, const auto &modifier) { | |
98 | auto orientationEnabled = event->modifiers().testFlag(modifier); |
|
104 | auto orientationEnabled = event->modifiers().testFlag(modifier); | |
99 | zoomOrientations.setFlag(orientation, orientationEnabled); |
|
105 | zoomOrientations.setFlag(orientation, orientationEnabled); | |
100 | }; |
|
106 | }; | |
101 | enableOrientation(Qt::Vertical, VERTICAL_ZOOM_MODIFIER); |
|
107 | enableOrientation(Qt::Vertical, VERTICAL_ZOOM_MODIFIER); | |
102 | enableOrientation(Qt::Horizontal, HORIZONTAL_ZOOM_MODIFIER); |
|
108 | enableOrientation(Qt::Horizontal, HORIZONTAL_ZOOM_MODIFIER); | |
103 |
|
109 | |||
104 | ui->widget->axisRect()->setRangeZoom(zoomOrientations); |
|
110 | ui->widget->axisRect()->setRangeZoom(zoomOrientations); | |
105 | } |
|
111 | } |
@@ -1,99 +1,104 | |||||
1 | #include "Visualization/VisualizationTabWidget.h" |
|
1 | #include "Visualization/VisualizationTabWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "ui_VisualizationTabWidget.h" |
|
3 | #include "ui_VisualizationTabWidget.h" | |
4 |
|
4 | |||
5 | #include "Visualization/VisualizationZoneWidget.h" |
|
5 | #include "Visualization/VisualizationZoneWidget.h" | |
6 |
|
6 | |||
|
7 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") | |||
|
8 | ||||
7 | namespace { |
|
9 | namespace { | |
8 |
|
10 | |||
9 | /// Generates a default name for a new zone, according to the number of zones already displayed in |
|
11 | /// Generates a default name for a new zone, according to the number of zones already displayed in | |
10 | /// the tab |
|
12 | /// the tab | |
11 | QString defaultZoneName(const QLayout &layout) |
|
13 | QString defaultZoneName(const QLayout &layout) | |
12 | { |
|
14 | { | |
13 | auto count = 0; |
|
15 | auto count = 0; | |
14 | for (auto i = 0; i < layout.count(); ++i) { |
|
16 | for (auto i = 0; i < layout.count(); ++i) { | |
15 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { |
|
17 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { | |
16 | count++; |
|
18 | count++; | |
17 | } |
|
19 | } | |
18 | } |
|
20 | } | |
19 |
|
21 | |||
20 | return QObject::tr("Zone %1").arg(count + 1); |
|
22 | return QObject::tr("Zone %1").arg(count + 1); | |
21 | } |
|
23 | } | |
22 |
|
24 | |||
23 | } // namespace |
|
25 | } // namespace | |
24 |
|
26 | |||
25 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { |
|
27 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |
26 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} |
|
28 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} | |
27 |
|
29 | |||
28 | QString m_Name; |
|
30 | QString m_Name; | |
29 | }; |
|
31 | }; | |
30 |
|
32 | |||
31 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) |
|
33 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) | |
32 | : QWidget{parent}, |
|
34 | : QWidget{parent}, | |
33 | ui{new Ui::VisualizationTabWidget}, |
|
35 | ui{new Ui::VisualizationTabWidget}, | |
34 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} |
|
36 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} | |
35 | { |
|
37 | { | |
36 | ui->setupUi(this); |
|
38 | ui->setupUi(this); | |
37 | } |
|
39 | } | |
38 |
|
40 | |||
39 | VisualizationTabWidget::~VisualizationTabWidget() |
|
41 | VisualizationTabWidget::~VisualizationTabWidget() | |
40 | { |
|
42 | { | |
41 | delete ui; |
|
43 | delete ui; | |
42 | } |
|
44 | } | |
43 |
|
45 | |||
44 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) |
|
46 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) | |
45 | { |
|
47 | { | |
46 | this->layout()->addWidget(zoneWidget); |
|
48 | this->layout()->addWidget(zoneWidget); | |
47 | } |
|
49 | } | |
48 |
|
50 | |||
49 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) |
|
51 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) | |
50 | { |
|
52 | { | |
51 | auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this}; |
|
53 | auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this}; | |
52 | this->addZone(zoneWidget); |
|
54 | this->addZone(zoneWidget); | |
53 |
|
55 | |||
54 | // Creates a new graph into the zone |
|
56 | // Creates a new graph into the zone | |
55 | zoneWidget->createGraph(variable); |
|
57 | zoneWidget->createGraph(variable); | |
56 |
|
58 | |||
57 | return zoneWidget; |
|
59 | return zoneWidget; | |
58 | } |
|
60 | } | |
59 |
|
61 | |||
60 | void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone) |
|
62 | void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone) | |
61 | { |
|
63 | { | |
62 | } |
|
64 | } | |
63 |
|
65 | |||
64 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
66 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) | |
65 | { |
|
67 | { | |
66 | if (visitor) { |
|
68 | if (visitor) { | |
67 | visitor->visitEnter(this); |
|
69 | visitor->visitEnter(this); | |
68 |
|
70 | |||
69 | // Apply visitor to zone children |
|
71 | // Apply visitor to zone children | |
70 | for (auto i = 0; i < layout()->count(); ++i) { |
|
72 | for (auto i = 0; i < layout()->count(); ++i) { | |
71 | if (auto item = layout()->itemAt(i)) { |
|
73 | if (auto item = layout()->itemAt(i)) { | |
72 | if (auto visualizationZoneWidget |
|
74 | if (auto visualizationZoneWidget | |
73 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { |
|
75 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { | |
74 | visualizationZoneWidget->accept(visitor); |
|
76 | visualizationZoneWidget->accept(visitor); | |
75 | } |
|
77 | } | |
76 | } |
|
78 | } | |
77 | } |
|
79 | } | |
78 |
|
80 | |||
79 | visitor->visitLeave(this); |
|
81 | visitor->visitLeave(this); | |
80 | } |
|
82 | } | |
|
83 | else { | |||
|
84 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); | |||
|
85 | } | |||
81 | } |
|
86 | } | |
82 |
|
87 | |||
83 | bool VisualizationTabWidget::canDrop(const Variable &variable) const |
|
88 | bool VisualizationTabWidget::canDrop(const Variable &variable) const | |
84 | { |
|
89 | { | |
85 | // A tab can always accomodate a variable |
|
90 | // A tab can always accomodate a variable | |
86 | Q_UNUSED(variable); |
|
91 | Q_UNUSED(variable); | |
87 | return true; |
|
92 | return true; | |
88 | } |
|
93 | } | |
89 |
|
94 | |||
90 | void VisualizationTabWidget::close() |
|
95 | void VisualizationTabWidget::close() | |
91 | { |
|
96 | { | |
92 | // The main view cannot be directly closed. |
|
97 | // The main view cannot be directly closed. | |
93 | return; |
|
98 | return; | |
94 | } |
|
99 | } | |
95 |
|
100 | |||
96 | QString VisualizationTabWidget::name() const |
|
101 | QString VisualizationTabWidget::name() const | |
97 | { |
|
102 | { | |
98 | return impl->m_Name; |
|
103 | return impl->m_Name; | |
99 | } |
|
104 | } |
@@ -1,132 +1,135 | |||||
1 | #include "Visualization/VisualizationWidget.h" |
|
1 | #include "Visualization/VisualizationWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "Visualization/VisualizationGraphWidget.h" |
|
3 | #include "Visualization/VisualizationGraphWidget.h" | |
4 | #include "Visualization/VisualizationTabWidget.h" |
|
4 | #include "Visualization/VisualizationTabWidget.h" | |
5 | #include "Visualization/VisualizationZoneWidget.h" |
|
5 | #include "Visualization/VisualizationZoneWidget.h" | |
6 | #include "Visualization/qcustomplot.h" |
|
6 | #include "Visualization/qcustomplot.h" | |
7 |
|
7 | |||
8 | #include "ui_VisualizationWidget.h" |
|
8 | #include "ui_VisualizationWidget.h" | |
9 |
|
9 | |||
10 | #include <QToolButton> |
|
10 | #include <QToolButton> | |
11 |
|
11 | |||
12 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") |
|
12 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | |
13 |
|
13 | |||
14 | VisualizationWidget::VisualizationWidget(QWidget *parent) |
|
14 | VisualizationWidget::VisualizationWidget(QWidget *parent) | |
15 | : QWidget{parent}, ui{new Ui::VisualizationWidget} |
|
15 | : QWidget{parent}, ui{new Ui::VisualizationWidget} | |
16 | { |
|
16 | { | |
17 | ui->setupUi(this); |
|
17 | ui->setupUi(this); | |
18 |
|
18 | |||
19 | auto addTabViewButton = new QToolButton{ui->tabWidget}; |
|
19 | auto addTabViewButton = new QToolButton{ui->tabWidget}; | |
20 | addTabViewButton->setText(tr("Add View")); |
|
20 | addTabViewButton->setText(tr("Add View")); | |
21 | addTabViewButton->setCursor(Qt::ArrowCursor); |
|
21 | addTabViewButton->setCursor(Qt::ArrowCursor); | |
22 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); |
|
22 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | |
23 |
|
23 | |||
24 | auto enableMinimumCornerWidgetSize = [this](bool enable) { |
|
24 | auto enableMinimumCornerWidgetSize = [this](bool enable) { | |
25 |
|
25 | |||
26 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); |
|
26 | auto tabViewCornerWidget = ui->tabWidget->cornerWidget(); | |
27 | auto width = enable ? tabViewCornerWidget->width() : 0; |
|
27 | auto width = enable ? tabViewCornerWidget->width() : 0; | |
28 | auto height = enable ? tabViewCornerWidget->height() : 0; |
|
28 | auto height = enable ? tabViewCornerWidget->height() : 0; | |
29 | tabViewCornerWidget->setMinimumHeight(height); |
|
29 | tabViewCornerWidget->setMinimumHeight(height); | |
30 | tabViewCornerWidget->setMinimumWidth(width); |
|
30 | tabViewCornerWidget->setMinimumWidth(width); | |
31 | ui->tabWidget->setMinimumHeight(height); |
|
31 | ui->tabWidget->setMinimumHeight(height); | |
32 | ui->tabWidget->setMinimumWidth(width); |
|
32 | ui->tabWidget->setMinimumWidth(width); | |
33 | }; |
|
33 | }; | |
34 |
|
34 | |||
35 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { |
|
35 | auto addTabView = [this, enableMinimumCornerWidgetSize]() { | |
36 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), |
|
36 | auto widget = new VisualizationTabWidget{QString{"View %1"}.arg(ui->tabWidget->count() + 1), | |
37 | ui->tabWidget}; |
|
37 | ui->tabWidget}; | |
38 | auto index = ui->tabWidget->addTab(widget, widget->name()); |
|
38 | auto index = ui->tabWidget->addTab(widget, widget->name()); | |
39 | if (ui->tabWidget->count() > 0) { |
|
39 | if (ui->tabWidget->count() > 0) { | |
40 | enableMinimumCornerWidgetSize(false); |
|
40 | enableMinimumCornerWidgetSize(false); | |
41 | } |
|
41 | } | |
42 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); |
|
42 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | |
43 | }; |
|
43 | }; | |
44 |
|
44 | |||
45 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { |
|
45 | auto removeTabView = [this, enableMinimumCornerWidgetSize](int index) { | |
46 | if (ui->tabWidget->count() == 1) { |
|
46 | if (ui->tabWidget->count() == 1) { | |
47 | enableMinimumCornerWidgetSize(true); |
|
47 | enableMinimumCornerWidgetSize(true); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | ui->tabWidget->removeTab(index); |
|
50 | ui->tabWidget->removeTab(index); | |
51 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); |
|
51 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | |
52 |
|
52 | |||
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | ui->tabWidget->setTabsClosable(true); |
|
55 | ui->tabWidget->setTabsClosable(true); | |
56 |
|
56 | |||
57 | connect(addTabViewButton, &QToolButton::clicked, addTabView); |
|
57 | connect(addTabViewButton, &QToolButton::clicked, addTabView); | |
58 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); |
|
58 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); | |
59 |
|
59 | |||
60 | // Adds default tab |
|
60 | // Adds default tab | |
61 | addTabView(); |
|
61 | addTabView(); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | VisualizationWidget::~VisualizationWidget() |
|
64 | VisualizationWidget::~VisualizationWidget() | |
65 | { |
|
65 | { | |
66 | delete ui; |
|
66 | delete ui; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget) |
|
69 | void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget) | |
70 | { |
|
70 | { | |
71 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as |
|
71 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as | |
72 | // lambda function (in the constructor) |
|
72 | // lambda function (in the constructor) | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | VisualizationTabWidget *VisualizationWidget::createTab() |
|
75 | VisualizationTabWidget *VisualizationWidget::createTab() | |
76 | { |
|
76 | { | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void VisualizationWidget::removeTab(VisualizationTabWidget *tab) |
|
79 | void VisualizationWidget::removeTab(VisualizationTabWidget *tab) | |
80 | { |
|
80 | { | |
81 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as |
|
81 | // NOTE: check is this method has to be deleted because of its dupplicated version visible as | |
82 | // lambda function (in the constructor) |
|
82 | // lambda function (in the constructor) | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
85 | void VisualizationWidget::accept(IVisualizationWidgetVisitor *visitor) | |
86 | { |
|
86 | { | |
87 | if (visitor) { |
|
87 | if (visitor) { | |
88 | visitor->visitEnter(this); |
|
88 | visitor->visitEnter(this); | |
89 |
|
89 | |||
90 | // Apply visitor for tab children |
|
90 | // Apply visitor for tab children | |
91 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { |
|
91 | for (auto i = 0; i < ui->tabWidget->count(); ++i) { | |
92 | if (auto visualizationTabWidget |
|
92 | if (auto visualizationTabWidget | |
93 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
93 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
94 | visualizationTabWidget->accept(visitor); |
|
94 | visualizationTabWidget->accept(visitor); | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | visitor->visitLeave(this); |
|
98 | visitor->visitLeave(this); | |
99 | } |
|
99 | } | |
|
100 | else { | |||
|
101 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); | |||
|
102 | } | |||
100 | } |
|
103 | } | |
101 |
|
104 | |||
102 | bool VisualizationWidget::canDrop(const Variable &variable) const |
|
105 | bool VisualizationWidget::canDrop(const Variable &variable) const | |
103 | { |
|
106 | { | |
104 | // The main widget can never accomodate a variable |
|
107 | // The main widget can never accomodate a variable | |
105 | Q_UNUSED(variable); |
|
108 | Q_UNUSED(variable); | |
106 | return false; |
|
109 | return false; | |
107 | } |
|
110 | } | |
108 |
|
111 | |||
109 | void VisualizationWidget::close() |
|
112 | void VisualizationWidget::close() | |
110 | { |
|
113 | { | |
111 | // The main view cannot be directly closed. |
|
114 | // The main view cannot be directly closed. | |
112 | return; |
|
115 | return; | |
113 | } |
|
116 | } | |
114 |
|
117 | |||
115 | QString VisualizationWidget::name() const |
|
118 | QString VisualizationWidget::name() const | |
116 | { |
|
119 | { | |
117 | return QStringLiteral("MainView"); |
|
120 | return QStringLiteral("MainView"); | |
118 | } |
|
121 | } | |
119 |
|
122 | |||
120 | void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept |
|
123 | void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept | |
121 | { |
|
124 | { | |
122 | if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { |
|
125 | if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { | |
123 | if (!currentTab->createZone(variable)) { |
|
126 | if (!currentTab->createZone(variable)) { | |
124 | qCCritical(LOG_VisualizationWidget()) |
|
127 | qCCritical(LOG_VisualizationWidget()) | |
125 | << tr("Can't display the variable : can't create a new zone in the current tab"); |
|
128 | << tr("Can't display the variable : can't create a new zone in the current tab"); | |
126 | } |
|
129 | } | |
127 | } |
|
130 | } | |
128 | else { |
|
131 | else { | |
129 | qCCritical(LOG_VisualizationWidget()) |
|
132 | qCCritical(LOG_VisualizationWidget()) | |
130 | << tr("Can't display the variable : there is no current tab"); |
|
133 | << tr("Can't display the variable : there is no current tab"); | |
131 | } |
|
134 | } | |
132 | } |
|
135 | } |
@@ -1,94 +1,99 | |||||
1 | #include "Visualization/VisualizationZoneWidget.h" |
|
1 | #include "Visualization/VisualizationZoneWidget.h" | |
2 | #include "Visualization/IVisualizationWidgetVisitor.h" |
|
2 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
3 | #include "ui_VisualizationZoneWidget.h" |
|
3 | #include "ui_VisualizationZoneWidget.h" | |
4 |
|
4 | |||
5 | #include "Visualization/VisualizationGraphWidget.h" |
|
5 | #include "Visualization/VisualizationGraphWidget.h" | |
6 |
|
6 | |||
|
7 | Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget") | |||
|
8 | ||||
7 | namespace { |
|
9 | namespace { | |
8 |
|
10 | |||
9 | /// Generates a default name for a new graph, according to the number of graphs already displayed in |
|
11 | /// Generates a default name for a new graph, according to the number of graphs already displayed in | |
10 | /// the zone |
|
12 | /// the zone | |
11 | QString defaultGraphName(const QLayout &layout) |
|
13 | QString defaultGraphName(const QLayout &layout) | |
12 | { |
|
14 | { | |
13 | auto count = 0; |
|
15 | auto count = 0; | |
14 | for (auto i = 0; i < layout.count(); ++i) { |
|
16 | for (auto i = 0; i < layout.count(); ++i) { | |
15 | if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) { |
|
17 | if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) { | |
16 | count++; |
|
18 | count++; | |
17 | } |
|
19 | } | |
18 | } |
|
20 | } | |
19 |
|
21 | |||
20 | return QObject::tr("Graph %1").arg(count + 1); |
|
22 | return QObject::tr("Graph %1").arg(count + 1); | |
21 | } |
|
23 | } | |
22 |
|
24 | |||
23 | } // namespace |
|
25 | } // namespace | |
24 |
|
26 | |||
25 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) |
|
27 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) | |
26 | : QWidget{parent}, ui{new Ui::VisualizationZoneWidget} |
|
28 | : QWidget{parent}, ui{new Ui::VisualizationZoneWidget} | |
27 | { |
|
29 | { | |
28 | ui->setupUi(this); |
|
30 | ui->setupUi(this); | |
29 |
|
31 | |||
30 | ui->zoneNameLabel->setText(name); |
|
32 | ui->zoneNameLabel->setText(name); | |
31 | } |
|
33 | } | |
32 |
|
34 | |||
33 | VisualizationZoneWidget::~VisualizationZoneWidget() |
|
35 | VisualizationZoneWidget::~VisualizationZoneWidget() | |
34 | { |
|
36 | { | |
35 | delete ui; |
|
37 | delete ui; | |
36 | } |
|
38 | } | |
37 |
|
39 | |||
38 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) |
|
40 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) | |
39 | { |
|
41 | { | |
40 | ui->visualizationZoneFrame->layout()->addWidget(graphWidget); |
|
42 | ui->visualizationZoneFrame->layout()->addWidget(graphWidget); | |
41 | } |
|
43 | } | |
42 |
|
44 | |||
43 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) |
|
45 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) | |
44 | { |
|
46 | { | |
45 | auto graphWidget = new VisualizationGraphWidget{ |
|
47 | auto graphWidget = new VisualizationGraphWidget{ | |
46 | defaultGraphName(*ui->visualizationZoneFrame->layout()), this}; |
|
48 | defaultGraphName(*ui->visualizationZoneFrame->layout()), this}; | |
47 | this->addGraph(graphWidget); |
|
49 | this->addGraph(graphWidget); | |
48 |
|
50 | |||
49 | graphWidget->addVariable(variable); |
|
51 | graphWidget->addVariable(variable); | |
50 |
|
52 | |||
51 | return graphWidget; |
|
53 | return graphWidget; | |
52 | } |
|
54 | } | |
53 |
|
55 | |||
54 | void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph) |
|
56 | void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph) | |
55 | { |
|
57 | { | |
56 | } |
|
58 | } | |
57 |
|
59 | |||
58 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
60 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) | |
59 | { |
|
61 | { | |
60 | if (visitor) { |
|
62 | if (visitor) { | |
61 | visitor->visitEnter(this); |
|
63 | visitor->visitEnter(this); | |
62 |
|
64 | |||
63 | // Apply visitor to graph children |
|
65 | // Apply visitor to graph children | |
64 | auto layout = ui->visualizationZoneFrame->layout(); |
|
66 | auto layout = ui->visualizationZoneFrame->layout(); | |
65 | for (auto i = 0; i < layout->count(); ++i) { |
|
67 | for (auto i = 0; i < layout->count(); ++i) { | |
66 | if (auto item = layout->itemAt(i)) { |
|
68 | if (auto item = layout->itemAt(i)) { | |
67 | if (auto visualizationGraphWidget |
|
69 | if (auto visualizationGraphWidget | |
68 | = dynamic_cast<VisualizationGraphWidget *>(item->widget())) { |
|
70 | = dynamic_cast<VisualizationGraphWidget *>(item->widget())) { | |
69 | visualizationGraphWidget->accept(visitor); |
|
71 | visualizationGraphWidget->accept(visitor); | |
70 | } |
|
72 | } | |
71 | } |
|
73 | } | |
72 | } |
|
74 | } | |
73 |
|
75 | |||
74 | visitor->visitLeave(this); |
|
76 | visitor->visitLeave(this); | |
75 | } |
|
77 | } | |
|
78 | else { | |||
|
79 | qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null"); | |||
|
80 | } | |||
76 | } |
|
81 | } | |
77 |
|
82 | |||
78 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const |
|
83 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const | |
79 | { |
|
84 | { | |
80 | // A tab can always accomodate a variable |
|
85 | // A tab can always accomodate a variable | |
81 | Q_UNUSED(variable); |
|
86 | Q_UNUSED(variable); | |
82 | return true; |
|
87 | return true; | |
83 | } |
|
88 | } | |
84 |
|
89 | |||
85 | void VisualizationZoneWidget::close() |
|
90 | void VisualizationZoneWidget::close() | |
86 | { |
|
91 | { | |
87 | // The main view cannot be directly closed. |
|
92 | // The main view cannot be directly closed. | |
88 | return; |
|
93 | return; | |
89 | } |
|
94 | } | |
90 |
|
95 | |||
91 | QString VisualizationZoneWidget::name() const |
|
96 | QString VisualizationZoneWidget::name() const | |
92 | { |
|
97 | { | |
93 | return ui->zoneNameLabel->text(); |
|
98 | return ui->zoneNameLabel->text(); | |
94 | } |
|
99 | } |
General Comments 0
You need to be logged in to leave comments.
Login now