| 328 | |
| 329 | |
| 330 | void Painter2DPeak::paintMaximumIntensities_(QPainter& painter, Plot2DCanvas* canvas, Size layer_index, Size rt_pixel_count, Size mz_pixel_count) |
| 331 | { |
| 332 | // set painter to black (we operate directly on the pixels for all colored data) |
| 333 | painter.setPen(Qt::black); |
| 334 | const double snap_factor = canvas->snap_factors_[layer_index]; |
| 335 | const auto& map = *layer_->getPeakData(); |
| 336 | const auto& area = canvas->visible_area_.getAreaUnit(); |
| 337 | |
| 338 | auto RT_or_IM_paint = [&](const DimInfo& mapper) { |
| 339 | // note: the variables are named, assuming we have an RT+mz canvas. |
| 340 | // However, by using 'DimInfo' this could well be an IM+mz canvas (i.e. an IM Frame) |
| 341 | |
| 342 | const double rt_min = mapper.dim_.getMin(); |
| 343 | const double rt_max = mapper.dim_.getMax(); |
| 344 | const double mz_min = area.getMinMZ(); |
| 345 | const double mz_max = area.getMaxMZ(); |
| 346 | |
| 347 | // calculate pixel size in data coordinates |
| 348 | double rt_step_size = (rt_max - rt_min) / rt_pixel_count; |
| 349 | double mz_step_size = (mz_max - mz_min) / mz_pixel_count; |
| 350 | |
| 351 | // start at first visible RT scan |
| 352 | Size scan_index = std::distance(map.begin(), mapper.getFirstScan(rt_min)); |
| 353 | vector<Size> scan_indices, peak_indices; |
| 354 | // iterate over all pixels (RT dimension) |
| 355 | for (Size rt = 0; rt < rt_pixel_count; ++rt) |
| 356 | { |
| 357 | // interval in data coordinates for the current pixel |
| 358 | double rt_start = rt_min + rt_step_size * rt; |
| 359 | double rt_end = rt_start + rt_step_size; |
| 360 | // cout << "rt: " << rt << " (" << rt_start << " - " << rt_end << ")" << endl; |
| 361 | |
| 362 | // reached the end of data |
| 363 | if (rt_end >= mapper.getMaximum()) |
| 364 | { |
| 365 | break; |
| 366 | } |
| 367 | // determine the relevant spectra and reserve an array for the peak indices |
| 368 | scan_indices.clear(); |
| 369 | peak_indices.clear(); |
| 370 | for (Size i = scan_index; i < map.size(); ++i) |
| 371 | { |
| 372 | const auto& spec = map[i]; |
| 373 | if (mapper.getValue(spec) >= rt_end) |
| 374 | { |
| 375 | scan_index = i; // store last scan index for next RT pixel |
| 376 | break; |
| 377 | } |
| 378 | if (spec.getMSLevel() == 1 && !spec.empty()) |
| 379 | { |
| 380 | scan_indices.push_back(i); |
| 381 | peak_indices.push_back(spec.MZBegin(mz_min) - spec.begin()); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | if (scan_indices.empty()) |
| 386 | { |
| 387 | continue; |
nothing calls this directly
no test coverage detected