| 590 | } |
| 591 | |
| 592 | void CartesianPlotDock::updateRangeList(const Dimension dim) { |
| 593 | if (!m_plot) |
| 594 | return; |
| 595 | |
| 596 | const auto dir_str = CartesianCoordinateSystem::dimensionToString(dim); |
| 597 | |
| 598 | QTableWidget* tw = nullptr; |
| 599 | QLabel* l = nullptr; |
| 600 | QToolButton* tb = nullptr; |
| 601 | switch (dim) { |
| 602 | case Dimension::X: |
| 603 | tw = ui.twXRanges; |
| 604 | l = ui.lXRanges; |
| 605 | tb = ui.tbRemoveXRange; |
| 606 | break; |
| 607 | case Dimension::Y: |
| 608 | tw = ui.twYRanges; |
| 609 | l = ui.lYRanges; |
| 610 | tb = ui.tbRemoveYRange; |
| 611 | break; |
| 612 | } |
| 613 | |
| 614 | tw->horizontalHeader()->setSectionResizeMode(TwRangesColumn::Automatic, QHeaderView::ResizeMode::ResizeToContents); |
| 615 | tw->horizontalHeader()->setSectionResizeMode(TwRangesColumn::Format, QHeaderView::ResizeMode::ResizeToContents); |
| 616 | tw->horizontalHeader()->setSectionResizeMode(TwRangesColumn::Min, QHeaderView::ResizeMode::Stretch); |
| 617 | tw->horizontalHeader()->setSectionResizeMode(TwRangesColumn::Max, QHeaderView::ResizeMode::Stretch); |
| 618 | tw->horizontalHeader()->setSectionResizeMode(TwRangesColumn::Scale, QHeaderView::ResizeMode::ResizeToContents); |
| 619 | tw->horizontalHeader()->setStretchLastSection(false); |
| 620 | |
| 621 | const int rangeCount = m_plot->rangeCount(dim); |
| 622 | DEBUG(Q_FUNC_INFO << ", " << dir_str.toStdString() << " range count = " << rangeCount) |
| 623 | |
| 624 | if (rangeCount > 1) |
| 625 | l->setText(i18n("%1-Ranges:", dir_str.toUpper())); |
| 626 | else |
| 627 | l->setText(i18n("%1-Range:", dir_str.toUpper())); |
| 628 | tw->setRowCount(rangeCount); |
| 629 | for (int i = 0; i < rangeCount; i++) { |
| 630 | const auto& r = m_plot->range(dim, i); |
| 631 | const auto format = r.format(); |
| 632 | const auto scale = r.scale(); |
| 633 | DEBUG(Q_FUNC_INFO << ", range " << i << ": format = " << ENUM_TO_STRING(RangeT, Format, format) << ", scale = " << ENUM_TO_STRING(RangeT, Scale, scale) |
| 634 | << ", auto scale = " << r.autoScale()) |
| 635 | |
| 636 | // auto scale |
| 637 | auto* chk = new QCheckBox(tw); |
| 638 | chk->setProperty("row", i); |
| 639 | chk->setChecked(r.autoScale()); |
| 640 | // chk->setStyleSheet("margin-left:50%; margin-right:50%;"); // center button |
| 641 | tw->setCellWidget(i, TwRangesColumn::Automatic, chk); |
| 642 | connect(chk, &QCheckBox::toggled, [this, chk, dim](bool checked) { |
| 643 | const int rangeIndex = chk->property("row").toInt(); |
| 644 | this->autoScaleChanged(dim, rangeIndex, checked); |
| 645 | }); |
| 646 | |
| 647 | // format |
| 648 | auto* cb = new ComboBoxIgnoreWheel(tw); |
| 649 | cb->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); |
nothing calls this directly
no test coverage detected