dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
trailitem.cpp
Go to the documentation of this file.
1 
13 /*
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, see <http://www.gnu.org/licenses/>
26 */
27 #include "trailitem.h"
28 #include <QDateTime>
29 namespace mapcontrol
30 {
31 TrailItem::TrailItem(internals::PointLatLng const& coord,int const& altitude, QBrush color, MapGraphicItem *map):QGraphicsItem(map),coord(coord),m_brush(color),m_map(map)
32  {
33  QDateTime time=QDateTime::currentDateTime();
34  QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
35  setToolTip(QString(tr("Position:")+"%1\n"+tr("Altitude:")+"%2\n"+tr("Time:")+"%3").arg(coord_str).arg(QString::number(altitude)).arg(time.toString()));
36  }
37 
38  void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
39  {
40  Q_UNUSED(option);
41  Q_UNUSED(widget);
42 
43  painter->setBrush(m_brush);
44  painter->drawEllipse(-2,-2,4,4);
45  }
46  QRectF TrailItem::boundingRect()const
47  {
48  return QRectF(-2,-2,4,4);
49  }
50 
51 
52  int TrailItem::type()const
53  {
54  return Type;
55  }
56 
58  {
59  setPos(m_map->FromLatLngToLocal(this->coord).X(),m_map->FromLatLngToLocal(this->coord).Y());
60  }
61 }
qint64 X() const
Definition: point.h:51
double Lng() const
Definition: pointlatlng.h:76
double Lat() const
Definition: pointlatlng.h:64
A graphicsItem representing a WayPoint.
qint64 Y() const
Definition: point.h:52