@@ -82,6 +82,7 @@ Viewport::Viewport(View &parent, View_type type) :
82
82
_mm_freq = " #####" ;
83
83
_mm_duty = " #####" ;
84
84
_measure_en = true ;
85
+ _edge_hit = false ;
85
86
transfer_started = false ;
86
87
timer_cnt = 0 ;
87
88
@@ -641,6 +642,30 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
641
642
}
642
643
643
644
// priority 2
645
+ if (_action_type == NO_ACTION) {
646
+ if (_mouse_down_point.x () == event->pos ().x ()) {
647
+ const vector< boost::shared_ptr<Signal> > sigs (_view.session ().get_signals ());
648
+ BOOST_FOREACH (const boost::shared_ptr<Signal> s, sigs) {
649
+ assert (s);
650
+ boost::shared_ptr<view::LogicSignal> logicSig;
651
+ if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
652
+ if (logicSig->edge (event->pos (), _edge_start, 10 )) {
653
+ _action_type = LOGIC_JUMP;
654
+ const double samples_per_pixel = _view.session ().cur_samplerate () * _view.scale ();
655
+ _cur_preX = _edge_start / samples_per_pixel - _view.offset ();
656
+ _cur_preY = logicSig->get_y ();
657
+ _cur_preY_top = logicSig->get_y () - logicSig->get_totalHeight ()/2 - 12 ;
658
+ _cur_preY_bottom = logicSig->get_y () + logicSig->get_totalHeight ()/2 + 2 ;
659
+ _cur_aftX = _cur_preX;
660
+ _cur_aftY = _cur_preY;
661
+ break ;
662
+ }
663
+ }
664
+ }
665
+ }
666
+ }
667
+
668
+ // priority 3
644
669
if (_action_type == NO_ACTION) {
645
670
if (_mouse_down_point.x () == event->pos ().x ()) {
646
671
const vector< boost::shared_ptr<Signal> > sigs (_view.session ().get_signals ());
@@ -738,6 +763,11 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
738
763
_action_type = NO_ACTION;
739
764
_edge_rising = 0 ;
740
765
_edge_falling = 0 ;
766
+ } else if (_action_type == LOGIC_JUMP) {
767
+ _action_type = NO_ACTION;
768
+ _edge_rising = 0 ;
769
+ _edge_falling = 0 ;
770
+ _edge_hit = false ;
741
771
} else if (_action_type == LOGIC_MOVE) {
742
772
if (_mouse_down_point == event->pos ()) {
743
773
_drag_strength = 0 ;
@@ -884,6 +914,10 @@ void Viewport::leaveEvent(QEvent *)
884
914
_edge_rising = 0 ;
885
915
_edge_falling = 0 ;
886
916
_action_type = NO_ACTION;
917
+ } else if (_action_type == LOGIC_JUMP) {
918
+ _edge_rising = 0 ;
919
+ _edge_falling = 0 ;
920
+ _action_type = NO_ACTION;
887
921
} else if (_action_type == LOGIC_MOVE) {
888
922
_drag_strength = 0 ;
889
923
_drag_timer.stop ();
@@ -975,6 +1009,18 @@ void Viewport::measure()
975
1009
976
1010
break ;
977
1011
}
1012
+ } else if (_action_type == LOGIC_JUMP) {
1013
+ const double samples_per_pixel = _view.session ().cur_samplerate () * _view.scale ();
1014
+ if (logicSig->edge (_view.hover_point (), _edge_end, 10 )) {
1015
+ _cur_aftX = _edge_end / samples_per_pixel - _view.offset ();
1016
+ _cur_aftY = logicSig->get_y ();
1017
+ _edge_hit = true ;
1018
+ break ;
1019
+ }
1020
+ _cur_preX = _edge_start / samples_per_pixel - _view.offset ();
1021
+ _cur_aftX = _view.hover_point ().x ();
1022
+ _cur_aftY = _view.hover_point ().y ();
1023
+ _edge_hit = false ;
978
1024
}
979
1025
} else if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
980
1026
if (_measure_en && dsoSig->measure (_view.hover_point ())) {
@@ -1287,6 +1333,56 @@ void Viewport::paintMeasure(QPainter &p)
1287
1333
p.drawText (measure3_rect, Qt::AlignRight | Qt::AlignVCenter, _em_falling);
1288
1334
1289
1335
}
1336
+
1337
+ if (_action_type == LOGIC_JUMP) {
1338
+ p.setPen (QColor (238 , 178 , 17 , 255 ));
1339
+ const QPoint pre_points[] = {
1340
+ QPoint (_cur_preX, _cur_preY),
1341
+ QPoint (_cur_preX-1 , _cur_preY-1 ),
1342
+ QPoint (_cur_preX+1 , _cur_preY-1 ),
1343
+ QPoint (_cur_preX-1 , _cur_preY+1 ),
1344
+ QPoint (_cur_preX+1 , _cur_preY+1 ),
1345
+ QPoint (_cur_preX-2 , _cur_preY-2 ),
1346
+ QPoint (_cur_preX+2 , _cur_preY-2 ),
1347
+ QPoint (_cur_preX-2 , _cur_preY+2 ),
1348
+ QPoint (_cur_preX+2 , _cur_preY+2 ),
1349
+ };
1350
+ p.drawPoints (pre_points, countof (pre_points));
1351
+ if (abs (_cur_aftX - _cur_preX) + abs (_cur_aftY - _cur_preY) > 20 ) {
1352
+ if (_edge_hit) {
1353
+ const QPoint aft_points[] = {
1354
+ QPoint (_cur_aftX, _cur_aftY),
1355
+ QPoint (_cur_aftX-1 , _cur_aftY-1 ),
1356
+ QPoint (_cur_aftX+1 , _cur_aftY-1 ),
1357
+ QPoint (_cur_aftX-1 , _cur_aftY+1 ),
1358
+ QPoint (_cur_aftX+1 , _cur_aftY+1 ),
1359
+ QPoint (_cur_aftX-2 , _cur_aftY-2 ),
1360
+ QPoint (_cur_aftX+2 , _cur_aftY-2 ),
1361
+ QPoint (_cur_aftX-2 , _cur_aftY+2 ),
1362
+ QPoint (_cur_aftX+2 , _cur_aftY+2 ),
1363
+ };
1364
+ p.drawPoints (aft_points, countof (aft_points));
1365
+
1366
+ int64_t delta = max (_edge_start, _edge_end) - min (_edge_start, _edge_end);
1367
+ QString delta_text = _view.get_index_delta (_edge_start, _edge_end) +
1368
+ " /" + QString::number (delta);
1369
+ QFontMetrics fm = this ->fontMetrics ();
1370
+ const int rectW = fm.width (delta_text);
1371
+ const int rectY = (_cur_aftY >= _cur_preY) ? _cur_preY_top : _cur_preY_bottom;
1372
+ const int rectX = (_cur_aftX >= _cur_preX) ? _cur_preX : _cur_preX - rectW;
1373
+ QRectF jump_rect = QRectF (rectX, rectY, rectW, 10 );
1374
+ p.drawText (jump_rect, Qt::AlignCenter | Qt::AlignVCenter, delta_text);
1375
+
1376
+ }
1377
+
1378
+ QPainterPath path (QPoint (_cur_preX, _cur_preY));
1379
+ QPoint c1 ((_cur_preX+_cur_aftX)/2 , _cur_preY);
1380
+ QPoint c2 ((_cur_preX+_cur_aftX)/2 , _cur_aftY);
1381
+ path.cubicTo (c1, c2, QPoint (_cur_aftX, _cur_aftY));
1382
+ p.drawPath (path);
1383
+
1384
+ }
1385
+ }
1290
1386
}
1291
1387
1292
1388
QString Viewport::get_measure (QString option)
0 commit comments