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

Method updateFillingRect

src/backend/worksheet/plots/cartesian/BarPlot.cpp:1010–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1008}
1009
1010void BarPlotPrivate::updateFillingRect(int columnIndex, int valueIndex, const QVector<QLineF>& lines) {
1011 const auto& unclippedLines = q->cSystem->mapLogicalToScene(lines, AbstractCoordinateSystem::MappingFlag::SuppressPageClipping);
1012
1013 if (unclippedLines.isEmpty()) {
1014 m_fillPolygons[columnIndex][valueIndex] = QPolygonF();
1015 return;
1016 }
1017
1018 // we have four unclipped lines for the box.
1019 // clip the points to the plot data rect and create a new polygon
1020 // out of them that will be filled out.
1021 QPolygonF polygon;
1022 const QRectF& dataRect = static_cast<CartesianPlot*>(q->parentAspect())->dataRect();
1023 int i = 0;
1024 for (const auto& line : unclippedLines) {
1025 // clip the first point of the line
1026 QPointF p1 = line.p1();
1027 if (p1.x() < dataRect.left())
1028 p1.setX(dataRect.left());
1029 else if (p1.x() > dataRect.right())
1030 p1.setX(dataRect.right());
1031
1032 if (p1.y() < dataRect.top())
1033 p1.setY(dataRect.top());
1034 else if (p1.y() > dataRect.bottom())
1035 p1.setY(dataRect.bottom());
1036
1037 // clip the second point of the line
1038 QPointF p2 = line.p2();
1039 if (p2.x() < dataRect.left())
1040 p2.setX(dataRect.left());
1041 else if (p2.x() > dataRect.right())
1042 p2.setX(dataRect.right());
1043
1044 if (p2.y() < dataRect.top())
1045 p2.setY(dataRect.top());
1046 else if (p2.y() > dataRect.bottom())
1047 p2.setY(dataRect.bottom());
1048
1049 if (i != unclippedLines.size() - 1)
1050 polygon << p1;
1051 else {
1052 // close the polygon for the last line
1053 polygon << p1;
1054 polygon << p2;
1055 }
1056
1057 ++i;
1058 }
1059
1060 m_fillPolygons[columnIndex][valueIndex] = polygon;
1061}
1062
1063void BarPlotPrivate::updateValues() {
1064 m_valuesPath = QPainterPath();

Callers

nothing calls this directly

Calls 9

mapLogicalToSceneMethod · 0.80
dataRectMethod · 0.80
parentAspectMethod · 0.80
xMethod · 0.80
setXMethod · 0.80
setYMethod · 0.80
isEmptyMethod · 0.45
yMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected