| 672 | } |
| 673 | |
| 674 | void Plot2DCanvas::mouseMoveEvent(QMouseEvent* e) |
| 675 | { |
| 676 | grabKeyboard(); // (re-)grab keyboard after it has been released by unhandled key |
| 677 | QPoint pos = e->pos(); |
| 678 | PointXYType data_pos = widgetToData_(pos); |
| 679 | emit sendCursorStatus(unit_mapper_.getDim(DIM::X).formattedValue(data_pos[0]), |
| 680 | unit_mapper_.getDim(DIM::Y).formattedValue(data_pos[1])); |
| 681 | |
| 682 | PeakIndex near_peak = findNearestPeak_(pos); |
| 683 | |
| 684 | //highlight current peak and display peak coordinates |
| 685 | if (action_mode_ == AM_MEASURE || (action_mode_ == AM_TRANSLATE && !(e->buttons() & Qt::LeftButton))) |
| 686 | { |
| 687 | //highlight peak |
| 688 | selected_peak_ = near_peak; |
| 689 | update_(OPENMS_PRETTY_FUNCTION); |
| 690 | |
| 691 | //show meta data in status bar (if available) |
| 692 | if (selected_peak_.isValid()) |
| 693 | { |
| 694 | String status; |
| 695 | auto* lf = dynamic_cast<LayerDataFeature*>(&getCurrentLayer()); |
| 696 | auto* lc = dynamic_cast<LayerDataConsensus*>(&getCurrentLayer()); |
| 697 | if (lf || lc) |
| 698 | { |
| 699 | //add meta info |
| 700 | const BaseFeature* f; |
| 701 | if (lf) |
| 702 | { |
| 703 | f = &selected_peak_.getFeature(*lf->getFeatureMap()); |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | f = &selected_peak_.getFeature(*lc->getConsensusMap()); |
| 708 | } |
| 709 | std::vector<String> keys; |
| 710 | f->getKeys(keys); |
| 711 | for (Size m = 0; m < keys.size(); ++m) |
| 712 | { |
| 713 | status += " " + keys[m] + ": "; |
| 714 | const DataValue& dv = f->getMetaValue(keys[m]); |
| 715 | if (dv.valueType() == DataValue::DOUBLE_VALUE) |
| 716 | { // use less precision for large numbers, for better readability |
| 717 | int precision(2); |
| 718 | if ((double)dv < 10) precision = 5; |
| 719 | // ... and add 1k separators, e.g. '540,321.99' |
| 720 | status += QLocale::c().toString((double)dv, 'f', precision); |
| 721 | } |
| 722 | else |
| 723 | { |
| 724 | status += (String)dv; |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | else if (auto* lp = dynamic_cast<LayerDataPeak*>(&getCurrentLayer())) |
| 729 | { |
| 730 | //meta info |
| 731 | const ExperimentType::SpectrumType & s = selected_peak_.getSpectrum(*lp->getPeakData()); |
nothing calls this directly
no test coverage detected