@ -1,5 +1,4 @@
@@ -1,5 +1,4 @@
/*=====================================================================
/*==================================================================
QGroundControl Open Source Ground Control Station
( c ) 2009 , 2010 QGROUNDCONTROL PROJECT < http : //www.qgroundcontrol.org>
@ -88,9 +87,9 @@ MapWidget::MapWidget(QWidget *parent) :
@@ -88,9 +87,9 @@ MapWidget::MapWidget(QWidget *parent) :
//
// Layer* gsatLayer = new Layer("Google Satellite", gsat, Layer::MapLayer);
// mc->addLayer(gsatLayer);
//
// Layer* gsatLayer = new Layer("Google Satellite", gsat, Layer::MapLayer);
// mc->addLayer(gsatLayer);
// SET INITIAL POSITION AND ZOOM
// Set default zoom level
@ -119,24 +118,24 @@ MapWidget::MapWidget(QWidget *parent) :
@@ -119,24 +118,24 @@ MapWidget::MapWidget(QWidget *parent) :
this , SLOT ( mapproviderSelected ( QAction * ) ) ) ;
// Overlay seems currently broken
// yahooActionOverlay = new QAction(tr("Yahoo: street overlay"), this);
// yahooActionOverlay->setCheckable(true);
// yahooActionOverlay->setChecked(overlay->isVisible());
// connect(yahooActionOverlay, SIGNAL(toggled(bool)),
// overlay, SLOT(setVisible(bool)));
// mapproviderGroup->addAction(googleSatAction);
// mapproviderGroup->addAction(osmAction);
// mapproviderGroup->addAction(yahooActionOverlay);
// mapproviderGroup->addAction(googleActionMap);
// mapproviderGroup->addAction(yahooActionMap);
// mapproviderGroup->addAction(yahooActionSatellite);
// yahooActionOverlay = new QAction(tr("Yahoo: street overlay"), this);
// yahooActionOverlay->setCheckable(true);
// yahooActionOverlay->setChecked(overlay->isVisible());
// connect(yahooActionOverlay, SIGNAL(toggled(bool)),
// overlay, SLOT(setVisible(bool)));
// mapproviderGroup->addAction(googleSatAction);
// mapproviderGroup->addAction(osmAction);
// mapproviderGroup->addAction(yahooActionOverlay);
// mapproviderGroup->addAction(googleActionMap);
// mapproviderGroup->addAction(yahooActionMap);
// mapproviderGroup->addAction(yahooActionSatellite);
// Create map provider selection menu
mapMenu = new QMenu ( this ) ;
mapMenu - > addActions ( mapproviderGroup - > actions ( ) ) ;
mapMenu - > addSeparator ( ) ;
// mapMenu->addAction(yahooActionOverlay);
// mapMenu->addAction(yahooActionOverlay);
mapButton = new QPushButton ( this ) ;
mapButton - > setText ( " Map Source " ) ;
@ -254,9 +253,9 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -254,9 +253,9 @@ void MapWidget::mapproviderSelected(QAction* action)
mc - > updateRequestNew ( ) ;
mc - > setZoom ( zoom ) ;
// yahooActionOverlay->setEnabled(false);
// yahooActionOverlay->setEnabled(false);
overlay - > setVisible ( false ) ;
// yahooActionOverlay->setChecked(false);
// yahooActionOverlay->setChecked(false);
}
else if ( action = = yahooActionMap )
@ -270,9 +269,9 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -270,9 +269,9 @@ void MapWidget::mapproviderSelected(QAction* action)
mc - > updateRequestNew ( ) ;
mc - > setZoom ( zoom ) ;
// yahooActionOverlay->setEnabled(false);
// yahooActionOverlay->setEnabled(false);
overlay - > setVisible ( false ) ;
// yahooActionOverlay->setChecked(false);
// yahooActionOverlay->setChecked(false);
}
else if ( action = = yahooActionSatellite )
{
@ -285,7 +284,7 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -285,7 +284,7 @@ void MapWidget::mapproviderSelected(QAction* action)
mc - > updateRequestNew ( ) ;
mc - > setZoom ( zoom ) ;
// yahooActionOverlay->setEnabled(true);
// yahooActionOverlay->setEnabled(true);
}
else if ( action = = googleActionMap )
{
@ -297,9 +296,9 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -297,9 +296,9 @@ void MapWidget::mapproviderSelected(QAction* action)
mc - > updateRequestNew ( ) ;
mc - > setZoom ( zoom ) ;
// yahooActionOverlay->setEnabled(false);
// yahooActionOverlay->setEnabled(false);
overlay - > setVisible ( false ) ;
// yahooActionOverlay->setChecked(false);
// yahooActionOverlay->setChecked(false);
}
else if ( action = = googleSatAction )
{
@ -311,9 +310,9 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -311,9 +310,9 @@ void MapWidget::mapproviderSelected(QAction* action)
mc - > updateRequestNew ( ) ;
mc - > setZoom ( zoom ) ;
// yahooActionOverlay->setEnabled(false);
// yahooActionOverlay->setEnabled(false);
overlay - > setVisible ( false ) ;
// yahooActionOverlay->setChecked(false);
// yahooActionOverlay->setChecked(false);
}
else
{
@ -324,7 +323,7 @@ void MapWidget::mapproviderSelected(QAction* action)
@@ -324,7 +323,7 @@ void MapWidget::mapproviderSelected(QAction* action)
void MapWidget : : createPathButtonClicked ( bool checked )
{
Q_UNUSED ( checked ) ;
Q_UNUSED ( checked ) ;
@ -338,13 +337,13 @@ void MapWidget::createPathButtonClicked(bool checked)
@@ -338,13 +337,13 @@ void MapWidget::createPathButtonClicked(bool checked)
// emit signal start to create a Waypoint global
emit createGlobalWP ( true , mc - > currentCoordinate ( ) ) ;
// // Clear the previous WP track
// // TODO: Move this to an actual clear track button and add a warning dialog
// mc->layer("Waypoints")->clearGeometries();
// wps.clear();
// path->setPoints(wps);
// mc->layer("Waypoints")->addGeometry(path);
// wpIndex.clear();
// // Clear the previous WP track
// // TODO: Move this to an actual clear track button and add a warning dialog
// mc->layer("Waypoints")->clearGeometries();
// wps.clear();
// path->setPoints(wps);
// mc->layer("Waypoints")->addGeometry(path);
// wpIndex.clear();
} else {
@ -368,100 +367,100 @@ void MapWidget::createPathButtonClicked(bool checked)
@@ -368,100 +367,100 @@ void MapWidget::createPathButtonClicked(bool checked)
void MapWidget : : captureMapClick ( const QMouseEvent * event , const QPointF coordinate )
{
qDebug ( ) < < mc - > mouseMode ( ) ;
qDebug ( ) < < mc - > mouseMode ( ) ;
if ( QEvent : : MouseButtonRelease = = event - > type ( ) & & createPath - > isChecked ( ) )
if ( QEvent : : MouseButtonRelease = = event - > type ( ) & & createPath - > isChecked ( ) )
{
// Create waypoint name
QString str ;
// Create waypoint name
QString str ;
str = QString ( " %1 " ) . arg ( path - > numberOfPoints ( ) ) ;
str = QString ( " %1 " ) . arg ( path - > numberOfPoints ( ) ) ;
// create the WP and set everything in the LineString to display the path
Waypoint2DIcon * tempCirclePoint ;
// create the WP and set everything in the LineString to display the path
Waypoint2DIcon * tempCirclePoint ;
if ( mav )
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle , new QPen ( mav - > getColor ( ) ) ) ;
}
else
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle ) ;
}
mc - > layer ( " Waypoints " ) - > addGeometry ( tempCirclePoint ) ;
if ( mav )
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle , new QPen ( mav - > getColor ( ) ) ) ;
}
else
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle ) ;
}
mc - > layer ( " Waypoints " ) - > addGeometry ( tempCirclePoint ) ;
qmapcontrol : : Point * tempPoint = new qmapcontrol : : Point ( coordinate . x ( ) , coordinate . y ( ) , str ) ;
wps . append ( tempPoint ) ;
path - > addPoint ( tempPoint ) ;
qmapcontrol : : Point * tempPoint = new qmapcontrol : : Point ( coordinate . x ( ) , coordinate . y ( ) , str ) ;
wps . append ( tempPoint ) ;
path - > addPoint ( tempPoint ) ;
wpIndex . insert ( str , tempPoint ) ;
wpIndex . insert ( str , tempPoint ) ;
// Refresh the screen
mc - > updateRequestNew ( ) ;
// Refresh the screen
mc - > updateRequestNew ( ) ;
// emit signal mouse was clicked
emit captureMapCoordinateClick ( coordinate ) ;
// emit signal mouse was clicked
emit captureMapCoordinateClick ( coordinate ) ;
}
}
}
void MapWidget : : createWaypointGraphAtMap ( const QPointF coordinate )
{
if ( ! wpExists ( coordinate ) ) {
// Create waypoint name
QString str ;
if ( ! wpExists ( coordinate ) ) {
// Create waypoint name
QString str ;
str = QString ( " %1 " ) . arg ( path - > numberOfPoints ( ) ) ;
str = QString ( " %1 " ) . arg ( path - > numberOfPoints ( ) ) ;
// create the WP and set everything in the LineString to display the path
//CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
Waypoint2DIcon * tempCirclePoint ;
// create the WP and set everything in the LineString to display the path
//CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
Waypoint2DIcon * tempCirclePoint ;
if ( mav )
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle , new QPen ( mav - > getColor ( ) ) ) ;
}
else
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle ) ;
}
if ( mav )
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle , new QPen ( mav - > getColor ( ) ) ) ;
}
else
{
tempCirclePoint = new Waypoint2DIcon ( coordinate . x ( ) , coordinate . y ( ) , 20 , str , qmapcontrol : : Point : : Middle ) ;
}
mc - > layer ( " Waypoints " ) - > addGeometry ( tempCirclePoint ) ;
mc - > layer ( " Waypoints " ) - > addGeometry ( tempCirclePoint ) ;
Point * tempPoint = new Point ( coordinate . x ( ) , coordinate . y ( ) , str ) ;
wps . append ( tempPoint ) ;
path - > addPoint ( tempPoint ) ;
Point * tempPoint = new Point ( coordinate . x ( ) , coordinate . y ( ) , str ) ;
wps . append ( tempPoint ) ;
path - > addPoint ( tempPoint ) ;
wpIndex . insert ( str , tempPoint ) ;
wpIndex . insert ( str , tempPoint ) ;
qDebug ( ) < < " Funcion createWaypointGraphAtMap WP= " < < str < < " -> x= " < < tempPoint - > latitude ( ) < < " y= " < < tempPoint - > longitude ( ) ;
// Refresh the screen
mc - > updateRequestNew ( ) ;
}
mc - > updateRequestNew ( ) ;
}
//// // emit signal mouse was clicked
// emit captureMapCoordinateClick(coordinate);
//// // emit signal mouse was clicked
// emit captureMapCoordinateClick(coordinate);
}
int MapWidget : : wpExists ( const QPointF coordinate ) {
for ( int i = 0 ; i < wps . size ( ) ; i + + ) {
if ( wps . at ( i ) - > latitude ( ) = = coordinate . y ( ) & &
wps . at ( i ) - > longitude ( ) = = coordinate . x ( ) ) {
return 1 ;
for ( int i = 0 ; i < wps . size ( ) ; i + + ) {
if ( wps . at ( i ) - > latitude ( ) = = coordinate . y ( ) & &
wps . at ( i ) - > longitude ( ) = = coordinate . x ( ) ) {
return 1 ;
}
}
}
return 0 ;
return 0 ;
}
void MapWidget : : captureGeometryClick ( Geometry * geom , QPoint point )
{
Q_UNUSED ( geom ) ;
Q_UNUSED ( point ) ;
Q_UNUSED ( geom ) ;
Q_UNUSED ( point ) ;
mc - > setMouseMode ( qmapcontrol : : MapControl : : None ) ;
mc - > setMouseMode ( qmapcontrol : : MapControl : : None ) ;
}
@ -469,43 +468,45 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate)
@@ -469,43 +468,45 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate)
{
waypointIsDrag = true ;
waypointIsDrag = true ;
// Refresh the screen
mc - > updateRequestNew ( ) ;
// Refresh the screen
mc - > updateRequestNew ( ) ;
int temp = 0 ;
qmapcontrol : : Point * point2Find ;
point2Find = wpIndex [ geom - > name ( ) ] ;
int temp = 0 ;
qmapcontrol : : Point * point2Find ;
point2Find = wpIndex [ geom - > name ( ) ] ;
if ( point2Find )
{
point2Find - > setCoordinate ( coordinate ) ;
if ( point2Find )
{
point2Find - > setCoordinate ( coordinate ) ;
point2Find = dynamic_cast < qmapcontrol : : Point * > ( geom ) ;
if ( point2Find )
{
point2Find - > setCoordinate ( coordinate ) ;
point2Find = dynamic_cast < qmapcontrol : : Point * > ( geom ) ;
if ( point2Find )
{
point2Find - > setCoordinate ( coordinate ) ;
// qDebug() << geom->name();
temp = geom - > get_myIndex ( ) ;
//qDebug() << temp;
emit sendGeometryEndDrag ( coordinate , temp ) ;
}
}
// qDebug() << geom->name();
temp = geom - > get_myIndex ( ) ;
//qDebug() << temp;
emit sendGeometryEndDrag ( coordinate , temp ) ;
}
}
}
void MapWidget : : captureGeometryEndDrag ( Geometry * geom , QPointF coordinate )
{
Q_UNUSED ( geom ) ;
Q_UNUSED ( coordinate ) ;
// TODO: Investigate why when creating the waypoint path this slot is being called
// TODO: Investigate why when creating the waypoint path this slot is being called
// Only change the mouse mode back to panning when not creating a WP path
if ( ! createPath - > isChecked ( ) ) {
waypointIsDrag = false ;
mc - > setMouseMode ( qmapcontrol : : MapControl : : Panning ) ;
}
// Only change the mouse mode back to panning when not creating a WP path
if ( ! createPath - > isChecked ( ) )
{
waypointIsDrag = false ;
mc - > setMouseMode ( qmapcontrol : : MapControl : : Panning ) ;
}
}
@ -629,7 +630,7 @@ void MapWidget::wheelEvent(QWheelEvent *event)
@@ -629,7 +630,7 @@ void MapWidget::wheelEvent(QWheelEvent *event)
detailZoom = qAbs ( qMin ( 0 , mc - > currentZoom ( ) - newZoom ) ) ;
// visual field of camera
updateCameraPosition ( 20 * newZoom , 0 , " no " ) ;
updateCameraPosition ( 20 * newZoom , 0 , " no " ) ;
}
@ -715,7 +716,7 @@ void MapWidget::changeGlobalWaypointPositionBySpinBox(int index, float lat, floa
@@ -715,7 +716,7 @@ void MapWidget::changeGlobalWaypointPositionBySpinBox(int index, float lat, floa
// Refresh the screen
mc - > updateRequestNew ( ) ;
}
}
}
@ -724,17 +725,17 @@ void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
@@ -724,17 +725,17 @@ void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
{
//camPoints.clear();
QPointF currentPos = mc - > currentCoordinate ( ) ;
// QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance);
// QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance);
// qmapcontrol::Point* tempPoint1 = new qmapcontrol::Point(currentPos.x(), currentPos.y(),"inicial",qmapcontrol::Point::Middle);
// qmapcontrol::Point* tempPoint2 = new qmapcontrol::Point(actualPos.x(), actualPos.y(),"final",qmapcontrol::Point::Middle);
// qmapcontrol::Point* tempPoint1 = new qmapcontrol::Point(currentPos.x(), currentPos.y(),"inicial",qmapcontrol::Point::Middle);
// qmapcontrol::Point* tempPoint2 = new qmapcontrol::Point(actualPos.x(), actualPos.y(),"final",qmapcontrol::Point::Middle);
// camPoints.append(tempPoint1);
// camPoints.append(tempPoint2);
// camPoints.append(tempPoint1);
// camPoints.append(tempPoint2);
// camLine->setPoints(camPoints);
// camLine->setPoints(camPoints);
QPen * camBorderPen = new QPen ( QColor ( 255 , 0 , 0 ) ) ;
QPen * camBorderPen = new QPen ( QColor ( 255 , 0 , 0 ) ) ;
camBorderPen - > setWidth ( 2 ) ;
//radio = mc->currentZoom()
@ -747,20 +748,20 @@ void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
@@ -747,20 +748,20 @@ void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
//create a camera borders
qmapcontrol : : CirclePoint * camBorder = new qmapcontrol : : CirclePoint ( currentPos . x ( ) , currentPos . y ( ) , radio , " camBorder " , qmapcontrol : : Point : : Middle , camBorderPen ) ;
//camBorder->setCoordinate(currentPos);
//camBorder->setCoordinate(currentPos);
mc - > layer ( " Camera " ) - > addGeometry ( camBorder ) ;
// mc->layer("Camera")->addGeometry(camLine);
// mc->layer("Camera")->addGeometry(camLine);
mc - > updateRequestNew ( ) ;
}
else
{
//clear camera borders
mc - > layer ( " Camera " ) - > clearGeometries ( ) ;
mc - > updateRequestNew ( ) ;
else
{
//clear camera borders
mc - > layer ( " Camera " ) - > clearGeometries ( ) ;
mc - > updateRequestNew ( ) ;
}
}
}