@@ -59,17 +59,26 struct GenerateVariableMenuOperation::GenerateVariableMenuOperationPrivate { | |||||
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | template <typename ActionFun> |
|
61 | template <typename ActionFun> | |
62 | void visitLeaf(const IVisualizationWidget &container, const QString &actionName, |
|
62 | void visitLeafPlot(const IVisualizationWidget &container, const QString &actionName, | |
63 | ActionFun actionFunction) |
|
63 | ActionFun actionFunction) | |
64 | { |
|
64 | { | |
65 | if (m_Variable && container.canDrop(*m_Variable)) { |
|
65 | if (m_Variable && container.canDrop(*m_Variable)) { | |
66 | m_PlotMenuBuilder.addAction(actionName, actionFunction); |
|
66 | m_PlotMenuBuilder.addAction(actionName, actionFunction); | |
67 | } |
|
67 | } | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
|
70 | template <typename ActionFun> | |||
|
71 | void visitLeafUnplot(const IVisualizationWidget &container, const QString &actionName, | |||
|
72 | ActionFun actionFunction) | |||
|
73 | { | |||
|
74 | if (m_Variable && container.contains(*m_Variable)) { | |||
|
75 | m_UnplotMenuBuilder.addAction(actionName, actionFunction); | |||
|
76 | } | |||
|
77 | } | |||
|
78 | ||||
70 | std::shared_ptr<Variable> m_Variable; |
|
79 | std::shared_ptr<Variable> m_Variable; | |
71 | MenuBuilder m_PlotMenuBuilder; ///< Builder for the 'Plot' menu |
|
80 | MenuBuilder m_PlotMenuBuilder; ///< Builder for the 'Plot' menu | |
72 |
MenuBuilder m_UnplotMenuBuilder; |
|
81 | MenuBuilder m_UnplotMenuBuilder; ///< Builder for the 'Unplot' menu | |
73 | }; |
|
82 | }; | |
74 |
|
83 | |||
75 | GenerateVariableMenuOperation::GenerateVariableMenuOperation(QMenu *menu, |
|
84 | GenerateVariableMenuOperation::GenerateVariableMenuOperation(QMenu *menu, | |
@@ -157,9 +166,15 void GenerateVariableMenuOperation::visitLeave(VisualizationZoneWidget *zoneWidg | |||||
157 | void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget) |
|
166 | void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget) | |
158 | { |
|
167 | { | |
159 | if (graphWidget) { |
|
168 | if (graphWidget) { | |
160 | impl->visitLeaf( |
|
169 | // 'Plot' menu | |
|
170 | impl->visitLeafPlot( | |||
161 | *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()), |
|
171 | *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()), | |
162 | [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariableUsingGraph(var); }); |
|
172 | [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariableUsingGraph(var); }); | |
|
173 | ||||
|
174 | // 'Unplot' menu | |||
|
175 | impl->visitLeafUnplot( | |||
|
176 | *graphWidget, QObject::tr("Remove from %1").arg(graphWidget->name()), | |||
|
177 | [ var = impl->m_Variable, graphWidget ]() { graphWidget->removeVariable(var); }); | |||
163 | } |
|
178 | } | |
164 | else { |
|
179 | else { | |
165 | qCCritical(LOG_GenerateVariableMenuOperation(), |
|
180 | qCCritical(LOG_GenerateVariableMenuOperation(), |
General Comments 0
You need to be logged in to leave comments.
Login now