MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / contextMenuEvent

Method contextMenuEvent

src/openms_gui/source/VISUAL/Plot1DCanvas.cpp:933–1100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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");

Callers

nothing calls this directly

Calls 15

gridLinesShownFunction · 0.85
getIntensityModeFunction · 0.85
setIntensityModeFunction · 0.85
getItemAtMethod · 0.80
posMethod · 0.80
deselectAllMethod · 0.80
selectItemAtMethod · 0.80
formattedValueMethod · 0.80
gravityValueMethod · 0.80
containsScanOfLevelMethod · 0.80
getPeakDataMethod · 0.80
containsIMDataMethod · 0.80

Tested by

no test coverage detected