! called when in one of the curves the data was changed. Autoscales the coordinate system and the x-axes, when "auto-scale" is active. */
| 2617 | Autoscales the coordinate system and the x-axes, when "auto-scale" is active. |
| 2618 | */ |
| 2619 | void 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 | |
| 2668 | void CartesianPlot::dataChanged(WorksheetElement* element) { |
| 2669 | DEBUG(Q_FUNC_INFO) |
no test coverage detected