##// END OF EJS Templates
Unplot menu (5): adds contains() method to an IVariableContainer...
Alexandre Leroux -
r327:87af69bdce8a
parent child
Show More
@@ -13,6 +13,9 public:
13 13
14 14 /// Checks if the container can handle the variable passed in parameter
15 15 virtual bool canDrop(const Variable &variable) const = 0;
16
17 /// Checks if the container contains the variable passed in parameter
18 virtual bool contains(const Variable &variable) const = 0;
16 19 };
17 20
18 21
@@ -35,6 +35,7 public:
35 35 // IVisualizationWidget interface
36 36 void accept(IVisualizationWidgetVisitor *visitor) override;
37 37 bool canDrop(const Variable &variable) const override;
38 bool contains(const Variable &variable) const override;
38 39 QString name() const override;
39 40
40 41 void updateDisplay(std::shared_ptr<Variable> variable);
@@ -38,6 +38,7 public:
38 38 // IVisualizationWidget interface
39 39 void accept(IVisualizationWidgetVisitor *visitor) override;
40 40 bool canDrop(const Variable &variable) const override;
41 bool contains(const Variable &variable) const override;
41 42 QString name() const override;
42 43
43 44 private:
@@ -26,6 +26,7 public:
26 26 // IVisualizationWidget interface
27 27 void accept(IVisualizationWidgetVisitor *visitor) override;
28 28 bool canDrop(const Variable &variable) const override;
29 bool contains(const Variable &variable) const override;
29 30 QString name() const override;
30 31
31 32 public slots:
@@ -35,6 +35,7 public:
35 35 // IVisualizationWidget interface
36 36 void accept(IVisualizationWidgetVisitor *visitor) override;
37 37 bool canDrop(const Variable &variable) const override;
38 bool contains(const Variable &variable) const override;
38 39 QString name() const override;
39 40
40 41 private:
@@ -141,6 +141,18 bool VisualizationGraphWidget::canDrop(const Variable &variable) const
141 141 return true;
142 142 }
143 143
144 bool VisualizationGraphWidget::contains(const Variable &variable) const
145 {
146 // Finds the variable among the keys of the map
147 auto variablePtr = &variable;
148 auto findVariable
149 = [variablePtr](const auto &entry) { return variablePtr == entry.first.get(); };
150
151 auto end = impl->m_VariableToPlotMultiMap.cend();
152 auto it = std::find_if(impl->m_VariableToPlotMultiMap.cbegin(), end, findVariable);
153 return it != end;
154 }
155
144 156 QString VisualizationGraphWidget::name() const
145 157 {
146 158 return ui->graphNameLabel->text();
@@ -93,6 +93,12 bool VisualizationTabWidget::canDrop(const Variable &variable) const
93 93 return true;
94 94 }
95 95
96 bool VisualizationTabWidget::contains(const Variable &variable) const
97 {
98 Q_UNUSED(variable);
99 return false;
100 }
101
96 102 QString VisualizationTabWidget::name() const
97 103 {
98 104 return impl->m_Name;
@@ -101,6 +101,12 bool VisualizationWidget::canDrop(const Variable &variable) const
101 101 return false;
102 102 }
103 103
104 bool VisualizationWidget::contains(const Variable &variable) const
105 {
106 Q_UNUSED(variable);
107 return false;
108 }
109
104 110 QString VisualizationWidget::name() const
105 111 {
106 112 return QStringLiteral("MainView");
@@ -99,6 +99,12 bool VisualizationZoneWidget::canDrop(const Variable &variable) const
99 99 return true;
100 100 }
101 101
102 bool VisualizationZoneWidget::contains(const Variable &variable) const
103 {
104 Q_UNUSED(variable);
105 return false;
106 }
107
102 108 QString VisualizationZoneWidget::name() const
103 109 {
104 110 return ui->zoneNameLabel->text();
General Comments 0
You need to be logged in to leave comments. Login now