Files

65 lines
2.2 KiB
C++
Raw Permalink Normal View History

2019-12-31 18:56:34 +08:00
/**
******************************************************************************
*
* @file trailitem.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief A graphicsItem representing a trail point
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "trailitem.h"
#include <QDateTime>
namespace mapcontrol {
TrailItem::TrailItem(internals::PointLatLng const & coord, int const & altitude, QBrush color, MapGraphicItem *map) : QGraphicsItem(map), coord(coord), m_brush(color), m_map(map)
{
QDateTime time = QDateTime::currentDateTime();
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
setToolTip(QString(tr("Position:") + "%1\n" + tr("Altitude:") + "%2\n" + tr("Time:") + "%3").arg(coord_str).arg(QString::number(altitude)).arg(time.toString()));
2022-10-09 14:57:48 +08:00
this->setZValue(6);
2022-07-29 01:43:16 +08:00
2019-12-31 18:56:34 +08:00
}
void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setBrush(m_brush);
2020-04-13 21:37:30 +08:00
//painter->drawEllipse(-2, -2, 4, 4);
painter->drawPoint(0,0);
2019-12-31 18:56:34 +08:00
}
QRectF TrailItem::boundingRect() const
{
return QRectF(-2, -2, 4, 4);
}
int TrailItem::type() const
{
return Type;
}
void TrailItem::setPosSLOT()
{
setPos(m_map->FromLatLngToLocal(this->coord).X(), m_map->FromLatLngToLocal(this->coord).Y());
}
}