! * Called when the model type or the degree of the model were changed. * Show the preview pixmap of the fit model expression for the current model category and type. */
| 956 | * Show the preview pixmap of the fit model expression for the current model category and type. |
| 957 | */ |
| 958 | void XYFitCurveDock::updateModelEquation() { |
| 959 | if (m_fitData.modelCategory == nsl_fit_model_custom) { |
| 960 | DEBUG(Q_FUNC_INFO << ", category = nsl_fit_model_custom, type = " << m_fitData.modelType); |
| 961 | } else { |
| 962 | DEBUG(Q_FUNC_INFO << ", category = " << nsl_fit_model_category_name[m_fitData.modelCategory] << ", type = " << m_fitData.modelType); |
| 963 | } |
| 964 | |
| 965 | // this function can also be called when the value for the degree was changed -> update the fit data structure |
| 966 | int degree = uiGeneralTab.sbDegree->value(); |
| 967 | if (!m_initializing) { |
| 968 | m_fitData.degree = degree; |
| 969 | XYFitCurve::initFitData(m_fitData); |
| 970 | // set model dependent start values from curve data |
| 971 | // invalidate result |
| 972 | m_fitCurve->clearFitResult(); |
| 973 | static_cast<XYFitCurve*>(m_curve)->initStartValues(m_fitData); |
| 974 | // udpate parameter widget |
| 975 | fitParametersWidget->setFitData(&m_fitData); |
| 976 | if (m_messageWidget && m_messageWidget->isVisible()) { |
| 977 | DEBUG(Q_FUNC_INFO << ", close message") |
| 978 | m_messageWidget->animatedHide(); |
| 979 | } |
| 980 | |
| 981 | if (m_fitData.previewEnabled) |
| 982 | showFitResult(); // show result of preview |
| 983 | } |
| 984 | |
| 985 | // variables/parameter that are known |
| 986 | QStringList vars = {QStringLiteral("x")}; |
| 987 | vars << m_fitData.paramNames; |
| 988 | uiGeneralTab.teEquation->setVariables(vars); |
| 989 | |
| 990 | // set formula picture |
| 991 | uiGeneralTab.lEquation->setText(QStringLiteral("f(x) =")); |
| 992 | QString file; |
| 993 | switch (m_fitData.modelCategory) { |
| 994 | case nsl_fit_model_basic: { |
| 995 | // formula pic depends on degree |
| 996 | QString numSuffix = QString::number(degree); |
| 997 | if (degree > 4) |
| 998 | numSuffix = QLatin1Char('4'); |
| 999 | if ((nsl_fit_model_type_basic)m_fitData.modelType == nsl_fit_model_power && degree > 2) |
| 1000 | numSuffix = QLatin1Char('2'); |
| 1001 | file = QStandardPaths::locate(QStandardPaths::AppDataLocation, |
| 1002 | QStringLiteral("pics/fit_models/") + QLatin1String(nsl_fit_model_basic_pic_name[m_fitData.modelType]) + numSuffix |
| 1003 | + QStringLiteral(".pdf")); |
| 1004 | break; |
| 1005 | } |
| 1006 | case nsl_fit_model_peak: { |
| 1007 | // formula pic depends on number of peaks |
| 1008 | QString numSuffix = QString::number(degree); |
| 1009 | if (degree > 4) |
| 1010 | numSuffix = QLatin1Char('4'); |
| 1011 | file = QStandardPaths::locate(QStandardPaths::AppDataLocation, |
| 1012 | QStringLiteral("pics/fit_models/") + QLatin1String(nsl_fit_model_peak_pic_name[m_fitData.modelType]) + numSuffix |
| 1013 | + QStringLiteral(".pdf")); |
| 1014 | break; |
| 1015 | } |
nothing calls this directly
no test coverage detected