MCPcopy Create free account
hub / github.com/KDE/labplot / updatePlotRangeList

Method updatePlotRangeList

src/frontend/dockwidgets/CartesianPlotDock.cpp:790–891  ·  view source on GitHub ↗

! * \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() */

Source from the content-addressed store, hash-verified

788 * Prefer updatePlotRangeListValues()
789 */
790void 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);

Callers

nothing calls this directly

Calls 15

generatePlotRangeStringFunction · 0.85
rangeMethod · 0.80
toStdStringMethod · 0.80
setReadOnlyMethod · 0.80
lineEditMethod · 0.80
heightMethod · 0.80
coordinateSystemCountMethod · 0.45
setTextMethod · 0.45
setRowCountMethod · 0.45
coordinateSystemMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected