| 931 | } |
| 932 | |
| 933 | void Plot1DCanvas::contextMenuEvent(QContextMenuEvent* e) |
| 934 | { |
| 935 | if (layers_.empty()) { return; } |
| 936 | |
| 937 | QMenu* context_menu = new QMenu(this); |
| 938 | |
| 939 | Annotations1DContainer& annots_1d = getCurrentLayer().getCurrentAnnotations(); |
| 940 | Annotation1DItem* annot_item = annots_1d.getItemAt(e->pos()); |
| 941 | bool need_repaint = false; /// will get updated by context menu actions |
| 942 | if (annot_item) |
| 943 | { |
| 944 | annots_1d.deselectAll(); |
| 945 | annots_1d.selectItemAt(e->pos()); |
| 946 | update_(OPENMS_PRETTY_FUNCTION); |
| 947 | |
| 948 | context_menu->addMenu(getCurrentLayer() |
| 949 | .getContextMenuAnnotation(annot_item, need_repaint)); |
| 950 | } |
| 951 | else // !annot_item |
| 952 | { |
| 953 | //Display name and warn if current layer invisible |
| 954 | String layer_name = String("Layer: ") + getCurrentLayer().getName(); |
| 955 | if (!getCurrentLayer().visible) |
| 956 | { |
| 957 | layer_name += " (invisible)"; |
| 958 | } |
| 959 | context_menu->addAction(layer_name.toQString())->setEnabled(false); |
| 960 | |
| 961 | context_menu->addSeparator(); |
| 962 | |
| 963 | context_menu->addAction("Add label", [&]() { |
| 964 | addUserLabelAnnotation_(e->pos()); |
| 965 | })->setEnabled(!(mirror_mode_ && (getCurrentLayer().flipped ^ (e->pos().y() > height() / 2)))); |
| 966 | |
| 967 | PeakIndex near_peak = findPeakAtPosition_(e->pos()); |
| 968 | context_menu->addAction("Add peak annotation", [&]() { |
| 969 | addUserPeakAnnotation_(near_peak); |
| 970 | })->setEnabled(near_peak.isValid()); |
| 971 | |
| 972 | context_menu->addAction((String("Add peak annotation ") + String(getNonGravityDim().getDimNameShort())).toQString(), [&]() { |
| 973 | const auto xy_point = getCurrentLayer().peakIndexToXY(near_peak, unit_mapper_); |
| 974 | QString label = getNonGravityDim().formattedValue(gr_.swap().gravityValue(xy_point)).toQString(); |
| 975 | addPeakAnnotation(near_peak, label, String(getCurrentLayer().param.getValue("peak_color").toString()).toQString()); |
| 976 | })->setEnabled(near_peak.isValid()); |
| 977 | |
| 978 | context_menu->addSeparator(); |
| 979 | |
| 980 | context_menu->addAction("Reset alignment", [&]() { |
| 981 | resetAlignment(); |
| 982 | })->setEnabled(show_alignment_); |
| 983 | |
| 984 | context_menu->addSeparator(); |
| 985 | |
| 986 | context_menu->addAction("Layer meta data", [&]() { |
| 987 | showMetaData(true); |
| 988 | }); |
| 989 | |
| 990 | QMenu* save_menu = new QMenu("Save"); |
nothing calls this directly
no test coverage detected