@@ -1,104 +1,105 | |||||
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") |
|
7 | Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget") | |
8 |
|
8 | |||
9 | namespace { |
|
9 | namespace { | |
10 |
|
10 | |||
11 | /// 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 | |
12 | /// the tab |
|
12 | /// the tab | |
13 | QString defaultZoneName(const QLayout &layout) |
|
13 | QString defaultZoneName(const QLayout &layout) | |
14 | { |
|
14 | { | |
15 | auto count = 0; |
|
15 | auto count = 0; | |
16 | for (auto i = 0; i < layout.count(); ++i) { |
|
16 | for (auto i = 0; i < layout.count(); ++i) { | |
17 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { |
|
17 | if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) { | |
18 | count++; |
|
18 | count++; | |
19 | } |
|
19 | } | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | return QObject::tr("Zone %1").arg(count + 1); |
|
22 | return QObject::tr("Zone %1").arg(count + 1); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | } // namespace |
|
25 | } // namespace | |
26 |
|
26 | |||
27 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { |
|
27 | struct VisualizationTabWidget::VisualizationTabWidgetPrivate { | |
28 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} |
|
28 | explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {} | |
29 |
|
29 | |||
30 | QString m_Name; |
|
30 | QString m_Name; | |
31 | }; |
|
31 | }; | |
32 |
|
32 | |||
33 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) |
|
33 | VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent) | |
34 | : QWidget{parent}, |
|
34 | : QWidget{parent}, | |
35 | ui{new Ui::VisualizationTabWidget}, |
|
35 | ui{new Ui::VisualizationTabWidget}, | |
36 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} |
|
36 | impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)} | |
37 | { |
|
37 | { | |
38 | ui->setupUi(this); |
|
38 | ui->setupUi(this); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | VisualizationTabWidget::~VisualizationTabWidget() |
|
41 | VisualizationTabWidget::~VisualizationTabWidget() | |
42 | { |
|
42 | { | |
43 | delete ui; |
|
43 | delete ui; | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) |
|
46 | void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) | |
47 | { |
|
47 | { | |
48 | this->layout()->addWidget(zoneWidget); |
|
48 | this->layout()->addWidget(zoneWidget); | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) |
|
51 | VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable) | |
52 | { |
|
52 | { | |
53 | auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this}; |
|
53 | auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this}; | |
54 | this->addZone(zoneWidget); |
|
54 | this->addZone(zoneWidget); | |
55 |
|
55 | |||
56 | // Creates a new graph into the zone |
|
56 | // Creates a new graph into the zone | |
57 | zoneWidget->createGraph(variable); |
|
57 | zoneWidget->createGraph(variable); | |
58 |
|
58 | |||
59 | return zoneWidget; |
|
59 | return zoneWidget; | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone) |
|
62 | void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone) | |
63 | { |
|
63 | { | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
66 | void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor) | |
67 | { |
|
67 | { | |
68 | if (visitor) { |
|
68 | if (visitor) { | |
69 | visitor->visitEnter(this); |
|
69 | visitor->visitEnter(this); | |
70 |
|
70 | |||
71 | // Apply visitor to zone children |
|
71 | // Apply visitor to zone children | |
72 | for (auto i = 0; i < layout()->count(); ++i) { |
|
72 | for (auto i = 0; i < layout()->count(); ++i) { | |
73 | if (auto item = layout()->itemAt(i)) { |
|
73 | if (auto item = layout()->itemAt(i)) { | |
|
74 | // Widgets different from zones are not visited (no action) | |||
74 | if (auto visualizationZoneWidget |
|
75 | if (auto visualizationZoneWidget | |
75 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { |
|
76 | = dynamic_cast<VisualizationZoneWidget *>(item->widget())) { | |
76 | visualizationZoneWidget->accept(visitor); |
|
77 | visualizationZoneWidget->accept(visitor); | |
77 | } |
|
78 | } | |
78 | } |
|
79 | } | |
79 | } |
|
80 | } | |
80 |
|
81 | |||
81 | visitor->visitLeave(this); |
|
82 | visitor->visitLeave(this); | |
82 | } |
|
83 | } | |
83 | else { |
|
84 | else { | |
84 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); |
|
85 | qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null"); | |
85 | } |
|
86 | } | |
86 | } |
|
87 | } | |
87 |
|
88 | |||
88 | bool VisualizationTabWidget::canDrop(const Variable &variable) const |
|
89 | bool VisualizationTabWidget::canDrop(const Variable &variable) const | |
89 | { |
|
90 | { | |
90 | // A tab can always accomodate a variable |
|
91 | // A tab can always accomodate a variable | |
91 | Q_UNUSED(variable); |
|
92 | Q_UNUSED(variable); | |
92 | return true; |
|
93 | return true; | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 | void VisualizationTabWidget::close() |
|
96 | void VisualizationTabWidget::close() | |
96 | { |
|
97 | { | |
97 | // The main view cannot be directly closed. |
|
98 | // The main view cannot be directly closed. | |
98 | return; |
|
99 | return; | |
99 | } |
|
100 | } | |
100 |
|
101 | |||
101 | QString VisualizationTabWidget::name() const |
|
102 | QString VisualizationTabWidget::name() const | |
102 | { |
|
103 | { | |
103 | return impl->m_Name; |
|
104 | return impl->m_Name; | |
104 | } |
|
105 | } |
@@ -1,135 +1,136 | |||||
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 | // Widgets different from tabs are not visited (no action) | |||
92 | if (auto visualizationTabWidget |
|
93 | if (auto visualizationTabWidget | |
93 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { |
|
94 | = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->widget(i))) { | |
94 | visualizationTabWidget->accept(visitor); |
|
95 | visualizationTabWidget->accept(visitor); | |
95 | } |
|
96 | } | |
96 | } |
|
97 | } | |
97 |
|
98 | |||
98 | visitor->visitLeave(this); |
|
99 | visitor->visitLeave(this); | |
99 | } |
|
100 | } | |
100 | else { |
|
101 | else { | |
101 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); |
|
102 | qCCritical(LOG_VisualizationWidget()) << tr("Can't visit widget : the visitor is null"); | |
102 | } |
|
103 | } | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | bool VisualizationWidget::canDrop(const Variable &variable) const |
|
106 | bool VisualizationWidget::canDrop(const Variable &variable) const | |
106 | { |
|
107 | { | |
107 | // The main widget can never accomodate a variable |
|
108 | // The main widget can never accomodate a variable | |
108 | Q_UNUSED(variable); |
|
109 | Q_UNUSED(variable); | |
109 | return false; |
|
110 | return false; | |
110 | } |
|
111 | } | |
111 |
|
112 | |||
112 | void VisualizationWidget::close() |
|
113 | void VisualizationWidget::close() | |
113 | { |
|
114 | { | |
114 | // The main view cannot be directly closed. |
|
115 | // The main view cannot be directly closed. | |
115 | return; |
|
116 | return; | |
116 | } |
|
117 | } | |
117 |
|
118 | |||
118 | QString VisualizationWidget::name() const |
|
119 | QString VisualizationWidget::name() const | |
119 | { |
|
120 | { | |
120 | return QStringLiteral("MainView"); |
|
121 | return QStringLiteral("MainView"); | |
121 | } |
|
122 | } | |
122 |
|
123 | |||
123 | void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept |
|
124 | void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept | |
124 | { |
|
125 | { | |
125 | if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { |
|
126 | if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) { | |
126 | if (!currentTab->createZone(variable)) { |
|
127 | if (!currentTab->createZone(variable)) { | |
127 | qCCritical(LOG_VisualizationWidget()) |
|
128 | qCCritical(LOG_VisualizationWidget()) | |
128 | << tr("Can't display the variable : can't create a new zone in the current tab"); |
|
129 | << tr("Can't display the variable : can't create a new zone in the current tab"); | |
129 | } |
|
130 | } | |
130 | } |
|
131 | } | |
131 | else { |
|
132 | else { | |
132 | qCCritical(LOG_VisualizationWidget()) |
|
133 | qCCritical(LOG_VisualizationWidget()) | |
133 | << tr("Can't display the variable : there is no current tab"); |
|
134 | << tr("Can't display the variable : there is no current tab"); | |
134 | } |
|
135 | } | |
135 | } |
|
136 | } |
@@ -1,99 +1,100 | |||||
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") |
|
7 | Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget") | |
8 |
|
8 | |||
9 | namespace { |
|
9 | namespace { | |
10 |
|
10 | |||
11 | /// 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 | |
12 | /// the zone |
|
12 | /// the zone | |
13 | QString defaultGraphName(const QLayout &layout) |
|
13 | QString defaultGraphName(const QLayout &layout) | |
14 | { |
|
14 | { | |
15 | auto count = 0; |
|
15 | auto count = 0; | |
16 | for (auto i = 0; i < layout.count(); ++i) { |
|
16 | for (auto i = 0; i < layout.count(); ++i) { | |
17 | if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) { |
|
17 | if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) { | |
18 | count++; |
|
18 | count++; | |
19 | } |
|
19 | } | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | return QObject::tr("Graph %1").arg(count + 1); |
|
22 | return QObject::tr("Graph %1").arg(count + 1); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | } // namespace |
|
25 | } // namespace | |
26 |
|
26 | |||
27 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) |
|
27 | VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent) | |
28 | : QWidget{parent}, ui{new Ui::VisualizationZoneWidget} |
|
28 | : QWidget{parent}, ui{new Ui::VisualizationZoneWidget} | |
29 | { |
|
29 | { | |
30 | ui->setupUi(this); |
|
30 | ui->setupUi(this); | |
31 |
|
31 | |||
32 | ui->zoneNameLabel->setText(name); |
|
32 | ui->zoneNameLabel->setText(name); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | VisualizationZoneWidget::~VisualizationZoneWidget() |
|
35 | VisualizationZoneWidget::~VisualizationZoneWidget() | |
36 | { |
|
36 | { | |
37 | delete ui; |
|
37 | delete ui; | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) |
|
40 | void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) | |
41 | { |
|
41 | { | |
42 | ui->visualizationZoneFrame->layout()->addWidget(graphWidget); |
|
42 | ui->visualizationZoneFrame->layout()->addWidget(graphWidget); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) |
|
45 | VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable) | |
46 | { |
|
46 | { | |
47 | auto graphWidget = new VisualizationGraphWidget{ |
|
47 | auto graphWidget = new VisualizationGraphWidget{ | |
48 | defaultGraphName(*ui->visualizationZoneFrame->layout()), this}; |
|
48 | defaultGraphName(*ui->visualizationZoneFrame->layout()), this}; | |
49 | this->addGraph(graphWidget); |
|
49 | this->addGraph(graphWidget); | |
50 |
|
50 | |||
51 | graphWidget->addVariable(variable); |
|
51 | graphWidget->addVariable(variable); | |
52 |
|
52 | |||
53 | return graphWidget; |
|
53 | return graphWidget; | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph) |
|
56 | void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph) | |
57 | { |
|
57 | { | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
60 | void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor) | |
61 | { |
|
61 | { | |
62 | if (visitor) { |
|
62 | if (visitor) { | |
63 | visitor->visitEnter(this); |
|
63 | visitor->visitEnter(this); | |
64 |
|
64 | |||
65 | // Apply visitor to graph children |
|
65 | // Apply visitor to graph children | |
66 | auto layout = ui->visualizationZoneFrame->layout(); |
|
66 | auto layout = ui->visualizationZoneFrame->layout(); | |
67 | for (auto i = 0; i < layout->count(); ++i) { |
|
67 | for (auto i = 0; i < layout->count(); ++i) { | |
68 | if (auto item = layout->itemAt(i)) { |
|
68 | if (auto item = layout->itemAt(i)) { | |
|
69 | // Widgets different from graphs are not visited (no action) | |||
69 | if (auto visualizationGraphWidget |
|
70 | if (auto visualizationGraphWidget | |
70 | = dynamic_cast<VisualizationGraphWidget *>(item->widget())) { |
|
71 | = dynamic_cast<VisualizationGraphWidget *>(item->widget())) { | |
71 | visualizationGraphWidget->accept(visitor); |
|
72 | visualizationGraphWidget->accept(visitor); | |
72 | } |
|
73 | } | |
73 | } |
|
74 | } | |
74 | } |
|
75 | } | |
75 |
|
76 | |||
76 | visitor->visitLeave(this); |
|
77 | visitor->visitLeave(this); | |
77 | } |
|
78 | } | |
78 | else { |
|
79 | else { | |
79 | qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null"); |
|
80 | qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null"); | |
80 | } |
|
81 | } | |
81 | } |
|
82 | } | |
82 |
|
83 | |||
83 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const |
|
84 | bool VisualizationZoneWidget::canDrop(const Variable &variable) const | |
84 | { |
|
85 | { | |
85 | // A tab can always accomodate a variable |
|
86 | // A tab can always accomodate a variable | |
86 | Q_UNUSED(variable); |
|
87 | Q_UNUSED(variable); | |
87 | return true; |
|
88 | return true; | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 | void VisualizationZoneWidget::close() |
|
91 | void VisualizationZoneWidget::close() | |
91 | { |
|
92 | { | |
92 | // The main view cannot be directly closed. |
|
93 | // The main view cannot be directly closed. | |
93 | return; |
|
94 | return; | |
94 | } |
|
95 | } | |
95 |
|
96 | |||
96 | QString VisualizationZoneWidget::name() const |
|
97 | QString VisualizationZoneWidget::name() const | |
97 | { |
|
98 | { | |
98 | return ui->zoneNameLabel->text(); |
|
99 | return ui->zoneNameLabel->text(); | |
99 | } |
|
100 | } |
General Comments 0
You need to be logged in to leave comments.
Login now