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

Method painterPathForX

src/backend/worksheet/plots/cartesian/ErrorBar.cpp:261–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void ErrorBarPrivate::painterPathForX(QPainterPath& path, const QVector<QPointF>& points, const CartesianCoordinateSystem* cSystem) const {
262 QVector<QLineF> elines;
263
264 switch (xErrorType) {
265 case ErrorBar::ErrorType::NoError:
266 case ErrorBar::ErrorType::Poisson:
267 return;
268 case ErrorBar::ErrorType::Symmetric: {
269 int index = 0;
270 for (auto& point : points) {
271 if (xPlusColumn && xPlusColumn->isValid(index) && !xPlusColumn->isMasked(index)) {
272 const double error = xPlusColumn->valueAt(index);
273 if (error != 0.)
274 elines << QLineF(point.x() - error, point.y(), point.x() + error, point.y());
275 }
276 ++index;
277 }
278
279 break;
280 }
281 case ErrorBar::ErrorType::Asymmetric: {
282 int index = 0;
283 for (auto& point : points) {
284 double errorPlus = 0.;
285 double errorMinus = 0.;
286
287 if (xPlusColumn && xPlusColumn->isValid(index) && !xPlusColumn->isMasked(index))
288 errorPlus = xPlusColumn->valueAt(index);
289
290 if (xMinusColumn && xMinusColumn->isValid(index) && !xMinusColumn->isMasked(index))
291 errorMinus = xMinusColumn->valueAt(index);
292
293 if (errorPlus != 0. || errorMinus != 0.)
294 elines << QLineF(point.x() - errorMinus, point.y(), point.x() + errorPlus, point.y());
295
296 ++index;
297 }
298
299 break;
300 }
301 }
302
303 // map the error bars to scene coordinates
304 elines = cSystem->mapLogicalToScene(elines);
305
306 // new painter path for the error bars
307 for (const auto& line : std::as_const(elines)) {
308 path.moveTo(line.p1());
309 path.lineTo(line.p2());
310 }
311
312 // add caps for error bars
313 if (type == ErrorBar::Type::WithEnds) {
314 for (const auto& line : std::as_const(elines)) {
315 const auto& p1 = line.p1();
316 path.moveTo(QPointF(p1.x(), p1.y() - capSize / 2.));
317 path.lineTo(QPointF(p1.x(), p1.y() + capSize / 2.));
318

Callers 1

painterPathMethod · 0.80

Calls 7

xMethod · 0.80
mapLogicalToSceneMethod · 0.80
QPointFClass · 0.70
isValidMethod · 0.45
isMaskedMethod · 0.45
valueAtMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected