| 423 | } |
| 424 | |
| 425 | void Ruler::draw_logic_tick_mark(QPainter &p) |
| 426 | { |
| 427 | using namespace Qt; |
| 428 | |
| 429 | if (_view.session().get_device()->have_instance() == false){ |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | const double SpacingIncrement = 32.0; |
| 434 | const double MinValueSpacing = 16.0; |
| 435 | const int ValueMargin = 5; |
| 436 | const double abs_min_period = 10.0 / _view.session().cur_snap_samplerate(); |
| 437 | |
| 438 | double min_width = SpacingIncrement; |
| 439 | double typical_width; |
| 440 | double tick_period = 0; |
| 441 | double scale = _view.scale(); |
| 442 | int64_t offset = _view.offset(); |
| 443 | |
| 444 | const uint64_t cur_period_scale = ceil((scale * min_width) / abs_min_period); |
| 445 | |
| 446 | // Find tick spacing, and number formatting that does not cause |
| 447 | // value to collide. |
| 448 | _min_period = cur_period_scale * abs_min_period; |
| 449 | |
| 450 | const int order = (int)floorf(log10f(scale * _view.get_view_width())); |
| 451 | //const double order_decimal = pow(10, order); |
| 452 | const unsigned int prefix = (order - FirstSIPrefixPower) / 3; |
| 453 | _cur_prefix = prefix; |
| 454 | assert(prefix < countof(SIPrefixes)); |
| 455 | typical_width = p.boundingRect(0, 0, INT_MAX, INT_MAX, |
| 456 | AlignLeft | AlignTop, format_time(offset * scale, |
| 457 | prefix)).width() + MinValueSpacing; |
| 458 | do |
| 459 | { |
| 460 | tick_period += _min_period; |
| 461 | |
| 462 | } while(typical_width > tick_period / scale); |
| 463 | |
| 464 | const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX, |
| 465 | AlignLeft | AlignTop, "8").height(); |
| 466 | |
| 467 | // Draw the tick marks |
| 468 | QColor fore(QWidget::palette().color(QWidget::foregroundRole())); |
| 469 | fore.setAlpha(View::ForeAlpha); |
| 470 | p.setPen(fore); |
| 471 | |
| 472 | const double minor_tick_period = tick_period / MinPeriodScale; |
| 473 | const int minor_order = (int)floorf(log10f(minor_tick_period)); |
| 474 | //const double minor_order_decimal = pow(10, minor_order); |
| 475 | const unsigned int minor_prefix = (minor_order - FirstSIPrefixPower) / 3; |
| 476 | assert(minor_prefix < countof(SIPrefixes)); |
| 477 | |
| 478 | const double first_major_division = |
| 479 | floor(offset * scale / tick_period); |
| 480 | const double first_minor_division = |
| 481 | floor(offset * scale / minor_tick_period + 1); |
| 482 | const double t0 = first_major_division * tick_period; |
nothing calls this directly
no test coverage detected