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>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "data/path.h"
|
2016-09-26 21:01:58 +02:00
|
|
|
#include "markeritem.h"
|
|
|
|
|
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-12-03 00:36:52 +01:00
|
|
|
void setMarkerColor(const QColor &color);
|
2019-02-16 12:39:23 +01:00
|
|
|
void showMarker(bool show);
|
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:
|
2019-02-11 23:28:08 +01:00
|
|
|
const PathSegment *segment(qreal x) const;
|
2016-11-14 22:12:43 +01:00
|
|
|
QPointF position(qreal distance) const;
|
2018-09-15 13:40:21 +02:00
|
|
|
void updatePainterPath();
|
2017-03-18 01:30:31 +01:00
|
|
|
void updateShape();
|
2018-09-15 13:40:21 +02:00
|
|
|
void addSegment(const Coordinates &c1, const Coordinates &c2);
|
|
|
|
|
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;
|
2019-02-16 12:39:23 +01:00
|
|
|
bool _showMarker;
|
2016-09-19 00:56:10 +02:00
|
|
|
};
|
|
|
|
|
2016-09-19 00:55:03 +02:00
|
|
|
#endif // PATHITEM_H
|