// SPDX-License-Identifier: GPL-2.0 #ifndef STATS_AXIS_H #define STATS_AXIS_H #include "chartitem.h" #include "statshelper.h" #include #include #include class StatsView; class ChartLineItem; class QFontMetrics; // The labels and the title of the axis are rendered into a pixmap. // The ticks and the baseline are realized as individual ChartLineItems. class StatsAxis : public ChartPixmapItem { public: virtual ~StatsAxis(); // Returns minimum and maximum of shown range, not of data points. std::pair minMax() const; std::pair minMaxScreen() const; // minimum and maximum in screen coordinates std::pair horizontalOverhang() const; // space that labels peak out in horizontal axes double width() const; // Only supported by vertical axes. Only valid after setSize(). double height() const; // Only supported for horizontal axes. Always valid. void setSize(double size); // Width for horizontal and height for vertical. void setPos(QPointF pos); // Must be called after setSize(). void setRange(double, double); // Map x (horizontal) or y (vertical) coordinate to or from screen coordinate double toScreen(double) const; double toValue(double) const; std::vector ticksPositions() const; // Positions in screen coordinates protected: StatsAxis(StatsView &view, const QString &title, bool horizontal, bool labelsBetweenTicks); ChartItemPtr line; QString title; double titleWidth; struct Label { QString label; int width; double pos; }; std::vector