@@ -27,6 +27,8 public: | |||
|
27 | 27 | virtual ~VisualizationGraphWidget(); |
|
28 | 28 | |
|
29 | 29 | void addVariable(std::shared_ptr<Variable> variable); |
|
30 | /// Removes a variable from the graph | |
|
31 | void removeVariable(std::shared_ptr<Variable> variable) noexcept; | |
|
30 | 32 | |
|
31 | 33 | // IVisualizationWidget interface |
|
32 | 34 | void accept(IVisualizationWidgetVisitor *visitor) override; |
@@ -26,8 +26,7 const auto VERTICAL_ZOOM_MODIFIER = Qt::ControlModifier; | |||
|
26 | 26 | struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { |
|
27 | 27 | |
|
28 | 28 | // 1 variable -> n qcpplot |
|
29 |
std:: |
|
|
30 | m_VariableToPlotMultiMap; | |
|
29 | std::multimap<std::shared_ptr<Variable>, QCPAbstractPlottable *> m_VariableToPlotMultiMap; | |
|
31 | 30 | }; |
|
32 | 31 | |
|
33 | 32 | VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget *parent) |
@@ -78,6 +77,10 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) | |||
|
78 | 77 | connect(variable.get(), SIGNAL(dataCacheUpdated()), this, SLOT(onDataCacheVariableUpdated())); |
|
79 | 78 | } |
|
80 | 79 | |
|
80 | void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept | |
|
81 | { | |
|
82 | } | |
|
83 | ||
|
81 | 84 | void VisualizationGraphWidget::accept(IVisualizationWidgetVisitor *visitor) |
|
82 | 85 | { |
|
83 | 86 | if (visitor) { |
@@ -105,6 +108,14 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept | |||
|
105 | 108 | { |
|
106 | 109 | QMenu graphMenu{}; |
|
107 | 110 | |
|
111 | // Iterates on variables (unique keys) | |
|
112 | for (auto it = impl->m_VariableToPlotMultiMap.cbegin(), | |
|
113 | end = impl->m_VariableToPlotMultiMap.cend(); | |
|
114 | it != end; it = impl->m_VariableToPlotMultiMap.upper_bound(it->first)) { | |
|
115 | // 'Remove variable' action | |
|
116 | graphMenu.addAction(tr("Remove variable %1").arg(it->first->name()), | |
|
117 | [ this, var = it->first ]() { removeVariable(var); }); | |
|
118 | } | |
|
108 | 119 | |
|
109 | 120 | if (!graphMenu.isEmpty()) { |
|
110 | 121 | graphMenu.exec(mapToGlobal(pos)); |
General Comments 0
You need to be logged in to leave comments.
Login now