| 341 | } |
| 342 | |
| 343 | bool LogicSignal::is_by_edge(const QPointF &p, uint64_t &index, int radius) |
| 344 | { |
| 345 | uint64_t pre_index, nxt_index; |
| 346 | const float gap = abs(p.y() - get_y()); |
| 347 | |
| 348 | if (gap < get_totalHeight() * 0.5) { |
| 349 | if (_data->empty() || !_data->has_data(_probe->index)) |
| 350 | return false; |
| 351 | |
| 352 | const uint64_t end = _data->get_ring_sample_count() - 1; |
| 353 | const double pos = _data->samplerate() * _view->scale() * (_view->offset() + p.x()); |
| 354 | index = floor(pos + 0.5); |
| 355 | if (index > end) |
| 356 | return false; |
| 357 | |
| 358 | bool sample = _data->get_sample(index, get_index()); |
| 359 | if (index == 0) |
| 360 | pre_index = index; |
| 361 | else { |
| 362 | index--; |
| 363 | if (_data->get_pre_edge(index, sample, 1, get_index())) |
| 364 | pre_index = index; |
| 365 | else |
| 366 | pre_index = 0; |
| 367 | } |
| 368 | |
| 369 | sample = _data->get_sample(index, get_index()); |
| 370 | index++; |
| 371 | if (_data->get_nxt_edge(index, sample, end, 1, get_index())) |
| 372 | nxt_index = index; |
| 373 | else |
| 374 | nxt_index = 0; |
| 375 | |
| 376 | if (pre_index == 0 && nxt_index == 0) |
| 377 | return false; |
| 378 | |
| 379 | if (pre_index > 0 && nxt_index > 0) |
| 380 | { |
| 381 | if (pos - pre_index > nxt_index - pos) |
| 382 | index = nxt_index; |
| 383 | else |
| 384 | index = pre_index; |
| 385 | } |
| 386 | else{ |
| 387 | index = pre_index > 0 ? pre_index : nxt_index; |
| 388 | } |
| 389 | |
| 390 | if (radius > abs((index-pos) / _view->scale() / _data->samplerate())) |
| 391 | return true; |
| 392 | } |
| 393 | return false; |
| 394 | } |
| 395 | |
| 396 | bool LogicSignal::edge(const QPointF &p, uint64_t &index, int radius) |
| 397 | { |
no test coverage detected