| 83 | } |
| 84 | |
| 85 | void XYFunctionCurveDock::initGeneralTab() { |
| 86 | // show the properties of the first curve |
| 87 | const auto* functionCurve = static_cast<const XYFunctionCurve*>(m_curve); |
| 88 | const auto* plot = m_curve->plot(); |
| 89 | Q_ASSERT(functionCurve); |
| 90 | uiGeneralTab.teFunction->setText(functionCurve->function()); |
| 91 | |
| 92 | removeAllVariableWidgets(); |
| 93 | const auto& formulaData = functionCurve->functionData(); |
| 94 | |
| 95 | if (formulaData.isEmpty()) { // no formula was used for this column -> add the first variable "x" |
| 96 | addVariable(); |
| 97 | m_variableLineEdits.constFirst()->setText(QStringLiteral("x")); |
| 98 | } else { // formula and variables are available |
| 99 | // add all available variables and select the corresponding columns |
| 100 | const auto& curves = plot->children<XYCurve>(AbstractAspect::ChildIndexFlag::Recursive); |
| 101 | for (int i = 0; i < formulaData.size(); ++i) { |
| 102 | addVariable(); |
| 103 | m_variableLineEdits.at(i)->setText(formulaData.at(i).variableName()); |
| 104 | auto* cb = m_variableComboBoxes.at(i); |
| 105 | |
| 106 | bool found = false; |
| 107 | for (const auto* curve : curves) { |
| 108 | if (curve != formulaData.at(i).curve()) |
| 109 | continue; |
| 110 | |
| 111 | if (curve) |
| 112 | cb->setCurrentModelIndex(aspectModel()->modelIndexOfAspect(curve)); |
| 113 | else |
| 114 | cb->setCurrentModelIndex(QModelIndex()); |
| 115 | |
| 116 | cb->setInvalid(false); |
| 117 | |
| 118 | found = true; |
| 119 | break; |
| 120 | } |
| 121 | |
| 122 | // for the current variable name no curve exists anymore (was deleted) |
| 123 | //->highlight the combobox red |
| 124 | if (!found) { |
| 125 | cb->setCurrentModelIndex(QModelIndex()); |
| 126 | cb->setInvalid( |
| 127 | true, |
| 128 | i18n("The curve \"%1\"\nis not available anymore. It will be automatically used once it is created again.", formulaData.at(i).curvePath())); |
| 129 | cb->setText(formulaData.at(i).curvePath().split(QLatin1Char('/')).last()); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | uiGeneralTab.chkLegendVisible->setChecked(m_curve->legendVisible()); |
| 135 | uiGeneralTab.chkVisible->setChecked(m_curve->isVisible()); |
| 136 | |
| 137 | // Slots |
| 138 | connect(m_functionCurve, &XYFunctionCurve::functionDataChanged, this, &XYFunctionCurveDock::curveFunctionDataChanged); |
| 139 | } |
| 140 | |
| 141 | /*! |
| 142 | sets the curves. The properties of the curves in the list \c list can be edited in this widget. |
nothing calls this directly
no test coverage detected