! * this function is used to restore the pointers to the columns in xy-curves etc. * from the stored column paths. This function is called after the project was loaded * and when an aspect is being pasted. In both cases we deserialized from XML and need * to restore the pointers. */
| 923 | * to restore the pointers. |
| 924 | */ |
| 925 | void Project::restorePointers(AbstractAspect* aspect) { |
| 926 | DEBUG(Q_FUNC_INFO) |
| 927 | // wait until all columns are decoded from base64-encoded data |
| 928 | QThreadPool::globalInstance()->waitForDone(); |
| 929 | |
| 930 | // when restoring pointers for an aspect having children, for example a Folder, we need to recursively traverse |
| 931 | // all its children and restore the pointers for all of them. Analysis curves, for example XYFitCurve, can also |
| 932 | // children (residuals column, note) but there is no need to check the children, the pointers need to be restored |
| 933 | // for the analysis curve itself. |
| 934 | bool hasChildren = (aspect->childCount<AbstractAspect>() > 0 && !aspect->inherits(AspectType::XYAnalysisCurve)); |
| 935 | |
| 936 | #ifndef SDK |
| 937 | // LiveDataSource: |
| 938 | // call finalizeLoad() to replace relative with absolute paths if required |
| 939 | // and to create columns during the initial read |
| 940 | for (auto* source : aspect->children<LiveDataSource>(ChildIndexFlag::Recursive)) { |
| 941 | if (!source) |
| 942 | continue; |
| 943 | source->finalizeLoad(); |
| 944 | } |
| 945 | #endif |
| 946 | |
| 947 | // aspects in the project that can be used as sources/references: |
| 948 | auto* project = aspect->project(); |
| 949 | const auto& columns = project->children<Column>(ChildIndexFlag::Recursive); |
| 950 | const auto& histogramsAll = project->children<Histogram>(ChildIndexFlag::Recursive); // needed for fit curves only. |
| 951 | const auto& curvesAll = project->children<XYCurve>(ChildIndexFlag::Recursive); |
| 952 | |
| 953 | // xy-curves |
| 954 | // cannot be removed by the column observer, because it does not react |
| 955 | // on curve changes |
| 956 | QVector<XYCurve*> curves; |
| 957 | if (hasChildren) |
| 958 | curves = aspect->children<XYCurve>(ChildIndexFlag::Recursive); |
| 959 | else if (aspect->inherits(AspectType::XYCurve) || aspect->inherits(AspectType::XYAnalysisCurve)) |
| 960 | // the object doesn't have any children -> one single aspect is being pasted. |
| 961 | // check whether the object being pasted is a XYCurve and add it to the |
| 962 | // list of curves to be retransformed |
| 963 | curves << static_cast<XYCurve*>(aspect); |
| 964 | |
| 965 | for (auto* curve : std::as_const(curves)) { |
| 966 | if (!curve) |
| 967 | continue; |
| 968 | curve->setSuppressRetransform(true); |
| 969 | |
| 970 | auto* analysisCurve = dynamic_cast<XYAnalysisCurve*>(curve); |
| 971 | if (analysisCurve) { |
| 972 | RESTORE_COLUMN_POINTER(analysisCurve, xDataColumn, XDataColumn); |
| 973 | RESTORE_COLUMN_POINTER(analysisCurve, yDataColumn, YDataColumn); |
| 974 | RESTORE_COLUMN_POINTER(analysisCurve, y2DataColumn, Y2DataColumn); |
| 975 | auto* fitCurve = dynamic_cast<XYFitCurve*>(curve); |
| 976 | if (fitCurve) { |
| 977 | RESTORE_COLUMN_POINTER(fitCurve, xErrorColumn, XErrorColumn); |
| 978 | RESTORE_COLUMN_POINTER(fitCurve, yErrorColumn, YErrorColumn); |
| 979 | RESTORE_POINTER(fitCurve, dataSourceHistogram, DataSourceHistogram, Histogram, histogramsAll); |
| 980 | } |
| 981 | } else { |
| 982 | RESTORE_COLUMN_POINTER(curve, xColumn, XColumn); |