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

Method curveAdded

src/backend/worksheet/Worksheet.cpp:1360–1404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1358}
1359
1360void Worksheet::curveAdded(const XYCurve* curve) {
1361 Q_D(const Worksheet);
1362 auto* plot = dynamic_cast<CartesianPlot*>(QObject::sender());
1363 if (!plot)
1364 return;
1365
1366 TreeModel* treeModel = cursorModel();
1367 int rowCount = treeModel->rowCount();
1368
1369 int i = 0;
1370 // first row is the x axis when applied to all plots. Starting at the second row
1371 if (cartesianPlotCursorMode() == CartesianPlotActionMode::ApplyActionToAll)
1372 i = 1;
1373
1374 for (; i < rowCount; i++) {
1375 QModelIndex plotIndex = treeModel->index(i, static_cast<int>(WorksheetPrivate::TreeModelColumn::PLOTNAME));
1376 if (plotIndex.data().toString().compare(plot->name()) != 0)
1377 continue;
1378 int row = 0;
1379 for (int j = 0; j < plot->curveCount(); j++) {
1380 if (plot->getCurve(j)->name().compare(curve->name()) != 0) {
1381 if (plot->getCurve(j)->isVisible())
1382 row++;
1383 continue;
1384 }
1385
1386 treeModel->insertRow(row, plotIndex);
1387
1388 treeModel->setTreeData(QVariant(curve->name()), row, static_cast<int>(WorksheetPrivate::TreeModelColumn::SIGNALNAME), plotIndex);
1389 QColor curveColor = curve->line()->pen().color();
1390 curveColor.setAlpha(d->cursorTreeModelCurveBackgroundAlpha);
1391 treeModel->setTreeData(QVariant(curveColor), row, static_cast<int>(WorksheetPrivate::TreeModelColumn::SIGNALNAME), plotIndex, Qt::BackgroundRole);
1392 bool valueFound;
1393 double valueCursor0 = curve->y(plot->cursorPos(0), valueFound);
1394 treeModel->setTreeData(QVariant(valueCursor0), row, static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSOR0), plotIndex);
1395
1396 double valueCursor1 = curve->y(plot->cursorPos(1), valueFound);
1397 treeModel->setTreeData(QVariant(valueCursor1), row, static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSOR1), plotIndex);
1398
1399 treeModel->setTreeData(QVariant(valueCursor1 - valueCursor0), row, static_cast<int>(WorksheetPrivate::TreeModelColumn::CURSORDIFF), plotIndex);
1400 break;
1401 }
1402 break;
1403 }
1404}
1405
1406void Worksheet::curveRemoved(const XYCurve* curve) {
1407 auto* plot = dynamic_cast<CartesianPlot*>(QObject::sender());

Callers

nothing calls this directly

Calls 13

curveCountMethod · 0.80
getCurveMethod · 0.80
setTreeDataMethod · 0.80
cursorPosMethod · 0.80
rowCountMethod · 0.45
indexMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
nameMethod · 0.45
isVisibleMethod · 0.45
colorMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected