| 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 |
no test coverage detected