| 56 | |
| 57 | STD_SWAP_METHOD_SETTER_CMD_IMPL(WorksheetElementContainer, SetVisible, bool, swapVisible) |
| 58 | void WorksheetElementContainer::setVisible(bool on) { |
| 59 | Q_D(WorksheetElementContainer); |
| 60 | |
| 61 | // take care of proper ordering on the undo-stack, |
| 62 | // when making the container and all its children visible/invisible. |
| 63 | // if visible is set true, change the visibility of the container first |
| 64 | if (on) { |
| 65 | beginMacro(i18n("%1: set visible", name())); |
| 66 | exec(new WorksheetElementContainerSetVisibleCmd(d, on, ki18n("%1: set visible"))); |
| 67 | } else |
| 68 | beginMacro(i18n("%1: set invisible", name())); |
| 69 | |
| 70 | // change the visibility of all children |
| 71 | const auto& elements = children<Plot>(AbstractAspect::ChildIndexFlag::IncludeHidden | AbstractAspect::ChildIndexFlag::Compress); |
| 72 | for (auto* elem : elements) { |
| 73 | auto* plot = dynamic_cast<Plot*>(elem); |
| 74 | if (plot) { |
| 75 | // making curves invisible triggers the recalculation of plot ranges if auto-scale is active. |
| 76 | // this should be avoided by supressing the retransformation in the curves. |
| 77 | plot->setSuppressRetransform(true); |
| 78 | elem->setVisible(on); |
| 79 | plot->setSuppressRetransform(false); |
| 80 | } else if (elem) |
| 81 | elem->setVisible(on); |
| 82 | } |
| 83 | |
| 84 | // if visible is set false, change the visibility of the container last |
| 85 | if (!on) |
| 86 | exec(new WorksheetElementContainerSetVisibleCmd(d, false, ki18n("%1: set invisible"))); |
| 87 | |
| 88 | endMacro(); |
| 89 | } |
| 90 | |
| 91 | bool WorksheetElementContainer::isFullyVisible() const { |
| 92 | const auto& elements = children<WorksheetElement>(AbstractAspect::ChildIndexFlag::IncludeHidden | AbstractAspect::ChildIndexFlag::Compress); |
no test coverage detected