2016-02-19 21:34:55 +01:00
|
|
|
#ifndef WAYPOINTITEM_H
|
|
|
|
#define WAYPOINTITEM_H
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2017-05-01 12:59:56 +02:00
|
|
|
#include <cmath>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QGraphicsItem>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "data/waypoint.h"
|
|
|
|
#include "map/map.h"
|
2016-08-02 00:28:56 +02:00
|
|
|
#include "units.h"
|
2018-02-11 20:39:39 +01:00
|
|
|
#include "format.h"
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2016-02-19 21:42:54 +01:00
|
|
|
class WaypointItem : public QGraphicsItem
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-03-18 01:30:31 +01:00
|
|
|
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-08-02 20:46:22 +02:00
|
|
|
const Waypoint &waypoint() const {return _waypoint;}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2017-05-01 12:59:56 +02:00
|
|
|
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
|
2018-02-11 20:49:26 +01:00
|
|
|
void setToolTipFormat(Units units, CoordinatesFormat format);
|
2017-09-10 12:42:49 +02:00
|
|
|
void setSize(int size);
|
|
|
|
void setColor(const QColor &color);
|
2016-08-09 01:16:19 +02:00
|
|
|
void showLabel(bool show);
|
2017-05-01 12:59:56 +02:00
|
|
|
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
|
2016-08-02 00:28:56 +02:00
|
|
|
|
2016-09-11 13:42:22 +02:00
|
|
|
QPainterPath shape() const {return _shape;}
|
|
|
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
2016-08-02 20:46:22 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget);
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
private:
|
2016-09-10 13:11:46 +02:00
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
|
2018-05-19 20:30:29 +02:00
|
|
|
void updateCache();
|
2018-02-11 20:49:26 +01:00
|
|
|
QString toolTip(Units units, CoordinatesFormat format);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-08-02 20:46:22 +02:00
|
|
|
Waypoint _waypoint;
|
2018-05-19 20:30:29 +02:00
|
|
|
QPainterPath _shape;
|
2017-09-10 12:42:49 +02:00
|
|
|
QColor _color;
|
|
|
|
int _size;
|
2016-08-09 01:16:19 +02:00
|
|
|
bool _showLabel;
|
2018-05-19 20:30:29 +02:00
|
|
|
QFont _font;
|
|
|
|
QRect _labelBB;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:34:55 +01:00
|
|
|
#endif // WAYPOINTITEM_H
|