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

48 lines
937 B
C++

#ifndef AXISITEM_H
#define AXISITEM_H
#include <QGraphicsItem>
#include <QVector>
#include <QLocale>
#include "common/range.h"
class AxisItem : public QGraphicsItem
{
public:
enum Type {X, Y};
AxisItem(Type type, QGraphicsItem *parent = 0);
/* 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 */
QRectF boundingRect() const {return _boundingRect;}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setRange(const RangeF &range);
void setSize(qreal size);
void setZoom(qreal zoom) {_zoom = zoom;}
QSizeF margin() const;
QList<qreal> ticks() const;
private:
struct Tick {
double value;
QRect boundingBox;
};
void updateBoundingRect();
Type _type;
RangeF _range;
qreal _size;
QVector<Tick> _ticks;
QRectF _boundingRect;
QFont _font;
QLocale _locale;
qreal _zoom;
};
#endif // AXISITEM_H