1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-25 12:15:54 +01:00
GPXSee/src/GUI/waypointitem.h

47 lines
1.2 KiB
C
Raw Normal View History

2016-02-19 21:34:55 +01:00
#ifndef WAYPOINTITEM_H
#define WAYPOINTITEM_H
2015-10-05 01:43:48 +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"
#include "format.h"
2016-02-19 21:42:54 +01:00
class WaypointItem : public QGraphicsItem
2015-10-05 01:43:48 +02:00
{
public:
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
2015-10-05 01:43:48 +02:00
const Waypoint &waypoint() const {return _waypoint;}
2015-10-05 01:43:48 +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);
void setSize(int size);
void setColor(const QColor &color);
2016-08-09 01:16:19 +02:00
void showLabel(bool show);
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
2016-08-02 00:28:56 +02:00
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
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
Waypoint _waypoint;
2018-05-19 20:30:29 +02:00
QPainterPath _shape;
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