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"
|
2017-03-18 01:30:31 +01:00
|
|
|
#include "path.h"
|
2016-09-19 00:56:10 +02:00
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
class Map;
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
class PathItem : public QGraphicsObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-03-18 01:30:31 +01:00
|
|
|
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);
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
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);
|
2017-05-01 12:59:56 +02:00
|
|
|
void setDigitalZoom(int zoom);
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
public slots:
|
2016-09-26 21:01:58 +02:00
|
|
|
void moveMarker(qreal distance);
|
2017-09-24 19:54:13 +02:00
|
|
|
void hover(bool hover);
|
2016-09-22 20:59:13 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void selected(bool);
|
2016-09-26 21:01:58 +02:00
|
|
|
|
|
|
|
protected:
|
2017-03-18 01:30:31 +01:00
|
|
|
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;
|
2017-03-18 01:30:31 +01:00
|
|
|
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
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
Map *_map;
|
2017-05-01 12:59:56 +02:00
|
|
|
qreal _markerDistance;
|
|
|
|
int _digitalZoom;
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2017-04-05 22:53:25 +02:00
|
|
|
qreal _width;
|
2016-12-06 01:48:26 +01:00
|
|
|
QPen _pen;
|
|
|
|
QPainterPath _shape;
|
2017-03-18 01:30:31 +01:00
|
|
|
QPainterPath _painterPath;
|
2016-09-19 00:56:10 +02:00
|
|
|
};
|
|
|
|
|
2016-09-19 00:55:03 +02:00
|
|
|
#endif // PATHITEM_H
|