-
Notifications
You must be signed in to change notification settings - Fork 0
/
legend.cpp
46 lines (44 loc) · 2 KB
/
legend.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "legend.h"
void legend_clicked(QCPLegend*,QCPAbstractLegendItem* ai,QMouseEvent*, QVector<Data*> &dataSets, QVector<QCPGraph*> &graphSets){
if(ai!=nullptr){
for (int i=0;i< dataSets.size();i++){
if(dataSets[i]->name== static_cast<QCPPlottableLegendItem*>(ai)->plottable()->name()){
if(ai->textColor()=="Grey"){
ai->setTextColor("black");
static_cast<QCPPlottableLegendItem*>(ai)->plottable()->setVisible(true);
dataSets[i]->data_visible=true;
}
else{
ai->setTextColor("Grey");
static_cast<QCPPlottableLegendItem*>(ai)->plottable()->setVisible(false);
dataSets[i]->data_visible=false;
}
}
}
for (int i=0;i<graphSets.size();i++){
if (graphSets[i]!=nullptr)
if(graphSets[i]->name() == static_cast<QCPPlottableLegendItem*>(ai)->plottable()->name()){
if(ai->textColor()=="Grey"){
ai->setTextColor("black");
static_cast<QCPPlottableLegendItem*>(ai)->plottable()->setVisible(true);
dataSets[i]->curve_visible=true;
}
else{
ai->setTextColor("Grey");
static_cast<QCPPlottableLegendItem*>(ai)->plottable()->setVisible(false);
dataSets[i]->curve_visible=false;
}
}
}
}
}
QString legend_double_clicked(QCPLegend*,QCPAbstractLegendItem* ai,QMouseEvent*, QVector<Data*> &dataSets, QString new_name){
for (int i=0;i< dataSets.size();i++){
if(dataSets[i]->name== static_cast<QCPPlottableLegendItem*>(ai)->plottable()->name()){
QString old_name=dataSets[i]->name;
dataSets[i]->name=new_name;
return old_name;
}
}
return "";
}