1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/graphitem.h

54 lines
983 B
C
Raw Normal View History

#ifndef GRAPHITEM_H
#define GRAPHITEM_H
2016-09-19 00:56:10 +02:00
#include <QGraphicsObject>
#include <QPen>
#include "graph.h"
2016-09-19 00:56:10 +02:00
class GraphItem : public QGraphicsObject
{
2016-09-19 00:56:10 +02:00
Q_OBJECT
public:
2016-09-19 00:56:10 +02:00
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
QRectF boundingRect() const
{return _path.boundingRect();}
2016-09-19 00:56:10 +02:00
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
const QRectF &bounds() const {return _bounds;}
void setScale(qreal sx, qreal sy);
2016-09-25 18:08:39 +02:00
void setGraphType(GraphType type);
2016-08-19 19:48:44 +02:00
int id() const {return _id;}
void setId(int id) {_id = id;}
2016-08-19 19:48:44 +02:00
void setColor(const QColor &color);
2016-09-19 00:56:10 +02:00
qreal yAtX(qreal x);
qreal distanceAtTime(qreal time);
signals:
void sliderPositionChanged(qreal);
public slots:
void emitSliderPositionChanged(qreal);
void selected(bool selected);
2016-09-19 00:56:10 +02:00
private:
void updatePath();
void updateBounds();
int _id;
2016-09-19 00:56:10 +02:00
QPen _pen;
Graph _graph;
2016-09-19 23:35:04 +02:00
GraphType _type;
QPainterPath _path;
QRectF _bounds;
qreal _sx, _sy;
};
#endif // GRAPHITEM_H