| 1340 | } |
| 1341 | |
| 1342 | void BoxPlotPrivate::updateFillingRect(int index, const QVector<QLineF>& lines) { |
| 1343 | const auto& unclippedLines = q->cSystem->mapLogicalToScene(lines, AbstractCoordinateSystem::MappingFlag::SuppressPageClipping); |
| 1344 | |
| 1345 | if (unclippedLines.isEmpty()) { |
| 1346 | m_fillPolygon[index] = QPolygonF(); |
| 1347 | return; |
| 1348 | } |
| 1349 | |
| 1350 | // we have four unclipped lines for the box. |
| 1351 | // clip the points to the plot data rect and create a new polygon |
| 1352 | // out of them that will be filled out. |
| 1353 | QPolygonF polygon; |
| 1354 | const QRectF& dataRect = static_cast<CartesianPlot*>(q->parentAspect())->dataRect(); |
| 1355 | int i = 0; |
| 1356 | for (const auto& line : unclippedLines) { |
| 1357 | // clip the first point of the line |
| 1358 | QPointF p1 = line.p1(); |
| 1359 | if (p1.x() < dataRect.left()) |
| 1360 | p1.setX(dataRect.left()); |
| 1361 | else if (p1.x() > dataRect.right()) |
| 1362 | p1.setX(dataRect.right()); |
| 1363 | |
| 1364 | if (p1.y() < dataRect.top()) |
| 1365 | p1.setY(dataRect.top()); |
| 1366 | else if (p1.y() > dataRect.bottom()) |
| 1367 | p1.setY(dataRect.bottom()); |
| 1368 | |
| 1369 | // clip the second point of the line |
| 1370 | QPointF p2 = line.p2(); |
| 1371 | if (p2.x() < dataRect.left()) |
| 1372 | p2.setX(dataRect.left()); |
| 1373 | else if (p2.x() > dataRect.right()) |
| 1374 | p2.setX(dataRect.right()); |
| 1375 | |
| 1376 | if (p2.y() < dataRect.top()) |
| 1377 | p2.setY(dataRect.top()); |
| 1378 | else if (p2.y() > dataRect.bottom()) |
| 1379 | p2.setY(dataRect.bottom()); |
| 1380 | |
| 1381 | if (i != unclippedLines.size() - 1) |
| 1382 | polygon << p1; |
| 1383 | else { |
| 1384 | // close the polygon for the last line |
| 1385 | polygon << p1; |
| 1386 | polygon << p2; |
| 1387 | } |
| 1388 | |
| 1389 | ++i; |
| 1390 | } |
| 1391 | |
| 1392 | m_fillPolygon[index] = std::move(polygon); |
| 1393 | } |
| 1394 | |
| 1395 | /*! |
| 1396 | * map the outlier points from logical to scene coordinates, |
nothing calls this directly
no test coverage detected