| 832 | #endif |
| 833 | |
| 834 | void Project::retransformElements(AbstractAspect* aspect) { |
| 835 | bool hasChildren = aspect->childCount<AbstractAspect>(); |
| 836 | |
| 837 | // recalculate all analysis curves if the results of the calculations were not saved in the project |
| 838 | if (!aspect->project()->saveCalculations()) { |
| 839 | for (auto* curve : aspect->children<XYAnalysisCurve>(ChildIndexFlag::Recursive)) |
| 840 | curve->recalculate(); |
| 841 | } |
| 842 | |
| 843 | // set "isLoading" to false for all worksheet elements |
| 844 | for (auto* child : aspect->children<WorksheetElement>(ChildIndexFlag::Recursive | ChildIndexFlag::IncludeHidden)) |
| 845 | child->setIsLoading(false); |
| 846 | |
| 847 | for (auto& column : aspect->project()->children<Column>(ChildIndexFlag::Recursive)) |
| 848 | column->setIsLoading(false); |
| 849 | |
| 850 | // all data was read: |
| 851 | // call retransform() to every element |
| 852 | if (hasChildren && aspect->type() == AspectType::Worksheet) { |
| 853 | const auto& elements = aspect->children<WorksheetElement>(ChildIndexFlag::Recursive | ChildIndexFlag::IncludeHidden); |
| 854 | for (auto* e : elements) |
| 855 | e->retransform(); |
| 856 | } else if (hasChildren && aspect->type() != AspectType::CartesianPlot) { |
| 857 | for (const auto* w : aspect->children<Worksheet>(ChildIndexFlag::Recursive | ChildIndexFlag::IncludeHidden)) { |
| 858 | // retransform all elements in the worksheet (labels, images, plots) |
| 859 | // the plots will then recursive retransform the childs of them |
| 860 | const auto& elements = w->children<WorksheetElement>(ChildIndexFlag::IncludeHidden); |
| 861 | for (auto* e : elements) |
| 862 | e->retransform(); |
| 863 | } |
| 864 | } else { |
| 865 | QVector<CartesianPlot*> plots; |
| 866 | if (aspect->type() == AspectType::CartesianPlot) |
| 867 | plots << static_cast<CartesianPlot*>(aspect); |
| 868 | else if (dynamic_cast<Plot*>(aspect)) |
| 869 | plots << static_cast<CartesianPlot*>(aspect->parentAspect()); |
| 870 | |
| 871 | if (!plots.isEmpty()) { |
| 872 | for (auto* plot : plots) |
| 873 | plot->retransform(); |
| 874 | } else { |
| 875 | // worksheet element is being copied alone without its parent plot object |
| 876 | // so the plot retransform is not called above. we need to call it for the aspect. |
| 877 | auto* e = dynamic_cast<WorksheetElement*>(aspect); |
| 878 | if (e) |
| 879 | e->retransform(); |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | #ifndef SDK |
| 884 | QVector<XYCurve*> curves; |
| 885 | if (hasChildren) |
| 886 | curves = aspect->children<XYCurve>(ChildIndexFlag::Recursive); |
| 887 | // all data was read in live-data sources: |
| 888 | // call CartesianPlot::dataChanged() to notify affected plots about the new data. |
| 889 | // this needs to be done here since in LiveDataSource::finalizeImport() called above |
| 890 | // where the data is read the column pointers are not restored yes in curves. |
| 891 | QVector<CartesianPlot*> plots; |