mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP37/GCS Added Home overlay.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1080 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
351c658400
commit
4774ed2164
79
ground/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp
Normal file
79
ground/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file homeitem.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @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 "homeitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
HomeItem::HomeItem(MapGraphicItem* map,OPMapWidget* parent):safe(true),map(map),mapwidget(parent),showsafearea(true),safearea(1000),altitude(0)
|
||||
{
|
||||
pic.load(QString::fromUtf8(":/markers/images/home2.svg"));
|
||||
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
coord=internals::PointLatLng(50,50);
|
||||
}
|
||||
|
||||
void HomeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
if(showsafearea)
|
||||
{
|
||||
if(safe)
|
||||
painter->setPen(Qt::green);
|
||||
else
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawEllipse(QPointF(0,0),localsafearea,localsafearea);
|
||||
// painter->drawRect(QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2));
|
||||
}
|
||||
|
||||
}
|
||||
QRectF HomeItem::boundingRect()const
|
||||
{
|
||||
if(!showsafearea)
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
else
|
||||
return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2);
|
||||
}
|
||||
|
||||
|
||||
int HomeItem::type()const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
void HomeItem::RefreshPos()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
localposition=map->FromLatLngToLocal(coord);
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
if(showsafearea)
|
||||
localsafearea=safearea/map->Projection()->GetGroundResolution(map->Zoom(),coord.Lat());
|
||||
|
||||
}
|
||||
|
||||
}
|
78
ground/src/libs/opmapcontrol/src/mapwidget/homeitem.h
Normal file
78
ground/src/libs/opmapcontrol/src/mapwidget/homeitem.h
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file homeitem.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @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 HOMEITEM_H
|
||||
#define HOMEITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "../internals/pointlatlng.h"
|
||||
#include <QObject>
|
||||
#include "opmapwidget.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
|
||||
class HomeItem:public QObject,public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 4 };
|
||||
HomeItem(MapGraphicItem* map,OPMapWidget* parent);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
int type() const;
|
||||
void RefreshPos();
|
||||
bool ShowSafeArea()const{return showsafearea;}
|
||||
void SetShowSafeArea(bool const& value){showsafearea=value;}
|
||||
int SafeArea()const{return safearea;}
|
||||
void SetSafeArea(bool const& value){safearea=value;}
|
||||
bool safe;
|
||||
void SetCoord(internals::PointLatLng const& value){coord=value;}
|
||||
internals::PointLatLng Coord()const{return coord;}
|
||||
void SetAltitude(int const& value){altitude=value;}
|
||||
int Altitude()const{return altitude;}
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
OPMapWidget* mapwidget;
|
||||
QPixmap pic;
|
||||
core::Point localposition;
|
||||
internals::PointLatLng coord;
|
||||
bool showsafearea;
|
||||
int safearea;
|
||||
int localsafearea;
|
||||
int altitude;
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
}
|
||||
#endif // HOMEITEM_H
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
ground/src/libs/opmapcontrol/src/mapwidget/images/home.png
Normal file
BIN
ground/src/libs/opmapcontrol/src/mapwidget/images/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
126
ground/src/libs/opmapcontrol/src/mapwidget/images/home.svg
Normal file
126
ground/src/libs/opmapcontrol/src/mapwidget/images/home.svg
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="1111.3383"
|
||||
height="1168.5715"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docname="antenna_and_radio_waves.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective10" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.0875"
|
||||
inkscape:cx="3193.6065"
|
||||
inkscape:cy="2405.053"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
inkscape:window-width="1355"
|
||||
inkscape:window-height="722"
|
||||
inkscape:window-x="4"
|
||||
inkscape:window-y="24" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(2201.53,2081.9236)">
|
||||
<g
|
||||
id="g2386"
|
||||
transform="matrix(0.2535648,0,0,0.2535648,-1643.2995,-1554.0211)">
|
||||
<path
|
||||
transform="matrix(4.3333332,0,0,4.3333332,4533.7078,193.07844)"
|
||||
d="M -582.85712,3.7907546 A 465.71429,465.71429 0 1 1 -1514.2857,3.7907546 A 465.71429,465.71429 0 1 1 -582.85712,3.7907546 z"
|
||||
sodipodi:ry="465.71429"
|
||||
sodipodi:rx="465.71429"
|
||||
sodipodi:cy="3.7907546"
|
||||
sodipodi:cx="-1048.5714"
|
||||
id="path3187"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(2.9548022,0,0,2.9548022,3088.2196,198.30411)"
|
||||
d="M -582.85712,3.7907546 A 465.71429,465.71429 0 1 1 -1514.2857,3.7907546 A 465.71429,465.71429 0 1 1 -582.85712,3.7907546 z"
|
||||
sodipodi:ry="465.71429"
|
||||
sodipodi:rx="465.71429"
|
||||
sodipodi:cy="3.7907546"
|
||||
sodipodi:cx="-1048.5714"
|
||||
id="path3185"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(1.8248587,0,0,1.8248587,1903.3932,202.58745)"
|
||||
d="M -582.85712,3.7907546 A 465.71429,465.71429 0 1 1 -1514.2857,3.7907546 A 465.71429,465.71429 0 1 1 -582.85712,3.7907546 z"
|
||||
sodipodi:ry="465.71429"
|
||||
sodipodi:rx="465.71429"
|
||||
sodipodi:cy="3.7907546"
|
||||
sodipodi:cx="-1048.5714"
|
||||
id="path3183"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="translate(1038.4699,205.71429)"
|
||||
d="M -582.85712,3.7907546 A 465.71429,465.71429 0 1 1 -1514.2857,3.7907546 A 465.71429,465.71429 0 1 1 -582.85712,3.7907546 z"
|
||||
sodipodi:ry="465.71429"
|
||||
sodipodi:rx="465.71429"
|
||||
sodipodi:cy="3.7907546"
|
||||
sodipodi:cx="-1048.5714"
|
||||
id="path3181"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path3192"
|
||||
d="M -7.2443685,220.93362 L 1504.1842,-2081.9236 L -1524.3873,-2081.9236 L -7.2443685,220.93362 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="rect3189"
|
||||
d="M -7.2442174,223.79075 L 1504.1842,2526.6479 L -1524.3873,2526.6479 L -7.2442174,223.79075 z"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:80;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccccccsc"
|
||||
id="path2385"
|
||||
d="M 131.32707,222.36219 C 129.85733,280.3008 96.457805,328.45177 44.931875,352.67094 C 36.472685,356.25085 126.39529,2164.396 129.8183,2222.3445 C -5.6975961,2222.8383 -8.9361161,2222.5375 -151.03146,2223.1095 C -148.6186,2165.161 -56.675715,356.25085 -65.13491,352.67094 C -118.03418,328.65681 -149.22461,279.34006 -151.53008,222.36219 C -151.53008,144.29362 -88.17009,80.933613 -10.101515,80.933613 C 67.967055,80.933613 131.32707,144.29362 131.32707,222.36219 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.7 KiB |
80
ground/src/libs/opmapcontrol/src/mapwidget/images/home2.svg
Normal file
80
ground/src/libs/opmapcontrol/src/mapwidget/images/home2.svg
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="463.89285"
|
||||
height="438.87704"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docname="dynaHouse.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective10" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.4098083"
|
||||
inkscape:cx="231.94643"
|
||||
inkscape:cy="219.43852"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1006"
|
||||
inkscape:window-height="954"
|
||||
inkscape:window-x="660"
|
||||
inkscape:window-y="43" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-42.339286,-276.34171)">
|
||||
<path
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 437.14509,499.4375 L 437.14509,499.4375 z M 437.14509,499.4375 L 274.33259,355.25 L 111.42634,499.5 L 111.42634,705.625 C 111.42634,710.94838 115.72796,715.21875 121.05134,715.21875 L 222.86384,715.21875 L 222.86384,624.84375 C 222.86384,619.52035 227.13421,615.21875 232.45759,615.21875 L 316.11384,615.21875 C 321.43719,615.21875 325.70759,619.52037 325.70759,624.84375 L 325.70759,715.21875 L 427.55134,715.21875 C 432.87471,715.21875 437.14511,710.9484 437.14509,705.625 L 437.14509,499.4375 z M 111.42634,499.5 L 111.42634,499.5 z"
|
||||
id="rect2391"
|
||||
sodipodi:nodetypes="cccccccccccccccccc" />
|
||||
<path
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 273.3878,276.34171 L 42.339286,480.92527 L 66.677596,508.38266 L 274.33298,324.49848 L 481.9411,508.38266 L 506.23215,480.92527 L 275.2309,276.34171 L 274.33298,277.3814 L 273.3878,276.34171 z"
|
||||
id="path2399" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-opacity:1"
|
||||
d="M 111.42634,305.79074 L 169.99777,305.79074 L 169.48739,340.48183 L 111.42634,392.9336 L 111.42634,305.79074 z"
|
||||
id="rect2404"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
@ -26,6 +26,7 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "uavitem.h"
|
||||
#include "homeitem.h"
|
||||
#include "mapgraphicitem.h"
|
||||
|
||||
namespace mapcontrol
|
||||
@ -40,7 +41,8 @@ namespace mapcontrol
|
||||
core->SetMapType(MapType::GoogleHybrid);
|
||||
this->SetZoom(2);
|
||||
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
||||
|
||||
connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh()));
|
||||
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh()));
|
||||
//resize();
|
||||
}
|
||||
void MapGraphicItem::start()
|
||||
@ -83,9 +85,27 @@ namespace mapcontrol
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ChildPosRefresh()
|
||||
{
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->RefreshPos();
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->RefreshPos();
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||
{
|
||||
QImage temp;
|
||||
@ -283,7 +303,7 @@ namespace mapcontrol
|
||||
core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width());
|
||||
core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height());
|
||||
core->tileRect.Offset(core->GetrenderOffset());
|
||||
qDebug()<<core->GetrenderOffset().ToString();
|
||||
//qDebug()<<core->GetrenderOffset().ToString();
|
||||
|
||||
if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
|
||||
{
|
||||
|
@ -97,6 +97,8 @@ namespace mapcontrol
|
||||
core::Point lastimagepoint;
|
||||
void paintImage(QPainter* painter);
|
||||
void ConstructLastImage(int const& zoomdiff);
|
||||
internals::PureProjection* Projection()const{return core->Projection();}
|
||||
double Zoom();
|
||||
protected:
|
||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
@ -118,7 +120,6 @@ namespace mapcontrol
|
||||
void SetZoomStep(int const& value);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
internals::Core *core;
|
||||
@ -175,7 +176,7 @@ namespace mapcontrol
|
||||
void Offset(int const& x, int const& y);
|
||||
bool CanDragMap()const{return core->CanDragMap;}
|
||||
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
|
||||
double Zoom();
|
||||
|
||||
void SetZoom(double const& value);
|
||||
void mapRotate ( qreal angle );
|
||||
void start();
|
||||
@ -186,6 +187,7 @@ namespace mapcontrol
|
||||
|
||||
private slots:
|
||||
void Core_OnNeedInvalidation();
|
||||
void ChildPosRefresh();
|
||||
public slots:
|
||||
/**
|
||||
* @brief To be called when the scene size changes
|
||||
|
@ -4,5 +4,9 @@
|
||||
<file>images/marker.png</file>
|
||||
<file>images/compas.svg</file>
|
||||
<file>images/airplane.svg</file>
|
||||
<file>images/home.png</file>
|
||||
<file>images/home.svg</file>
|
||||
<file>images/home2.svg</file>
|
||||
<file>images/airplanepip.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -9,7 +9,8 @@ SOURCES += mapgraphicitem.cpp \
|
||||
configuration.cpp \
|
||||
waypointitem.cpp \
|
||||
uavitem.cpp \
|
||||
trailitem.cpp
|
||||
trailitem.cpp \
|
||||
homeitem.cpp
|
||||
LIBS += -L../build \
|
||||
-lcore \
|
||||
-linternals \
|
||||
@ -21,7 +22,8 @@ HEADERS += mapgraphicitem.h \
|
||||
uavitem.h \
|
||||
uavmapfollowtype.h \
|
||||
uavtrailtype.h \
|
||||
trailitem.h
|
||||
trailitem.h \
|
||||
homeitem.h
|
||||
QT += opengl
|
||||
QT += network
|
||||
QT += sql
|
||||
|
@ -34,7 +34,7 @@
|
||||
namespace mapcontrol
|
||||
{
|
||||
|
||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),followmouse(true),compass(0),showuav(false)
|
||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),Home(0),followmouse(true),compass(0),showuav(false),showhome(false)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
core=new internals::Core;
|
||||
@ -76,6 +76,23 @@ namespace mapcontrol
|
||||
|
||||
}
|
||||
}
|
||||
void OPMapWidget::SetShowHome(const bool &value)
|
||||
{
|
||||
if(value && Home==0)
|
||||
{
|
||||
Home=new HomeItem(map,this);
|
||||
Home->setParentItem(map);
|
||||
}
|
||||
else if(!value)
|
||||
{
|
||||
if(Home!=0)
|
||||
{
|
||||
delete Home;
|
||||
Home=0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
|
@ -38,9 +38,11 @@
|
||||
#include "waypointitem.h"
|
||||
#include "QtSvg/QGraphicsSvgItem"
|
||||
#include "uavitem.h"
|
||||
#include "homeitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
class UAVItem;
|
||||
class HomeItem;
|
||||
/**
|
||||
* @brief Collection of static functions to help dealing with various enums used
|
||||
* Contains functions for enumToString conversio, StringToEnum, QStringList of enum values...
|
||||
@ -332,10 +334,11 @@ namespace mapcontrol
|
||||
void SetShowCompass(bool const& value);
|
||||
|
||||
UAVItem* UAV;
|
||||
|
||||
HomeItem* Home;
|
||||
void SetShowUAV(bool const& value);
|
||||
bool ShowUAV()const{return showuav;}
|
||||
|
||||
void SetShowHome(bool const& value);
|
||||
bool ShowHome()const{return showhome;}
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
@ -349,6 +352,7 @@ namespace mapcontrol
|
||||
void ConnectWP(WayPointItem* item);
|
||||
QGraphicsSvgItem *compass;
|
||||
bool showuav;
|
||||
bool showhome;
|
||||
// WayPointItem* item;//apagar
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
@ -29,10 +29,11 @@
|
||||
#include "uavitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent):map(map),mapwidget(parent),showtrail(true),trailtime(5),traildistance(100)
|
||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent):map(map),mapwidget(parent),showtrail(true),trailtime(5),traildistance(100),autosetreached(true)
|
||||
,autosetdistance(100)
|
||||
{
|
||||
pic.load(QString::fromUtf8(":/markers/images/airplane.svg"));
|
||||
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
||||
pic.load(QString::fromUtf8(":/markers/images/airplanepip.png"));
|
||||
pic=pic.scaled(45,45,Qt::IgnoreAspectRatio);
|
||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||
this->setPos(localposition.X(),localposition.Y());
|
||||
this->setZValue(4);
|
||||
@ -55,13 +56,13 @@ namespace mapcontrol
|
||||
|
||||
void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
painter->rotate(-90);
|
||||
// painter->rotate(-90);
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
||||
}
|
||||
QRectF UAVItem::boundingRect()const
|
||||
{
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());;
|
||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||
}
|
||||
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||
{
|
||||
@ -95,6 +96,42 @@ namespace mapcontrol
|
||||
mapwidget->SetCurrentPosition(coord);
|
||||
}
|
||||
this->update();
|
||||
if(autosetreached)
|
||||
{
|
||||
foreach(QGraphicsItem* i,map->childItems())
|
||||
{
|
||||
WayPointItem* wp=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(wp)
|
||||
{
|
||||
if(Distance3D(wp->Coord(),wp->Altitude())<autosetdistance)
|
||||
{
|
||||
wp->SetReached(true);
|
||||
emit UAVReachedWayPoint(wp->Number(),wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mapwidget->Home!=0)
|
||||
{
|
||||
if(Distance3D(mapwidget->Home->Coord(),mapwidget->Home->Altitude())>mapwidget->Home->SafeArea())
|
||||
{
|
||||
if(mapwidget->Home->safe!=false);
|
||||
{
|
||||
mapwidget->Home->safe=false;
|
||||
mapwidget->Home->update();
|
||||
emit UAVLeftSafetyBouble(this->coord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mapwidget->Home->safe!=true);
|
||||
{
|
||||
mapwidget->Home->safe=true;
|
||||
mapwidget->Home->update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void UAVItem::SetUAVHeading(const qreal &value)
|
||||
@ -121,6 +158,7 @@ namespace mapcontrol
|
||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
||||
//this->update();
|
||||
}
|
||||
|
||||
}
|
||||
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
|
||||
{
|
||||
@ -138,4 +176,10 @@ namespace mapcontrol
|
||||
foreach(QGraphicsItem* i,trail->childItems())
|
||||
delete i;
|
||||
}
|
||||
double UAVItem::Distance3D(const internals::PointLatLng &coord, const int &altitude)
|
||||
{
|
||||
return sqrt(pow(internals::PureProjection::DistanceBetweenLatLng(this->coord,coord)*1000,2)+
|
||||
pow(this->altitude-altitude,2));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ namespace mapcontrol
|
||||
bool ShowTrail()const{return showtrail;}
|
||||
void SetShowTrail(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;
|
||||
private:
|
||||
@ -94,6 +98,9 @@ namespace mapcontrol
|
||||
bool showtrail;
|
||||
int trailtime;
|
||||
int traildistance;
|
||||
bool autosetreached;
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
Loading…
Reference in New Issue
Block a user