##// END OF EJS Templates
Creates a method (slot) in VisualizationWidget to add the plot menu to a variable menu
Alexandre Leroux -
r248:5b41c2a03db2
parent child
Show More
@@ -8,6 +8,7
8
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
9 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
10
10
11 class QMenu;
11 class Variable;
12 class Variable;
12 class VisualizationTabWidget;
13 class VisualizationTabWidget;
13
14
@@ -39,12 +40,11 public:
39
40
40 public slots:
41 public slots:
41 /**
42 /**
42 * Displays a variable in a new graph of a new zone of the current tab
43 * Attaches to a menu the menu relating to the visualization of a variable
43 * @param variable the variable to display
44 * @param menu the parent menu of the generated menu
44 * @todo this is a temporary method that will be replaced by own actions for each type of
45 * @param variable the variable for which to generate the menu
45 * visualization widget
46 */
46 */
47 void displayVariable(std::shared_ptr<Variable> variable) noexcept;
47 void attachVariableMenu(QMenu *menu, std::shared_ptr<Variable> variable) noexcept;
48
48
49 private:
49 private:
50 Ui::VisualizationWidget *ui;
50 Ui::VisualizationWidget *ui;
@@ -3,6 +3,7
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/operations/GenerateVariableMenuOperation.h"
6 #include "Visualization/qcustomplot.h"
7 #include "Visualization/qcustomplot.h"
7
8
8 #include "ui_VisualizationWidget.h"
9 #include "ui_VisualizationWidget.h"
@@ -121,16 +122,10 QString VisualizationWidget::name() const
121 return QStringLiteral("MainView");
122 return QStringLiteral("MainView");
122 }
123 }
123
124
124 void VisualizationWidget::displayVariable(std::shared_ptr<Variable> variable) noexcept
125 void VisualizationWidget::attachVariableMenu(QMenu *menu,
126 std::shared_ptr<Variable> variable) noexcept
125 {
127 {
126 if (auto currentTab = dynamic_cast<VisualizationTabWidget *>(ui->tabWidget->currentWidget())) {
128 // Generates the actions that make it possible to visualize the variable
127 if (!currentTab->createZone(variable)) {
129 auto generateVariableMenuOperation = GenerateVariableMenuOperation{menu, variable};
128 qCCritical(LOG_VisualizationWidget())
130 accept(&generateVariableMenuOperation);
129 << tr("Can't display the variable : can't create a new zone in the current tab");
130 }
131 }
132 else {
133 qCCritical(LOG_VisualizationWidget())
134 << tr("Can't display the variable : there is no current tab");
135 }
136 }
131 }
General Comments 0
You need to be logged in to leave comments. Login now