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

Method dataChanged

src/backend/worksheet/plots/cartesian/CartesianPlot.cpp:2619–2666  ·  view source on GitHub ↗

! called when in one of the curves the data was changed. Autoscales the coordinate system and the x-axes, when "auto-scale" is active. */

Source from the content-addressed store, hash-verified

2617 Autoscales the coordinate system and the x-axes, when "auto-scale" is active.
2618*/
2619void CartesianPlot::dataChanged(int xIndex, int yIndex, WorksheetElement* sender) {
2620 DEBUG(Q_FUNC_INFO << ", x/y index = " << xIndex << "/" << yIndex)
2621 if (isLoading())
2622 return;
2623
2624 Q_D(CartesianPlot);
2625 if (d->suppressRetransform)
2626 return;
2627
2628 if (xIndex == -1) {
2629 for (int i = 0; i < rangeCount(Dimension::X); i++)
2630 d->setRangeDirty(Dimension::X, i, true);
2631 } else
2632 d->setRangeDirty(Dimension::X, xIndex, true);
2633
2634 if (yIndex == -1) {
2635 for (int i = 0; i < rangeCount(Dimension::Y); i++)
2636 d->setRangeDirty(Dimension::Y, i, true);
2637 } else
2638 d->setRangeDirty(Dimension::Y, yIndex, true);
2639
2640 bool updated = false;
2641 if (autoScale(Dimension::X, xIndex) && autoScale(Dimension::Y, yIndex))
2642 updated = scaleAuto(xIndex, yIndex);
2643 else if (autoScale(Dimension::X, xIndex))
2644 updated = scaleAuto(Dimension::X, xIndex);
2645 else if (autoScale(Dimension::Y, yIndex))
2646 updated = scaleAuto(Dimension::Y, yIndex);
2647
2648 if (updated)
2649 WorksheetElementContainer::retransform();
2650 else {
2651 // even if the plot ranges were not changed, either no auto scale active or the new data
2652 // is within the current ranges and no change of the ranges is required,
2653 // retransform the curve in order to show the changes
2654 if (sender)
2655 sender->retransform();
2656 else {
2657 // no sender available, the function was called directly in the file filter (live data source got new data) or in Project::load()-.
2658 // -> recalculate the internal structures in all plots and retransform them since we don't know which plots are affected.
2659 // TODO: this logic can be very expensive
2660 for (auto* plot : children<Plot>()) {
2661 plot->recalc();
2662 plot->retransform();
2663 }
2664 }
2665 }
2666}
2667
2668void CartesianPlot::dataChanged(WorksheetElement* element) {
2669 DEBUG(Q_FUNC_INFO)

Callers 5

childAddedMethod · 0.95
recalcMethod · 0.45
recalcMethod · 0.45
recalcMethod · 0.45
recalcMethod · 0.45

Calls 12

scaleAutoMethod · 0.95
isLoadingMethod · 0.80
coordinateSystemIndexMethod · 0.80
setRangeDirtyMethod · 0.45
retransformMethod · 0.45
recalcMethod · 0.45
indexMethod · 0.45
indexOfMethod · 0.45
sizeMethod · 0.45
columnMethod · 0.45
formatMethod · 0.45
columnModeMethod · 0.45

Tested by

no test coverage detected