/** ****************************************************************************** * * @file uavitem.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @brief A graphicsItem representing a WayPoint * @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 */ #ifndef UAVITEM_H #define UAVITEM_H #include #include #include #include "pointlatlng.h" #include "mapgraphicitem.h" #include "waypointitem.h" #include #include "uavmapfollowtype.h" #include "uavtrailtype.h" #include #include "opmapwidget.h" #include "trailitem.h" #include "traillineitem.h" #include "QFont" namespace mapcontrol { class WayPointItem; class OPMapWidget; /** * @brief A QGraphicsItem representing the UAV * * @class UAVItem uavitem.h "mapwidget/uavitem.h" */ #ifdef QtopmapWidget #include class OPMAPWIDGETSHARED_EXPORT UAVItem : public QObject, public QGraphicsItem { #else class UAVItem : public QObject, public QGraphicsItem { #endif Q_OBJECT Q_INTERFACES(QGraphicsItem) public: enum { Type = UserType + 2 }; UAVItem(MapGraphicItem *map, OPMapWidget *parent, QString uavPic = QString::fromUtf8(":/uavs/images/mapquad.png"), uint8_t sysid = 0, uint8_t compid = 0); ~UAVItem(); void SetNED(double NED[3]); void SetGroundspeed(double vNED[3], int m_maxUpdateRate); void SetCAS(double CAS); void SetYawRate(double yawRate_dps); void SetUAVPos(internals::PointLatLng const & position, int const & altitude); void SetUAVHeading(qreal const & value); internals::PointLatLng UAVPos() const { return coord; } void SetMapFollowType(UAVMapFollowType::Types const & value) { mapfollowtype = value; } void SetTrailType(UAVTrailType::Types const & value); UAVMapFollowType::Types GetMapFollowType() const { return mapfollowtype; } UAVTrailType::Types GetTrailType() const { return trailtype; } void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); QRectF boundingRect() const; void SetTrailTime(int const & seconds) { trailtime = seconds; } int TrailTime() const { return trailtime; } void SetTrailDistance(int const & distance) { traildistance = distance; } int TrailDistance() const { return traildistance; } bool ShowTrail() const { return showtrail; } bool ShowTrailLine() const { return showtrailline; } void SetShowTrail(bool const & value); void SetShowTrailLine(bool const & value); void DeleteTrail() const; bool AutoSetReached() const { return autosetreached; } void SetAutoSetReached(bool const & value) { autosetreached = value; } double AutoSetDistance() const { return autosetdistance; } void SetAutoSetDistance(double const & value) { autosetdistance = value; } int type() const; void SetUavPic(QString UAVPic); void SetShowUAVInfo(bool const & value); void updateTextOverlay(); int SysID() { return sysid; } void setSysID(int id) { sysid = id; } int CompID() { return compid; } void setCompID(int id) { compid = id; } bool Select(void) { return isSelected; } void setSelect(bool select); private: void generateArrowhead(); MapGraphicItem *map; OPMapWidget *mapwidget; QPolygonF arrowHead; QLineF arrowShaft; int altitude; UAVMapFollowType::Types mapfollowtype; UAVTrailType::Types trailtype; internals::PointLatLng coord; internals::PointLatLng lastcoord; double NED[3]; double vNED[3]; double CAS_mps; double groundspeed_kph; double groundspeed_mps; double yawRate_dps; double trendRadius; double trendSpanAngle; float meters2pixels; double precalcRings; double ringTime; QPixmap pic; core::Point localposition; QGraphicsItemGroup *trail; QGraphicsItemGroup *trailLine; internals::PointLatLng lasttrailline; QTime timer; bool showtrail; bool showtrailline; int trailtime; int traildistance; bool autosetreached; double Distance3D(internals::PointLatLng const & coord, int const & altitude); double autosetdistance; bool showUAVInfo; static double groundspeed_mps_filt; float boundingRectSize; bool showJustChanged; bool refreshPaint_flag; QPainterPath textPath; bool isSelected = false; uint8_t sysid; uint8_t compid; bool isEdit = false; protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); public slots: void setEdit(bool value); void setID(int sys,int comp); void RefreshPos(); void setOpacitySlot(qreal opacity); void zoomChangedSlot(); signals: void selected(int sys,int comp); void UAVReachedWayPoint(int const & waypointnumber, WayPointItem *waypoint); void UAVLeftSafetyBouble(internals::PointLatLng const & position); void setChildPosition(); void setChildLine(); }; } #endif // UAVITEM_H