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

Function addFeatures

src/openms_gui/source/VISUAL/TVDIATreeTabController.cpp:83–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 }
82
83 void addFeatures(Plot1DWidget* w, std::vector<OSWPeakGroup>& features)
84 {
85 // nothing to do...
86 if (features.empty())
87 {
88 return;
89 }
90 // sort features by left RT
91 std::sort(features.begin(), features.end(), [](const OSWPeakGroup& a, const OSWPeakGroup& b)
92 {
93 return a.getRTLeftWidth() < b.getRTLeftWidth();
94 });
95 const OSWPeakGroup* best_feature = &features[0];
96 auto findBestFeature = [&best_feature](const OSWPeakGroup& f)
97 {
98 if (best_feature->getQValue() > f.getQValue())
99 {
100 best_feature = &f;
101 }
102 };
103 std::for_each(features.begin(), features.end(), findBestFeature);
104 if (best_feature->getQValue() == -1)
105 { // no q-values are annotated. make them all grey.
106 best_feature = nullptr;
107 }
108 GUIHelpers::OverlapDetector od(3); // three y-levels for showing annotation
109
110
111 // show feature boundaries
112 for (const auto& feature : features)
113 {
114 auto width = feature.getRTRightWidth() - feature.getRTLeftWidth();
115 auto center = feature.getRTLeftWidth() + width / 2;
116 String ann = String("RT:\n ") + String(feature.getRTExperimental(), false) + "\ndRT:\n " + String(feature.getRTDelta(), false) + "\nQ:\n " + String(feature.getQValue(), false);
117 QColor col = GUIHelpers::ColorBrewer::Distinct().values[(best_feature == &feature)
118 ? GUIHelpers::ColorBrewer::Distinct::LightGreen
119 : GUIHelpers::ColorBrewer::Distinct::LightGrey];
120 Annotation1DVerticalLineItem* item = new Annotation1DVerticalLineItem(center, width, 150, false, col, ann.toQString());
121 item->setSelected(false);
122 auto text_size = item->getTextRect(); // this is in px units (Qt widget coordinates)
123 // translate to axis units (our native 'data'):
124 auto p_text = w->canvas()->widgetToDataDistance(text_size.width(), 0);
125 auto chunk = od.placeItem(feature.getRTLeftWidth(), feature.getRTLeftWidth() + p_text.getX());
126 item->setTextOffset(chunk * text_size.height());
127
128 w->canvas()->getCurrentLayer().getCurrentAnnotations().push_back(item);
129 }
130 // paint the expected RT once
131 auto expected_RT = features[0].getRTExperimental() - features[0].getRTDelta();
132 Annotation1DItem* item = new Annotation1DVerticalLineItem(expected_RT, 3, 200, true, Qt::darkGreen, "");
133 item->setSelected(false);
134 w->canvas()->getCurrentLayer().getCurrentAnnotations().push_back(item);
135 }
136
137
138

Callers 1

Calls 15

sortFunction · 0.85
DistinctClass · 0.85
setSelectedMethod · 0.80
getTextRectMethod · 0.80
widthMethod · 0.80
placeItemMethod · 0.80
getXMethod · 0.80
setTextOffsetMethod · 0.80
heightMethod · 0.80
getCurrentLayerMethod · 0.80
StringClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected