mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into next
Conflicts: ground/openpilotgcs/src/plugins/config/input.ui
This commit is contained in:
commit
fa465c54a8
@ -1 +1,20 @@
|
|||||||
|
#ifndef OPMAP_CONTROL_H_
|
||||||
|
#define OPMAP_CONTROL_H_
|
||||||
#include "src/mapwidget/opmapwidget.h"
|
#include "src/mapwidget/opmapwidget.h"
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
struct customData
|
||||||
|
{
|
||||||
|
float velocity;
|
||||||
|
int mode;
|
||||||
|
float mode_params[4];
|
||||||
|
int condition;
|
||||||
|
float condition_params[4];
|
||||||
|
int command;
|
||||||
|
int jumpdestination;
|
||||||
|
int errordestination;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
Q_DECLARE_METATYPE(mapcontrol::customData)
|
||||||
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file accessmode.h
|
* @file accessmode.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file alllayersoftype.cpp
|
* @file alllayersoftype.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file alllayersoftype.h
|
* @file alllayersoftype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file cache.cpp
|
* @file cache.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file cache.h
|
* @file cache.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file cacheitemqueue.cpp
|
* @file cacheitemqueue.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file cacheitemqueue.h
|
* @file cacheitemqueue.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file diagnostics.cpp
|
* @file diagnostics.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file diagnostics.h
|
* @file diagnostics.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file geodecoderstatus.h
|
* @file geodecoderstatus.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file kibertilecache.cpp
|
* @file kibertilecache.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file kibertilecache.h
|
* @file kibertilecache.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file languagetype.cpp
|
* @file languagetype.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file languagetype.h
|
* @file languagetype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file maptype.h
|
* @file maptype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file memorycache.cpp
|
* @file memorycache.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file memorycache.h
|
* @file memorycache.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file OPMaps.cpp
|
* @file OPMaps.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file OPMaps.h
|
* @file OPMaps.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file placemark.cpp
|
* @file placemark.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file placemark.h
|
* @file placemark.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file point.cpp
|
* @file point.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file point.h
|
* @file point.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file providerstrings.cpp
|
* @file providerstrings.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file providerstrings.h
|
* @file providerstrings.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureimage.cpp
|
* @file pureimage.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureimage.h
|
* @file pureimage.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureimagecache.cpp
|
* @file pureimagecache.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureimagecache.h
|
* @file pureimagecache.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rawtile.cpp
|
* @file rawtile.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rawtile.h
|
* @file rawtile.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file size.cpp
|
* @file size.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file size.h
|
* @file size.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tilecachequeue.cpp
|
* @file tilecachequeue.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tilecachequeue.h
|
* @file tilecachequeue.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file urlfactory.cpp
|
* @file urlfactory.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file urlfactory.h
|
* @file urlfactory.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file MouseWheelZoomType.cpp
|
* @file MouseWheelZoomType.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file copyrightstrings.h
|
* @file copyrightstrings.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -31,11 +31,11 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
namespace internals {
|
namespace internals {
|
||||||
static const QString googleCopyright = QString("©%1 Google - Map data ©%1 Tele Atlas, Imagery ©%1 TerraMetrics").arg(QDate::currentDate().year());
|
static const QString googleCopyright = QString("%1 Google - Map data %1 Tele Atlas, Imagery %1 TerraMetrics").arg(QDate::currentDate().year());
|
||||||
static const QString openStreetMapCopyright = QString("© OpenStreetMap - Map data ©%1 OpenStreetMap").arg(QDate::currentDate().year());
|
static const QString openStreetMapCopyright = QString(" OpenStreetMap - Map data %1 OpenStreetMap").arg(QDate::currentDate().year());
|
||||||
static const QString yahooMapCopyright = QString("© Yahoo! Inc. - Map data & Imagery ©%1 NAVTEQ").arg(QDate::currentDate().year());
|
static const QString yahooMapCopyright = QString(" Yahoo! Inc. - Map data & Imagery %1 NAVTEQ").arg(QDate::currentDate().year());
|
||||||
static const QString virtualEarthCopyright = QString("©%1 Microsoft Corporation, ©%1 NAVTEQ, ©%1 Image courtesy of NASA").arg(QDate::currentDate().year());
|
static const QString virtualEarthCopyright = QString("%1 Microsoft Corporation, %1 NAVTEQ, %1 Image courtesy of NASA").arg(QDate::currentDate().year());
|
||||||
static const QString arcGisCopyright = QString("©%1 ESRI - Map data ©%1 ArcGIS").arg(QDate::currentDate().year());
|
static const QString arcGisCopyright = QString("%1 ESRI - Map data %1 ArcGIS").arg(QDate::currentDate().year());
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // COPYRIGHTSTRINGS_H
|
#endif // COPYRIGHTSTRINGS_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file core.cpp
|
* @file core.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -251,6 +251,7 @@ namespace internals {
|
|||||||
Matrix.Clear();
|
Matrix.Clear();
|
||||||
GoToCurrentPositionOnZoom();
|
GoToCurrentPositionOnZoom();
|
||||||
UpdateBounds();
|
UpdateBounds();
|
||||||
|
keepInBounds();
|
||||||
emit OnMapDrag();
|
emit OnMapDrag();
|
||||||
emit OnMapZoomChanged();
|
emit OnMapZoomChanged();
|
||||||
emit OnNeedInvalidation();
|
emit OnNeedInvalidation();
|
||||||
@ -572,7 +573,7 @@ namespace internals {
|
|||||||
{
|
{
|
||||||
renderOffset.SetX(pt.X() - dragPoint.X());
|
renderOffset.SetX(pt.X() - dragPoint.X());
|
||||||
renderOffset.SetY(pt.Y() - dragPoint.Y());
|
renderOffset.SetY(pt.Y() - dragPoint.Y());
|
||||||
|
keepInBounds();
|
||||||
UpdateCenterTileXYLocation();
|
UpdateCenterTileXYLocation();
|
||||||
|
|
||||||
if(centerTileXYLocation != centerTileXYLocationLast)
|
if(centerTileXYLocation != centerTileXYLocationLast)
|
||||||
@ -692,4 +693,18 @@ namespace internals {
|
|||||||
pxRes1000km = (int) (1000000.0 / rez); // 1000km
|
pxRes1000km = (int) (1000000.0 / rez); // 1000km
|
||||||
pxRes5000km = (int) (5000000.0 / rez); // 5000km
|
pxRes5000km = (int) (5000000.0 / rez); // 5000km
|
||||||
}
|
}
|
||||||
|
void Core::keepInBounds()
|
||||||
|
{
|
||||||
|
if(renderOffset.X()>0)
|
||||||
|
renderOffset.SetX(0);
|
||||||
|
if(renderOffset.Y()>0)
|
||||||
|
renderOffset.SetY(0);
|
||||||
|
int maxDragY=GetCurrentRegion().Height()-GettileRect().Height()*(maxOfTiles.Height()-minOfTiles.Height()+1);
|
||||||
|
int maxDragX=GetCurrentRegion().Width()-GettileRect().Width()*(maxOfTiles.Width()-minOfTiles.Width()+1);
|
||||||
|
|
||||||
|
if(maxDragY>renderOffset.Y())
|
||||||
|
renderOffset.SetY(maxDragY);
|
||||||
|
if(maxDragX>renderOffset.X())
|
||||||
|
renderOffset.SetX(maxDragX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file core.h
|
* @file core.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -193,6 +193,7 @@ namespace internals {
|
|||||||
bool isStarted(){return started;}
|
bool isStarted(){return started;}
|
||||||
|
|
||||||
diagnostics GetDiagnostics();
|
diagnostics GetDiagnostics();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void OnCurrentPositionChanged(internals::PointLatLng point);
|
void OnCurrentPositionChanged(internals::PointLatLng point);
|
||||||
void OnTileLoadComplete();
|
void OnTileLoadComplete();
|
||||||
@ -206,7 +207,7 @@ namespace internals {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void keepInBounds();
|
||||||
PointLatLng currentPosition;
|
PointLatLng currentPosition;
|
||||||
core::Point currentPositionPixel;
|
core::Point currentPositionPixel;
|
||||||
core::Point renderOffset;
|
core::Point renderOffset;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file loadtask.cpp
|
* @file loadtask.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file loadtask.h
|
* @file loadtask.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mousewheelzoomtype.h
|
* @file mousewheelzoomtype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pointlatlng.cpp
|
* @file pointlatlng.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pointlatlng.h
|
* @file pointlatlng.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file lks94projection.cpp
|
* @file lks94projection.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -614,6 +614,9 @@ double LKS94Projection::GetTileMatrixResolution(int const& zoom)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Returns the conversion from pixels to meters
|
||||||
|
*/
|
||||||
double LKS94Projection::GetGroundResolution(int const& zoom, double const& latitude)
|
double LKS94Projection::GetGroundResolution(int const& zoom, double const& latitude)
|
||||||
{
|
{
|
||||||
Q_UNUSED(zoom);
|
Q_UNUSED(zoom);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file lks94projection.h
|
* @file lks94projection.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mercatorprojection.cpp
|
* @file mercatorprojection.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mercatorprojection.h
|
* @file mercatorprojection.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mercatorprojectionyandex.cpp
|
* @file mercatorprojectionyandex.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mercatorprojectionyandex.h
|
* @file mercatorprojectionyandex.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file platecarreeprojection.cpp
|
* @file platecarreeprojection.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file platecarreeprojection.h
|
* @file platecarreeprojection.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file platecarreeprojectionpergo.cpp
|
* @file platecarreeprojectionpergo.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file platecarreeprojectionpergo.h
|
* @file platecarreeprojectionpergo.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureprojection.cpp
|
* @file pureprojection.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -103,6 +103,9 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Returns the conversion from pixels to meters
|
||||||
|
*/
|
||||||
double PureProjection::GetGroundResolution(const int &zoom,const double &latitude)
|
double PureProjection::GetGroundResolution(const int &zoom,const double &latitude)
|
||||||
{
|
{
|
||||||
return (cos(latitude * (PI / 180)) * 2 * PI * Axis()) / GetTileMatrixSizePixel(zoom).Width();
|
return (cos(latitude * (PI / 180)) * 2 * PI * Axis()) / GetTileMatrixSizePixel(zoom).Width();
|
||||||
@ -215,6 +218,18 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
|
|||||||
Lat /= (PI / 180);
|
Lat /= (PI / 180);
|
||||||
Lng /= (PI / 180);
|
Lng /= (PI / 180);
|
||||||
}
|
}
|
||||||
|
double PureProjection::courseBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
||||||
|
{
|
||||||
|
|
||||||
|
double lon1=p1.Lng()* (M_PI / 180);
|
||||||
|
double lat1=p1.Lat()* (M_PI / 180);
|
||||||
|
double lon2=p2.Lng()* (M_PI / 180);
|
||||||
|
double lat2=p2.Lat()* (M_PI / 180);
|
||||||
|
|
||||||
|
return 2*M_PI-myfmod(atan2(sin(lon1-lon2)*cos(lat2),
|
||||||
|
cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon1-lon2)), 2*M_PI);
|
||||||
|
}
|
||||||
|
|
||||||
double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
||||||
{
|
{
|
||||||
double R = 6371; // km
|
double R = 6371; // km
|
||||||
@ -229,4 +244,34 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
|
|||||||
double d = R * c;
|
double d = R * c;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PureProjection::offSetFromLatLngs(PointLatLng p1,PointLatLng p2,double &distance,double &bearing)
|
||||||
|
{
|
||||||
|
distance=DistanceBetweenLatLng(p1,p2)*1000;
|
||||||
|
bearing=courseBetweenLatLng(p1,p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
double PureProjection::myfmod(double x,double y)
|
||||||
|
{
|
||||||
|
return x - y*floor(x/y);
|
||||||
|
}
|
||||||
|
|
||||||
|
PointLatLng PureProjection::translate(PointLatLng p1,double distance,double bearing)
|
||||||
|
{
|
||||||
|
PointLatLng ret;
|
||||||
|
double d=distance;
|
||||||
|
double tc=bearing;
|
||||||
|
double lat1=p1.Lat()*M_PI/180;
|
||||||
|
double lon1=p1.Lng()*M_PI/180;
|
||||||
|
double R=6378137;
|
||||||
|
double lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(tc) );
|
||||||
|
double lon2 = lon1 + atan2(sin(tc)*sin(d/R)*cos(lat1),
|
||||||
|
cos(d/R)-sin(lat1)*sin(lat2));
|
||||||
|
lat2=lat2*180/M_PI;
|
||||||
|
lon2=lon2*180/M_PI;
|
||||||
|
ret.SetLat(lat2);
|
||||||
|
ret.SetLng(lon2);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file pureprojection.h
|
* @file pureprojection.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#include "pointlatlng.h"
|
#include "pointlatlng.h"
|
||||||
#include "cmath"
|
#include "cmath"
|
||||||
#include "rectlatlng.h"
|
#include "rectlatlng.h"
|
||||||
|
#include <QDebug>
|
||||||
using namespace core;
|
using namespace core;
|
||||||
|
|
||||||
namespace internals
|
namespace internals
|
||||||
@ -81,6 +81,9 @@ public:
|
|||||||
void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng);
|
void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng);
|
||||||
static double DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2);
|
static double DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2);
|
||||||
|
|
||||||
|
PointLatLng translate(PointLatLng p1, double distance, double bearing);
|
||||||
|
double courseBetweenLatLng(const PointLatLng &p1, const PointLatLng &p2);
|
||||||
|
void offSetFromLatLngs(PointLatLng p1, PointLatLng p2, double &dX, double &dY);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const double PI;
|
static const double PI;
|
||||||
@ -103,7 +106,8 @@ protected:
|
|||||||
static double e3fn(const double &x);
|
static double e3fn(const double &x);
|
||||||
static double mlfn(const double &e0,const double &e1,const double &e2,const double &e3,const double &phi);
|
static double mlfn(const double &e0,const double &e1,const double &e2,const double &e3,const double &phi);
|
||||||
static qlonglong GetUTMzone(const double &lon);
|
static qlonglong GetUTMzone(const double &lon);
|
||||||
|
private:
|
||||||
|
double myfmod(double x, double y);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rectangle.cpp
|
* @file rectangle.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rectangle.h
|
* @file rectangle.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rectlatlng.cpp
|
* @file rectlatlng.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file rectlatlng.h
|
* @file rectlatlng.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file sizelatlng.cpp
|
* @file sizelatlng.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file sizelatlng.h
|
* @file sizelatlng.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tile.cpp
|
* @file tile.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tile.h
|
* @file tile.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tilematrix.cpp
|
* @file tilematrix.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file tilematrix.h
|
* @file tilematrix.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file configuration.cpp
|
* @file configuration.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A class that centralizes most of the mapcontrol configurations
|
* @brief A class that centralizes most of the mapcontrol configurations
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file configuration.h
|
* @file configuration.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A class that centralizes most of the mapcontrol configurations
|
* @brief A class that centralizes most of the mapcontrol configurations
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file gpsitem.cpp
|
* @file gpsitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a UAV
|
* @brief A graphicsItem representing a UAV
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -37,27 +37,27 @@ namespace mapcontrol
|
|||||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
this->setZValue(4);
|
this->setZValue(4);
|
||||||
trail=new QGraphicsItemGroup();
|
trail=new QGraphicsItemGroup(this);
|
||||||
trail->setParentItem(map);
|
trail->setParentItem(map);
|
||||||
trailLine=new QGraphicsItemGroup();
|
trailLine=new QGraphicsItemGroup(this);
|
||||||
trailLine->setParentItem(map);
|
trailLine->setParentItem(map);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
mapfollowtype=UAVMapFollowType::None;
|
mapfollowtype=UAVMapFollowType::None;
|
||||||
trailtype=UAVTrailType::ByDistance;
|
trailtype=UAVTrailType::ByDistance;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
}
|
}
|
||||||
GPSItem::~GPSItem()
|
GPSItem::~GPSItem()
|
||||||
{
|
{
|
||||||
delete trail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPSItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void GPSItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
// painter->rotate(-90);
|
|
||||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
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 GPSItem::boundingRect()const
|
QRectF GPSItem::boundingRect()const
|
||||||
{
|
{
|
||||||
@ -74,9 +74,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(timer.elapsed()>trailtime*1000)
|
if(timer.elapsed()>trailtime*1000)
|
||||||
{
|
{
|
||||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
TrailItem * ob=new TrailItem(position,altitude,Qt::green,map);
|
||||||
|
trail->addToGroup(ob);
|
||||||
|
connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT()));
|
||||||
if(!lasttrailline.IsEmpty())
|
if(!lasttrailline.IsEmpty())
|
||||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::green,map)));
|
{
|
||||||
|
TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map);
|
||||||
|
trailLine->addToGroup(obj);
|
||||||
|
connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot()));
|
||||||
|
}
|
||||||
lasttrailline=position;
|
lasttrailline=position;
|
||||||
timer.restart();
|
timer.restart();
|
||||||
}
|
}
|
||||||
@ -86,10 +92,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||||
{
|
{
|
||||||
trail->addToGroup(new TrailItem(position,altitude,Qt::green,this));
|
TrailItem * ob=new TrailItem(position,altitude,Qt::green,map);
|
||||||
|
trail->addToGroup(ob);
|
||||||
|
connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT()));
|
||||||
if(!lasttrailline.IsEmpty())
|
if(!lasttrailline.IsEmpty())
|
||||||
|
{
|
||||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::green,this)));
|
TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map);
|
||||||
|
trailLine->addToGroup(obj);
|
||||||
|
connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot()));
|
||||||
|
}
|
||||||
lasttrailline=position;
|
lasttrailline=position;
|
||||||
lastcoord=position;
|
lastcoord=position;
|
||||||
}
|
}
|
||||||
@ -97,48 +108,6 @@ namespace mapcontrol
|
|||||||
coord=position;
|
coord=position;
|
||||||
this->altitude=altitude;
|
this->altitude=altitude;
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
/*if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
//verify if the UAV is inside the safety bouble
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,20 +138,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
localposition=map->FromLatLngToLocal(coord);
|
localposition=map->FromLatLngToLocal(coord);
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
foreach(QGraphicsItem* i,trail->childItems())
|
emit setChildPosition();
|
||||||
{
|
emit setChildLine();
|
||||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
|
||||||
if(w)
|
|
||||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
|
||||||
}
|
|
||||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
|
||||||
{
|
|
||||||
TrailLineItem* ww=qgraphicsitem_cast<TrailLineItem*>(i);
|
|
||||||
if(ww)
|
|
||||||
ww->setLine(map->FromLatLngToLocal(ww->coord1).X(),map->FromLatLngToLocal(ww->coord1).Y(),map->FromLatLngToLocal(ww->coord2).X(),map->FromLatLngToLocal(ww->coord2).Y());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPSItem::setOpacitySlot(qreal opacity)
|
||||||
|
{
|
||||||
|
setOpacity(opacity);
|
||||||
|
}
|
||||||
void GPSItem::SetTrailType(const UAVTrailType::Types &value)
|
void GPSItem::SetTrailType(const UAVTrailType::Types &value)
|
||||||
{
|
{
|
||||||
trailtype=value;
|
trailtype=value;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file gpsitem.h
|
* @file gpsitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -103,7 +103,6 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
void RefreshPos();
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
/**
|
/**
|
||||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||||
@ -218,10 +217,13 @@ namespace mapcontrol
|
|||||||
// QRectF rect;
|
// QRectF rect;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void RefreshPos();
|
||||||
|
void setOpacitySlot(qreal opacity);
|
||||||
signals:
|
signals:
|
||||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||||
|
void setChildPosition();
|
||||||
|
void setChildLine();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // GPSITEM_H
|
#endif // GPSITEM_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file homeitem.cpp
|
* @file homeitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a trail point
|
* @brief A graphicsItem representing a trail point
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -27,17 +27,32 @@
|
|||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
HomeItem::HomeItem(MapGraphicItem* map,OPMapWidget* parent):safe(true),map(map),mapwidget(parent),showsafearea(true),safearea(1000),altitude(0)
|
HomeItem::HomeItem(MapGraphicItem* map,OPMapWidget* parent):safe(true),map(map),mapwidget(parent),
|
||||||
|
showsafearea(true),safearea(1000),altitude(0),isDragging(false),toggleRefresh(true)
|
||||||
{
|
{
|
||||||
pic.load(QString::fromUtf8(":/markers/images/home2.svg"));
|
pic.load(QString::fromUtf8(":/markers/images/home2.svg"));
|
||||||
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,false);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,false);
|
||||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
this->setZValue(4);
|
this->setZValue(4);
|
||||||
coord=internals::PointLatLng(50,50);
|
coord=internals::PointLatLng(50,50);
|
||||||
|
RefreshToolTip();
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HomeItem::RefreshToolTip()
|
||||||
|
{
|
||||||
|
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
||||||
|
|
||||||
|
setToolTip(QString("Waypoint: Home\nCoordinate:%1\nAltitude:%2\n").arg(coord_str).arg(QString::number(altitude)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HomeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void HomeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
@ -56,7 +71,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
QRectF HomeItem::boundingRect()const
|
QRectF HomeItem::boundingRect()const
|
||||||
{
|
{
|
||||||
if(!showsafearea)
|
if(pic.width()>localsafearea*2 && !toggleRefresh)
|
||||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||||
else
|
else
|
||||||
return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2);
|
return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2);
|
||||||
@ -67,6 +82,7 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomeItem::RefreshPos()
|
void HomeItem::RefreshPos()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
@ -75,6 +91,56 @@ namespace mapcontrol
|
|||||||
if(showsafearea)
|
if(showsafearea)
|
||||||
localsafearea=safearea/map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
localsafearea=safearea/map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
||||||
|
|
||||||
|
RefreshToolTip();
|
||||||
|
|
||||||
|
this->update();
|
||||||
|
toggleRefresh=false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HomeItem::setOpacitySlot(qreal opacity)
|
||||||
|
{
|
||||||
|
setOpacity(opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HomeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
isDragging=true;
|
||||||
|
}
|
||||||
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HomeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
isDragging=false;
|
||||||
|
|
||||||
|
emit homePositionChanged(coord,Altitude());
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
|
||||||
|
RefreshToolTip();
|
||||||
|
}
|
||||||
|
void HomeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
emit homedoubleclick(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void HomeItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isDragging)
|
||||||
|
{
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
emit homePositionChanged(coord,Altitude());
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file homeitem.h
|
* @file homeitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -47,31 +47,41 @@ namespace mapcontrol
|
|||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
int type() const;
|
int type() const;
|
||||||
void RefreshPos();
|
|
||||||
bool ShowSafeArea()const{return showsafearea;}
|
bool ShowSafeArea()const{return showsafearea;}
|
||||||
void SetShowSafeArea(bool const& value){showsafearea=value;}
|
void SetShowSafeArea(bool const& value){showsafearea=value;}
|
||||||
|
void SetToggleRefresh(bool const& value){toggleRefresh=value;}
|
||||||
int SafeArea()const{return safearea;}
|
int SafeArea()const{return safearea;}
|
||||||
void SetSafeArea(int const& value){safearea=value;}
|
void SetSafeArea(int const& value){safearea=value;}
|
||||||
bool safe;
|
bool safe;
|
||||||
void SetCoord(internals::PointLatLng const& value){coord=value;}
|
void SetCoord(internals::PointLatLng const& value){coord=value;emit homePositionChanged(value,Altitude());}
|
||||||
internals::PointLatLng Coord()const{return coord;}
|
internals::PointLatLng Coord()const{return coord;}
|
||||||
void SetAltitude(int const& value){altitude=value;}
|
void SetAltitude(float const& value){altitude=value;emit homePositionChanged(Coord(),Altitude());}
|
||||||
int Altitude()const{return altitude;}
|
float Altitude()const{return altitude;}
|
||||||
|
void RefreshToolTip();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MapGraphicItem* map;
|
MapGraphicItem* map;
|
||||||
OPMapWidget* mapwidget;
|
OPMapWidget* mapwidget;
|
||||||
QPixmap pic;
|
QPixmap pic;
|
||||||
core::Point localposition;
|
core::Point localposition;
|
||||||
internals::PointLatLng coord;
|
internals::PointLatLng coord;
|
||||||
bool showsafearea;
|
bool showsafearea;
|
||||||
|
bool toggleRefresh;
|
||||||
int safearea;
|
int safearea;
|
||||||
int localsafearea;
|
int localsafearea;
|
||||||
int altitude;
|
float altitude;
|
||||||
|
bool isDragging;
|
||||||
|
protected:
|
||||||
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||||
public slots:
|
public slots:
|
||||||
|
void RefreshPos();
|
||||||
|
void setOpacitySlot(qreal opacity);
|
||||||
signals:
|
signals:
|
||||||
|
void homePositionChanged(internals::PointLatLng coord,float);
|
||||||
|
void homedoubleclick(HomeItem* waypoint);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // HOMEITEM_H
|
#endif // HOMEITEM_H
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapgraphicitem.cpp
|
* @file mapgraphicitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -40,11 +40,13 @@ namespace mapcontrol
|
|||||||
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
|
||||||
core->SetMapType(MapType::GoogleHybrid);
|
core->SetMapType(MapType::GoogleHybrid);
|
||||||
this->SetZoom(2);
|
this->SetZoom(2);
|
||||||
|
this->setFlag(ItemIsFocusable);
|
||||||
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
|
||||||
connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh()));
|
connect(core,SIGNAL(OnMapDrag()),this,SLOT(childPosRefresh()));
|
||||||
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh()));
|
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(childPosRefresh()));
|
||||||
//resize();
|
setCacheMode(QGraphicsItem::ItemCoordinateCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapGraphicItem::start()
|
void MapGraphicItem::start()
|
||||||
{
|
{
|
||||||
core->StartSystem();
|
core->StartSystem();
|
||||||
@ -77,39 +79,15 @@ namespace mapcontrol
|
|||||||
void MapGraphicItem::Core_OnNeedInvalidation()
|
void MapGraphicItem::Core_OnNeedInvalidation()
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
foreach(QGraphicsItem* i,this->childItems())
|
emit childRefreshPosition();
|
||||||
{
|
|
||||||
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();
|
|
||||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
|
||||||
if(wwww)
|
|
||||||
wwww->RefreshPos();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void MapGraphicItem::ChildPosRefresh()
|
void MapGraphicItem::childPosRefresh()
|
||||||
{
|
{
|
||||||
foreach(QGraphicsItem* i,this->childItems())
|
emit childRefreshPosition();
|
||||||
{
|
}
|
||||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
void MapGraphicItem::setOverlayOpacity(qreal value)
|
||||||
if(w)
|
{
|
||||||
w->RefreshPos();
|
emit childSetOpacity(value);
|
||||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
|
||||||
if(ww)
|
|
||||||
ww->RefreshPos();
|
|
||||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
|
||||||
if(www)
|
|
||||||
www->RefreshPos();
|
|
||||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
|
||||||
if(wwww)
|
|
||||||
wwww->RefreshPos();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||||
{
|
{
|
||||||
@ -117,8 +95,7 @@ namespace mapcontrol
|
|||||||
QSize size=boundingRect().size().toSize();
|
QSize size=boundingRect().size().toSize();
|
||||||
size.setWidth(size.width()*2*zoomdiff);
|
size.setWidth(size.width()*2*zoomdiff);
|
||||||
size.setHeight(size.height()*2*zoomdiff);
|
size.setHeight(size.height()*2*zoomdiff);
|
||||||
temp=QImage(size,
|
temp=QImage(size,QImage::Format_ARGB32_Premultiplied);
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
temp.fill(0);
|
temp.fill(0);
|
||||||
QPainter imagePainter(&temp);
|
QPainter imagePainter(&temp);
|
||||||
imagePainter.translate(-boundingRect().topLeft());
|
imagePainter.translate(-boundingRect().topLeft());
|
||||||
@ -196,7 +173,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::AltModifier || event->modifiers() == Qt::ShiftModifier))
|
else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::ControlModifier || event->modifiers() == Qt::ShiftModifier))
|
||||||
{
|
{
|
||||||
selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||||
{
|
{
|
||||||
@ -215,12 +192,9 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!IsMouseOverMarker())
|
if(!IsMouseOverMarker())
|
||||||
{
|
{
|
||||||
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::ShiftModifier)||(event->modifiers()==Qt::ControlModifier)))
|
||||||
{
|
{
|
||||||
core->mouseDown.SetX(event->pos().x());
|
core->mouseDown.SetX(event->pos().x());
|
||||||
core->mouseDown.SetY(event->pos().y());
|
core->mouseDown.SetY(event->pos().y());
|
||||||
@ -232,7 +206,7 @@ namespace mapcontrol
|
|||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(!isSelected && ((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
else if(!isSelected && ((event->modifiers()==Qt::ControlModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||||
{
|
{
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
SetSelectedArea (internals::RectLatLng::Empty);
|
SetSelectedArea (internals::RectLatLng::Empty);
|
||||||
@ -240,7 +214,6 @@ namespace mapcontrol
|
|||||||
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
@ -269,11 +242,25 @@ namespace mapcontrol
|
|||||||
if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
|
if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
SetZoomToFitRect(SelectedArea());
|
SetZoomToFitRect(SelectedArea());
|
||||||
|
selectedArea=internals::RectLatLng::Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MapGraphicItem::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if(event->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier))
|
||||||
|
this->setCursor(Qt::CrossCursor);
|
||||||
|
if(event->key()==Qt::Key_Escape)
|
||||||
|
selectedArea=internals::RectLatLng::Empty;
|
||||||
|
QGraphicsItem::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
void MapGraphicItem::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if((event->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier))==0)
|
||||||
|
this->setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
bool MapGraphicItem::SetZoomToFitRect(internals::RectLatLng const& rect)
|
bool MapGraphicItem::SetZoomToFitRect(internals::RectLatLng const& rect)
|
||||||
{
|
{
|
||||||
int maxZoom = core->GetMaxZoomToFitRect(rect);
|
int maxZoom = core->GetMaxZoomToFitRect(rect);
|
||||||
@ -380,7 +367,6 @@ namespace mapcontrol
|
|||||||
found = true;
|
found = true;
|
||||||
{
|
{
|
||||||
painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img));
|
painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img));
|
||||||
// qDebug()<<"tile:"<<core->tileRect.X()<<core->tileRect.Y();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -394,7 +380,6 @@ namespace mapcontrol
|
|||||||
painter->setFont(config->MissingDataFont);
|
painter->setFont(config->MissingDataFont);
|
||||||
painter->setPen(Qt::red);
|
painter->setPen(Qt::red);
|
||||||
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),Qt::AlignCenter,(core->GettilePoint() == core->GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core->GettilePoint().ToString());
|
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),Qt::AlignCenter,(core->GettilePoint() == core->GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core->GettilePoint().ToString());
|
||||||
//qDebug()<<"ShowTileGridLine:"<<core->GettilePoint().ToString()<<"=="<<core->GetcenterTileXYLocation().ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,11 +416,6 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
|
|
||||||
// painter->setPen(Qt::red);
|
|
||||||
// painter->drawLine(-10,-10,10,10);
|
|
||||||
// painter->drawLine(10,10,-10,-10);
|
|
||||||
// painter->drawRect(boundingRect().adjusted(100,100,-100,-100));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -506,7 +486,6 @@ namespace mapcontrol
|
|||||||
float scaleValue = zoomDigi+remainder + 1;
|
float scaleValue = zoomDigi+remainder + 1;
|
||||||
{
|
{
|
||||||
MapRenderTransform = scaleValue;
|
MapRenderTransform = scaleValue;
|
||||||
// qDebug()<<"scale="<<scaleValue<<"zoomdigi:"<<ZoomDigi()<<"integer:"<<integer;
|
|
||||||
}
|
}
|
||||||
if(integer>MaxZoom())
|
if(integer>MaxZoom())
|
||||||
integer=MaxZoom();
|
integer=MaxZoom();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapgraphicitem.h
|
* @file mapgraphicitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -40,8 +40,10 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
//#include "uavitem.h"
|
//#include "uavitem.h"
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
class WayPointItem;
|
||||||
class OPMapWidget;
|
class OPMapWidget;
|
||||||
/**
|
/**
|
||||||
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
@ -92,7 +94,6 @@ namespace mapcontrol
|
|||||||
bool IsDragging()const{return core->IsDragging();}
|
bool IsDragging()const{return core->IsDragging();}
|
||||||
|
|
||||||
QImage lastimage;
|
QImage lastimage;
|
||||||
// QPainter* imagePainter;
|
|
||||||
core::Point lastimagepoint;
|
core::Point lastimagepoint;
|
||||||
void paintImage(QPainter* painter);
|
void paintImage(QPainter* painter);
|
||||||
void ConstructLastImage(int const& zoomdiff);
|
void ConstructLastImage(int const& zoomdiff);
|
||||||
@ -100,13 +101,15 @@ namespace mapcontrol
|
|||||||
double Zoom();
|
double Zoom();
|
||||||
double ZoomDigi();
|
double ZoomDigi();
|
||||||
double ZoomTotal();
|
double ZoomTotal();
|
||||||
|
void setOverlayOpacity(qreal value);
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
void wheelEvent ( QGraphicsSceneWheelEvent * event );
|
void wheelEvent ( QGraphicsSceneWheelEvent * event );
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
bool IsMouseOverMarker()const{return isMouseOverMarker;}
|
bool IsMouseOverMarker()const{return isMouseOverMarker;}
|
||||||
|
void keyPressEvent ( QKeyEvent * event );
|
||||||
|
void keyReleaseEvent ( QKeyEvent * event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns current map zoom
|
* @brief Returns current map zoom
|
||||||
@ -197,7 +200,7 @@ namespace mapcontrol
|
|||||||
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
||||||
private slots:
|
private slots:
|
||||||
void Core_OnNeedInvalidation();
|
void Core_OnNeedInvalidation();
|
||||||
void ChildPosRefresh();
|
void childPosRefresh();
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief To be called when the scene size changes
|
* @brief To be called when the scene size changes
|
||||||
@ -211,7 +214,10 @@ namespace mapcontrol
|
|||||||
*
|
*
|
||||||
* @param zoom
|
* @param zoom
|
||||||
*/
|
*/
|
||||||
|
void wpdoubleclicked(WayPointItem * wp);
|
||||||
void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
|
void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
|
||||||
|
void childRefreshPosition();
|
||||||
|
void childSetOpacity(qreal value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // MAPGRAPHICITEM_H
|
#endif // MAPGRAPHICITEM_H
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
<file>images/mapquad.png</file>
|
<file>images/mapquad.png</file>
|
||||||
<file>images/dragons1.jpg</file>
|
<file>images/dragons1.jpg</file>
|
||||||
<file>images/dragons2.jpeg</file>
|
<file>images/dragons2.jpeg</file>
|
||||||
|
<file>images/waypoint_marker1.png</file>
|
||||||
|
<file>images/waypoint_marker2.png</file>
|
||||||
|
<file>images/waypoint_marker3.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/uavs">
|
<qresource prefix="/uavs">
|
||||||
<file>images/airplanepip.png</file>
|
<file>images/airplanepip.png</file>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapripform.cpp
|
* @file mapripform.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief Form to be used with the MapRipper class
|
* @brief Form to be used with the MapRipper class
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -33,6 +33,7 @@ MapRipForm::MapRipForm(QWidget *parent) :
|
|||||||
ui(new Ui::MapRipForm)
|
ui(new Ui::MapRipForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->cancelButton,SIGNAL(clicked()),this,SIGNAL(cancelRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MapRipForm::~MapRipForm()
|
MapRipForm::~MapRipForm()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapripform.h
|
* @file mapripform.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief Form to be used with the MapRipper class
|
* @brief Form to be used with the MapRipper class
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -44,6 +44,8 @@ public slots:
|
|||||||
void SetPercentage(int const& perc);
|
void SetPercentage(int const& perc);
|
||||||
void SetProvider(QString const& prov,int const& zoom);
|
void SetProvider(QString const& prov,int const& zoom);
|
||||||
void SetNumberOfTiles(int const& total,int const& actual);
|
void SetNumberOfTiles(int const& total,int const& actual);
|
||||||
|
signals:
|
||||||
|
void cancelRequest();
|
||||||
private:
|
private:
|
||||||
Ui::MapRipForm *ui;
|
Ui::MapRipForm *ui;
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>392</width>
|
<width>521</width>
|
||||||
<height>133</height>
|
<height>133</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>60</y>
|
<y>60</y>
|
||||||
<width>371</width>
|
<width>481</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>321</width>
|
<width>481</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<widget class="QPushButton" name="cancelButton">
|
<widget class="QPushButton" name="cancelButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>280</x>
|
<x>220</x>
|
||||||
<y>100</y>
|
<y>100</y>
|
||||||
<width>75</width>
|
<width>75</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapripper.cpp
|
* @file mapripper.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A class that allows ripping of a selection of the map
|
* @brief A class that allows ripping of a selection of the map
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -28,17 +28,19 @@
|
|||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
|
||||||
MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect):sleep(100),cancel(false),progressForm(0),core(core)
|
MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect):sleep(100),cancel(false),progressForm(0),core(core),yesToAll(false)
|
||||||
{
|
{
|
||||||
if(!rect.IsEmpty())
|
if(!rect.IsEmpty())
|
||||||
{
|
{
|
||||||
type=core->GetMapType();
|
type=core->GetMapType();
|
||||||
progressForm=new MapRipForm;
|
progressForm=new MapRipForm;
|
||||||
|
connect(progressForm,SIGNAL(cancelRequest()),this,SLOT(stopFetching()));
|
||||||
area=rect;
|
area=rect;
|
||||||
zoom=core->Zoom();
|
zoom=core->Zoom();
|
||||||
maxzoom=core->MaxZoom();
|
maxzoom=core->MaxZoom();
|
||||||
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
||||||
this->start();
|
this->start();
|
||||||
|
cancel=false;
|
||||||
progressForm->show();
|
progressForm->show();
|
||||||
connect(this,SIGNAL(percentageChanged(int)),progressForm,SLOT(SetPercentage(int)));
|
connect(this,SIGNAL(percentageChanged(int)),progressForm,SLOT(SetPercentage(int)));
|
||||||
connect(this,SIGNAL(numberOfTilesChanged(int,int)),progressForm,SLOT(SetNumberOfTiles(int,int)));
|
connect(this,SIGNAL(numberOfTilesChanged(int,int)),progressForm,SLOT(SetNumberOfTiles(int,int)));
|
||||||
@ -46,32 +48,58 @@ namespace mapcontrol
|
|||||||
connect(this,SIGNAL(finished()),this,SLOT(finish()));
|
connect(this,SIGNAL(finished()),this,SLOT(finish()));
|
||||||
emit numberOfTilesChanged(0,0);
|
emit numberOfTilesChanged(0,0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
QMessageBox::information(new QWidget(),"No valid selection","This pre-caches map data.\n\nPlease first select the area of the map to rip with <COMMAND>+Left mouse click");
|
||||||
|
#else
|
||||||
|
QMessageBox::information(new QWidget(),"No valid selection","This pre-caches map data.\n\nPlease first select the area of the map to rip with <CTRL>+Left mouse click");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void MapRipper::finish()
|
void MapRipper::finish()
|
||||||
|
{
|
||||||
|
if(zoom<maxzoom && !cancel)
|
||||||
{
|
{
|
||||||
if(zoom<maxzoom)
|
++zoom;
|
||||||
|
int ret;
|
||||||
|
if(!yesToAll)
|
||||||
{
|
{
|
||||||
++zoom;
|
QMessageBox msgBox;
|
||||||
QMessageBox msgBox;
|
msgBox.setText(QString("Continue Ripping at zoom level %1?").arg(zoom));
|
||||||
msgBox.setText(QString("Continue Ripping at zoom level %1?").arg(zoom));
|
// msgBox.setInformativeText("Do you want to save your changes?");
|
||||||
// msgBox.setInformativeText("Do you want to save your changes?");
|
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::YesAll);
|
||||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
ret = msgBox.exec();
|
||||||
int ret = msgBox.exec();
|
}
|
||||||
if(ret==QMessageBox::Yes)
|
else
|
||||||
{
|
ret=QMessageBox::Yes;
|
||||||
points.clear();
|
if(ret==QMessageBox::Yes)
|
||||||
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
{
|
||||||
this->start();
|
points.clear();
|
||||||
}
|
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
||||||
else
|
this->start();
|
||||||
{
|
}
|
||||||
progressForm->close();
|
else if(ret==QMessageBox::YesAll)
|
||||||
delete progressForm;
|
{
|
||||||
this->deleteLater();
|
yesToAll=true;
|
||||||
}
|
points.clear();
|
||||||
}
|
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
||||||
|
this->start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressForm->close();
|
||||||
|
delete progressForm;
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yesToAll=false;
|
||||||
|
progressForm->close();
|
||||||
|
delete progressForm;
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapRipper::run()
|
void MapRipper::run()
|
||||||
@ -119,4 +147,10 @@ namespace mapcontrol
|
|||||||
QThread::msleep(sleep);
|
QThread::msleep(sleep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapRipper::stopFetching()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mutex);
|
||||||
|
cancel=true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file mapripper.h
|
* @file mapripper.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A class that allows ripping of a selection of the map
|
* @brief A class that allows ripping of a selection of the map
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -50,6 +50,8 @@ namespace mapcontrol
|
|||||||
MapRipForm * progressForm;
|
MapRipForm * progressForm;
|
||||||
int maxzoom;
|
int maxzoom;
|
||||||
internals::Core * core;
|
internals::Core * core;
|
||||||
|
bool yesToAll;
|
||||||
|
QMutex mutex;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void percentageChanged(int const& perc);
|
void percentageChanged(int const& perc);
|
||||||
@ -58,6 +60,7 @@ namespace mapcontrol
|
|||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void stopFetching();
|
||||||
void finish();
|
void finish();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,9 @@ SOURCES += mapgraphicitem.cpp \
|
|||||||
homeitem.cpp \
|
homeitem.cpp \
|
||||||
mapripform.cpp \
|
mapripform.cpp \
|
||||||
mapripper.cpp \
|
mapripper.cpp \
|
||||||
traillineitem.cpp
|
traillineitem.cpp \
|
||||||
|
waypointline.cpp \
|
||||||
|
waypointcircle.cpp
|
||||||
|
|
||||||
LIBS += -L../build \
|
LIBS += -L../build \
|
||||||
-lcore \
|
-lcore \
|
||||||
@ -39,7 +41,9 @@ HEADERS += mapgraphicitem.h \
|
|||||||
homeitem.h \
|
homeitem.h \
|
||||||
mapripform.h \
|
mapripform.h \
|
||||||
mapripper.h \
|
mapripper.h \
|
||||||
traillineitem.h
|
traillineitem.h \
|
||||||
|
waypointline.h \
|
||||||
|
waypointcircle.h
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += network
|
QT += network
|
||||||
QT += sql
|
QT += sql
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapwidget.cpp
|
* @file opmapwidget.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief The Map Widget, this is the part exposed to the user
|
* @brief The Map Widget, this is the part exposed to the user
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -33,13 +33,18 @@
|
|||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
|
||||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),GPS(0),Home(0),followmouse(true),compass(0),showuav(false),showhome(false),showDiag(false),diagGraphItem(0),diagTimer(0)
|
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),UAV(0),GPS(0),Home(0)
|
||||||
|
,followmouse(true),compass(0),showuav(false),showhome(false),showDiag(false),diagGraphItem(0),diagTimer(0),overlayOpacity(1)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
core=new internals::Core;
|
core=new internals::Core;
|
||||||
map=new MapGraphicItem(core,config);
|
map=new MapGraphicItem(core,config);
|
||||||
mscene.addItem(map);
|
mscene.addItem(map);
|
||||||
this->setScene(&mscene);
|
this->setScene(&mscene);
|
||||||
|
Home=new HomeItem(map,this);
|
||||||
|
Home->setParentItem(map);
|
||||||
|
Home->setZValue(-1);
|
||||||
|
setStyleSheet("QToolTip {font-size:8pt; color:blue;opacity: 223; padding:2px; border-width:2px; border-style:solid; border-color: rgb(170, 170, 127);border-radius:4px }");
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
connect(map,SIGNAL(zoomChanged(double,double,double)),this,SIGNAL(zoomChanged(double,double,double)));
|
connect(map,SIGNAL(zoomChanged(double,double,double)),this,SIGNAL(zoomChanged(double,double,double)));
|
||||||
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
|
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
|
||||||
@ -50,10 +55,12 @@ namespace mapcontrol
|
|||||||
connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete()));
|
connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete()));
|
||||||
connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart()));
|
connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart()));
|
||||||
connect(map->core,SIGNAL(OnTilesStillToLoad(int)),this,SIGNAL(OnTilesStillToLoad(int)));
|
connect(map->core,SIGNAL(OnTilesStillToLoad(int)),this,SIGNAL(OnTilesStillToLoad(int)));
|
||||||
|
connect(map,SIGNAL(wpdoubleclicked(WayPointItem*)),this,SIGNAL(OnWayPointDoubleClicked(WayPointItem*)));
|
||||||
|
connect(&mscene,SIGNAL(selectionChanged()),this,SLOT(OnSelectionChanged()));
|
||||||
SetShowDiagnostics(showDiag);
|
SetShowDiagnostics(showDiag);
|
||||||
this->setMouseTracking(followmouse);
|
this->setMouseTracking(followmouse);
|
||||||
SetShowCompass(true);
|
SetShowCompass(true);
|
||||||
|
QPixmapCache::setCacheLimit(64*1024);
|
||||||
}
|
}
|
||||||
void OPMapWidget::SetShowDiagnostics(bool const& value)
|
void OPMapWidget::SetShowDiagnostics(bool const& value)
|
||||||
{
|
{
|
||||||
@ -70,12 +77,24 @@ namespace mapcontrol
|
|||||||
delete diagTimer;
|
delete diagTimer;
|
||||||
diagTimer=0;
|
diagTimer=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GPS!=0)
|
||||||
|
{
|
||||||
|
delete GPS;
|
||||||
|
GPS=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
diagTimer=new QTimer();
|
diagTimer=new QTimer();
|
||||||
connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh()));
|
connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh()));
|
||||||
diagTimer->start(500);
|
diagTimer->start(500);
|
||||||
|
if(GPS==0)
|
||||||
|
{
|
||||||
|
GPS=new GPSItem(map,this);
|
||||||
|
GPS->setParentItem(map);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,8 +104,40 @@ namespace mapcontrol
|
|||||||
UAV->SetUavPic(UAVPic);
|
UAV->SetUavPic(UAVPic);
|
||||||
if(GPS!=0)
|
if(GPS!=0)
|
||||||
GPS->SetUavPic(UAVPic);
|
GPS->SetUavPic(UAVPic);
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointLine * OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to,QColor color)
|
||||||
|
{
|
||||||
|
if(!from|!to)
|
||||||
|
return NULL;
|
||||||
|
WayPointLine* ret= new WayPointLine(from,to,map,color);
|
||||||
|
ret->setOpacity(overlayOpacity);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
WayPointLine * OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to,QColor color)
|
||||||
|
{
|
||||||
|
if(!from|!to)
|
||||||
|
return NULL;
|
||||||
|
WayPointLine* ret= new WayPointLine(from,to,map,color);
|
||||||
|
ret->setOpacity(overlayOpacity);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
WayPointCircle * OPMapWidget::WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise,QColor color)
|
||||||
|
{
|
||||||
|
if(!center|!radius)
|
||||||
|
return NULL;
|
||||||
|
WayPointCircle* ret= new WayPointCircle(center,radius,clockwise,map,color);
|
||||||
|
ret->setOpacity(overlayOpacity);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointCircle *OPMapWidget::WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise,QColor color)
|
||||||
|
{
|
||||||
|
if(!center|!radius)
|
||||||
|
return NULL;
|
||||||
|
WayPointCircle* ret= new WayPointCircle(center,radius,clockwise,map,color);
|
||||||
|
ret->setOpacity(overlayOpacity);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
void OPMapWidget::SetShowUAV(const bool &value)
|
void OPMapWidget::SetShowUAV(const bool &value)
|
||||||
{
|
{
|
||||||
@ -96,47 +147,21 @@ namespace mapcontrol
|
|||||||
UAV->setParentItem(map);
|
UAV->setParentItem(map);
|
||||||
connect(this,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)),UAV,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)));
|
connect(this,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)),UAV,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)));
|
||||||
connect(this,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)),UAV,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)));
|
connect(this,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)),UAV,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)));
|
||||||
|
UAV->setOpacity(overlayOpacity);
|
||||||
}
|
}
|
||||||
else if(!value)
|
else if(!value)
|
||||||
{
|
{
|
||||||
if(UAV!=0)
|
if(UAV!=0)
|
||||||
{
|
{
|
||||||
delete UAV;
|
delete UAV;
|
||||||
UAV=0;
|
UAV=NULL;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if(value && GPS==0)
|
|
||||||
{
|
|
||||||
GPS=new GPSItem(map,this);
|
|
||||||
GPS->setParentItem(map);
|
|
||||||
}
|
|
||||||
else if(!value)
|
|
||||||
{
|
|
||||||
if(GPS!=0)
|
|
||||||
{
|
|
||||||
delete GPS;
|
|
||||||
GPS=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::SetShowHome(const bool &value)
|
void OPMapWidget::SetShowHome(const bool &value)
|
||||||
{
|
{
|
||||||
if(value && Home==0)
|
Home->setVisible(value);
|
||||||
{
|
|
||||||
Home=new HomeItem(map,this);
|
|
||||||
Home->setParentItem(map);
|
|
||||||
}
|
|
||||||
else if(!value)
|
|
||||||
{
|
|
||||||
if(Home!=0)
|
|
||||||
{
|
|
||||||
delete Home;
|
|
||||||
Home=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
||||||
@ -161,14 +186,20 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
OPMapWidget::~OPMapWidget()
|
OPMapWidget::~OPMapWidget()
|
||||||
{
|
{
|
||||||
delete UAV;
|
if(UAV)
|
||||||
delete Home;
|
delete UAV;
|
||||||
delete map;
|
if(Home)
|
||||||
delete core;
|
delete Home;
|
||||||
delete configuration;
|
if(map)
|
||||||
|
delete map;
|
||||||
|
if(core)
|
||||||
|
delete core;
|
||||||
|
if(configuration)
|
||||||
|
delete configuration;
|
||||||
foreach(QGraphicsItem* i,this->items())
|
foreach(QGraphicsItem* i,this->items())
|
||||||
{
|
{
|
||||||
delete i;
|
if(i)
|
||||||
|
delete i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::closeEvent(QCloseEvent *event)
|
void OPMapWidget::closeEvent(QCloseEvent *event)
|
||||||
@ -203,18 +234,33 @@ namespace mapcontrol
|
|||||||
WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map);
|
WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map);
|
||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
|
int position=item->Number();
|
||||||
|
emit WPCreated(position,item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::magicWPCreate()
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(map,true);
|
||||||
|
item->SetShowNumber(false);
|
||||||
|
item->setParentItem(map);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
void OPMapWidget::WPCreate(WayPointItem* item)
|
void OPMapWidget::WPCreate(WayPointItem* item)
|
||||||
{
|
{
|
||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
|
int position=item->Number();
|
||||||
|
emit WPCreated(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
}
|
}
|
||||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude)
|
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude)
|
||||||
{
|
{
|
||||||
WayPointItem* item=new WayPointItem(coord,altitude,map);
|
WayPointItem* item=new WayPointItem(coord,altitude,map);
|
||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
|
int position=item->Number();
|
||||||
|
emit WPCreated(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description)
|
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description)
|
||||||
@ -222,6 +268,19 @@ namespace mapcontrol
|
|||||||
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
|
int position=item->Number();
|
||||||
|
emit WPCreated(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, const QString &description)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(relativeCoord,description,map);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
int position=item->Number();
|
||||||
|
emit WPCreated(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
WayPointItem* OPMapWidget::WPInsert(const int &position)
|
WayPointItem* OPMapWidget::WPInsert(const int &position)
|
||||||
@ -231,6 +290,7 @@ namespace mapcontrol
|
|||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
emit WPInserted(position,item);
|
emit WPInserted(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
void OPMapWidget::WPInsert(WayPointItem* item,const int &position)
|
void OPMapWidget::WPInsert(WayPointItem* item,const int &position)
|
||||||
@ -239,7 +299,7 @@ namespace mapcontrol
|
|||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
emit WPInserted(position,item);
|
emit WPInserted(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
}
|
}
|
||||||
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude,const int &position)
|
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude,const int &position)
|
||||||
{
|
{
|
||||||
@ -248,29 +308,131 @@ namespace mapcontrol
|
|||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
emit WPInserted(position,item);
|
emit WPInserted(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,const int &position)
|
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,const int &position)
|
||||||
{
|
{
|
||||||
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
internals::PointLatLng mcoord;
|
||||||
|
bool reloc=false;
|
||||||
|
if(mcoord==internals::PointLatLng(0,0))
|
||||||
|
{
|
||||||
|
mcoord=CurrentPosition();
|
||||||
|
reloc=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mcoord=coord;
|
||||||
|
WayPointItem* item=new WayPointItem(mcoord,altitude,description,map);
|
||||||
item->SetNumber(position);
|
item->SetNumber(position);
|
||||||
ConnectWP(item);
|
ConnectWP(item);
|
||||||
item->setParentItem(map);
|
item->setParentItem(map);
|
||||||
emit WPInserted(position,item);
|
emit WPInserted(position,item);
|
||||||
|
if(reloc)
|
||||||
|
emit WPValuesChanged(item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPInsert(distBearingAltitude const& relative, QString const& description,const int &position)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(relative,description,map);
|
||||||
|
item->SetNumber(position);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
emit WPInserted(position,item);
|
||||||
|
setOverlayOpacity(overlayOpacity);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
void OPMapWidget::WPDelete(WayPointItem *item)
|
void OPMapWidget::WPDelete(WayPointItem *item)
|
||||||
{
|
{
|
||||||
emit WPDeleted(item->Number());
|
emit WPDeleted(item->Number(),item);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
void OPMapWidget::WPDeleteAll()
|
void OPMapWidget::WPDelete(int number)
|
||||||
{
|
{
|
||||||
foreach(QGraphicsItem* i,map->childItems())
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
{
|
{
|
||||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
if(w)
|
if(w)
|
||||||
delete w;
|
{
|
||||||
|
if(w->Number()==number)
|
||||||
|
{
|
||||||
|
emit WPDeleted(w->Number(),w);
|
||||||
|
delete w;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WayPointItem * OPMapWidget::WPFind(int number)
|
||||||
|
{
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
{
|
||||||
|
if(w->Number()==number)
|
||||||
|
{
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPSetVisibleAll(bool value)
|
||||||
|
{
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
{
|
||||||
|
if(w->Number()!=-1)
|
||||||
|
w->setVisible(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPDeleteAll()
|
||||||
|
{
|
||||||
|
int x=0;
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
{
|
||||||
|
if(w->Number()!=-1)
|
||||||
|
{
|
||||||
|
emit WPDeleted(w->Number(),w);
|
||||||
|
delete w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool OPMapWidget::WPPresent()
|
||||||
|
{
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
{
|
||||||
|
if(w->Number()!=-1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OPMapWidget::deleteAllOverlays()
|
||||||
|
{
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointLine* w=qgraphicsitem_cast<WayPointLine*>(i);
|
||||||
|
if(w)
|
||||||
|
w->deleteLater();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WayPointCircle* ww=qgraphicsitem_cast<WayPointCircle*>(i);
|
||||||
|
if(ww)
|
||||||
|
ww->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList<WayPointItem*> OPMapWidget::WPSelected()
|
QList<WayPointItem*> OPMapWidget::WPSelected()
|
||||||
@ -291,11 +453,13 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void OPMapWidget::ConnectWP(WayPointItem *item)
|
void OPMapWidget::ConnectWP(WayPointItem *item)
|
||||||
{
|
{
|
||||||
connect(item,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)));
|
connect(item,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),Qt::DirectConnection);
|
||||||
connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*)));
|
connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*)),Qt::DirectConnection);
|
||||||
connect(this,SIGNAL(WPInserted(int,WayPointItem*)),item,SLOT(WPInserted(int,WayPointItem*)));
|
connect(item,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SIGNAL(WPLocalPositionChanged(QPointF,WayPointItem*)),Qt::DirectConnection);
|
||||||
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)));
|
connect(item,SIGNAL(manualCoordChange(WayPointItem*)),this,SIGNAL(WPManualCoordChange(WayPointItem*)),Qt::DirectConnection);
|
||||||
connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int)));
|
connect(this,SIGNAL(WPInserted(int,WayPointItem*)),item,SLOT(WPInserted(int,WayPointItem*)),Qt::DirectConnection);
|
||||||
|
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)),Qt::DirectConnection);
|
||||||
|
connect(this,SIGNAL(WPDeleted(int,WayPointItem*)),item,SLOT(WPDeleted(int,WayPointItem*)),Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
void OPMapWidget::diagRefresh()
|
void OPMapWidget::diagRefresh()
|
||||||
{
|
{
|
||||||
@ -329,12 +493,12 @@ namespace mapcontrol
|
|||||||
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
||||||
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
||||||
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
compass->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
mscene.addItem(compass);
|
mscene.addItem(compass);
|
||||||
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
||||||
compass->setPos(55-compass->boundingRect().width()/2,55-compass->boundingRect().height()/2);
|
compass->setPos(55-compass->boundingRect().width()/2,55-compass->boundingRect().height()/2);
|
||||||
compass->setZValue(3);
|
compass->setZValue(3);
|
||||||
compass->setOpacity(0.7);
|
compass->setOpacity(0.7);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!value && compass)
|
if(!value && compass)
|
||||||
{
|
{
|
||||||
@ -342,6 +506,12 @@ namespace mapcontrol
|
|||||||
compass=0;
|
compass=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPMapWidget::setOverlayOpacity(qreal value)
|
||||||
|
{
|
||||||
|
map->setOverlayOpacity(value);
|
||||||
|
overlayOpacity=value;
|
||||||
|
}
|
||||||
void OPMapWidget::SetRotate(qreal const& value)
|
void OPMapWidget::SetRotate(qreal const& value)
|
||||||
{
|
{
|
||||||
map->mapRotate(value);
|
map->mapRotate(value);
|
||||||
@ -353,4 +523,28 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
new MapRipper(core,map->SelectedArea());
|
new MapRipper(core,map->SelectedArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPMapWidget::setSelectedWP(QList<WayPointItem * >list)
|
||||||
|
{
|
||||||
|
this->scene()->clearSelection();
|
||||||
|
foreach(WayPointItem * wp,list)
|
||||||
|
{
|
||||||
|
wp->setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPMapWidget::OnSelectionChanged()
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem*> list;
|
||||||
|
QList<WayPointItem*> wplist;
|
||||||
|
list=this->scene()->selectedItems();
|
||||||
|
foreach(QGraphicsItem* item,list)
|
||||||
|
{
|
||||||
|
WayPointItem * wp=qgraphicsitem_cast<WayPointItem*>(item);
|
||||||
|
if(wp)
|
||||||
|
wplist.append(wp);
|
||||||
|
}
|
||||||
|
if(wplist.length()>0)
|
||||||
|
emit selectedWPChanged(wplist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file opmapwidget.h
|
* @file opmapwidget.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief The Map Widget, this is the part exposed to the user
|
* @brief The Map Widget, this is the part exposed to the user
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -41,6 +41,9 @@
|
|||||||
#include "gpsitem.h"
|
#include "gpsitem.h"
|
||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
#include "mapripper.h"
|
#include "mapripper.h"
|
||||||
|
#include "waypointline.h"
|
||||||
|
#include "waypointcircle.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
class UAVItem;
|
class UAVItem;
|
||||||
@ -279,6 +282,15 @@ namespace mapcontrol
|
|||||||
*/
|
*/
|
||||||
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
|
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
|
||||||
/**
|
/**
|
||||||
|
* @brief Creates a new WayPoint
|
||||||
|
*
|
||||||
|
* @param coord the offset in meters to the home position
|
||||||
|
* @param altitude the Altitude of the WayPoint
|
||||||
|
* @param description the description of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint created
|
||||||
|
*/
|
||||||
|
WayPointItem *WPCreate(const distBearingAltitude &relativeCoord, const QString &description);
|
||||||
|
/**
|
||||||
* @brief Inserts a new WayPoint on the specified position
|
* @brief Inserts a new WayPoint on the specified position
|
||||||
*
|
*
|
||||||
* @param position index of the WayPoint
|
* @param position index of the WayPoint
|
||||||
@ -311,6 +323,7 @@ namespace mapcontrol
|
|||||||
* @return WayPointItem a pointer to the WayPoint Inserted
|
* @return WayPointItem a pointer to the WayPoint Inserted
|
||||||
*/
|
*/
|
||||||
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
|
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
|
||||||
|
WayPointItem *WPInsert(const distBearingAltitude &relative, const QString &description, const int &position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Deletes the WayPoint
|
* @brief Deletes the WayPoint
|
||||||
@ -340,6 +353,8 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void SetShowCompass(bool const& value);
|
void SetShowCompass(bool const& value);
|
||||||
|
|
||||||
|
void setOverlayOpacity(qreal value);
|
||||||
|
|
||||||
UAVItem* UAV;
|
UAVItem* UAV;
|
||||||
GPSItem* GPS;
|
GPSItem* GPS;
|
||||||
HomeItem* Home;
|
HomeItem* Home;
|
||||||
@ -349,7 +364,18 @@ namespace mapcontrol
|
|||||||
bool ShowHome()const{return showhome;}
|
bool ShowHome()const{return showhome;}
|
||||||
void SetShowDiagnostics(bool const& value);
|
void SetShowDiagnostics(bool const& value);
|
||||||
void SetUavPic(QString UAVPic);
|
void SetUavPic(QString UAVPic);
|
||||||
private:
|
WayPointLine * WPLineCreate(WayPointItem *from,WayPointItem *to, QColor color);
|
||||||
|
WayPointLine * WPLineCreate(HomeItem *from,WayPointItem *to, QColor color);
|
||||||
|
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius,bool clockwise,QColor color);
|
||||||
|
WayPointCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius,bool clockwise,QColor color);
|
||||||
|
void deleteAllOverlays();
|
||||||
|
void WPSetVisibleAll(bool value);
|
||||||
|
WayPointItem *magicWPCreate();
|
||||||
|
bool WPPresent();
|
||||||
|
void WPDelete(int number);
|
||||||
|
WayPointItem *WPFind(int number);
|
||||||
|
void setSelectedWP(QList<WayPointItem *> list);
|
||||||
|
private:
|
||||||
internals::Core *core;
|
internals::Core *core;
|
||||||
MapGraphicItem *map;
|
MapGraphicItem *map;
|
||||||
QGraphicsScene mscene;
|
QGraphicsScene mscene;
|
||||||
@ -366,6 +392,7 @@ namespace mapcontrol
|
|||||||
QTimer * diagTimer;
|
QTimer * diagTimer;
|
||||||
QGraphicsTextItem * diagGraphItem;
|
QGraphicsTextItem * diagGraphItem;
|
||||||
bool showDiag;
|
bool showDiag;
|
||||||
|
qreal overlayOpacity;
|
||||||
private slots:
|
private slots:
|
||||||
void diagRefresh();
|
void diagRefresh();
|
||||||
// WayPointItem* item;//apagar
|
// WayPointItem* item;//apagar
|
||||||
@ -398,6 +425,9 @@ namespace mapcontrol
|
|||||||
* @param waypoint WayPoint inserted
|
* @param waypoint WayPoint inserted
|
||||||
*/
|
*/
|
||||||
void WPReached(WayPointItem* waypoint);
|
void WPReached(WayPointItem* waypoint);
|
||||||
|
|
||||||
|
void WPCreated(int const& number,WayPointItem* waypoint);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fires when a new WayPoint is inserted
|
* @brief Fires when a new WayPoint is inserted
|
||||||
*
|
*
|
||||||
@ -410,7 +440,10 @@ namespace mapcontrol
|
|||||||
*
|
*
|
||||||
* @param number number of the deleted WayPoint
|
* @param number number of the deleted WayPoint
|
||||||
*/
|
*/
|
||||||
void WPDeleted(int const& number);
|
void WPDeleted(int const& number,WayPointItem* waypoint);
|
||||||
|
|
||||||
|
void WPLocalPositionChanged(QPointF,WayPointItem*);
|
||||||
|
void WPManualCoordChange(WayPointItem*);
|
||||||
/**
|
/**
|
||||||
* @brief Fires When a WayPoint is Reached
|
* @brief Fires When a WayPoint is Reached
|
||||||
*
|
*
|
||||||
@ -469,11 +502,14 @@ namespace mapcontrol
|
|||||||
* @param number the number of tiles still in the queue
|
* @param number the number of tiles still in the queue
|
||||||
*/
|
*/
|
||||||
void OnTilesStillToLoad(int number);
|
void OnTilesStillToLoad(int number);
|
||||||
|
void OnWayPointDoubleClicked(WayPointItem * waypoint);
|
||||||
|
void selectedWPChanged(QList<WayPointItem*>);
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief Ripps the current selection to the DB
|
* @brief Ripps the current selection to the DB
|
||||||
*/
|
*/
|
||||||
void RipMap();
|
void RipMap();
|
||||||
|
void OnSelectionChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file trailitem.cpp
|
* @file trailitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a trail point
|
* @brief A graphicsItem representing a trail point
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -28,9 +28,8 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
TrailItem::TrailItem(internals::PointLatLng const& coord,int const& altitude, QBrush color, QGraphicsItem* parent):QGraphicsItem(parent),coord(coord)
|
TrailItem::TrailItem(internals::PointLatLng const& coord,int const& altitude, QBrush color, MapGraphicItem *map):QGraphicsItem(map),coord(coord),m_brush(color),m_map(map)
|
||||||
{
|
{
|
||||||
m_brush=color;
|
|
||||||
QDateTime time=QDateTime::currentDateTime();
|
QDateTime time=QDateTime::currentDateTime();
|
||||||
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
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()));
|
setToolTip(QString(tr("Position:")+"%1\n"+tr("Altitude:")+"%2\n"+tr("Time:")+"%3").arg(coord_str).arg(QString::number(altitude)).arg(time.toString()));
|
||||||
@ -38,7 +37,6 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
// painter->drawRect(QRectF(-3,-3,6,6));
|
|
||||||
painter->setBrush(m_brush);
|
painter->setBrush(m_brush);
|
||||||
painter->drawEllipse(-2,-2,4,4);
|
painter->drawEllipse(-2,-2,4,4);
|
||||||
}
|
}
|
||||||
@ -53,5 +51,8 @@ namespace mapcontrol
|
|||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrailItem::setPosSLOT()
|
||||||
|
{
|
||||||
|
setPos(m_map->FromLatLngToLocal(this->coord).X(),m_map->FromLatLngToLocal(this->coord).Y());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file trailitem.h
|
* @file trailitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "../internals/pointlatlng.h"
|
#include "../internals/pointlatlng.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "mapgraphicitem.h"
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
@ -42,7 +43,7 @@ namespace mapcontrol
|
|||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 3 };
|
enum { Type = UserType + 3 };
|
||||||
TrailItem(internals::PointLatLng const& coord,int const& altitude, QBrush color, QGraphicsItem* parent);
|
TrailItem(internals::PointLatLng const& coord,int const& altitude, QBrush color,MapGraphicItem * map);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
@ -50,10 +51,9 @@ namespace mapcontrol
|
|||||||
internals::PointLatLng coord;
|
internals::PointLatLng coord;
|
||||||
private:
|
private:
|
||||||
QBrush m_brush;
|
QBrush m_brush;
|
||||||
|
MapGraphicItem * m_map;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void setPosSLOT();
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file trailitem.cpp
|
* @file trailitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a trail point
|
* @brief A graphicsItem representing a trail point
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -28,29 +28,21 @@
|
|||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
TrailLineItem::TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color, QGraphicsItem* parent):QGraphicsLineItem(parent),coord1(coord1),coord2(coord2)
|
TrailLineItem::TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color, MapGraphicItem * map):QGraphicsLineItem(map),coord1(coord1),coord2(coord2),m_brush(color),m_map(map)
|
||||||
{
|
{
|
||||||
m_brush=color;
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setBrush(m_brush);
|
pen.setBrush(m_brush);
|
||||||
pen.setWidth(1);
|
pen.setWidth(1);
|
||||||
this->setPen(pen);
|
this->setPen(pen);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
void TrailLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
// painter->drawRect(QRectF(-3,-3,6,6));
|
|
||||||
painter->setBrush(m_brush);
|
|
||||||
QPen pen;
|
|
||||||
pen.setBrush(m_brush);
|
|
||||||
pen.setWidth(2);
|
|
||||||
painter->drawLine(this->line().x1(),this->line().y1(),this->line().x2(),this->line().y2());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
int TrailLineItem::type()const
|
int TrailLineItem::type()const
|
||||||
{
|
{
|
||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrailLineItem::setLineSlot()
|
||||||
|
{
|
||||||
|
setLine(m_map->FromLatLngToLocal(this->coord1).X(),m_map->FromLatLngToLocal(this->coord1).Y(),m_map->FromLatLngToLocal(this->coord2).X(),m_map->FromLatLngToLocal(this->coord2).Y());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file traillineitem.h
|
* @file traillineitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "../internals/pointlatlng.h"
|
#include "../internals/pointlatlng.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "mapgraphicitem.h"
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
@ -42,18 +43,15 @@ namespace mapcontrol
|
|||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 7 };
|
enum { Type = UserType + 7 };
|
||||||
TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color, QGraphicsItem* parent);
|
TrailLineItem(internals::PointLatLng const& coord1,internals::PointLatLng const& coord2, QBrush color,MapGraphicItem * map);
|
||||||
int type() const;
|
int type() const;
|
||||||
// void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
||||||
// QWidget *widget);
|
|
||||||
internals::PointLatLng coord1;
|
internals::PointLatLng coord1;
|
||||||
internals::PointLatLng coord2;
|
internals::PointLatLng coord2;
|
||||||
private:
|
private:
|
||||||
QBrush m_brush;
|
QBrush m_brush;
|
||||||
|
MapGraphicItem * m_map;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void setLineSlot();
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file uavitem.cpp
|
* @file uavitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a UAV
|
* @brief A graphicsItem representing a UAV
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -26,45 +26,225 @@
|
|||||||
*/
|
*/
|
||||||
#include "../internals/pureprojection.h"
|
#include "../internals/pureprojection.h"
|
||||||
#include "uavitem.h"
|
#include "uavitem.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
|
||||||
|
double UAVItem::groundspeed_mps_filt = 0;
|
||||||
|
|
||||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true)
|
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||||
,autosetdistance(100)
|
,autosetdistance(100),altitude(0),showUAVInfo(false)
|
||||||
{
|
{
|
||||||
//QDir dir(":/uavs/images/");
|
|
||||||
//QStringList list=dir.entryList();
|
|
||||||
pic.load(uavPic);
|
pic.load(uavPic);
|
||||||
// Don't scale but trust the image we are given
|
this->setFlag(QGraphicsItem::ItemIsMovable,false);
|
||||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
this->setFlag(QGraphicsItem::ItemIsSelectable,false);
|
||||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
this->setZValue(4);
|
this->setZValue(4);
|
||||||
trail=new QGraphicsItemGroup();
|
trail=new QGraphicsItemGroup(this);
|
||||||
trail->setParentItem(map);
|
trail->setParentItem(map);
|
||||||
trailLine=new QGraphicsItemGroup();
|
trailLine=new QGraphicsItemGroup(this);
|
||||||
trailLine->setParentItem(map);
|
trailLine->setParentItem(map);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
setCacheMode(QGraphicsItem::ItemCoordinateCache);
|
||||||
mapfollowtype=UAVMapFollowType::None;
|
mapfollowtype=UAVMapFollowType::None;
|
||||||
trailtype=UAVTrailType::ByDistance;
|
trailtype=UAVTrailType::ByDistance;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
generateArrowhead();
|
||||||
|
double pixels2meters = map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
||||||
|
meters2pixels=1.0 / pixels2meters;
|
||||||
|
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
connect(map,SIGNAL(zoomChanged(double,double,double)),this,SLOT(zoomChangedSlot()));
|
||||||
}
|
}
|
||||||
UAVItem::~UAVItem()
|
UAVItem::~UAVItem()
|
||||||
{
|
{
|
||||||
delete trail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
// painter->rotate(-90);
|
|
||||||
|
//Draw plane
|
||||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
|
||||||
|
//Return if UAV Info context menu is turned off
|
||||||
|
if(!showUAVInfo){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPen myPen;
|
||||||
|
|
||||||
|
//Turn on anti-aliasing so the fonts don't look terrible
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
|
//Set pen attributes
|
||||||
|
QColor myColor(Qt::red);
|
||||||
|
myPen.setWidth(3);
|
||||||
|
myPen.setColor(myColor);
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawPolygon(arrowHead);
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawLine(arrowShaft);
|
||||||
|
|
||||||
|
//Set trend arc's color
|
||||||
|
myPen.setColor(Qt::magenta);
|
||||||
|
painter->setPen(myPen);
|
||||||
|
|
||||||
|
if (trendSpanAngle > 0){
|
||||||
|
QRectF rect(0, -trendRadius, trendRadius*2, trendRadius*2);
|
||||||
|
painter->drawArc(rect, 180*16, -trendSpanAngle*16);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
QRectF rect(-2*trendRadius, -trendRadius, trendRadius*2, trendRadius*2);
|
||||||
|
painter->drawArc(rect, 0*16, -trendSpanAngle*16);
|
||||||
|
}
|
||||||
|
|
||||||
|
//*********** Create time rings
|
||||||
|
if(groundspeed_mps_filt > 0){ //Don't clutter the display with rings that are only one pixel wide
|
||||||
|
myPen.setWidth(2);
|
||||||
|
|
||||||
|
myPen.setColor(QColor(0, 0, 0, 100));
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawEllipse(QPointF(0,0),precalcRings,precalcRings);
|
||||||
|
|
||||||
|
myPen.setColor(QColor(0, 0, 0, 110));
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawEllipse(QPointF(0,0),precalcRings*2,precalcRings*2);
|
||||||
|
|
||||||
|
myPen.setColor(QColor(0, 0, 0, 120));
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawEllipse(QPointF(0,0),precalcRings*4,precalcRings*4);
|
||||||
|
}
|
||||||
|
//Rotate the text back to vertical
|
||||||
|
qreal rot=this->rotation();
|
||||||
|
painter->rotate(-1*rot);
|
||||||
|
|
||||||
|
myPen.setWidth(1);
|
||||||
|
myPen.setColor(Qt::white);
|
||||||
|
painter->setBrush(Qt::white);
|
||||||
|
painter->setPen(myPen);
|
||||||
|
painter->drawPath(textPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UAVItem::updateTextOverlay()
|
||||||
|
{
|
||||||
|
QPainterPath temp;
|
||||||
|
if(!showUAVInfo)
|
||||||
|
{
|
||||||
|
temp.swap(textPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont borderfont( "Arial", 14, QFont::Normal, false );
|
||||||
|
|
||||||
|
//Top left corner of text
|
||||||
|
int textAnchorX = 20;
|
||||||
|
int textAnchorY = 20;
|
||||||
|
|
||||||
|
QString uavoInfoStrLine1, uavoInfoStrLine2;
|
||||||
|
QString uavoInfoStrLine3, uavoInfoStrLine4;
|
||||||
|
QString uavoInfoStrLine5;
|
||||||
|
|
||||||
|
uavoInfoStrLine1.append(QString("CAS: %1 kph").arg(CAS_mps));
|
||||||
|
uavoInfoStrLine2.append(QString("Groundspeed: %1 kph").arg(groundspeed_kph, 0, 'f',1));
|
||||||
|
uavoInfoStrLine3.append(QString("Lat-Lon: %1, %2").arg(coord.Lat(), 0, 'f',7).arg(coord.Lng(), 0, 'f',7));
|
||||||
|
uavoInfoStrLine4.append(QString("North-East: %1 m, %2 m").arg(NED[0], 0, 'f',1).arg(NED[1], 0, 'f',1));
|
||||||
|
uavoInfoStrLine5.append(QString("Altitude: %1 m").arg(-NED[2], 0, 'f',1));
|
||||||
|
temp.addText(textAnchorX, textAnchorY+16*0, borderfont, uavoInfoStrLine1);
|
||||||
|
temp.addText(textAnchorX, textAnchorY+16*1, borderfont, uavoInfoStrLine2);
|
||||||
|
temp.addText(textAnchorX, textAnchorY+16*2, borderfont, uavoInfoStrLine3);
|
||||||
|
temp.addText(textAnchorX, textAnchorY+16*3, borderfont, uavoInfoStrLine4);
|
||||||
|
temp.addText(textAnchorX, textAnchorY+16*4, borderfont, uavoInfoStrLine5);
|
||||||
|
|
||||||
|
//Add text for time rings.
|
||||||
|
if(groundspeed_mps > 0){
|
||||||
|
//Always add the left side...
|
||||||
|
temp.addText(-(groundspeed_mps_filt*ringTime*1*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||||
|
temp.addText(-(groundspeed_mps_filt*ringTime*2*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||||
|
temp.addText(-(groundspeed_mps_filt*ringTime*4*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||||
|
//... and add the right side, only if it doesn't interfere with the uav info text
|
||||||
|
if(groundspeed_mps_filt*ringTime*4*meters2pixels > 200){
|
||||||
|
if(groundspeed_mps_filt*ringTime*2*meters2pixels > 200){
|
||||||
|
if(groundspeed_mps_filt*ringTime*1*meters2pixels > 200){
|
||||||
|
temp.addText(groundspeed_mps_filt*ringTime*1*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||||
|
}
|
||||||
|
temp.addText(groundspeed_mps_filt*ringTime*2*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||||
|
}
|
||||||
|
temp.addText(groundspeed_mps_filt*ringTime*4*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temp.swap(textPath);
|
||||||
|
}
|
||||||
|
|
||||||
QRectF UAVItem::boundingRect()const
|
QRectF UAVItem::boundingRect()const
|
||||||
{
|
{
|
||||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
if(showUAVInfo){
|
||||||
|
if (boundingRectSize < 220){
|
||||||
|
//In case the bounding rectangle isn't big enough to get the whole of the UAV Info graphic
|
||||||
|
return QRectF(-boundingRectSize,-80,boundingRectSize+220,180);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return QRectF(-boundingRectSize,-boundingRectSize,2*boundingRectSize,2*boundingRectSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UAVItem::SetNED(double NED[3]){
|
||||||
|
this->NED[0] = NED[0];
|
||||||
|
this->NED[1] = NED[1];
|
||||||
|
this->NED[2] = NED[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAVItem::SetYawRate(double yawRate_dps){
|
||||||
|
this->yawRate_dps=yawRate_dps;
|
||||||
|
|
||||||
|
if (fabs(this->yawRate_dps) < 5e-1){ //This number is really the smallest we can go. Any smaller, and it might have problems if we forecast a shorter distance into the future
|
||||||
|
this->yawRate_dps=5e-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*********** Create trend arc
|
||||||
|
trendSpanAngle = this->yawRate_dps * 5; //Forecast 5 seconds into the future
|
||||||
|
|
||||||
|
//Calculate radius in [m], and then convert to pixels in local frame (not the same frame as is displayed on the map widget)
|
||||||
|
trendRadius=fabs(groundspeed_mps/(this->yawRate_dps*M_PI/180))*meters2pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAVItem::SetCAS(double CAS_mps){
|
||||||
|
this->CAS_mps=CAS_mps;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAVItem::SetGroundspeed(double vNED[3], int m_maxUpdateRate_ms){
|
||||||
|
this->vNED[0] = vNED[0];
|
||||||
|
this->vNED[1] = vNED[1];
|
||||||
|
this->vNED[2] = vNED[2];
|
||||||
|
groundspeed_kph=sqrt(vNED[0]*vNED[0] + vNED[1]*vNED[1] + vNED[2]*vNED[2])*3.6;
|
||||||
|
groundspeed_mps=groundspeed_kph/3.6;
|
||||||
|
//On the first pass, set the filtered speed to the reported speed.
|
||||||
|
static bool firstGroundspeed=true;
|
||||||
|
if (firstGroundspeed){
|
||||||
|
groundspeed_mps_filt=groundspeed_kph/3.6;
|
||||||
|
firstGroundspeed=false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
int riseTime_ms=1000;
|
||||||
|
double alpha= m_maxUpdateRate_ms/(double)(m_maxUpdateRate_ms+riseTime_ms);
|
||||||
|
groundspeed_mps_filt= alpha*groundspeed_mps_filt + (1-alpha)*(groundspeed_kph/3.6);
|
||||||
|
}
|
||||||
|
ringTime=10*pow(2,17-map->ZoomTotal()); //Basic ring is 10 seconds wide at zoom level 17
|
||||||
|
precalcRings=groundspeed_mps_filt*ringTime*meters2pixels;
|
||||||
|
boundingRectSize=groundspeed_mps_filt*ringTime*4*meters2pixels+20;
|
||||||
|
prepareGeometryChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||||
{
|
{
|
||||||
if(coord.IsEmpty())
|
if(coord.IsEmpty())
|
||||||
@ -76,9 +256,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(timer.elapsed()>trailtime*1000)
|
if(timer.elapsed()>trailtime*1000)
|
||||||
{
|
{
|
||||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
TrailItem * ob=new TrailItem(position,altitude,Qt::green,map);
|
||||||
|
trail->addToGroup(ob);
|
||||||
|
connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT()));
|
||||||
if(!lasttrailline.IsEmpty())
|
if(!lasttrailline.IsEmpty())
|
||||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::red,map)));
|
{
|
||||||
|
TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map);
|
||||||
|
trailLine->addToGroup(obj);
|
||||||
|
connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot()));
|
||||||
|
}
|
||||||
lasttrailline=position;
|
lasttrailline=position;
|
||||||
timer.restart();
|
timer.restart();
|
||||||
}
|
}
|
||||||
@ -88,9 +274,15 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance)
|
||||||
{
|
{
|
||||||
trail->addToGroup(new TrailItem(position,altitude,Qt::red,this));
|
TrailItem * ob=new TrailItem(position,altitude,Qt::green,map);
|
||||||
|
trail->addToGroup(ob);
|
||||||
|
connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT()));
|
||||||
if(!lasttrailline.IsEmpty())
|
if(!lasttrailline.IsEmpty())
|
||||||
trailLine->addToGroup((new TrailLineItem(lasttrailline,position,Qt::red,map)));
|
{
|
||||||
|
TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map);
|
||||||
|
trailLine->addToGroup(obj);
|
||||||
|
connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot()));
|
||||||
|
}
|
||||||
lasttrailline=position;
|
lasttrailline=position;
|
||||||
lastcoord=position;
|
lastcoord=position;
|
||||||
}
|
}
|
||||||
@ -102,7 +294,6 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
mapwidget->SetCurrentPosition(coord);
|
mapwidget->SetCurrentPosition(coord);
|
||||||
}
|
}
|
||||||
this->update();
|
|
||||||
if(autosetreached)
|
if(autosetreached)
|
||||||
{
|
{
|
||||||
foreach(QGraphicsItem* i,map->childItems())
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
@ -170,19 +361,24 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
localposition=map->FromLatLngToLocal(coord);
|
localposition=map->FromLatLngToLocal(coord);
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
foreach(QGraphicsItem* i,trail->childItems())
|
emit setChildPosition();
|
||||||
{
|
emit setChildLine();
|
||||||
TrailItem* w=qgraphicsitem_cast<TrailItem*>(i);
|
updateTextOverlay();
|
||||||
if(w)
|
}
|
||||||
w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y());
|
|
||||||
}
|
|
||||||
foreach(QGraphicsItem* i,trailLine->childItems())
|
|
||||||
{
|
|
||||||
TrailLineItem* ww=qgraphicsitem_cast<TrailLineItem*>(i);
|
|
||||||
if(ww)
|
|
||||||
ww->setLine(map->FromLatLngToLocal(ww->coord1).X(),map->FromLatLngToLocal(ww->coord1).Y(),map->FromLatLngToLocal(ww->coord2).X(),map->FromLatLngToLocal(ww->coord2).Y());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void UAVItem::setOpacitySlot(qreal opacity)
|
||||||
|
{
|
||||||
|
this->setOpacity(opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAVItem::zoomChangedSlot()
|
||||||
|
{
|
||||||
|
double pixels2meters = map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
||||||
|
meters2pixels=1.0 / pixels2meters;
|
||||||
|
boundingRectSize=groundspeed_mps_filt*ringTime*4*meters2pixels+20;
|
||||||
|
prepareGeometryChange();
|
||||||
|
updateTextOverlay();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
|
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
|
||||||
{
|
{
|
||||||
@ -217,4 +413,40 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
pic.load(":/uavs/images/"+UAVPic);
|
pic.load(":/uavs/images/"+UAVPic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UAVItem::SetShowUAVInfo(bool const& value)
|
||||||
|
{
|
||||||
|
showUAVInfo=value;
|
||||||
|
showJustChanged=true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAVItem::generateArrowhead(){
|
||||||
|
qreal arrowSize = 10;
|
||||||
|
|
||||||
|
//Create line from (0,0), to (1,1). Later, we'll scale and rotate it
|
||||||
|
arrowShaft=QLineF(0,0,1.0,1.0);
|
||||||
|
|
||||||
|
//Set the starting point to (0,0)
|
||||||
|
arrowShaft.setP1(QPointF(0,0));
|
||||||
|
|
||||||
|
//Set angle and length
|
||||||
|
arrowShaft.setLength(60.0);
|
||||||
|
arrowShaft.setAngle(90.0);
|
||||||
|
|
||||||
|
//Form arrowhead
|
||||||
|
double angle = ::acos(arrowShaft.dx() / arrowShaft.length());
|
||||||
|
if (arrowShaft.dy() <= 0)
|
||||||
|
angle = (M_PI * 2) - angle;
|
||||||
|
|
||||||
|
QPointF arrowP1 = arrowShaft.pointAt(1) + QPointF(sin(angle + M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI / 3) * arrowSize);
|
||||||
|
QPointF arrowP2 = arrowShaft.pointAt(1) + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI - M_PI / 3) * arrowSize);
|
||||||
|
|
||||||
|
//Assemble arrowhead
|
||||||
|
arrowHead.clear();
|
||||||
|
arrowHead << arrowShaft.pointAt(1) << arrowP1 << arrowP2;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file uavitem.h
|
* @file uavitem.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -57,6 +57,31 @@ namespace mapcontrol
|
|||||||
enum { Type = UserType + 2 };
|
enum { Type = UserType + 2 };
|
||||||
UAVItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"));
|
UAVItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"));
|
||||||
~UAVItem();
|
~UAVItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the UAV NED position
|
||||||
|
*
|
||||||
|
* @param NED
|
||||||
|
*/
|
||||||
|
void SetNED(double NED[3]);
|
||||||
|
/**
|
||||||
|
* @brief Sets the UAV groundspeed
|
||||||
|
*
|
||||||
|
* @param NED
|
||||||
|
*/
|
||||||
|
void SetGroundspeed(double vNED[3], int m_maxUpdateRate);
|
||||||
|
/**
|
||||||
|
* @brief Sets the UAV Calibrated Airspeed
|
||||||
|
*
|
||||||
|
* @param NED
|
||||||
|
*/
|
||||||
|
void SetCAS(double CAS);
|
||||||
|
/**
|
||||||
|
* @brief Sets the UAV yaw rate
|
||||||
|
*
|
||||||
|
* @param NED
|
||||||
|
*/
|
||||||
|
void SetYawRate(double yawRate_dps);
|
||||||
/**
|
/**
|
||||||
* @brief Sets the UAV position
|
* @brief Sets the UAV position
|
||||||
*
|
*
|
||||||
@ -103,7 +128,6 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
void RefreshPos();
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
/**
|
/**
|
||||||
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
|
||||||
@ -193,17 +217,32 @@ namespace mapcontrol
|
|||||||
int type() const;
|
int type() const;
|
||||||
|
|
||||||
void SetUavPic(QString UAVPic);
|
void SetUavPic(QString UAVPic);
|
||||||
|
void SetShowUAVInfo(bool const& value);
|
||||||
|
void updateTextOverlay();
|
||||||
private:
|
private:
|
||||||
|
void generateArrowhead();
|
||||||
MapGraphicItem* map;
|
MapGraphicItem* map;
|
||||||
|
OPMapWidget* mapwidget;
|
||||||
|
QPolygonF arrowHead;
|
||||||
|
QLineF arrowShaft;
|
||||||
int altitude;
|
int altitude;
|
||||||
UAVMapFollowType::Types mapfollowtype;
|
UAVMapFollowType::Types mapfollowtype;
|
||||||
UAVTrailType::Types trailtype;
|
UAVTrailType::Types trailtype;
|
||||||
internals::PointLatLng coord;
|
internals::PointLatLng coord;
|
||||||
internals::PointLatLng lastcoord;
|
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;
|
QPixmap pic;
|
||||||
core::Point localposition;
|
core::Point localposition;
|
||||||
OPMapWidget* mapwidget;
|
|
||||||
QGraphicsItemGroup* trail;
|
QGraphicsItemGroup* trail;
|
||||||
QGraphicsItemGroup * trailLine;
|
QGraphicsItemGroup * trailLine;
|
||||||
internals::PointLatLng lasttrailline;
|
internals::PointLatLng lasttrailline;
|
||||||
@ -215,13 +254,24 @@ namespace mapcontrol
|
|||||||
bool autosetreached;
|
bool autosetreached;
|
||||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||||
double autosetdistance;
|
double autosetdistance;
|
||||||
// QRectF rect;
|
bool showUAVInfo;
|
||||||
|
static double groundspeed_mps_filt;
|
||||||
|
float boundingRectSize;
|
||||||
|
bool showJustChanged;
|
||||||
|
|
||||||
|
bool refreshPaint_flag;
|
||||||
|
|
||||||
|
QPainterPath textPath;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void RefreshPos();
|
||||||
|
void setOpacitySlot(qreal opacity);
|
||||||
|
void zoomChangedSlot();
|
||||||
signals:
|
signals:
|
||||||
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||||
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||||
|
void setChildPosition();
|
||||||
|
void setChildLine();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // UAVITEM_H
|
#endif // UAVITEM_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file uavmapfollowtype.h
|
* @file uavmapfollowtype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief An enum representing the various map follow modes
|
* @brief An enum representing the various map follow modes
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file uavtrailtype.h
|
* @file uavtrailtype.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief An enum representing the uav trailing modes
|
* @brief An enum representing the uav trailing modes
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file waypointcircle.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @brief A graphicsItem representing a circle connecting 2 waypoints
|
||||||
|
* @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 "waypointcircle.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "homeitem.h"
|
||||||
|
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius,bool clockwise, MapGraphicItem *map,QColor color):my_center(center),
|
||||||
|
my_radius(radius),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||||
|
{
|
||||||
|
connect(center,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations()));
|
||||||
|
connect(radius,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations()));
|
||||||
|
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||||
|
connect(radius,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||||
|
refreshLocations();
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointCircle::WayPointCircle(HomeItem *radius, WayPointItem *center, bool clockwise, MapGraphicItem *map, QColor color):my_center(center),
|
||||||
|
my_radius(radius),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||||
|
{
|
||||||
|
connect(radius,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(refreshLocations()));
|
||||||
|
connect(center,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||||
|
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||||
|
refreshLocations();
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int WayPointCircle::type() const
|
||||||
|
{
|
||||||
|
// Enable the use of qgraphicsitem_cast with this item.
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
QPointF p1;
|
||||||
|
QPointF p2;
|
||||||
|
p1=QPointF(line.p1().x(),line.p1().y()+line.length());
|
||||||
|
p2=QPointF(line.p1().x(),line.p1().y()-line.length());
|
||||||
|
QPen myPen = pen();
|
||||||
|
myPen.setColor(myColor);
|
||||||
|
qreal arrowSize = 10;
|
||||||
|
painter->setPen(myPen);
|
||||||
|
QBrush brush=painter->brush();
|
||||||
|
painter->setBrush(myColor);
|
||||||
|
double angle =0;
|
||||||
|
if(!myClockWise)
|
||||||
|
angle+=M_PI;
|
||||||
|
|
||||||
|
QPointF arrowP1 = p1 + QPointF(sin(angle + M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI / 3) * arrowSize);
|
||||||
|
QPointF arrowP2 = p1 + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI - M_PI / 3) * arrowSize);
|
||||||
|
|
||||||
|
QPointF arrowP21 = p2 + QPointF(sin(angle + M_PI + M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI + M_PI / 3) * arrowSize);
|
||||||
|
QPointF arrowP22 = p2 + QPointF(sin(angle + M_PI + M_PI - M_PI / 3) * arrowSize,
|
||||||
|
cos(angle + M_PI + M_PI - M_PI / 3) * arrowSize);
|
||||||
|
|
||||||
|
arrowHead.clear();
|
||||||
|
arrowHead << p1 << arrowP1 << arrowP2;
|
||||||
|
painter->drawPolygon(arrowHead);
|
||||||
|
arrowHead.clear();
|
||||||
|
arrowHead << p2 << arrowP21 << arrowP22;
|
||||||
|
painter->drawPolygon(arrowHead);
|
||||||
|
painter->translate(-line.length(),-line.length());
|
||||||
|
painter->setBrush(brush);
|
||||||
|
painter->drawEllipse(this->rect());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointCircle::refreshLocations()
|
||||||
|
{
|
||||||
|
line=QLineF(my_center->pos(),my_radius->pos());
|
||||||
|
this->setRect(my_center->pos().x(),my_center->pos().y(),2*line.length(),2*line.length());
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointCircle::waypointdeleted()
|
||||||
|
{
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointCircle::setOpacitySlot(qreal opacity)
|
||||||
|
{
|
||||||
|
setOpacity(opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file waypointcircle.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @brief A graphicsItem representing a circle connecting 2 waypoints
|
||||||
|
* @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 WAYPOINTCIRCLE_H
|
||||||
|
#define WAYPOINTCIRCLE_H
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QLabel>
|
||||||
|
#include "../internals/pointlatlng.h"
|
||||||
|
#include "mapgraphicitem.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
|
||||||
|
class WayPointCircle:public QObject,public QGraphicsEllipseItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(QGraphicsItem)
|
||||||
|
public:
|
||||||
|
enum { Type = UserType + 9 };
|
||||||
|
WayPointCircle(WayPointItem * center, WayPointItem * radius,bool clockwise,MapGraphicItem * map,QColor color=Qt::green);
|
||||||
|
WayPointCircle(HomeItem * center, WayPointItem * radius,bool clockwise,MapGraphicItem * map,QColor color=Qt::green);
|
||||||
|
int type() const;
|
||||||
|
void setColor(const QColor &color)
|
||||||
|
{ myColor = color; }
|
||||||
|
private:
|
||||||
|
QGraphicsItem * my_center;
|
||||||
|
QGraphicsItem * my_radius;
|
||||||
|
MapGraphicItem * my_map;
|
||||||
|
QPolygonF arrowHead;
|
||||||
|
QColor myColor;
|
||||||
|
bool myClockWise;
|
||||||
|
QLineF line;
|
||||||
|
protected:
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
public slots:
|
||||||
|
void refreshLocations();
|
||||||
|
void waypointdeleted();
|
||||||
|
void setOpacitySlot(qreal opacity);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WAYPOINTCIRCLE_H
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file waypointitem.cpp
|
* @file waypointitem.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @brief A graphicsItem representing a WayPoint
|
* @brief A graphicsItem representing a WayPoint
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup OPMapWidget
|
* @defgroup OPMapWidget
|
||||||
@ -25,39 +25,167 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
#include "homeitem.h"
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, MapGraphicItem *map):coord(coord),reached(false),description(""),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, MapGraphicItem *map,wptype type):coord(coord),reached(false),description(""),shownumber(true),isDragging(false),altitude(altitude),map(map),myType(type)
|
||||||
{
|
{
|
||||||
text=0;
|
text=0;
|
||||||
numberI=0;
|
numberI=0;
|
||||||
|
isMagic=false;
|
||||||
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
number=WayPointItem::snumber;
|
number=WayPointItem::snumber;
|
||||||
++WayPointItem::snumber;
|
++WayPointItem::snumber;
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
// transf.translate(picture.width()/2,picture.height());
|
|
||||||
// this->setTransform(transf);
|
|
||||||
SetShowNumber(shownumber);
|
SetShowNumber(shownumber);
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
|
myHome=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
myHome=h;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
relativeCoord.altitudeRelative=Altitude()-myHome->Altitude();
|
||||||
|
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||||
|
}
|
||||||
|
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||||
|
emit manualCoordChange(this);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(false),description(""),shownumber(true),isDragging(false),altitude(0),map(map)
|
||||||
|
{
|
||||||
|
relativeCoord.bearing=0;
|
||||||
|
relativeCoord.distance=0;
|
||||||
|
relativeCoord.altitudeRelative=0;
|
||||||
|
myType=relative;
|
||||||
|
if(magicwaypoint)
|
||||||
|
{
|
||||||
|
isMagic=true;
|
||||||
|
picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
|
||||||
|
number=-1;
|
||||||
}
|
}
|
||||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map):coord(coord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
else
|
||||||
|
{
|
||||||
|
isMagic=false;
|
||||||
|
number=WayPointItem::snumber;
|
||||||
|
++WayPointItem::snumber;
|
||||||
|
}
|
||||||
|
text=0;
|
||||||
|
numberI=0;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
|
SetShowNumber(shownumber);
|
||||||
|
RefreshToolTip();
|
||||||
|
RefreshPos();
|
||||||
|
myHome=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
myHome=h;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
coord=map->Projection()->translate(myHome->Coord(),relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
SetAltitude(myHome->Altitude()+relativeCoord.altitudeRelative);
|
||||||
|
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||||
|
}
|
||||||
|
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||||
|
emit manualCoordChange(this);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
}
|
||||||
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map,wptype type):coord(coord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map),myType(type)
|
||||||
{
|
{
|
||||||
text=0;
|
text=0;
|
||||||
numberI=0;
|
numberI=0;
|
||||||
|
isMagic=false;
|
||||||
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
number=WayPointItem::snumber;
|
number=WayPointItem::snumber;
|
||||||
++WayPointItem::snumber;
|
++WayPointItem::snumber;
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
//transf.translate(picture.width()/2,picture.height());
|
|
||||||
// this->setTransform(transf);
|
|
||||||
SetShowNumber(shownumber);
|
SetShowNumber(shownumber);
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
|
myHome=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
myHome=h;
|
||||||
|
}
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
relativeCoord.altitudeRelative=Altitude()-myHome->Altitude();
|
||||||
|
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||||
|
}
|
||||||
|
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||||
|
emit manualCoordChange(this);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const QString &description, MapGraphicItem *map):relativeCoord(relativeCoordenate),reached(false),description(description),shownumber(true),isDragging(false),map(map)
|
||||||
|
{
|
||||||
|
myHome=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
myHome=h;
|
||||||
|
}
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||||
|
coord=map->Projection()->translate(myHome->Coord(),relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
SetAltitude(myHome->Altitude()+relativeCoord.altitudeRelative);
|
||||||
|
}
|
||||||
|
myType=relative;
|
||||||
|
text=0;
|
||||||
|
numberI=0;
|
||||||
|
isMagic=false;
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
number=WayPointItem::snumber;
|
||||||
|
++WayPointItem::snumber;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
|
SetShowNumber(shownumber);
|
||||||
|
RefreshToolTip();
|
||||||
|
RefreshPos();
|
||||||
|
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||||
|
emit manualCoordChange(this);
|
||||||
|
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
|
||||||
|
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointItem::setWPType(wptype type)
|
||||||
|
{
|
||||||
|
myType=type;
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
RefreshPos();
|
||||||
|
RefreshToolTip();
|
||||||
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF WayPointItem::boundingRect() const
|
QRectF WayPointItem::boundingRect() const
|
||||||
@ -69,40 +197,55 @@ namespace mapcontrol
|
|||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
painter->drawPixmap(-picture.width()/2,-picture.height(),picture);
|
painter->drawPixmap(-picture.width()/2,-picture.height(),picture);
|
||||||
|
painter->setPen(Qt::green);
|
||||||
if(this->isSelected())
|
if(this->isSelected())
|
||||||
painter->drawRect(QRectF(-picture.width()/2,-picture.height(),picture.width()-1,picture.height()-1));
|
painter->drawRect(QRectF(-picture.width()/2,-picture.height(),picture.width()-1,picture.height()-1));
|
||||||
}
|
}
|
||||||
|
void WayPointItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
emit waypointdoubleclick(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button()==Qt::LeftButton)
|
if(event->button()==Qt::LeftButton)
|
||||||
{
|
{
|
||||||
text=new QGraphicsSimpleTextItem(this);
|
text=new QGraphicsSimpleTextItem(this);
|
||||||
textBG=new QGraphicsRectItem(this);
|
textBG=new QGraphicsRectItem(this);
|
||||||
|
|
||||||
// textBG->setBrush(Qt::white);
|
textBG->setBrush(Qt::yellow);
|
||||||
// textBG->setOpacity(0.5);
|
|
||||||
|
|
||||||
textBG->setBrush(QColor(255, 255, 255, 128));
|
text->setPen(QPen(Qt::red));
|
||||||
|
text->setPos(10,-picture.height());
|
||||||
text->setPen(QPen(Qt::red));
|
textBG->setPos(10,-picture.height());
|
||||||
text->setPos(10,-picture.height());
|
text->setZValue(3);
|
||||||
textBG->setPos(10,-picture.height());
|
RefreshToolTip();
|
||||||
text->setZValue(3);
|
isDragging=true;
|
||||||
RefreshToolTip();
|
}
|
||||||
isDragging=true;
|
|
||||||
}
|
|
||||||
QGraphicsItem::mousePressEvent(event);
|
QGraphicsItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button()==Qt::LeftButton)
|
if(event->button()==Qt::LeftButton)
|
||||||
{
|
{
|
||||||
delete text;
|
if(text)
|
||||||
delete textBG;
|
{
|
||||||
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
delete text;
|
||||||
|
text=NULL;
|
||||||
|
}
|
||||||
|
if(textBG)
|
||||||
|
{
|
||||||
|
delete textBG;
|
||||||
|
textBG=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
isDragging=false;
|
isDragging=false;
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
|
emit manualCoordChange(this);
|
||||||
|
emit localPositionChanged(this->pos(),this);
|
||||||
emit WPValuesChanged(this);
|
emit WPValuesChanged(this);
|
||||||
}
|
}
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
@ -114,31 +257,77 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
||||||
text->setText(coord_str);
|
if(myHome)
|
||||||
|
{
|
||||||
|
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
}
|
||||||
|
QString relativeCoord_str = QString::number(relativeCoord.distance) + "m " + QString::number(relativeCoord.bearing*180/M_PI)+"deg";
|
||||||
|
text->setText(coord_str+"\n"+relativeCoord_str);
|
||||||
textBG->setRect(text->boundingRect());
|
textBG->setRect(text->boundingRect());
|
||||||
|
emit localPositionChanged(this->pos(),this);
|
||||||
emit WPValuesChanged(this);
|
emit WPValuesChanged(this);
|
||||||
}
|
}
|
||||||
QGraphicsItem::mouseMoveEvent(event);
|
QGraphicsItem::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
void WayPointItem::SetAltitude(const int &value)
|
void WayPointItem::SetAltitude(const float &value)
|
||||||
{
|
{
|
||||||
|
if(altitude==value)
|
||||||
|
return;
|
||||||
altitude=value;
|
altitude=value;
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
relativeCoord.altitudeRelative=altitude-myHome->Altitude();
|
||||||
|
}
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
|
|
||||||
emit WPValuesChanged(this);
|
emit WPValuesChanged(this);
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WayPointItem::setRelativeCoord(distBearingAltitude value)
|
||||||
|
{
|
||||||
|
if(qAbs(value.distance-relativeCoord.distance)<0.1
|
||||||
|
&& qAbs(value.bearing-relativeCoord.bearing)<0.01 && value.altitudeRelative==relativeCoord.altitudeRelative)
|
||||||
|
return;
|
||||||
|
relativeCoord=value;
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
SetCoord(map->Projection()->translate(myHome->Coord(),relativeCoord.distance,relativeCoord.bearing));
|
||||||
|
SetAltitude(myHome->Altitude()+relativeCoord.altitudeRelative);
|
||||||
|
}
|
||||||
|
RefreshPos();
|
||||||
|
RefreshToolTip();
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
|
||||||
void WayPointItem::SetCoord(const internals::PointLatLng &value)
|
void WayPointItem::SetCoord(const internals::PointLatLng &value)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"1 SetCoord("<<value.Lat()<<","<<value.Lng()<<")"<<"OLD:"<<Coord().Lat()<<","<<Coord().Lng();
|
||||||
|
if(qAbs(Coord().Lat()-value.Lat())<0.0001 && qAbs(Coord().Lng()-value.Lng())<0.0001)
|
||||||
|
{
|
||||||
|
qDebug()<<"2 SetCoord nothing changed returning";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug()<<"3 setCoord there were changes";
|
||||||
coord=value;
|
coord=value;
|
||||||
|
distBearingAltitude back=relativeCoord;
|
||||||
|
if(myHome)
|
||||||
|
map->Projection()->offSetFromLatLngs(myHome->Coord(),Coord(),back.distance,back.bearing);
|
||||||
|
if(qAbs(back.bearing-relativeCoord.bearing)>0.01 || qAbs(back.distance-relativeCoord.distance)>0.1)
|
||||||
|
{
|
||||||
|
qDebug()<<"4 setCoord-relative coordinates where also updated";
|
||||||
|
relativeCoord=back;
|
||||||
|
}
|
||||||
emit WPValuesChanged(this);
|
emit WPValuesChanged(this);
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
this->update();
|
this->update();
|
||||||
|
qDebug()<<"5 setCoord EXIT";
|
||||||
}
|
}
|
||||||
void WayPointItem::SetDescription(const QString &value)
|
void WayPointItem::SetDescription(const QString &value)
|
||||||
{
|
{
|
||||||
|
if(description==value)
|
||||||
|
return;
|
||||||
description=value;
|
description=value;
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
emit WPValuesChanged(this);
|
emit WPValuesChanged(this);
|
||||||
@ -146,12 +335,13 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
void WayPointItem::SetNumber(const int &value)
|
void WayPointItem::SetNumber(const int &value)
|
||||||
{
|
{
|
||||||
emit WPNumberChanged(number,value,this);
|
int oldnumber=number;
|
||||||
number=value;
|
number=value;
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
numberI->setText(QString::number(number));
|
numberI->setText(QString::number(numberAdjusted()));
|
||||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||||
this->update();
|
this->update();
|
||||||
|
emit WPNumberChanged(oldnumber,value,this);
|
||||||
}
|
}
|
||||||
void WayPointItem::SetReached(const bool &value)
|
void WayPointItem::SetReached(const bool &value)
|
||||||
{
|
{
|
||||||
@ -160,8 +350,20 @@ namespace mapcontrol
|
|||||||
if(value)
|
if(value)
|
||||||
picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
|
picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
|
||||||
else
|
else
|
||||||
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
{
|
||||||
this->update();
|
if(!isMagic)
|
||||||
|
{
|
||||||
|
if(this->flags() & QGraphicsItem::ItemIsMovable==QGraphicsItem::ItemIsMovable)
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
else
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->update();
|
||||||
|
|
||||||
}
|
}
|
||||||
void WayPointItem::SetShowNumber(const bool &value)
|
void WayPointItem::SetShowNumber(const bool &value)
|
||||||
@ -177,7 +379,7 @@ namespace mapcontrol
|
|||||||
numberI->setPen(QPen(Qt::blue));
|
numberI->setPen(QPen(Qt::blue));
|
||||||
numberI->setPos(0,-13-picture.height());
|
numberI->setPos(0,-13-picture.height());
|
||||||
numberIBG->setPos(0,-13-picture.height());
|
numberIBG->setPos(0,-13-picture.height());
|
||||||
numberI->setText(QString::number(number));
|
numberI->setText(QString::number(numberAdjusted()));
|
||||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
||||||
}
|
}
|
||||||
else if (!value && numberI)
|
else if (!value && numberI)
|
||||||
@ -187,49 +389,61 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
void WayPointItem::WPDeleted(const int &onumber)
|
void WayPointItem::WPDeleted(const int &onumber,WayPointItem *waypoint)
|
||||||
{
|
{
|
||||||
if(number>onumber) --number;
|
Q_UNUSED(waypoint);
|
||||||
numberI->setText(QString::number(number));
|
int n=number;
|
||||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
if(number>onumber) SetNumber(--n);
|
||||||
RefreshToolTip();
|
|
||||||
this->update();
|
|
||||||
}
|
}
|
||||||
void WayPointItem::WPInserted(const int &onumber, WayPointItem *waypoint)
|
void WayPointItem::WPInserted(const int &onumber, WayPointItem *waypoint)
|
||||||
{
|
{
|
||||||
|
if(Number()==-1)
|
||||||
|
return;
|
||||||
|
|
||||||
if(waypoint!=this)
|
if(waypoint!=this)
|
||||||
{
|
{
|
||||||
if(onumber<=number) ++number;
|
if(onumber<=number) SetNumber(++number);
|
||||||
numberI->setText(QString::number(number));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointItem::onHomePositionChanged(internals::PointLatLng homepos, float homeAltitude)
|
||||||
|
{
|
||||||
|
if(myType==relative)
|
||||||
|
{
|
||||||
|
coord=map->Projection()->translate(homepos,relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
SetAltitude(relativeCoord.altitudeRelative+homeAltitude);
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
RefreshPos();
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(myHome)
|
||||||
|
{
|
||||||
|
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||||
|
relativeCoord.altitudeRelative=Altitude()-homeAltitude;
|
||||||
|
}
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayPointItem *waypoint)
|
void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayPointItem *waypoint)
|
||||||
{
|
{
|
||||||
if (waypoint!=this)
|
if (waypoint!=this)
|
||||||
{
|
{
|
||||||
if(((oldnumber>number) && (newnumber<=number)))
|
if(((oldnumber>number) && (newnumber<=number)))
|
||||||
{
|
{
|
||||||
++number;
|
SetNumber(++number);
|
||||||
numberI->setText(QString::number(number));
|
|
||||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
|
||||||
RefreshToolTip();
|
|
||||||
}
|
}
|
||||||
else if (((oldnumber<number) && (newnumber>number)))
|
else if (((oldnumber<number) && (newnumber>number)))
|
||||||
{
|
{
|
||||||
--number;
|
SetNumber(--number);
|
||||||
numberI->setText(QString::number(number));
|
|
||||||
numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0));
|
|
||||||
RefreshToolTip();
|
|
||||||
}
|
}
|
||||||
else if (newnumber==number)
|
else if (newnumber==number)
|
||||||
{
|
{
|
||||||
++number;
|
SetNumber(++number);
|
||||||
numberI->setText(QString::number(number));
|
|
||||||
RefreshToolTip();
|
|
||||||
}
|
}
|
||||||
this->update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int WayPointItem::type() const
|
int WayPointItem::type() const
|
||||||
@ -240,17 +454,51 @@ namespace mapcontrol
|
|||||||
|
|
||||||
WayPointItem::~WayPointItem()
|
WayPointItem::~WayPointItem()
|
||||||
{
|
{
|
||||||
|
emit aboutToBeDeleted(this);
|
||||||
--WayPointItem::snumber;
|
--WayPointItem::snumber;
|
||||||
}
|
}
|
||||||
void WayPointItem::RefreshPos()
|
void WayPointItem::RefreshPos()
|
||||||
{
|
{
|
||||||
core::Point point=map->FromLatLngToLocal(coord);
|
core::Point point=map->FromLatLngToLocal(coord);
|
||||||
this->setPos(point.X(),point.Y());
|
this->setPos(point.X(),point.Y());
|
||||||
|
emit localPositionChanged(this->pos(),this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointItem::setOpacitySlot(qreal opacity)
|
||||||
|
{
|
||||||
|
setOpacity(opacity);
|
||||||
}
|
}
|
||||||
void WayPointItem::RefreshToolTip()
|
void WayPointItem::RefreshToolTip()
|
||||||
{
|
{
|
||||||
|
QString type_str;
|
||||||
|
if(myType==relative)
|
||||||
|
type_str="Relative";
|
||||||
|
else
|
||||||
|
type_str="Absolute";
|
||||||
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
||||||
setToolTip(QString("WayPoint Number:%1\nDescription:%2\nCoordinate:%4\nAltitude:%5").arg(QString::number(WayPointItem::number)).arg(description).arg(coord_str).arg(QString::number(altitude)));
|
QString relativeCoord_str = " Distance:" + QString::number(relativeCoord.distance) + " Bearing:" + QString::number(relativeCoord.bearing*180/M_PI);
|
||||||
|
QString relativeAltitude_str=QString::number(relativeCoord.altitudeRelative);
|
||||||
|
if(Number()!=-1)
|
||||||
|
setToolTip(QString("WayPoint Number:%1\nDescription:%2\nCoordinate:%4\nFrom Home:%5\nRelative altitude:%6\nAltitude:%7\nType:%8\n%9").arg(QString::number(numberAdjusted())).arg(description).arg(coord_str).arg(relativeCoord_str).arg(relativeAltitude_str).arg(QString::number(altitude)).arg(type_str).arg(myCustomString));
|
||||||
|
else
|
||||||
|
setToolTip(QString("Magic WayPoint\nCoordinate:%1\nFrom Home:%2\nAltitude:%3\nType:%4\n%5").arg(coord_str).arg(relativeCoord_str).arg(QString::number(altitude)).arg(type_str).arg(myCustomString));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WayPointItem::setFlag(QGraphicsItem::GraphicsItemFlag flag, bool enabled)
|
||||||
|
{
|
||||||
|
if(isMagic)
|
||||||
|
{
|
||||||
|
QGraphicsItem::setFlag(flag,enabled);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(flag==QGraphicsItem::ItemIsMovable)
|
||||||
|
{
|
||||||
|
if(enabled)
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
else
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png"));
|
||||||
|
}
|
||||||
|
QGraphicsItem::setFlag(flag,enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WayPointItem::snumber=0;
|
int WayPointItem::snumber=0;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user