1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/GUI/axisitem.h

45 lines
788 B
C
Raw Normal View History

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>
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
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);
void setLabel(const QString& label);
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;
QString _label;
2018-05-18 20:08:52 +02:00
QRect _labelBB;
QVector<Tick> _ticks;
2015-10-05 01:43:48 +02:00
QRectF _boundingRect;
2018-05-18 01:38:33 +02:00
QFont _font;
2015-10-05 01:43:48 +02:00
};
#endif // AXISITEM_H