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

62 lines
1.1 KiB
C
Raw Normal View History

2016-09-19 00:55:03 +02:00
#ifndef PATHITEM_H
#define PATHITEM_H
2016-09-19 00:56:10 +02:00
#include <QGraphicsObject>
2016-09-26 21:01:58 +02:00
#include <QPen>
#include "markeritem.h"
#include "path.h"
2016-09-19 00:56:10 +02:00
2016-09-26 21:01:58 +02:00
class Map;
2016-09-19 00:56:10 +02:00
class PathItem : public QGraphicsObject
{
Q_OBJECT
public:
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
2016-09-26 21:01:58 +02:00
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
const Path &path() const {return _path;}
void setMap(Map *map);
2016-09-26 21:01:58 +02:00
void setColor(const QColor &color);
2017-04-05 22:53:25 +02:00
void setWidth(qreal width);
2016-12-06 01:48:26 +01:00
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
2016-09-19 00:56:10 +02:00
public slots:
2016-09-26 21:01:58 +02:00
void moveMarker(qreal distance);
signals:
void selected(bool);
2016-09-26 21:01:58 +02:00
protected:
Path _path;
2016-09-26 21:01:58 +02:00
MarkerItem *_marker;
private:
2016-11-14 22:12:43 +01:00
QPointF position(qreal distance) const;
void updatePainterPath(Map *map);
void updateShape();
2016-11-14 22:12:43 +01:00
2016-09-26 21:01:58 +02:00
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
2016-12-06 01:48:26 +01:00
Map *_map;
qreal _markerDistance;
int _digitalZoom;
2017-04-05 22:53:25 +02:00
qreal _width;
2016-12-06 01:48:26 +01:00
QPen _pen;
QPainterPath _shape;
QPainterPath _painterPath;
2016-09-19 00:56:10 +02:00
};
2016-09-19 00:55:03 +02:00
#endif // PATHITEM_H