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

Method addCurve

src/backend/worksheet/InfoElement.cpp:228–289  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

226 * @param custompoint Use existing point, if the project was loaded the custompoint can have different settings
227 */
228void 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 }

Callers

nothing calls this directly

Calls 15

coordinateSystemIndexMethod · 0.80
setUndoAwareMethod · 0.80
xMethod · 0.80
appendMethod · 0.80
lengthMethod · 0.80
QPointFClass · 0.50
nameMethod · 0.45
yMethod · 0.45
setPositionLogicalMethod · 0.45

Tested by

no test coverage detected