1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/GUI/waypointitem.h

62 lines
1.5 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>
#include <QFont>
2020-05-20 21:00:36 +02:00
#include <QTimeZone>
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 "graphicsscene.h"
#include "format.h"
class WaypointItem : public GraphicsItem
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()));}
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);
QString info() const;
2020-05-20 21:00:36 +02:00
static void setUnits(Units units) {_units = units;}
static void setCoordinatesFormat(CoordinatesFormat format)
{_format = format;}
static void setTimeZone(const QTimeZone &zone) {_timeZone = zone;}
protected:
2016-09-10 13:11:46 +02:00
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
2016-09-10 13:11:46 +02:00
private:
2018-05-19 20:30:29 +02:00
void updateCache();
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;
2020-05-20 21:00:36 +02:00
static Units _units;
static CoordinatesFormat _format;
static QTimeZone _timeZone;
2015-10-05 01:43:48 +02:00
};
2016-02-19 21:34:55 +01:00
#endif // WAYPOINTITEM_H