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

Method updateFilling

src/backend/worksheet/plots/cartesian/XYCurve.cpp:2043–2299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2041}
2042
2043void XYCurvePrivate::updateFilling() {
2044 if (suppressRetransform)
2045 return;
2046
2047 m_fillPolygons.clear();
2048
2049 // don't try to calculate the filling polygons if
2050 // - no filling was enabled
2051 // - the number of visible points on the scene is too high
2052 // - no scene points available, everything outside of the plot region or no scene points calculated yet
2053 auto fillingPosition = background->position();
2054 if (fillingPosition == Background::Position::No) {
2055 recalcShapeAndBoundingRect();
2056 return;
2057 }
2058 calculateScenePoints(); // TODO: find other way
2059 if (m_scenePoints.size() > 1000 || m_scenePoints.isEmpty()) {
2060 recalcShapeAndBoundingRect();
2061 return;
2062 }
2063
2064 QVector<QLineF> fillLines;
2065
2066 // if there're no interpolation lines available (XYCurve::NoLine selected), create line-interpolation,
2067 // use already available lines otherwise.
2068 if (!m_lines.isEmpty())
2069 fillLines = m_lines;
2070 else {
2071 for (int i = 0; i < m_logicalPoints.size() - 1; i++) {
2072 if (!lineSkipGaps && !connectedPointsLogical[i])
2073 continue;
2074 fillLines.append(QLineF(m_logicalPoints.at(i), m_logicalPoints.at(i + 1)));
2075 }
2076
2077 // no lines available (no points), nothing to do
2078 if (fillLines.isEmpty())
2079 return;
2080
2081 fillLines = q->cSystem->mapLogicalToScene(fillLines);
2082
2083 // no lines available (no points) after mapping, nothing to do
2084 if (fillLines.isEmpty())
2085 return;
2086 }
2087
2088 // create polygon(s):
2089 // 1. Depending on the current zoom-level, only a subset of the curve may be visible in the plot
2090 // and more of the filling area should be shown than the area defined by the start and end points of the currently visible points.
2091 // We check first whether the curve crosses the boundaries of the plot and determine new start and end points and put them to the boundaries.
2092 // 2. Furthermore, depending on the current filling type we determine the end point (x- or y-coordinate) where all polygons are closed at the end.
2093 QPolygonF pol;
2094 QPointF start = fillLines.at(0).p1(); // starting point of the current polygon, initialize with the first visible point
2095 QPointF end = fillLines.at(fillLines.size() - 1).p2(); // end point of the current polygon, initialize with the last visible point
2096 const QPointF& first = m_logicalPoints.at(0); // first point of the curve, may not be visible currently
2097 const QPointF& last = m_logicalPoints.at(m_logicalPoints.size() - 1); // last point of the curve, may not be visible currently
2098 QPointF edge;
2099 double xEnd{0.}, yEnd{0.};
2100 auto cs = plot()->coordinateSystem(q->coordinateSystemIndex());

Callers 1

initMethod · 0.45

Calls 15

positionMethod · 0.80
appendMethod · 0.80
mapLogicalToSceneMethod · 0.80
coordinateSystemIndexMethod · 0.80
rangeMethod · 0.80
xMethod · 0.80
QPointFClass · 0.70
clearMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45
coordinateSystemMethod · 0.45

Tested by

no test coverage detected