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

Method contextMenuEvent

src/openms_gui/source/VISUAL/Plot2DCanvas.cpp:846–1269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

844 }
845
846 void Plot2DCanvas::contextMenuEvent(QContextMenuEvent * e)
847 {
848 // abort if there are no layers
849 if (layers_.empty())
850 {
851 return;
852 }
853 const LayerDataBase& layer = getCurrentLayer();
854
855 QMenu* context_menu = new QMenu(this);
856
857 QAction* a = nullptr;
858 QAction* result = nullptr;
859
860 //Display name and warn if current layer invisible
861 String layer_name = String("Layer: ") + layer.getName();
862 if (!layer.visible)
863 {
864 layer_name += " (invisible)";
865 }
866 context_menu->addAction(layer_name.toQString())->setEnabled(false);
867 context_menu->addSeparator();
868
869 context_menu->addAction("Layer meta data");
870
871 QMenu * settings_menu = new QMenu("Settings");
872 settings_menu->addAction("Show/hide grid lines");
873 settings_menu->addAction("Show/hide axis legends");
874 context_menu->addSeparator();
875
876 context_menu->addAction("Switch to 3D view");
877
878 const RangeType e_units = [&](){ // mouse position in units
879 RangeType r;
880 unit_mapper_.fromXY(widgetToData_(e->pos()), r);
881 return r; }();
882
883 // a small 10x10 pixel area around the current mouse position
884 auto check_area = visible_area_.cloneWith({widgetToData_(e->pos() - QPoint(10, 10)), widgetToData_(e->pos() + QPoint(10, 10))}).getAreaUnit();
885
886 //-------------------PEAKS----------------------------------
887 if (auto* lp = dynamic_cast<const LayerDataPeak*>(&layer))
888 {
889 //add settings
890 settings_menu->addSeparator();
891 settings_menu->addAction("Show/hide projections");
892 settings_menu->addAction("Show/hide MS/MS precursors");
893
894 //add surrounding survey scans
895 //find nearest survey scan
896 SignedSize size = lp->getPeakData()->size();
897 Int current = lp->getPeakData()->RTBegin(e_units.getMinRT()) - lp->getPeakData()->begin();
898 if (current == size) // if only one element is present RTBegin points to one after the last element (see RTBegin implementation)
899 {
900 current = 0;
901 }
902
903 SignedSize i = 0;

Callers

nothing calls this directly

Calls 15

widgetToData_Function · 0.85
sortFunction · 0.85
numberFunction · 0.85
gridLinesShownFunction · 0.85
setLayerFlagFunction · 0.85
getLayerFlagFunction · 0.85
fromXYMethod · 0.80
posMethod · 0.80
cloneWithMethod · 0.80
getPeakDataMethod · 0.80
getMinRTMethod · 0.80
getMSLevelMethod · 0.80

Tested by

no test coverage detected