| 394 | } |
| 395 | |
| 396 | void Plot1DCanvas::mouseMoveEvent(QMouseEvent* e) |
| 397 | { |
| 398 | // mouse position relative to the diagram widget |
| 399 | QPoint p = e->pos(); |
| 400 | PointXYType data_pos = widgetToData(p); |
| 401 | emit sendCursorStatus(unit_mapper_.getDim(DIM::X).formattedValue(data_pos[0]), |
| 402 | unit_mapper_.getDim(DIM::Y).formattedValue(data_pos[1])); |
| 403 | |
| 404 | PeakIndex near_peak = findPeakAtPosition_(p); |
| 405 | |
| 406 | if (e->buttons() & Qt::LeftButton) |
| 407 | { |
| 408 | bool move = moving_annotations_; |
| 409 | if (mirror_mode_ && (getCurrentLayer().flipped ^ (p.y() > height() / 2))) |
| 410 | { |
| 411 | move = false; |
| 412 | } |
| 413 | if (move) |
| 414 | { |
| 415 | recalculatePercentageFactor_(getCurrentLayerIndex()); |
| 416 | PointXYType delta = widgetToData(p) - widgetToData(last_mouse_pos_); |
| 417 | |
| 418 | Annotations1DContainer& ann_1d = getCurrentLayer().getCurrentAnnotations(); |
| 419 | for (Annotations1DContainer::Iterator it = ann_1d.begin(); it != ann_1d.end(); ++it) |
| 420 | { |
| 421 | if ((*it)->isSelected()) |
| 422 | { |
| 423 | (*it)->move(delta, gr_, unit_mapper_); |
| 424 | } |
| 425 | } |
| 426 | update_(OPENMS_PRETTY_FUNCTION); |
| 427 | last_mouse_pos_ = p; |
| 428 | } |
| 429 | else if (action_mode_ == AM_TRANSLATE) |
| 430 | { |
| 431 | // translation in data metric |
| 432 | const double shift = widgetToData(last_mouse_pos_).getX() - widgetToData(p).getX(); |
| 433 | auto new_va = visible_area_.cloneWith(visible_area_.getAreaXY() + PointXYType(shift, 0)).getAreaUnit(); |
| 434 | |
| 435 | // change data area |
| 436 | changeVisibleArea_(new_va); |
| 437 | last_mouse_pos_ = p; |
| 438 | } |
| 439 | else if (action_mode_ == AM_MEASURE) |
| 440 | { |
| 441 | if (near_peak.peak != measurement_start_.peak) |
| 442 | { |
| 443 | selected_peak_ = near_peak; |
| 444 | last_mouse_pos_ = p; |
| 445 | update_(OPENMS_PRETTY_FUNCTION); |
| 446 | } |
| 447 | } |
| 448 | else if (action_mode_ == AM_ZOOM) |
| 449 | { |
| 450 | const auto pixel_area = canvasPixelArea(); |
| 451 | auto r_start = gr_.gravitateMin(last_mouse_pos_, pixel_area); |
| 452 | auto r_end = gr_.gravitateMax(p, pixel_area); |
| 453 | rubber_band_.setGeometry(QRect(r_start, r_end).normalized()); |
nothing calls this directly
no test coverage detected