| 637 | } |
| 638 | |
| 639 | void CartesianAxis::paintCtx(PaintContext *context) |
| 640 | { |
| 641 | Q_ASSERT_X(d->diagram(), "CartesianAxis::paint", |
| 642 | "Function call not allowed: The axis is not assigned to any diagram."); |
| 643 | |
| 644 | auto *plane = dynamic_cast<CartesianCoordinatePlane *>(context->coordinatePlane()); |
| 645 | Q_ASSERT_X(plane, "CartesianAxis::paint", |
| 646 | "Bad function call: PaintContext::coordinatePlane() NOT a cartesian plane."); |
| 647 | |
| 648 | // note: Not having any data model assigned is no bug |
| 649 | // but we can not draw an axis then either. |
| 650 | if (!d->diagram()->model()) { |
| 651 | return; |
| 652 | } |
| 653 | |
| 654 | const bool centerTicks = referenceDiagramNeedsCenteredAbscissaTicks(d->diagram()) && isAbscissa(); |
| 655 | |
| 656 | XySwitch geoXy(d->isVertical()); |
| 657 | |
| 658 | QPainter *const painter = context->painter(); |
| 659 | |
| 660 | // determine the position of the axis (also required for labels) and paint it |
| 661 | |
| 662 | qreal transversePosition = signalingNaN; // in data space |
| 663 | // the next one describes an additional shift in screen space; it is unfortunately required to |
| 664 | // make axis sharing work, which uses the areaGeometry() to override the position of the axis. |
| 665 | qreal transverseScreenSpaceShift = signalingNaN; |
| 666 | { |
| 667 | // determine the unadulterated position in screen space |
| 668 | |
| 669 | DataDimension dimX = plane->gridDimensionsList().first(); |
| 670 | DataDimension dimY = plane->gridDimensionsList().last(); |
| 671 | QPointF start(dimX.start, dimY.start); |
| 672 | QPointF end(dimX.end, dimY.end); |
| 673 | // consider this: you can turn a diagonal line into a horizontal or vertical line on any |
| 674 | // edge by changing just one of its four coordinates. |
| 675 | switch (position()) { |
| 676 | case CartesianAxis::Bottom: |
| 677 | end.setY(dimY.start); |
| 678 | break; |
| 679 | case CartesianAxis::Top: |
| 680 | start.setY(dimY.end); |
| 681 | break; |
| 682 | case CartesianAxis::Left: |
| 683 | end.setX(dimX.start); |
| 684 | break; |
| 685 | case CartesianAxis::Right: |
| 686 | start.setX(dimX.end); |
| 687 | break; |
| 688 | } |
| 689 | |
| 690 | transversePosition = geoXy(start.y(), start.x()); |
| 691 | |
| 692 | QPointF transStart = plane->translate(start); |
| 693 | QPointF transEnd = plane->translate(end); |
| 694 | |
| 695 | // an externally set areaGeometry() moves the axis position transversally; the shift is |
| 696 | // nonzero only when this is a shared axis |
nothing calls this directly
no test coverage detected