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>
|
2020-05-20 21:00:36 +02:00
|
|
|
#include <QTimeZone>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "data/path.h"
|
2019-10-15 23:59:15 +02:00
|
|
|
#include "graphicsscene.h"
|
2021-01-17 18:39:57 +01:00
|
|
|
#include "units.h"
|
2016-09-26 21:01:58 +02:00
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
class Map;
|
2019-05-24 18:37:15 +02:00
|
|
|
class PathTickItem;
|
2021-01-17 16:02:37 +01:00
|
|
|
class GraphItem;
|
2021-01-17 18:39:57 +01:00
|
|
|
class MarkerItem;
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2019-10-15 23:59:15 +02:00
|
|
|
class PathItem : public QObject, public GraphicsItem
|
2016-09-19 00:56:10 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-03-18 01:30:31 +01:00
|
|
|
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
2019-10-13 20:20:32 +02:00
|
|
|
virtual ~PathItem() {}
|
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
QPainterPath shape() const {return _shape;}
|
2019-05-24 18:37:15 +02:00
|
|
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
2016-09-26 21:01:58 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget);
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
const Path &path() const {return _path;}
|
|
|
|
|
2021-01-17 16:02:37 +01:00
|
|
|
void addGraph(GraphItem *graph);
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
void setMap(Map *map);
|
2021-01-17 16:02:37 +01:00
|
|
|
void setGraph(int index);
|
2017-03-18 01:30:31 +01:00
|
|
|
|
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);
|
2019-05-23 08:44:55 +02:00
|
|
|
void showTicks(bool show);
|
|
|
|
|
2021-01-17 16:02:37 +01:00
|
|
|
void setMarkerPosition(qreal pos);
|
|
|
|
|
2020-05-20 21:00:36 +02:00
|
|
|
void updateTicks();
|
|
|
|
|
|
|
|
static void setUnits(Units units) {_units = units;}
|
|
|
|
static void setTimeZone(const QTimeZone &zone) {_timeZone = zone;}
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
public slots:
|
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
|
|
|
|
2019-10-13 20:20:32 +02:00
|
|
|
protected:
|
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
2020-05-20 21:00:36 +02:00
|
|
|
static Units _units;
|
|
|
|
static QTimeZone _timeZone;
|
2019-10-15 23:59:15 +02:00
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
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);
|
|
|
|
|
2019-05-23 08:44:55 +02:00
|
|
|
qreal xInM() const;
|
|
|
|
unsigned tickSize() const;
|
2016-11-14 22:12:43 +01:00
|
|
|
|
2019-05-24 18:37:15 +02:00
|
|
|
Path _path;
|
2017-03-18 01:30:31 +01:00
|
|
|
Map *_map;
|
2021-01-17 16:02:37 +01:00
|
|
|
QList<GraphItem *> _graphs;
|
|
|
|
GraphItem *_graph;
|
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;
|
2019-05-23 08:44:55 +02:00
|
|
|
bool _showTicks;
|
|
|
|
|
2019-05-24 18:37:15 +02:00
|
|
|
MarkerItem *_marker;
|
|
|
|
QVector<PathTickItem*> _ticks;
|
2016-09-19 00:56:10 +02:00
|
|
|
};
|
|
|
|
|
2016-09-19 00:55:03 +02:00
|
|
|
#endif // PATHITEM_H
|