2015-10-05 01:43:48 +02:00
|
|
|
#ifndef AXISITEM_H
|
|
|
|
#define AXISITEM_H
|
|
|
|
|
|
|
|
#include <QGraphicsItem>
|
2018-05-18 20:08:52 +02:00
|
|
|
#include <QVector>
|
2018-09-09 18:46:43 +02:00
|
|
|
#include <QLocale>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/range.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
class AxisItem : public QGraphicsItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type {X, Y};
|
|
|
|
|
2015-10-17 01:33:02 +02:00
|
|
|
AxisItem(Type type, QGraphicsItem *parent = 0);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2020-11-22 14:38:52 +01:00
|
|
|
/* Note: The items position is at the 0 point of the axis line, not at the
|
|
|
|
top-left point of the bounding rect as usual */
|
2015-10-05 01:43:48 +02:00
|
|
|
QRectF boundingRect() const {return _boundingRect;}
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget);
|
|
|
|
|
2016-03-27 13:23:00 +02:00
|
|
|
void setRange(const RangeF &range);
|
2015-10-05 01:43:48 +02:00
|
|
|
void setSize(qreal size);
|
2020-11-21 20:37:22 +01:00
|
|
|
void setZoom(qreal zoom) {_zoom = zoom;}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-19 17:24:53 +01:00
|
|
|
QSizeF margin() const;
|
2016-10-17 23:14:07 +02:00
|
|
|
QList<qreal> ticks() const;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
private:
|
2018-05-18 20:08:52 +02:00
|
|
|
struct Tick {
|
|
|
|
double value;
|
|
|
|
QRect boundingBox;
|
|
|
|
};
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void updateBoundingRect();
|
|
|
|
|
|
|
|
Type _type;
|
2016-03-27 13:23:00 +02:00
|
|
|
RangeF _range;
|
2015-10-05 01:43:48 +02:00
|
|
|
qreal _size;
|
2018-05-18 20:08:52 +02:00
|
|
|
QVector<Tick> _ticks;
|
2015-10-05 01:43:48 +02:00
|
|
|
QRectF _boundingRect;
|
2018-05-18 01:38:33 +02:00
|
|
|
QFont _font;
|
2018-09-09 18:46:43 +02:00
|
|
|
QLocale _locale;
|
2020-11-21 20:37:22 +01:00
|
|
|
qreal _zoom;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AXISITEM_H
|