MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / mouseMoveEvent

Method mouseMoveEvent

src/openms_gui/source/VISUAL/Plot1DCanvas.cpp:396–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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());

Callers

nothing calls this directly

Calls 15

getCurrentLayerIndexFunction · 0.85
canvasPixelAreaFunction · 0.85
posMethod · 0.80
formattedValueMethod · 0.80
isSelectedMethod · 0.80
getXMethod · 0.80
cloneWithMethod · 0.80
gravitateMinMethod · 0.80
gravitateMaxMethod · 0.80
showMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected