! * @brief InfoElement::addCurve * Adds a new markerpoint to the plot which is placed on the curve curve * @param curve Curve on which the markerpoints sits * @param custompoint Use existing point, if the project was loaded the custompoint can have different settings */
| 226 | * @param custompoint Use existing point, if the project was loaded the custompoint can have different settings |
| 227 | */ |
| 228 | void InfoElement::addCurve(const XYCurve* curve, CustomPoint* custompoint) { |
| 229 | Q_D(InfoElement); |
| 230 | |
| 231 | for (auto& markerpoint : markerpoints) { |
| 232 | if (curve == markerpoint.curve) |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | project()->setSuppressAspectAddedSignal(true); |
| 237 | |
| 238 | if (!custompoint) { |
| 239 | m_suppressChildPositionChanged = true; |
| 240 | custompoint = new CustomPoint(d->m_plot, curve->name()); |
| 241 | custompoint->setCoordinateBindingEnabled(true); |
| 242 | custompoint->setCoordinateSystemIndex(curve->coordinateSystemIndex()); |
| 243 | setUndoAware(false); |
| 244 | addChild(custompoint); |
| 245 | setUndoAware(true); |
| 246 | |
| 247 | if (curve->xColumn() && curve->yColumn()) { |
| 248 | bool valueFound; |
| 249 | double x_new, y; |
| 250 | y = curve->y(d->positionLogical, x_new, valueFound); |
| 251 | |
| 252 | custompoint->setUndoAware(false); |
| 253 | custompoint->setPositionLogical(QPointF(x_new, y)); |
| 254 | custompoint->setUndoAware(true); |
| 255 | } |
| 256 | m_suppressChildPositionChanged = false; |
| 257 | } else |
| 258 | addChild(custompoint); |
| 259 | |
| 260 | project()->setSuppressAspectAddedSignal(true); |
| 261 | |
| 262 | initCurveConnections(curve); |
| 263 | |
| 264 | custompoint->setUndoAware(false); |
| 265 | custompoint->setVisible(curve->isVisible()); |
| 266 | custompoint->setUndoAware(true); |
| 267 | |
| 268 | if (d->m_index < 0 && curve->xColumn()) |
| 269 | d->m_index = curve->xColumn()->indexForValue(custompoint->positionLogical().x(), false); |
| 270 | |
| 271 | struct MarkerPoints_T markerpoint = {custompoint, curve, curve->path()}; |
| 272 | markerpoints.append(markerpoint); |
| 273 | |
| 274 | if (markerpoints.count() == 1) // first point |
| 275 | setConnectionLineCurveName(curve->name()); |
| 276 | |
| 277 | m_title->setUndoAware(false); |
| 278 | m_title->setText(createTextLabelText()); |
| 279 | |
| 280 | if (markerpoints.length() == 1) { |
| 281 | // Do a retransform, because when the first markerpoint |
| 282 | // was added, after a curve was removed and added, the |
| 283 | // position of the connection line must be recalculated |
| 284 | retransform(); |
| 285 | } |
nothing calls this directly
no test coverage detected