MCPcopy Create free account
hub / github.com/KDE/labplot / updateModelEquation

Method updateModelEquation

src/frontend/dockwidgets/XYFitCurveDock.cpp:958–1074  ·  view source on GitHub ↗

! * 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. */

Source from the content-addressed store, hash-verified

956 * Show the preview pixmap of the fit model expression for the current model category and type.
957 */
958void 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 }

Callers

nothing calls this directly

Calls 14

clearFitResultMethod · 0.80
initStartValuesMethod · 0.80
showMethod · 0.80
heightMethod · 0.80
isNullMethod · 0.80
valueMethod · 0.45
setFitDataMethod · 0.45
isVisibleMethod · 0.45
setVariablesMethod · 0.45
setTextMethod · 0.45
widthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected