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

Method PlotRangeChanged

src/frontend/dockwidgets/CartesianPlotDock.cpp:1236–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236void CartesianPlotDock::PlotRangeChanged(const int plotRangeIndex, const Dimension dim, const int index) {
1237 const std::string dimStr = CartesianCoordinateSystem::dimensionToString(dim).toStdString();
1238 DEBUG(Q_FUNC_INFO << ", Set " << dimStr << " range of plot range " << plotRangeIndex + 1 << " to " << index + 1)
1239 auto* cSystem{m_plot->coordinateSystem(plotRangeIndex)};
1240 const auto indexOld = cSystem->index(dim);
1241 m_plot->setCoordinateSystemRangeIndex(plotRangeIndex, dim, index);
1242
1243 m_plot->setRangeDirty(dim, index, true);
1244 m_plot->setRangeDirty(dim, indexOld, true);
1245
1246 // auto scale x range when on auto scale (now that it is used)
1247 if (m_plot->range(dim, index).autoScale()) {
1248 autoScaleRange(dim, index, true);
1249 updateRangeList(dim);
1250 }
1251
1252 for (auto* axis : m_plot->children<Axis>()) {
1253 const int cSystemIndex{axis->coordinateSystemIndex()};
1254 DEBUG(Q_FUNC_INFO << ", Axis \"" << STDSTRING(axis->name()) << "\" cSystem index = " << cSystemIndex)
1255 if (cSystemIndex == plotRangeIndex) {
1256 DEBUG(Q_FUNC_INFO << ", Plot range used in axis \"" << STDSTRING(axis->name()) << "\" has changed")
1257 if (axis->rangeType() == Axis::RangeType::Auto
1258 && ((dim == Dimension::X && axis->orientation() == Axis::Orientation::Horizontal)
1259 || (dim == Dimension::Y && axis->orientation() == Axis::Orientation::Vertical))) {
1260 DEBUG(Q_FUNC_INFO << ", set " << dimStr << " range of axis to " << m_plot->range(dim, index).toStdString())
1261 axis->setRange(m_plot->range(dim, index));
1262 }
1263 }
1264 }
1265
1266 // Retransform axes and all other elements, because the coordinatesystem changed
1267 m_plot->WorksheetElementContainer::retransform();
1268}
1269
1270/*
1271 * Called when x/y range of plot range in plot range list changes

Calls 11

toStdStringMethod · 0.80
rangeMethod · 0.80
coordinateSystemIndexMethod · 0.80
coordinateSystemMethod · 0.45
indexMethod · 0.45
setRangeDirtyMethod · 0.45
autoScaleMethod · 0.45
nameMethod · 0.45
orientationMethod · 0.45
setRangeMethod · 0.45

Tested by 4

TestChangePlotRangeMethod · 0.64