| 394 | } |
| 395 | |
| 396 | bool LogicSignal::edge(const QPointF &p, uint64_t &index, int radius) |
| 397 | { |
| 398 | uint64_t pre_index, nxt_index; |
| 399 | const float gap = abs(p.y() - get_y()); |
| 400 | |
| 401 | if (gap < get_totalHeight() * 0.5) { |
| 402 | if (_data->empty() || !_data->has_data(_probe->index)) |
| 403 | return false; |
| 404 | |
| 405 | const uint64_t end = _data->get_ring_sample_count() - 1; |
| 406 | const double pos = _data->samplerate() * _view->scale() * (_view->offset() + p.x()); |
| 407 | index = floor(pos + 0.5); |
| 408 | if (index > end) |
| 409 | return false; |
| 410 | |
| 411 | bool sample = _data->get_sample(index, get_index()); |
| 412 | if (index == 0) |
| 413 | pre_index = index; |
| 414 | else { |
| 415 | index--; |
| 416 | if (_data->get_pre_edge(index, sample, 1, get_index())) |
| 417 | pre_index = index; |
| 418 | else |
| 419 | pre_index = 0; |
| 420 | } |
| 421 | |
| 422 | sample = _data->get_sample(index, get_index()); |
| 423 | index++; |
| 424 | if (_data->get_nxt_edge(index, sample, end, 1, get_index())) |
| 425 | nxt_index = index; |
| 426 | else |
| 427 | nxt_index = 0; |
| 428 | |
| 429 | if (pre_index == 0 || nxt_index == 0) |
| 430 | return false; |
| 431 | |
| 432 | if (pos - pre_index > nxt_index - pos) |
| 433 | index = nxt_index; |
| 434 | else |
| 435 | index = pre_index; |
| 436 | |
| 437 | if (radius > abs((index-pos) / _view->scale() / _data->samplerate())) |
| 438 | return true; |
| 439 | } |
| 440 | return false; |
| 441 | } |
| 442 | |
| 443 | bool LogicSignal::edges(const QPointF &p, uint64_t start, uint64_t &rising, uint64_t &falling) |
| 444 | { |
no test coverage detected