| 37 | } |
| 38 | |
| 39 | PeakIndex LayerData1DChrom::findClosestDataPoint(const RangeAllType& area) const |
| 40 | { |
| 41 | ChromatogramPeak peak_lt {area.getMinRT(), area.getMinIntensity()}, peak_rb {area.getMaxRT(), area.getMaxIntensity()}; |
| 42 | // reference to the current data |
| 43 | const auto& chrom = getCurrentChrom(); |
| 44 | const Size index = getCurrentIndex(); |
| 45 | |
| 46 | // get iterator on first peak with lower position than interval_start |
| 47 | auto left_it = lower_bound(chrom.begin(), chrom.end(), peak_lt, ChromatogramPeak::PositionLess()); |
| 48 | |
| 49 | // get iterator on first peak with higher position than interval_end |
| 50 | auto right_it = lower_bound(left_it, chrom.end(), peak_rb, ChromatogramPeak::PositionLess()); |
| 51 | |
| 52 | if (left_it == right_it) // both are equal => no peak falls into this interval |
| 53 | { |
| 54 | return PeakIndex(); |
| 55 | } |
| 56 | |
| 57 | if (left_it == right_it - 1) |
| 58 | { |
| 59 | return PeakIndex(index, left_it - chrom.begin()); |
| 60 | } |
| 61 | |
| 62 | auto nearest_it = left_it; |
| 63 | const auto center_intensity = (peak_lt.getIntensity() + peak_rb.getIntensity()) * 0.5; |
| 64 | for (auto it = left_it; it != right_it; ++it) |
| 65 | { |
| 66 | if (abs(center_intensity - it->getIntensity()) < abs(center_intensity - nearest_it->getIntensity())) |
| 67 | { |
| 68 | nearest_it = it; |
| 69 | } |
| 70 | } |
| 71 | return PeakIndex(index, nearest_it - chrom.begin()); |
| 72 | } |
| 73 | |
| 74 | std::unique_ptr<Painter1DBase> LayerData1DChrom::getPainter1D() const |
| 75 | { |
nothing calls this directly
no test coverage detected