! * \brief CartesianPlotDock::updatePlotRangeList * update plot ranges in list by recreating all widgets. This function is really slow, use it only for non-critical workflows which are called not that often. * Prefer updatePlotRangeListValues() */
| 788 | * Prefer updatePlotRangeListValues() |
| 789 | */ |
| 790 | void CartesianPlotDock::updatePlotRangeList() { |
| 791 | if (!m_plot) |
| 792 | return; |
| 793 | |
| 794 | const int cSystemCount{m_plot->coordinateSystemCount()}; |
| 795 | DEBUG(Q_FUNC_INFO << ", nr of coordinate systems = " << cSystemCount) |
| 796 | if (cSystemCount > 1) |
| 797 | ui.lPlotRanges->setText(i18n("Plot Ranges:")); |
| 798 | else |
| 799 | ui.lPlotRanges->setText(i18n("Plot Range:")); |
| 800 | ui.twPlotRanges->setRowCount(cSystemCount); |
| 801 | ui.twPlotRanges->horizontalHeader()->setSectionResizeMode(TwPlotRangesColumn::XRange, QHeaderView::ResizeMode::Stretch); |
| 802 | ui.twPlotRanges->horizontalHeader()->setSectionResizeMode(TwPlotRangesColumn::YRange, QHeaderView::ResizeMode::Stretch); |
| 803 | ui.twPlotRanges->horizontalHeader()->setSectionResizeMode(TwPlotRangesColumn::Default, QHeaderView::ResizeMode::ResizeToContents); |
| 804 | ui.twPlotRanges->horizontalHeader()->setSectionResizeMode(TwPlotRangesColumn::Name, QHeaderView::ResizeMode::ResizeToContents); |
| 805 | ui.twPlotRanges->horizontalHeader()->setStretchLastSection(false); |
| 806 | for (int i = 0; i < cSystemCount; i++) { |
| 807 | auto* cSystem{m_plot->coordinateSystem(i)}; |
| 808 | const int xIndex{cSystem->index(Dimension::X)}, yIndex{cSystem->index(Dimension::Y)}; |
| 809 | const auto& xRange = m_plot->range(Dimension::X, xIndex); |
| 810 | const auto& yRange = m_plot->range(Dimension::Y, yIndex); |
| 811 | |
| 812 | DEBUG(Q_FUNC_INFO << ", coordinate system " << i + 1 << " : xIndex = " << xIndex << ", yIndex = " << yIndex) |
| 813 | DEBUG(Q_FUNC_INFO << ", x range = " << xRange.toStdString() << ", auto scale = " << xRange.autoScale()) |
| 814 | DEBUG(Q_FUNC_INFO << ", y range = " << yRange.toStdString() << ", auto scale = " << yRange.autoScale()) |
| 815 | |
| 816 | // X-range |
| 817 | auto* cb = new ComboBoxIgnoreWheel(ui.twPlotRanges); |
| 818 | cb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 819 | cb->setEditable(true); // to have a line edit |
| 820 | cb->lineEdit()->setReadOnly(true); |
| 821 | cb->lineEdit()->setAlignment(Qt::AlignHCenter); |
| 822 | const auto xRangeCount = m_plot->rangeCount(Dimension::X); |
| 823 | if (xRangeCount > 1) { |
| 824 | for (int index = 0; index < xRangeCount; index++) |
| 825 | cb->addItem(generatePlotRangeString(xRangeCount, index, m_plot->range(Dimension::X, index)), QVariant::fromValue(index)); |
| 826 | cb->setCurrentIndex(xIndex); |
| 827 | cb->setProperty("row", i); |
| 828 | connect(cb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CartesianPlotDock::PlotRangeXChanged); |
| 829 | } else { |
| 830 | cb->addItem(generatePlotRangeString(xRangeCount, 0, xRange), QVariant::fromValue(0)); |
| 831 | cb->setStyleSheet(QStringLiteral("QComboBox::drop-down {border-width: 0px;}")); // hide arrow if there is only one range |
| 832 | } |
| 833 | ui.twPlotRanges->setCellWidget(i, TwPlotRangesColumn::XRange, cb); |
| 834 | |
| 835 | // Y-range |
| 836 | cb = new ComboBoxIgnoreWheel(ui.twPlotRanges); |
| 837 | cb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 838 | cb->setEditable(true); // to have a line edit |
| 839 | cb->lineEdit()->setReadOnly(true); |
| 840 | cb->lineEdit()->setAlignment(Qt::AlignHCenter); |
| 841 | const auto yRangeCount = m_plot->rangeCount(Dimension::Y); |
| 842 | if (yRangeCount > 1) { |
| 843 | for (int index = 0; index < yRangeCount; index++) |
| 844 | cb->addItem(generatePlotRangeString(yRangeCount, index, m_plot->range(Dimension::Y, index))); |
| 845 | cb->setCurrentIndex(yIndex); |
| 846 | cb->setProperty("row", i); |
| 847 | connect(cb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CartesianPlotDock::PlotRangeYChanged); |
nothing calls this directly
no test coverage detected