MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / mousePressEvent

Method mousePressEvent

DSView/pv/view/viewport.cpp:640–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638}
639
640void Viewport::mousePressEvent(QMouseEvent *event)
641{
642 assert(event);
643
644 _mouse_down_point = event->pos();
645 _mouse_down_offset = _view.offset();
646 _drag_strength = 0;
647 _elapsed_time.restart();
648
649 if (_action_type == NO_ACTION
650 && event->button() == Qt::RightButton
651 && _view.session().is_stopped_status())
652 {
653 if (_view.session().get_device()->get_work_mode() == LOGIC) {
654 set_action(LOGIC_ZOOM);
655 }
656 else if (_view.session().get_device()->get_work_mode() == DSO) {
657 if (_hover_hit) {
658 const int64_t index = _view.pixel2index(event->pos().x());
659 auto &cursor_list = _view.get_cursorList();
660 _view.add_cursor(index);
661 _view.show_cursors(true);
662 }
663 }
664 }
665
666 if (_action_type == NO_ACTION &&
667 event->button() == Qt::LeftButton &&
668 _view.session().get_device()->get_work_mode() == DSO) {
669
670 for(auto s : _view.session().get_signals())
671 {
672 if (s->signal_type() == SR_CHANNEL_DSO && s->enabled()) {
673 DsoSignal *dsoSig = (DsoSignal*)s;
674 if (dsoSig->get_trig_rect(0, _view.get_view_width()).contains(_mouse_point)) {
675 _drag_sig = s;
676 set_action(DSO_TRIG_MOVE);
677 dsoSig->select(true);
678 break;
679 }
680 }
681 }
682 }
683
684 if (_action_type == NO_ACTION
685 && event->button() == Qt::LeftButton) {
686 if (_action_type == NO_ACTION && _view.search_cursor_shown()) {
687 const int64_t searchX = _view.index2pixel(_view.get_search_cursor()->index());
688
689 if (_view.get_search_cursor()->grabbed()) {
690 _view.get_ruler()->rel_grabbed_cursor();
691 }
692 else if (qAbs(searchX - event->pos().x()) <= HitCursorMargin) {
693 _view.get_ruler()->set_grabbed_cursor(_view.get_search_cursor());
694 set_action(CURS_MOVE);
695 }
696 }
697

Callers

nothing calls this directly

Calls 15

offsetMethod · 0.80
is_stopped_statusMethod · 0.80
sessionMethod · 0.80
get_work_modeMethod · 0.80
get_deviceMethod · 0.80
pixel2indexMethod · 0.80
add_cursorMethod · 0.80
show_cursorsMethod · 0.80
signal_typeMethod · 0.80
get_trig_rectMethod · 0.80
get_view_widthMethod · 0.80
selectMethod · 0.80

Tested by

no test coverage detected