diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.h b/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.h index 4add132fd..aae8fd5ff 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.h @@ -1 +1,20 @@ +#ifndef OPMAP_CONTROL_H_ +#define OPMAP_CONTROL_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 diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/accessmode.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/accessmode.h index d152936f2..f81efa710 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/accessmode.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/accessmode.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp index 4a6e87a88..e1b956f9c 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.h index 94f7442b5..3f351e83d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.cpp index eb910b56a..e4059af55 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.h index 3162de00d..8811d4ae7 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cache.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.cpp index e926ebf6b..1d7d2b1cd 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.h index 45cf8beb5..89676624b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/cacheitemqueue.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.cpp index 33bbbcc58..eb345a2c8 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.h index 113faef19..07269b5fa 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/diagnostics.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/geodecoderstatus.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/geodecoderstatus.h index 58b653dee..53e4b0c70 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/geodecoderstatus.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/geodecoderstatus.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.cpp index 37c45f83f..af5ae472d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.h index f856dee8b..d117d0361 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/kibertilecache.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.cpp index 2c4ee2a7c..432719c71 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.h index 4b8411e45..577a0a81a 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/languagetype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h index 741832abc..16ac1a8e1 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.cpp index 94df6d0bc..88f7e3a6b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.h index 88a7e6ec6..237bd3a7e 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/memorycache.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp index b2db6747d..86660fd3e 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.h index f94f3fa06..81b7daf2c 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.cpp index 1f8971aae..8bee1b057 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.h index 3f338b3f5..3606d9991 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/placemark.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.cpp index a8f43ed0e..145c1b225 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.h index 83d1f079e..5e46ca926 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/point.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp index 8d1f63e30..5fda6ac71 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h index 8759057b4..504453fd0 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.cpp index e938db04d..fe4dabcab 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.h index 76e1b552f..44e51594b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimage.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.cpp index be38fcbfa..eb16755ea 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.h index 7d8942b31..d92d58090 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/pureimagecache.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.cpp index f357ae50f..12d58e43d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.h index 7b3901f6f..1493b2bb5 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/rawtile.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.cpp index 65a26fac2..7709de7ee 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.h index da340b9a6..0a0a5a7dc 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/size.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.cpp index 166e66a29..9843f2f45 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.h index a0bf2b7e0..f53873f3b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/tilecachequeue.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index ca250228b..2ebdeffc5 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h index 2f4bfbeb1..a40947cc2 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp index d36691145..3d67f27ec 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/copyrightstrings.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/copyrightstrings.h index 6115297d6..edea169c1 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/copyrightstrings.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/copyrightstrings.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -31,11 +31,11 @@ #include namespace internals { -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 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 arcGisCopyright = QString("©%1 ESRI - Map data ©%1 ArcGIS").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 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 arcGisCopyright = QString("%1 ESRI - Map data %1 ArcGIS").arg(QDate::currentDate().year()); } #endif // COPYRIGHTSTRINGS_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp index 8a3fafc05..b484f2537 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -251,6 +251,7 @@ namespace internals { Matrix.Clear(); GoToCurrentPositionOnZoom(); UpdateBounds(); + keepInBounds(); emit OnMapDrag(); emit OnMapZoomChanged(); emit OnNeedInvalidation(); @@ -572,7 +573,7 @@ namespace internals { { renderOffset.SetX(pt.X() - dragPoint.X()); renderOffset.SetY(pt.Y() - dragPoint.Y()); - + keepInBounds(); UpdateCenterTileXYLocation(); if(centerTileXYLocation != centerTileXYLocationLast) @@ -692,4 +693,18 @@ namespace internals { pxRes1000km = (int) (1000000.0 / rez); // 1000km 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); + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h index 73c652de5..dca51d646 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -193,6 +193,7 @@ namespace internals { bool isStarted(){return started;} diagnostics GetDiagnostics(); + signals: void OnCurrentPositionChanged(internals::PointLatLng point); void OnTileLoadComplete(); @@ -206,7 +207,7 @@ namespace internals { private: - + void keepInBounds(); PointLatLng currentPosition; core::Point currentPositionPixel; core::Point renderOffset; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.cpp index 0deb23025..00e373cfb 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.h index df38337b0..662420d6e 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/loadtask.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h index 218815c36..59938129d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.cpp index 850401582..7869a723a 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.h index 190cabec9..2c30cf6ff 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pointlatlng.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp index f476ba2f1..82a59ab23 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -614,6 +614,9 @@ double LKS94Projection::GetTileMatrixResolution(int const& zoom) return ret; } +/* + * Returns the conversion from pixels to meters + */ double LKS94Projection::GetGroundResolution(int const& zoom, double const& latitude) { Q_UNUSED(zoom); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h index 4eee20aaa..66581c694 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp index 30b94d2e4..cd5bbb95b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h index 1c55f5638..25e52df1b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp index 0a695308d..54812e60c 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h index 949f83f1f..af9cc620e 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp index be3989d92..18688ca06 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h index c57285a2f..61454f00d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp index c9ad01d1f..106674ad2 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h index f0ca29fdf..cf52aa036 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.cpp index 432defd06..b817ff25e 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -103,6 +103,9 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom) return ret; } + /* + * Returns the conversion from pixels to meters + */ double PureProjection::GetGroundResolution(const int &zoom,const double &latitude) { 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); 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 R = 6371; // km @@ -229,4 +244,34 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom) double d = R * c; 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; + } + } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.h index 4ab806a62..5402d13e6 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/pureprojection.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -33,7 +33,7 @@ #include "pointlatlng.h" #include "cmath" #include "rectlatlng.h" - +#include using namespace core; namespace internals @@ -81,6 +81,9 @@ public: void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng); 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: static const double PI; @@ -103,7 +106,8 @@ protected: 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 qlonglong GetUTMzone(const double &lon); - +private: + double myfmod(double x, double y); }; } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.cpp index f513b2271..ac31898af 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.h index 78919c1af..0cc20d1ee 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectangle.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.cpp index 2d9877262..4cc98f5e3 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.h index bbc86bac1..8a54cc84b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/rectlatlng.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.cpp index 9222c3704..e22527429 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.h index 4ee5388cc..c22249314 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/sizelatlng.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.cpp index 5d8289e71..b70887d7d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.h index 6b1ae2023..5055ca6c6 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tile.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.cpp index 658d3be95..9def2e176 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.h index 0f431567d..dd56e0987 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/tilematrix.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.cpp index 2dd1b95b4..d32b8dcb2 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.h index 46dd0d03c..cadb045ca 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/configuration.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.cpp index aeb9055c3..07d75da2a 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -37,27 +37,27 @@ namespace mapcontrol localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition()); this->setPos(localposition.X(),localposition.Y()); this->setZValue(4); - trail=new QGraphicsItemGroup(); + trail=new QGraphicsItemGroup(this); trail->setParentItem(map); - trailLine=new QGraphicsItemGroup(); + trailLine=new QGraphicsItemGroup(this); trailLine->setParentItem(map); this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true); mapfollowtype=UAVMapFollowType::None; trailtype=UAVTrailType::ByDistance; timer.start(); + connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos())); + connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal))); } GPSItem::~GPSItem() { - delete trail; + } void GPSItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); - // painter->rotate(-90); painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic); - // painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1)); } QRectF GPSItem::boundingRect()const { @@ -74,9 +74,15 @@ namespace mapcontrol { 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()) - 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; timer.restart(); } @@ -86,10 +92,15 @@ namespace mapcontrol { 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()) - - 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; lastcoord=position; } @@ -97,48 +108,6 @@ namespace mapcontrol coord=position; this->altitude=altitude; RefreshPos(); - /*if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap||mapfollowtype==UAVMapFollowType::CenterMap) - { - mapwidget->SetCurrentPosition(coord); - }*/ - this->update(); - /*if(autosetreached) - { - foreach(QGraphicsItem* i,map->childItems()) - { - WayPointItem* wp=qgraphicsitem_cast(i); - if(wp) - { - if(Distance3D(wp->Coord(),wp->Altitude())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); this->setPos(localposition.X(),localposition.Y()); - foreach(QGraphicsItem* i,trail->childItems()) - { - TrailItem* w=qgraphicsitem_cast(i); - if(w) - w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y()); - } - foreach(QGraphicsItem* i,trailLine->childItems()) - { - TrailLineItem* ww=qgraphicsitem_cast(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()); - } + emit setChildPosition(); + emit setChildLine(); } + + void GPSItem::setOpacitySlot(qreal opacity) + { + setOpacity(opacity); + } void GPSItem::SetTrailType(const UAVTrailType::Types &value) { trailtype=value; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.h index 64931ea7f..c78c734aa 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/gpsitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -103,7 +103,6 @@ namespace mapcontrol void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void RefreshPos(); QRectF boundingRect() const; /** * @brief Sets the trail time to be used if TrailType is ByTimeElapsed @@ -218,10 +217,13 @@ namespace mapcontrol // QRectF rect; public slots: - + void RefreshPos(); + void setOpacitySlot(qreal opacity); signals: void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint); void UAVLeftSafetyBouble(internals::PointLatLng const& position); + void setChildPosition(); + void setChildLine(); }; } #endif // GPSITEM_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp index 815aa86f3..6dad1e034 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -27,17 +27,32 @@ #include "homeitem.h" 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=pic.scaled(30,30,Qt::IgnoreAspectRatio); this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true); + this->setFlag(QGraphicsItem::ItemIsMovable,false); + this->setFlag(QGraphicsItem::ItemIsSelectable,false); localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition()); this->setPos(localposition.X(),localposition.Y()); this->setZValue(4); 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) { Q_UNUSED(option); @@ -56,7 +71,7 @@ namespace mapcontrol } QRectF HomeItem::boundingRect()const { - if(!showsafearea) + if(pic.width()>localsafearea*2 && !toggleRefresh) return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height()); else return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2); @@ -67,6 +82,7 @@ namespace mapcontrol { return Type; } + void HomeItem::RefreshPos() { prepareGeometryChange(); @@ -75,6 +91,56 @@ namespace mapcontrol if(showsafearea) 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); + } } + diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.h index 3c03396ee..4830f9b52 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/homeitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -47,31 +47,41 @@ namespace mapcontrol QWidget *widget); QRectF boundingRect() const; int type() const; - void RefreshPos(); bool ShowSafeArea()const{return showsafearea;} void SetShowSafeArea(bool const& value){showsafearea=value;} + void SetToggleRefresh(bool const& value){toggleRefresh=value;} int SafeArea()const{return safearea;} void SetSafeArea(int const& value){safearea=value;} 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;} - void SetAltitude(int const& value){altitude=value;} - int Altitude()const{return altitude;} + void SetAltitude(float const& value){altitude=value;emit homePositionChanged(Coord(),Altitude());} + float Altitude()const{return altitude;} + void RefreshToolTip(); private: + MapGraphicItem* map; OPMapWidget* mapwidget; QPixmap pic; core::Point localposition; internals::PointLatLng coord; bool showsafearea; + bool toggleRefresh; int safearea; 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: - + void RefreshPos(); + void setOpacitySlot(qreal opacity); signals: - + void homePositionChanged(internals::PointLatLng coord,float); + void homedoubleclick(HomeItem* waypoint); }; } #endif // HOMEITEM_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker1.png b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker1.png new file mode 100644 index 000000000..179be2007 Binary files /dev/null and b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker1.png differ diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker2.png b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker2.png new file mode 100644 index 000000000..7834aa543 Binary files /dev/null and b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker2.png differ diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker3.png b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker3.png new file mode 100644 index 000000000..bd86af025 Binary files /dev/null and b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/images/waypoint_marker3.png differ diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp index 7c7984aa0..587303d6d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -40,11 +40,13 @@ namespace mapcontrol core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height())); core->SetMapType(MapType::GoogleHybrid); this->SetZoom(2); + this->setFlag(ItemIsFocusable); connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation())); - connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh())); - connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh())); - //resize(); + connect(core,SIGNAL(OnMapDrag()),this,SLOT(childPosRefresh())); + connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(childPosRefresh())); + setCacheMode(QGraphicsItem::ItemCoordinateCache); } + void MapGraphicItem::start() { core->StartSystem(); @@ -77,39 +79,15 @@ namespace mapcontrol void MapGraphicItem::Core_OnNeedInvalidation() { this->update(); - foreach(QGraphicsItem* i,this->childItems()) - { - WayPointItem* w=qgraphicsitem_cast(i); - if(w) - w->RefreshPos(); - UAVItem* ww=qgraphicsitem_cast(i); - if(ww) - ww->RefreshPos(); - HomeItem* www=qgraphicsitem_cast(i); - if(www) - www->RefreshPos(); - GPSItem* wwww=qgraphicsitem_cast(i); - if(wwww) - wwww->RefreshPos(); - } + emit childRefreshPosition(); } - void MapGraphicItem::ChildPosRefresh() + void MapGraphicItem::childPosRefresh() { - foreach(QGraphicsItem* i,this->childItems()) - { - WayPointItem* w=qgraphicsitem_cast(i); - if(w) - w->RefreshPos(); - UAVItem* ww=qgraphicsitem_cast(i); - if(ww) - ww->RefreshPos(); - HomeItem* www=qgraphicsitem_cast(i); - if(www) - www->RefreshPos(); - GPSItem* wwww=qgraphicsitem_cast(i); - if(wwww) - wwww->RefreshPos(); - } + emit childRefreshPosition(); + } + void MapGraphicItem::setOverlayOpacity(qreal value) + { + emit childSetOpacity(value); } void MapGraphicItem::ConstructLastImage(int const& zoomdiff) { @@ -117,8 +95,7 @@ namespace mapcontrol QSize size=boundingRect().size().toSize(); size.setWidth(size.width()*2*zoomdiff); size.setHeight(size.height()*2*zoomdiff); - temp=QImage(size, - QImage::Format_ARGB32_Premultiplied); + temp=QImage(size,QImage::Format_ARGB32_Premultiplied); temp.fill(0); QPainter imagePainter(&temp); 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()); { @@ -215,12 +192,9 @@ namespace mapcontrol } void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { - - - 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.SetY(event->pos().y()); @@ -232,7 +206,7 @@ namespace mapcontrol 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; SetSelectedArea (internals::RectLatLng::Empty); @@ -240,7 +214,6 @@ namespace mapcontrol selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y()); } } - } void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { @@ -269,11 +242,25 @@ namespace mapcontrol if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier) { 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) { int maxZoom = core->GetMaxZoomToFitRect(rect); @@ -380,7 +367,6 @@ namespace mapcontrol found = true; { painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img)); - // qDebug()<<"tile:"<tileRect.X()<tileRect.Y(); } } } @@ -394,7 +380,6 @@ namespace mapcontrol painter->setFont(config->MissingDataFont); 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()); - //qDebug()<<"ShowTileGridLine:"<GettilePoint().ToString()<<"=="<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; { MapRenderTransform = scaleValue; - // qDebug()<<"scale="<MaxZoom()) integer=MaxZoom(); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h index 034b1c8b8..a87450dd1 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -40,8 +40,10 @@ #include #include "waypointitem.h" //#include "uavitem.h" + namespace mapcontrol { + class WayPointItem; class OPMapWidget; /** * @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();} QImage lastimage; -// QPainter* imagePainter; core::Point lastimagepoint; void paintImage(QPainter* painter); void ConstructLastImage(int const& zoomdiff); @@ -100,13 +101,15 @@ namespace mapcontrol double Zoom(); double ZoomDigi(); double ZoomTotal(); - + void setOverlayOpacity(qreal value); protected: void mouseMoveEvent ( QGraphicsSceneMouseEvent * event ); void mousePressEvent ( QGraphicsSceneMouseEvent * event ); void wheelEvent ( QGraphicsSceneWheelEvent * event ); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); bool IsMouseOverMarker()const{return isMouseOverMarker;} + void keyPressEvent ( QKeyEvent * event ); + void keyReleaseEvent ( QKeyEvent * event ); /** * @brief Returns current map zoom @@ -197,7 +200,7 @@ namespace mapcontrol void SetMapType(MapType::Types const& value){core->SetMapType(value);} private slots: void Core_OnNeedInvalidation(); - void ChildPosRefresh(); + void childPosRefresh(); public slots: /** * @brief To be called when the scene size changes @@ -211,7 +214,10 @@ namespace mapcontrol * * @param zoom */ + void wpdoubleclicked(WayPointItem * wp); void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi); + void childRefreshPosition(); + void childSetOpacity(qreal value); }; } #endif // MAPGRAPHICITEM_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc index b7a0b985c..b7709e2cc 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc @@ -12,6 +12,9 @@ images/mapquad.png images/dragons1.jpg images/dragons2.jpeg + images/waypoint_marker1.png + images/waypoint_marker2.png + images/waypoint_marker3.png images/airplanepip.png diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp index bbd1725a1..55eadacc2 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -33,6 +33,7 @@ MapRipForm::MapRipForm(QWidget *parent) : ui(new Ui::MapRipForm) { ui->setupUi(this); + connect(ui->cancelButton,SIGNAL(clicked()),this,SIGNAL(cancelRequest())); } MapRipForm::~MapRipForm() diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.h index b1ff3637f..d3df3f881 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -44,6 +44,8 @@ public slots: void SetPercentage(int const& perc); void SetProvider(QString const& prov,int const& zoom); void SetNumberOfTiles(int const& total,int const& actual); +signals: + void cancelRequest(); private: Ui::MapRipForm *ui; }; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.ui b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.ui index 8100f8651..1fa6a935d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.ui +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripform.ui @@ -6,7 +6,7 @@ 0 0 - 392 + 521 133 @@ -18,7 +18,7 @@ 20 60 - 371 + 481 23 @@ -31,7 +31,7 @@ 30 10 - 321 + 481 16 @@ -55,7 +55,7 @@ - 280 + 220 100 75 23 diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp index 00a2053cd..4c8bbcd1c 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -28,17 +28,19 @@ 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()) { type=core->GetMapType(); progressForm=new MapRipForm; + connect(progressForm,SIGNAL(cancelRequest()),this,SLOT(stopFetching())); area=rect; zoom=core->Zoom(); maxzoom=core->MaxZoom(); points=core->Projection()->GetAreaTileList(area,zoom,0); this->start(); + cancel=false; progressForm->show(); connect(this,SIGNAL(percentageChanged(int)),progressForm,SLOT(SetPercentage(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())); 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 +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 +Left mouse click"); +#endif } - void MapRipper::finish() +void MapRipper::finish() +{ + if(zoomProjection()->GetAreaTileList(area,zoom,0); - this->start(); - } - else - { - progressForm->close(); - delete progressForm; - this->deleteLater(); - } - } + QMessageBox msgBox; + msgBox.setText(QString("Continue Ripping at zoom level %1?").arg(zoom)); + // msgBox.setInformativeText("Do you want to save your changes?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::YesAll); + msgBox.setDefaultButton(QMessageBox::Yes); + ret = msgBox.exec(); + } + else + ret=QMessageBox::Yes; + if(ret==QMessageBox::Yes) + { + points.clear(); + points=core->Projection()->GetAreaTileList(area,zoom,0); + this->start(); + } + else if(ret==QMessageBox::YesAll) + { + 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() @@ -119,4 +147,10 @@ namespace mapcontrol QThread::msleep(sleep); } } + + void MapRipper::stopFetching() + { + QMutexLocker locker(&mutex); + cancel=true; + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h index 6b2087a12..a53c443f5 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -50,6 +50,8 @@ namespace mapcontrol MapRipForm * progressForm; int maxzoom; internals::Core * core; + bool yesToAll; + QMutex mutex; signals: void percentageChanged(int const& perc); @@ -58,6 +60,7 @@ namespace mapcontrol public slots: + void stopFetching(); void finish(); }; } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro index b2098fb78..93627ddc5 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro @@ -1,50 +1,54 @@ -TEMPLATE = lib -TARGET = opmapwidget -DEFINES += OPMAPWIDGET_LIBRARY -include(../../../../openpilotgcslibrary.pri) - -# DESTDIR = ../build -SOURCES += mapgraphicitem.cpp \ - opmapwidget.cpp \ - configuration.cpp \ - waypointitem.cpp \ - uavitem.cpp \ - gpsitem.cpp \ - trailitem.cpp \ - homeitem.cpp \ - mapripform.cpp \ - mapripper.cpp \ - traillineitem.cpp - -LIBS += -L../build \ - -lcore \ - -linternals \ - -lcore - -# order of linking matters -include(../../../utils/utils.pri) - -POST_TARGETDEPS += ../build/libcore.a -POST_TARGETDEPS += ../build/libinternals.a - -HEADERS += mapgraphicitem.h \ - opmapwidget.h \ - configuration.h \ - waypointitem.h \ - uavitem.h \ - gpsitem.h \ - uavmapfollowtype.h \ - uavtrailtype.h \ - trailitem.h \ - homeitem.h \ - mapripform.h \ - mapripper.h \ - traillineitem.h -QT += opengl -QT += network -QT += sql -QT += svg -RESOURCES += mapresources.qrc - -FORMS += \ - mapripform.ui +TEMPLATE = lib +TARGET = opmapwidget +DEFINES += OPMAPWIDGET_LIBRARY +include(../../../../openpilotgcslibrary.pri) + +# DESTDIR = ../build +SOURCES += mapgraphicitem.cpp \ + opmapwidget.cpp \ + configuration.cpp \ + waypointitem.cpp \ + uavitem.cpp \ + gpsitem.cpp \ + trailitem.cpp \ + homeitem.cpp \ + mapripform.cpp \ + mapripper.cpp \ + traillineitem.cpp \ + waypointline.cpp \ + waypointcircle.cpp + +LIBS += -L../build \ + -lcore \ + -linternals \ + -lcore + +# order of linking matters +include(../../../utils/utils.pri) + +POST_TARGETDEPS += ../build/libcore.a +POST_TARGETDEPS += ../build/libinternals.a + +HEADERS += mapgraphicitem.h \ + opmapwidget.h \ + configuration.h \ + waypointitem.h \ + uavitem.h \ + gpsitem.h \ + uavmapfollowtype.h \ + uavtrailtype.h \ + trailitem.h \ + homeitem.h \ + mapripform.h \ + mapripper.h \ + traillineitem.h \ + waypointline.h \ + waypointcircle.h +QT += opengl +QT += network +QT += sql +QT += svg +RESOURCES += mapresources.qrc + +FORMS += \ + mapripform.ui diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp index c506532d4..30eea862d 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -33,13 +33,18 @@ 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); core=new internals::Core; map=new MapGraphicItem(core,config); mscene.addItem(map); 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(); 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))); @@ -50,10 +55,12 @@ namespace mapcontrol connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete())); connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart())); 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); this->setMouseTracking(followmouse); SetShowCompass(true); - + QPixmapCache::setCacheLimit(64*1024); } void OPMapWidget::SetShowDiagnostics(bool const& value) { @@ -70,12 +77,24 @@ namespace mapcontrol delete diagTimer; diagTimer=0; } + + if(GPS!=0) + { + delete GPS; + GPS=0; + } } else { diagTimer=new QTimer(); connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh())); 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); if(GPS!=0) 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) { @@ -96,47 +147,21 @@ namespace mapcontrol UAV->setParentItem(map); connect(this,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)),UAV,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng))); connect(this,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)),UAV,SIGNAL(UAVReachedWayPoint(int,WayPointItem*))); + UAV->setOpacity(overlayOpacity); } else if(!value) { if(UAV!=0) { delete UAV; - UAV=0; - } - - } - if(value && GPS==0) - { - GPS=new GPSItem(map,this); - GPS->setParentItem(map); - } - else if(!value) - { - if(GPS!=0) - { - delete GPS; - GPS=0; + UAV=NULL; } } } void OPMapWidget::SetShowHome(const bool &value) { - if(value && Home==0) - { - Home=new HomeItem(map,this); - Home->setParentItem(map); - } - else if(!value) - { - if(Home!=0) - { - delete Home; - Home=0; - } - - } + Home->setVisible(value); } void OPMapWidget::resizeEvent(QResizeEvent *event) @@ -161,14 +186,20 @@ namespace mapcontrol } OPMapWidget::~OPMapWidget() { - delete UAV; - delete Home; - delete map; - delete core; - delete configuration; + if(UAV) + delete UAV; + if(Home) + delete Home; + if(map) + delete map; + if(core) + delete core; + if(configuration) + delete configuration; foreach(QGraphicsItem* i,this->items()) { - delete i; + if(i) + delete i; } } void OPMapWidget::closeEvent(QCloseEvent *event) @@ -203,18 +234,33 @@ namespace mapcontrol WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map); ConnectWP(item); 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; } void OPMapWidget::WPCreate(WayPointItem* item) { ConnectWP(item); item->setParentItem(map); + int position=item->Number(); + emit WPCreated(position,item); + setOverlayOpacity(overlayOpacity); } WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude) { WayPointItem* item=new WayPointItem(coord,altitude,map); ConnectWP(item); item->setParentItem(map); + int position=item->Number(); + emit WPCreated(position,item); + setOverlayOpacity(overlayOpacity); return item; } 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); ConnectWP(item); 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; } WayPointItem* OPMapWidget::WPInsert(const int &position) @@ -231,6 +290,7 @@ namespace mapcontrol ConnectWP(item); item->setParentItem(map); emit WPInserted(position,item); + setOverlayOpacity(overlayOpacity); return item; } void OPMapWidget::WPInsert(WayPointItem* item,const int &position) @@ -239,7 +299,7 @@ namespace mapcontrol ConnectWP(item); item->setParentItem(map); emit WPInserted(position,item); - + setOverlayOpacity(overlayOpacity); } WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude,const int &position) { @@ -248,29 +308,131 @@ namespace mapcontrol ConnectWP(item); item->setParentItem(map); emit WPInserted(position,item); + setOverlayOpacity(overlayOpacity); return item; } 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); ConnectWP(item); item->setParentItem(map); 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; } void OPMapWidget::WPDelete(WayPointItem *item) { - emit WPDeleted(item->Number()); + emit WPDeleted(item->Number(),item); delete item; } - void OPMapWidget::WPDeleteAll() + void OPMapWidget::WPDelete(int number) { foreach(QGraphicsItem* i,map->childItems()) { WayPointItem* w=qgraphicsitem_cast(i); 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(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(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(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(i); + if(w) + { + if(w->Number()!=-1) + { + return true; + } + } + } + } + void OPMapWidget::deleteAllOverlays() + { + foreach(QGraphicsItem* i,map->childItems()) + { + WayPointLine* w=qgraphicsitem_cast(i); + if(w) + w->deleteLater(); + else + { + WayPointCircle* ww=qgraphicsitem_cast(i); + if(ww) + ww->deleteLater(); + } } } QList OPMapWidget::WPSelected() @@ -291,11 +453,13 @@ namespace mapcontrol void OPMapWidget::ConnectWP(WayPointItem *item) { - connect(item,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SIGNAL(WPNumberChanged(int,int,WayPointItem*))); - connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*))); - connect(this,SIGNAL(WPInserted(int,WayPointItem*)),item,SLOT(WPInserted(int,WayPointItem*))); - connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*))); - connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int))); + connect(item,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),Qt::DirectConnection); + connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*)),Qt::DirectConnection); + connect(item,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SIGNAL(WPLocalPositionChanged(QPointF,WayPointItem*)),Qt::DirectConnection); + connect(item,SIGNAL(manualCoordChange(WayPointItem*)),this,SIGNAL(WPManualCoordChange(WayPointItem*)),Qt::DirectConnection); + 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() { @@ -329,12 +493,12 @@ namespace mapcontrol 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->setFlag(QGraphicsItem::ItemIsMovable,true); + compass->setFlag(QGraphicsItem::ItemIsSelectable,true); mscene.addItem(compass); compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2); compass->setPos(55-compass->boundingRect().width()/2,55-compass->boundingRect().height()/2); compass->setZValue(3); compass->setOpacity(0.7); - } if(!value && compass) { @@ -342,6 +506,12 @@ namespace mapcontrol compass=0; } } + + void OPMapWidget::setOverlayOpacity(qreal value) + { + map->setOverlayOpacity(value); + overlayOpacity=value; + } void OPMapWidget::SetRotate(qreal const& value) { map->mapRotate(value); @@ -353,4 +523,28 @@ namespace mapcontrol { new MapRipper(core,map->SelectedArea()); } + + void OPMapWidget::setSelectedWP(QListlist) + { + this->scene()->clearSelection(); + foreach(WayPointItem * wp,list) + { + wp->setSelected(true); + } + } + + void OPMapWidget::OnSelectionChanged() + { + QList list; + QList wplist; + list=this->scene()->selectedItems(); + foreach(QGraphicsItem* item,list) + { + WayPointItem * wp=qgraphicsitem_cast(item); + if(wp) + wplist.append(wp); + } + if(wplist.length()>0) + emit selectedWPChanged(wplist); + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h index 5fd906de1..020f3831b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -41,6 +41,9 @@ #include "gpsitem.h" #include "homeitem.h" #include "mapripper.h" +#include "waypointline.h" +#include "waypointcircle.h" +#include "waypointitem.h" namespace mapcontrol { class UAVItem; @@ -279,6 +282,15 @@ namespace mapcontrol */ 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 * * @param position index of the WayPoint @@ -311,6 +323,7 @@ namespace mapcontrol * @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(const distBearingAltitude &relative, const QString &description, const int &position); /** * @brief Deletes the WayPoint @@ -340,6 +353,8 @@ namespace mapcontrol void SetShowCompass(bool const& value); + void setOverlayOpacity(qreal value); + UAVItem* UAV; GPSItem* GPS; HomeItem* Home; @@ -349,7 +364,18 @@ namespace mapcontrol bool ShowHome()const{return showhome;} void SetShowDiagnostics(bool const& value); 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 list); + private: internals::Core *core; MapGraphicItem *map; QGraphicsScene mscene; @@ -366,6 +392,7 @@ namespace mapcontrol QTimer * diagTimer; QGraphicsTextItem * diagGraphItem; bool showDiag; + qreal overlayOpacity; private slots: void diagRefresh(); // WayPointItem* item;//apagar @@ -398,6 +425,9 @@ namespace mapcontrol * @param waypoint WayPoint inserted */ void WPReached(WayPointItem* waypoint); + + void WPCreated(int const& number,WayPointItem* waypoint); + /** * @brief Fires when a new WayPoint is inserted * @@ -410,7 +440,10 @@ namespace mapcontrol * * @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 * @@ -469,11 +502,14 @@ namespace mapcontrol * @param number the number of tiles still in the queue */ void OnTilesStillToLoad(int number); + void OnWayPointDoubleClicked(WayPointItem * waypoint); + void selectedWPChanged(QList); public slots: /** * @brief Ripps the current selection to the DB */ void RipMap(); + void OnSelectionChanged(); }; } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.cpp index 41e50c29b..fabf6ee9a 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -28,9 +28,8 @@ #include 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(); 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())); @@ -38,7 +37,6 @@ namespace mapcontrol void TrailItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - // painter->drawRect(QRectF(-3,-3,6,6)); painter->setBrush(m_brush); painter->drawEllipse(-2,-2,4,4); } @@ -53,5 +51,8 @@ namespace mapcontrol return Type; } - + void TrailItem::setPosSLOT() + { + setPos(m_map->FromLatLngToLocal(this->coord).X(),m_map->FromLatLngToLocal(this->coord).Y()); + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.h index 4af8282d5..f926d61fc 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/trailitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -32,6 +32,7 @@ #include #include "../internals/pointlatlng.h" #include +#include "mapgraphicitem.h" namespace mapcontrol { @@ -42,7 +43,7 @@ namespace mapcontrol Q_INTERFACES(QGraphicsItem) public: 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, QWidget *widget); QRectF boundingRect() const; @@ -50,10 +51,9 @@ namespace mapcontrol internals::PointLatLng coord; private: QBrush m_brush; - - + MapGraphicItem * m_map; public slots: - + void setPosSLOT(); signals: }; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.cpp index c7cd05694..4550613db 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -28,29 +28,21 @@ 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; pen.setBrush(m_brush); pen.setWidth(1); 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 { 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()); + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.h index f749e51bd..0243907fa 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/traillineitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -32,6 +32,7 @@ #include #include "../internals/pointlatlng.h" #include +#include "mapgraphicitem.h" namespace mapcontrol { @@ -42,18 +43,15 @@ namespace mapcontrol Q_INTERFACES(QGraphicsItem) public: 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; - // void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - // QWidget *widget); internals::PointLatLng coord1; internals::PointLatLng coord2; private: QBrush m_brush; - - + MapGraphicItem * m_map; public slots: - + void setLineSlot(); signals: }; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.cpp index b28230da5..506d90b65 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -26,45 +26,225 @@ */ #include "../internals/pureprojection.h" #include "uavitem.h" +#include + 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) - ,autosetdistance(100) + ,autosetdistance(100),altitude(0),showUAVInfo(false) { - //QDir dir(":/uavs/images/"); - //QStringList list=dir.entryList(); pic.load(uavPic); - // Don't scale but trust the image we are given - // pic=pic.scaled(50,33,Qt::IgnoreAspectRatio); + this->setFlag(QGraphicsItem::ItemIsMovable,false); + this->setFlag(QGraphicsItem::ItemIsSelectable,false); localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition()); this->setPos(localposition.X(),localposition.Y()); this->setZValue(4); - trail=new QGraphicsItemGroup(); + trail=new QGraphicsItemGroup(this); trail->setParentItem(map); - trailLine=new QGraphicsItemGroup(); + trailLine=new QGraphicsItemGroup(this); trailLine->setParentItem(map); this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true); + setCacheMode(QGraphicsItem::ItemCoordinateCache); mapfollowtype=UAVMapFollowType::None; trailtype=UAVTrailType::ByDistance; 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() { - delete trail; + } void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); - // painter->rotate(-90); + + //Draw plane 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 { - 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) { if(coord.IsEmpty()) @@ -76,9 +256,15 @@ namespace mapcontrol { 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()) - 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; timer.restart(); } @@ -88,9 +274,15 @@ namespace mapcontrol { 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()) - 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; lastcoord=position; } @@ -102,7 +294,6 @@ namespace mapcontrol { mapwidget->SetCurrentPosition(coord); } - this->update(); if(autosetreached) { foreach(QGraphicsItem* i,map->childItems()) @@ -170,19 +361,24 @@ namespace mapcontrol { localposition=map->FromLatLngToLocal(coord); this->setPos(localposition.X(),localposition.Y()); - foreach(QGraphicsItem* i,trail->childItems()) - { - TrailItem* w=qgraphicsitem_cast(i); - if(w) - w->setPos(map->FromLatLngToLocal(w->coord).X(),map->FromLatLngToLocal(w->coord).Y()); - } - foreach(QGraphicsItem* i,trailLine->childItems()) - { - TrailLineItem* ww=qgraphicsitem_cast(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()); - } + emit setChildPosition(); + emit setChildLine(); + updateTextOverlay(); + } + 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) { @@ -217,4 +413,40 @@ namespace mapcontrol { 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; + + } } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.h index ca41a3d3d..472563f37 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -57,6 +57,31 @@ namespace mapcontrol enum { Type = UserType + 2 }; UAVItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png")); ~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 * @@ -103,7 +128,6 @@ namespace mapcontrol void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void RefreshPos(); QRectF boundingRect() const; /** * @brief Sets the trail time to be used if TrailType is ByTimeElapsed @@ -193,17 +217,32 @@ namespace mapcontrol int type() const; void SetUavPic(QString UAVPic); + void SetShowUAVInfo(bool const& value); + void updateTextOverlay(); private: + void generateArrowhead(); MapGraphicItem* map; - + OPMapWidget* mapwidget; + QPolygonF arrowHead; + QLineF arrowShaft; int altitude; UAVMapFollowType::Types mapfollowtype; UAVTrailType::Types trailtype; internals::PointLatLng coord; internals::PointLatLng lastcoord; + double NED[3]; + double vNED[3]; + double CAS_mps; + double groundspeed_kph; + double groundspeed_mps; + double yawRate_dps; + double trendRadius; + double trendSpanAngle; + float meters2pixels; + double precalcRings; + double ringTime; QPixmap pic; core::Point localposition; - OPMapWidget* mapwidget; QGraphicsItemGroup* trail; QGraphicsItemGroup * trailLine; internals::PointLatLng lasttrailline; @@ -215,13 +254,24 @@ namespace mapcontrol bool autosetreached; double Distance3D(internals::PointLatLng const& coord, int const& altitude); double autosetdistance; - // QRectF rect; + bool showUAVInfo; + static double groundspeed_mps_filt; + float boundingRectSize; + bool showJustChanged; + + bool refreshPaint_flag; + + QPainterPath textPath; public slots: - + void RefreshPos(); + void setOpacitySlot(qreal opacity); + void zoomChangedSlot(); signals: void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint); void UAVLeftSafetyBouble(internals::PointLatLng const& position); + void setChildPosition(); + void setChildLine(); }; } #endif // UAVITEM_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavmapfollowtype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavmapfollowtype.h index a2321a4c3..5fca96b68 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavmapfollowtype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavmapfollowtype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h index e9a852960..df8489aa7 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.cpp new file mode 100644 index 000000000..9f045a701 --- /dev/null +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.cpp @@ -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 +#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); +} + +} diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.h new file mode 100644 index 000000000..db839819d --- /dev/null +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointcircle.h @@ -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 +#include +#include +#include "../internals/pointlatlng.h" +#include "mapgraphicitem.h" +#include "waypointitem.h" +#include +#include + +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 diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp index 89c180f2d..e60f749ed 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -25,39 +25,167 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "waypointitem.h" +#include "homeitem.h" + 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; 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); - // transf.translate(picture.width()/2,picture.height()); - // this->setTransform(transf); SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); + myHome=NULL; + QList list=map->childItems(); + foreach(QGraphicsItem * obj,list) + { + HomeItem* h=qgraphicsitem_cast (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 list=map->childItems(); + foreach(QGraphicsItem * obj,list) + { + HomeItem* h=qgraphicsitem_cast (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; 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); - //transf.translate(picture.width()/2,picture.height()); - // this->setTransform(transf); SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); + myHome=NULL; + QList list=map->childItems(); + foreach(QGraphicsItem * obj,list) + { + HomeItem* h=qgraphicsitem_cast (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 list=map->childItems(); + foreach(QGraphicsItem * obj,list) + { + HomeItem* h=qgraphicsitem_cast (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 @@ -69,40 +197,55 @@ namespace mapcontrol Q_UNUSED(option); Q_UNUSED(widget); painter->drawPixmap(-picture.width()/2,-picture.height(),picture); + painter->setPen(Qt::green); if(this->isSelected()) 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) { if(event->button()==Qt::LeftButton) { - text=new QGraphicsSimpleTextItem(this); + text=new QGraphicsSimpleTextItem(this); textBG=new QGraphicsRectItem(this); -// textBG->setBrush(Qt::white); -// textBG->setOpacity(0.5); + textBG->setBrush(Qt::yellow); - textBG->setBrush(QColor(255, 255, 255, 128)); - - text->setPen(QPen(Qt::red)); - text->setPos(10,-picture.height()); - textBG->setPos(10,-picture.height()); - text->setZValue(3); - RefreshToolTip(); - isDragging=true; - } + text->setPen(QPen(Qt::red)); + text->setPos(10,-picture.height()); + textBG->setPos(10,-picture.height()); + text->setZValue(3); + RefreshToolTip(); + isDragging=true; + } QGraphicsItem::mousePressEvent(event); } void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if(event->button()==Qt::LeftButton) { - delete text; - delete textBG; - coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y()); + if(text) + { + delete text; + text=NULL; + } + if(textBG) + { + delete textBG; + textBG=NULL; + } + isDragging=false; RefreshToolTip(); - + emit manualCoordChange(this); + emit localPositionChanged(this->pos(),this); emit WPValuesChanged(this); } QGraphicsItem::mouseReleaseEvent(event); @@ -114,31 +257,77 @@ namespace mapcontrol { coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y()); 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()); - + emit localPositionChanged(this->pos(),this); emit WPValuesChanged(this); } QGraphicsItem::mouseMoveEvent(event); } - void WayPointItem::SetAltitude(const int &value) + void WayPointItem::SetAltitude(const float &value) { + if(altitude==value) + return; altitude=value; + if(myHome) + { + relativeCoord.altitudeRelative=altitude-myHome->Altitude(); + } RefreshToolTip(); - emit WPValuesChanged(this); 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) { + qDebug()<<"1 SetCoord("<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); RefreshPos(); RefreshToolTip(); this->update(); + qDebug()<<"5 setCoord EXIT"; } void WayPointItem::SetDescription(const QString &value) { + if(description==value) + return; description=value; RefreshToolTip(); emit WPValuesChanged(this); @@ -146,12 +335,13 @@ namespace mapcontrol } void WayPointItem::SetNumber(const int &value) { - emit WPNumberChanged(number,value,this); + int oldnumber=number; number=value; RefreshToolTip(); - numberI->setText(QString::number(number)); + numberI->setText(QString::number(numberAdjusted())); numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0)); this->update(); + emit WPNumberChanged(oldnumber,value,this); } void WayPointItem::SetReached(const bool &value) { @@ -160,8 +350,20 @@ namespace mapcontrol if(value) picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png")); 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) @@ -177,7 +379,7 @@ namespace mapcontrol numberI->setPen(QPen(Qt::blue)); numberI->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)); } else if (!value && numberI) @@ -187,49 +389,61 @@ namespace mapcontrol } this->update(); } - void WayPointItem::WPDeleted(const int &onumber) + void WayPointItem::WPDeleted(const int &onumber,WayPointItem *waypoint) { - if(number>onumber) --number; - numberI->setText(QString::number(number)); - numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0)); - RefreshToolTip(); - this->update(); + Q_UNUSED(waypoint); + int n=number; + if(number>onumber) SetNumber(--n); } void WayPointItem::WPInserted(const int &onumber, WayPointItem *waypoint) { + if(Number()==-1) + return; + if(waypoint!=this) { - if(onumber<=number) ++number; - numberI->setText(QString::number(number)); + if(onumber<=number) SetNumber(++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(); 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) { if (waypoint!=this) { if(((oldnumber>number) && (newnumber<=number))) { - ++number; - numberI->setText(QString::number(number)); - numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0)); - RefreshToolTip(); + SetNumber(++number); } else if (((oldnumbernumber))) { - --number; - numberI->setText(QString::number(number)); - numberIBG->setRect(numberI->boundingRect().adjusted(-2,0,1,0)); - RefreshToolTip(); + SetNumber(--number); } else if (newnumber==number) { - ++number; - numberI->setText(QString::number(number)); - RefreshToolTip(); + SetNumber(++number); } - this->update(); } } int WayPointItem::type() const @@ -240,17 +454,51 @@ namespace mapcontrol WayPointItem::~WayPointItem() { + emit aboutToBeDeleted(this); --WayPointItem::snumber; } void WayPointItem::RefreshPos() { core::Point point=map->FromLatLngToLocal(coord); this->setPos(point.X(),point.Y()); + emit localPositionChanged(this->pos(),this); + } + + void WayPointItem::setOpacitySlot(qreal opacity) + { + setOpacity(opacity); } 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); - 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; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.h index b9bee5ce5..9be8e39cc 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointitem.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file waypointitem.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 * @see The GNU Public License (GPL) Version 3 * @defgroup OPMapWidget @@ -33,8 +33,19 @@ #include "../internals/pointlatlng.h" #include "mapgraphicitem.h" #include +#include + namespace mapcontrol { +struct distBearingAltitude +{ + double distance; + double bearing; + float altitudeRelative; + double bearingToDegrees(){return bearing*180/M_PI;} + void setBearingFromDegrees(double degrees){bearing=degrees*M_PI/180;} +}; +class HomeItem; /** * @brief A QGraphicsItem representing a WayPoint * @@ -46,15 +57,17 @@ class WayPointItem:public QObject,public QGraphicsItem Q_INTERFACES(QGraphicsItem) public: enum { Type = UserType + 1 }; + enum wptype {absolute,relative}; /** * @brief Constructer * * @param coord coordinates in LatLng of the Waypoint * @param altitude altitude of the WayPoint * @param map pointer to map to use - * @return + * @return */ - WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map); + WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map,wptype type=absolute); + WayPointItem(MapGraphicItem* map,bool magicwaypoint); /** * @brief Constructer * @@ -64,7 +77,9 @@ public: * @param map pointer to map to use * @return */ - WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map); + WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map,wptype type=absolute); + WayPointItem(distBearingAltitude const& relativeCoord,QString const& description,MapGraphicItem* map); + /** * @brief Returns the WayPoint description * @@ -94,6 +109,7 @@ public: * */ int Number(){return number;} + int numberAdjusted(){return number+1;} /** * @brief Sets WayPoint number * @@ -127,45 +143,54 @@ public: * * @return int */ - int Altitude(){return altitude;} + float Altitude(){return altitude;} /** * @brief Sets the WayPoint Altitude * * @param value */ - void SetAltitude(int const& value); + void SetAltitude(const float &value); + void setRelativeCoord(distBearingAltitude value); + distBearingAltitude getRelativeCoord(){return relativeCoord;} int type() const; QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - void RefreshPos(); void RefreshToolTip(); QPixmap picture; + QString customString(){return myCustomString;} + void setCustomString(QString arg){myCustomString=arg;} + void setFlag(GraphicsItemFlag flag, bool enabled); ~WayPointItem(); static int snumber; + void setWPType(wptype type); + wptype WPType(){return myType;} protected: void mouseMoveEvent ( QGraphicsSceneMouseEvent * event ); void mousePressEvent ( QGraphicsSceneMouseEvent * event ); void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - - + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); private: internals::PointLatLng coord;//coordinates of this WayPoint + distBearingAltitude relativeCoord; bool reached; QString description; bool shownumber; bool isDragging; - int altitude; + float altitude; MapGraphicItem* map; int number; - + bool isMagic; QGraphicsSimpleTextItem* text; QGraphicsRectItem* textBG; QGraphicsSimpleTextItem* numberI; QGraphicsRectItem* numberIBG; QTransform transf; + HomeItem * myHome; + wptype myType; + QString myCustomString; public slots: /** @@ -173,7 +198,7 @@ public slots: * * @param number number of the WayPoint that was deleted */ - void WPDeleted(int const& number); + void WPDeleted(int const& number,WayPointItem *waypoint); /** * @brief Called when a WayPoint is renumbered * @@ -189,6 +214,10 @@ public slots: * @param waypoint a pointer to the WayPoint inserted */ void WPInserted(int const& number,WayPointItem* waypoint); + + void onHomePositionChanged(internals::PointLatLng,float altitude); + void RefreshPos(); + void setOpacitySlot(qreal opacity); signals: /** * @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering) @@ -203,8 +232,12 @@ signals: * * @param waypoint a pointer to this WayPoint */ - void WPValuesChanged(WayPointItem* waypoint); + void WPValuesChanged(WayPointItem* waypoint); + void waypointdoubleclick(WayPointItem* waypoint); + void localPositionChanged(QPointF point,WayPointItem* waypoint); + void manualCoordChange(WayPointItem *); + void aboutToBeDeleted(WayPointItem *); }; } #endif // WAYPOINTITEM_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.cpp new file mode 100644 index 000000000..527ca46f9 --- /dev/null +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.cpp @@ -0,0 +1,122 @@ +/** +****************************************************************************** +* +* @file waypointline.cpp +* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. +* @brief A graphicsItem representing a line 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 "waypointline.h" +#include +#include "homeitem.h" + +namespace mapcontrol +{ +WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map,QColor color):source(from), + destination(to),my_map(map),QGraphicsLineItem(map),myColor(color) +{ + this->setLine(to->pos().x(),to->pos().y(),from->pos().x(),from->pos().y()); + connect(from,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations())); + connect(to,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations())); + connect(from,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted())); + connect(to,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted())); + if(myColor==Qt::green) + this->setZValue(10); + else if(myColor==Qt::yellow) + this->setZValue(9); + else if(myColor==Qt::red) + this->setZValue(8); + connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal))); +} + +WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color):source(from), + destination(to),my_map(map),QGraphicsLineItem(map),myColor(color) +{ + this->setLine(to->pos().x(),to->pos().y(),from->pos().x(),from->pos().y()); + connect(from,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(refreshLocations())); + connect(to,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations())); + connect(to,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted())); + if(myColor==Qt::green) + this->setZValue(10); + else if(myColor==Qt::yellow) + this->setZValue(9); + else if(myColor==Qt::red) + this->setZValue(8); + connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal))); +} +int WayPointLine::type() const +{ + // Enable the use of qgraphicsitem_cast with this item. + return Type; +} +QPainterPath WayPointLine::shape() const +{ + QPainterPath path = QGraphicsLineItem::shape(); + path.addPolygon(arrowHead); + return path; +} +void WayPointLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + + QPen myPen = pen(); + myPen.setColor(myColor); + qreal arrowSize = 10; + painter->setPen(myPen); + painter->setBrush(myColor); + + double angle = ::acos(line().dx() / line().length()); + if (line().dy() >= 0) + angle = (M_PI * 2) - angle; + + QPointF arrowP1 = line().pointAt(0.5) + QPointF(sin(angle + M_PI / 3) * arrowSize, + cos(angle + M_PI / 3) * arrowSize); + QPointF arrowP2 = line().pointAt(0.5) + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize, + cos(angle + M_PI - M_PI / 3) * arrowSize); + arrowHead.clear(); + arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2; + painter->drawPolygon(arrowHead); + if(myColor==Qt::red) + myPen.setWidth(3); + else if(myColor==Qt::yellow) + myPen.setWidth(2); + else if(myColor==Qt::green) + myPen.setWidth(1); + painter->setPen(myPen); + painter->drawLine(line()); + +} + +void WayPointLine::refreshLocations() +{ + this->setLine(destination->pos().x(),destination->pos().y(),source->pos().x(),source->pos().y()); +} + +void WayPointLine::waypointdeleted() +{ + this->deleteLater(); +} + +void WayPointLine::setOpacitySlot(qreal opacity) +{ + setOpacity(opacity); +} + +} diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.h new file mode 100644 index 000000000..6b6bc4133 --- /dev/null +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/waypointline.h @@ -0,0 +1,66 @@ +/** +****************************************************************************** +* +* @file waypointline.h +* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. +* @brief A graphicsItem representing a line 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 WAYPOINTLINE_H +#define WAYPOINTLINE_H +#include +#include +#include +#include "../internals/pointlatlng.h" +#include "mapgraphicitem.h" +#include "waypointitem.h" +#include +#include + +namespace mapcontrol +{ +class WayPointLine:public QObject,public QGraphicsLineItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsItem) +public: + enum { Type = UserType + 8 }; + WayPointLine(WayPointItem * from, WayPointItem * to,MapGraphicItem * map,QColor color=Qt::green); + WayPointLine(HomeItem * from, WayPointItem * to,MapGraphicItem * map,QColor color=Qt::green); + int type() const; + QPainterPath shape() const; + void setColor(const QColor &color) + { myColor = color; } +private: + QGraphicsItem * source; + QGraphicsItem * destination; + MapGraphicItem * my_map; + QPolygonF arrowHead; + QColor myColor; +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); +public slots: + void refreshLocations(); + void waypointdeleted(); + void setOpacitySlot(qreal opacity); +}; +} +#endif // WAYPOINTLINE_H diff --git a/ground/openpilotgcs/src/libs/utils/coordinateconversions.cpp b/ground/openpilotgcs/src/libs/utils/coordinateconversions.cpp index ba67d8ab5..a7f7117b1 100644 --- a/ground/openpilotgcs/src/libs/utils/coordinateconversions.cpp +++ b/ground/openpilotgcs/src/libs/utils/coordinateconversions.cpp @@ -121,19 +121,18 @@ int CoordinateConversions::ECEF2LLA(double ECEF[3], double LLA[3]) } /** - * Get the current location in Longitude, Latitude Altitude (above WSG-48 ellipsoid) - * @param[in] BaseECEF the ECEF of the home location (in cm) + * Get the current location in Longitude, Latitude Altitude (above WSG-84 ellipsoid) + * @param[in] BaseECEF the ECEF of the home location (in m) * @param[in] NED the offset from the home location (in m) - * @param[out] position three element double for position in degrees and meters + * @param[out] position three element double for position in decimal degrees and altitude in meters * @returns * @arg 0 success * @arg -1 for failure */ -int CoordinateConversions::GetLLA(double BaseECEFcm[3], double NED[3], double position[3]) +int CoordinateConversions::NED2LLA_HomeECEF(double BaseECEFm[3], double NED[3], double position[3]) { int i; // stored value is in cm, convert to m - double BaseECEFm[3] = {BaseECEFcm[0], BaseECEFcm[1], BaseECEFcm[2]}; double BaseLLA[3]; double ECEF[3]; double Rne [3][3]; @@ -151,6 +150,29 @@ int CoordinateConversions::GetLLA(double BaseECEFcm[3], double NED[3], double po return 0; } +/** + * Get the current location in Longitude, Latitude, Altitude (above WSG-84 ellipsoid) + * @param[in] homeLLA the latitude, longitude, and altitude of the home location (in [m]) + * @param[in] NED the offset from the home location (in [m]) + * @param[out] position three element double for position in decimal degrees and altitude in meters + * @returns + * @arg 0 success + * @arg -1 for failure + */ +int CoordinateConversions::NED2LLA_HomeLLA(double homeLLA[3], double NED[3], double position[3]) +{ + double T[3]; + T[0] = homeLLA[2]+6.378137E6f * M_PI / 180.0; + T[1] = cosf(homeLLA[0] * M_PI / 180.0)*(homeLLA[2]+6.378137E6f) * M_PI / 180.0; + T[2] = -1.0f; + + position[0] = homeLLA[0] + NED[0] / T[0]; + position[1] = homeLLA[1] + NED[1] / T[1]; + position[2] = homeLLA[2] + NED[2] / T[2]; + + return 0; +} + void CoordinateConversions::LLA2Base(double LLA[3], double BaseECEF[3], float Rne[3][3], float NED[3]) { double ECEF[3]; diff --git a/ground/openpilotgcs/src/libs/utils/coordinateconversions.h b/ground/openpilotgcs/src/libs/utils/coordinateconversions.h index f6f47a8d7..ca077a0c4 100644 --- a/ground/openpilotgcs/src/libs/utils/coordinateconversions.h +++ b/ground/openpilotgcs/src/libs/utils/coordinateconversions.h @@ -41,7 +41,8 @@ class QTCREATOR_UTILS_EXPORT CoordinateConversions { public: CoordinateConversions(); - int GetLLA(double LLA[3], double NED[3], double position[3]); + int NED2LLA_HomeECEF(double BaseECEFcm[3], double NED[3], double position[3]); + int NED2LLA_HomeLLA(double LLA[3], double NED[3], double position[3]); void RneFromLLA(double LLA[3], double Rne[3][3]); void LLA2ECEF(double LLA[3], double ECEF[3]); int ECEF2LLA(double ECEF[3], double LLA[3]); diff --git a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h index 5e9dc6e67..9e5156198 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configgadgetwidget.h @@ -34,11 +34,9 @@ #include "objectpersistence.h" #include #include -//#include #include #include "utils/pathutils.h" #include -//#include "fancytabwidget.h" #include "utils/mytabbedstackwidget.h" #include "../uavobjectwidgetutils/configtaskwidget.h" diff --git a/ground/openpilotgcs/src/plugins/hitlnew/il2simulator.cpp b/ground/openpilotgcs/src/plugins/hitlnew/il2simulator.cpp index 78f78ffac..f61feb9cf 100644 --- a/ground/openpilotgcs/src/plugins/hitlnew/il2simulator.cpp +++ b/ground/openpilotgcs/src/plugins/hitlnew/il2simulator.cpp @@ -333,7 +333,7 @@ void IL2Simulator::processUpdate(const QByteArray& inp) NED[0] = current.Y; NED[1] = current.X; NED[2] = -current.Z; - Utils::CoordinateConversions().GetLLA(ECEF,NED,LLA); + Utils::CoordinateConversions().NED2LLA_HomeECEF(ECEF,NED,LLA); gpsData.Latitude = LLA[0] * 10e6; gpsData.Longitude = LLA[1] * 10e6; gpsData.Satellites = 7; diff --git a/ground/openpilotgcs/src/plugins/hitlnew/xplanesimulator.cpp b/ground/openpilotgcs/src/plugins/hitlnew/xplanesimulator.cpp index 66dbfd1d6..1546b862e 100644 --- a/ground/openpilotgcs/src/plugins/hitlnew/xplanesimulator.cpp +++ b/ground/openpilotgcs/src/plugins/hitlnew/xplanesimulator.cpp @@ -210,9 +210,9 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf) float accX = 0; float accY = 0; float accZ = 0; - float rollRate=0; - float pitchRate=0; - float yawRate=0; + float rollRate_rad=0; + float pitchRate_rad=0; + float yawRate_rad=0; QString str; QByteArray& buf = const_cast(dataBuf); @@ -269,10 +269,10 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf) velZ = *((float*)(buf.data()+4*5)); break; - case XplaneSimulator::AngularVelocities: - pitchRate = *((float*)(buf.data()+4*1)); - rollRate = *((float*)(buf.data()+4*2)); - yawRate = *((float*)(buf.data()+4*3)); + case XplaneSimulator::AngularVelocities: //In [rad/s] + pitchRate_rad = *((float*)(buf.data()+4*1)); + rollRate_rad = *((float*)(buf.data()+4*2)); + yawRate_rad = *((float*)(buf.data()+4*3)); break; case XplaneSimulator::Gload: @@ -380,8 +380,8 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf) //memset(&rawData, 0, sizeof(AttitudeRaw::DataFields)); //rawData = attRaw->getData(); //rawData.gyros[0] = rollRate; - //rawData.gyros_filtered[1] = cos(DEG2RAD * roll) * pitchRate + sin(DEG2RAD * roll) * yawRate; - //rawData.gyros_filtered[2] = cos(DEG2RAD * roll) * yawRate - sin(DEG2RAD * roll) * pitchRate; + //rawData.gyros_filtered[1] = cos(DEG2RAD * roll) * pitchRate_rad + sin(DEG2RAD * roll) * yawRate_rad; + //rawData.gyros_filtered[2] = cos(DEG2RAD * roll) * yawRate_rad - sin(DEG2RAD * roll) * pitchRate_rad; //rawData.gyros[1] = pitchRate; //rawData.gyros[2] = yawRate; //rawData.accels[0] = accX; @@ -390,9 +390,10 @@ void XplaneSimulator::processUpdate(const QByteArray& dataBuf) //attRaw->setData(rawData); Gyros::DataFields gyroData; memset(&gyroData, 0, sizeof(Gyros::DataFields)); - gyroData.x = rollRate; - gyroData.y = pitchRate; - gyroData.z = yawRate; +#define Pi 3.141529654 + gyroData.x = rollRate_rad*180/Pi; + gyroData.y = pitchRate_rad*180/Pi; + gyroData.z = yawRate_rad*180/Pi; gyros->setData(gyroData); Accels::DataFields accelData; @@ -420,7 +421,7 @@ void TraceBuf(const char* buf,int len) { if(i>0) { - qDebug() << str; +// qDebug() << str; str.clear(); reminder=false; } @@ -429,6 +430,7 @@ void TraceBuf(const char* buf,int len) str+=QString(" 0x%1").arg((quint8)buf[i],2,16,QLatin1Char('0')); } - if(reminder) - qDebug() << str; + if(reminder){ +// qDebug() << str; + } } diff --git a/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp new file mode 100644 index 000000000..04bcdd93c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.cpp @@ -0,0 +1,639 @@ +/** + ****************************************************************************** + * + * @file flightdatamodel.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "flightdatamodel.h" +#include +#include +flightDataModel::flightDataModel(QObject *parent):QAbstractTableModel(parent) +{ + +} + +int flightDataModel::rowCount(const QModelIndex &/*parent*/) const +{ + return dataStorage.length(); +} + +int flightDataModel::columnCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + return 23; +} + +QVariant flightDataModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole||role==Qt::EditRole) + { + int rowNumber=index.row(); + int columnNumber=index.column(); + if(rowNumber>dataStorage.length()-1 || rowNumber<0) + return QVariant::Invalid; + pathPlanData * myRow=dataStorage.at(rowNumber); + QVariant ret=getColumnByIndex(myRow,columnNumber); + return ret; + } + /* + else if (role == Qt::BackgroundRole) { + // WaypointActive::DataFields waypointActive = waypointActiveObj->getData(); + + if(index.row() == waypointActive.Index) { + return QBrush(Qt::lightGray); + } else + return QVariant::Invalid; + }*/ + else { + return QVariant::Invalid; + } +} + +bool flightDataModel::setColumnByIndex(pathPlanData *row,const int index,const QVariant value) +{ + switch(index) + { + case WPDESCRITPTION: + row->wpDescritption=value.toString(); + return true; + break; + case LATPOSITION: + row->latPosition=value.toDouble(); + return true; + break; + case LNGPOSITION: + row->lngPosition=value.toDouble(); + return true; + break; + case DISRELATIVE: + row->disRelative=value.toDouble(); + return true; + break; + case BEARELATIVE: + row->beaRelative=value.toDouble(); + return true; + break; + case ALTITUDERELATIVE: + row->altitudeRelative=value.toFloat(); + return true; + break; + case ISRELATIVE: + row->isRelative=value.toDouble(); + return true; + break; + case ALTITUDE: + row->altitude=value.toDouble(); + return true; + break; + case VELOCITY: + row->velocity=value.toFloat(); + return true; + break; + case MODE: + row->mode=value.toInt(); + return true; + break; + case MODE_PARAMS0: + row->mode_params[0]=value.toInt(); + return true; + break; + case MODE_PARAMS1: + row->mode_params[1]=value.toInt(); + return true; + break; + case MODE_PARAMS2: + row->mode_params[2]=value.toInt(); + return true; + break; + case MODE_PARAMS3: + row->mode_params[3]=value.toInt(); + return true; + break; + case CONDITION: + row->condition=value.toInt(); + return true; + break; + case CONDITION_PARAMS0: + row->condition_params[0]=value.toInt(); + return true; + break; + case CONDITION_PARAMS1: + row->condition_params[1]=value.toInt(); + return true; + break; + case CONDITION_PARAMS2: + row->condition_params[2]=value.toInt(); + return true; + break; + case CONDITION_PARAMS3: + row->condition_params[3]=value.toInt(); + return true; + break; + case COMMAND: + row->command=value.toInt(); + break; + case JUMPDESTINATION: + row->jumpdestination=value.toInt(); + return true; + break; + case ERRORDESTINATION: + row->errordestination=value.toInt(); + return true; + break; + case LOCKED: + row->locked=value.toBool(); + return true; + break; + default: + return false; + } +} +QVariant flightDataModel::getColumnByIndex(const pathPlanData *row,const int index) const +{ + switch(index) + { + case WPDESCRITPTION: + return row->wpDescritption; + break; + case LATPOSITION: + return row->latPosition; + break; + case LNGPOSITION: + return row->lngPosition; + break; + case DISRELATIVE: + return row->disRelative; + break; + case BEARELATIVE: + return row->beaRelative; + break; + case ALTITUDERELATIVE: + return row->altitudeRelative; + break; + case ISRELATIVE: + return row->isRelative; + break; + case ALTITUDE: + return row->altitude; + break; + case VELOCITY: + return row->velocity; + break; + case MODE: + return row->mode; + break; + case MODE_PARAMS0: + return row->mode_params[0]; + break; + case MODE_PARAMS1: + return row->mode_params[1]; + break; + case MODE_PARAMS2: + return row->mode_params[2]; + break; + case MODE_PARAMS3: + return row->mode_params[3]; + break; + case CONDITION: + return row->condition; + break; + case CONDITION_PARAMS0: + return row->condition_params[0]; + break; + case CONDITION_PARAMS1: + return row->condition_params[1]; + break; + case CONDITION_PARAMS2: + return row->condition_params[2]; + break; + case CONDITION_PARAMS3: + return row->condition_params[3]; + break; + case COMMAND: + return row->command; + break; + case JUMPDESTINATION: + return row->jumpdestination; + break; + case ERRORDESTINATION: + return row->errordestination; + break; + case LOCKED: + return row->locked; + } +} +QVariant flightDataModel::headerData(int section, Qt::Orientation orientation, int role) const + { + if (role == Qt::DisplayRole) + { + if(orientation==Qt::Vertical) + { + return QString::number(section+1); + } + else if (orientation == Qt::Horizontal) { + switch (section) + { + case WPDESCRITPTION: + return QString("Description"); + break; + case LATPOSITION: + return QString("Latitude"); + break; + case LNGPOSITION: + return QString("Longitude"); + break; + case DISRELATIVE: + return QString("Distance to home"); + break; + case BEARELATIVE: + return QString("Bearing from home"); + break; + case ALTITUDERELATIVE: + return QString("Altitude above home"); + break; + case ISRELATIVE: + return QString("Relative to home"); + break; + case ALTITUDE: + return QString("Altitude"); + break; + case VELOCITY: + return QString("Velocity"); + break; + case MODE: + return QString("Mode"); + break; + case MODE_PARAMS0: + return QString("Mode parameter 0"); + break; + case MODE_PARAMS1: + return QString("Mode parameter 1"); + break; + case MODE_PARAMS2: + return QString("Mode parameter 2"); + break; + case MODE_PARAMS3: + return QString("Mode parameter 3"); + break; + case CONDITION: + return QString("Condition"); + break; + case CONDITION_PARAMS0: + return QString("Condition parameter 0"); + break; + case CONDITION_PARAMS1: + return QString("Condition parameter 1"); + break; + case CONDITION_PARAMS2: + return QString("Condition parameter 2"); + break; + case CONDITION_PARAMS3: + return QString("Condition parameter 3"); + break; + case COMMAND: + return QString("Command"); + break; + case JUMPDESTINATION: + return QString("Jump Destination"); + break; + case ERRORDESTINATION: + return QString("Error Destination"); + break; + case LOCKED: + return QString("Locked"); + break; + default: + return QString(); + break; + } + } + } + else + return QAbstractTableModel::headerData(section, orientation, role); +} +bool flightDataModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (role == Qt::EditRole) + { + int columnIndex=index.column(); + int rowIndex=index.row(); + if(rowIndex>dataStorage.length()-1) + return false; + pathPlanData * myRow=dataStorage.at(rowIndex); + setColumnByIndex(myRow,columnIndex,value); + emit dataChanged(index,index); + } + return true; +} + +Qt::ItemFlags flightDataModel::flags(const QModelIndex & /*index*/) const + { + return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ; +} + +bool flightDataModel::insertRows(int row, int count, const QModelIndex &/*parent*/) +{ + pathPlanData * data; + beginInsertRows(QModelIndex(),row,row+count-1); + for(int x=0; xlatPosition=0; + data->lngPosition=0; + data->disRelative=0; + data->beaRelative=0; + data->altitudeRelative=0; + data->isRelative=0; + data->altitude=0; + data->velocity=0; + data->mode=0; + data->mode_params[0]=0; + data->mode_params[1]=0; + data->mode_params[2]=0; + data->mode_params[3]=0; + data->condition=0; + data->condition_params[0]=0; + data->condition_params[1]=0; + data->condition_params[2]=0; + data->condition_params[3]=0; + data->command=0; + data->jumpdestination=0; + data->errordestination=0; + data->locked=false; + dataStorage.insert(row,data); + } + endInsertRows(); +} + +bool flightDataModel::removeRows(int row, int count, const QModelIndex &/*parent*/) +{ + if(row<0) + return false; + beginRemoveRows(QModelIndex(),row,row+count-1); + for(int x=0; xwpDescritption); + field.setAttribute("name","description"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->latPosition); + field.setAttribute("name","latitude"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->lngPosition); + field.setAttribute("name","longitude"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->disRelative); + field.setAttribute("name","distance_to_home"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->beaRelative); + field.setAttribute("name","bearing_from_home"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->altitudeRelative); + field.setAttribute("name","altitude_above_home"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->isRelative); + field.setAttribute("name","is_relative_to_home"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->altitude); + field.setAttribute("name","altitude"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->velocity); + field.setAttribute("name","velocity"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->mode); + field.setAttribute("name","mode"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->mode_params[0]); + field.setAttribute("name","mode_param0"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->mode_params[1]); + field.setAttribute("name","mode_param1"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->mode_params[2]); + field.setAttribute("name","mode_param2"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->mode_params[3]); + field.setAttribute("name","mode_param3"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->condition); + field.setAttribute("name","condition"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->condition_params[0]); + field.setAttribute("name","condition_param0"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->condition_params[1]); + field.setAttribute("name","condition_param1"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->condition_params[2]); + field.setAttribute("name","condition_param2"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->condition_params[3]); + field.setAttribute("name","condition_param3"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->command); + field.setAttribute("name","command"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->jumpdestination); + field.setAttribute("name","jumpdestination"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->errordestination); + field.setAttribute("name","errordestination"); + waypoint.appendChild(field); + + field=doc.createElement("field"); + field.setAttribute("value",obj->locked); + field.setAttribute("name","is_locked"); + waypoint.appendChild(field); + + } + file.write(doc.toString().toAscii()); + file.close(); + return true; +} +void flightDataModel::readFromFile(QString fileName) +{ + //TODO warning message + removeRows(0,rowCount()); + QFile file(fileName); + QDomDocument doc("PathPlan"); + if (!doc.setContent(file.readAll())) { + QMessageBox msgBox; + msgBox.setText(tr("File Parsing Failed.")); + msgBox.setInformativeText(tr("This file is not a correct XML file")); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + file.close(); + + QDomElement root = doc.documentElement(); + + if (root.isNull() || (root.tagName() != "waypoints")) { + QMessageBox msgBox; + msgBox.setText(tr("Wrong file contents")); + msgBox.setInformativeText(tr("This file does not contain correct UAVSettings")); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + + pathPlanData * data=NULL; + QDomNode node = root.firstChild(); + while (!node.isNull()) { + QDomElement e = node.toElement(); + if (e.tagName() == "waypoint") { + QDomNode fieldNode=e.firstChild(); + data=new pathPlanData; + while (!fieldNode.isNull()) { + QDomElement field = fieldNode.toElement(); + if (field.tagName() == "field") { + if(field.attribute("name")=="altitude") + data->altitude=field.attribute("value").toDouble(); + else if(field.attribute("name")=="description") + data->wpDescritption=field.attribute("value"); + else if(field.attribute("name")=="latitude") + data->latPosition=field.attribute("value").toDouble(); + else if(field.attribute("name")=="longitude") + data->lngPosition=field.attribute("value").toDouble(); + else if(field.attribute("name")=="distance_to_home") + data->disRelative=field.attribute("value").toDouble(); + else if(field.attribute("name")=="bearing_from_home") + data->beaRelative=field.attribute("value").toDouble(); + else if(field.attribute("name")=="altitude_above_home") + data->altitudeRelative=field.attribute("value").toFloat(); + else if(field.attribute("name")=="is_relative_to_home") + data->isRelative=field.attribute("value").toInt(); + else if(field.attribute("name")=="altitude") + data->altitude=field.attribute("value").toDouble(); + else if(field.attribute("name")=="velocity") + data->velocity=field.attribute("value").toDouble(); + else if(field.attribute("name")=="mode") + data->mode=field.attribute("value").toInt(); + else if(field.attribute("name")=="mode_param0") + data->mode_params[0]=field.attribute("value").toDouble(); + else if(field.attribute("name")=="mode_param1") + data->mode_params[1]=field.attribute("value").toDouble(); + else if(field.attribute("name")=="mode_param2") + data->mode_params[2]=field.attribute("value").toDouble(); + else if(field.attribute("name")=="mode_param3") + data->mode_params[3]=field.attribute("value").toDouble(); + else if(field.attribute("name")=="condition") + data->condition=field.attribute("value").toDouble(); + else if(field.attribute("name")=="condition_param0") + data->condition_params[0]=field.attribute("value").toFloat(); + else if(field.attribute("name")=="condition_param1") + data->condition_params[1]=field.attribute("value").toFloat(); + else if(field.attribute("name")=="condition_param2") + data->condition_params[2]=field.attribute("value").toFloat(); + else if(field.attribute("name")=="condition_param3") + data->condition_params[3]=field.attribute("value").toFloat(); + else if(field.attribute("name")=="command") + data->command=field.attribute("value").toInt(); + else if(field.attribute("name")=="jumpdestination") + data->jumpdestination=field.attribute("value").toInt(); + else if(field.attribute("name")=="errordestination") + data->errordestination=field.attribute("value").toInt(); + else if(field.attribute("name")=="is_locked") + data->locked=field.attribute("value").toInt(); + + } + fieldNode=fieldNode.nextSibling(); + } + beginInsertRows(QModelIndex(),dataStorage.length(),dataStorage.length()); + dataStorage.append(data); + endInsertRows(); + } + node=node.nextSibling(); + } +} + diff --git a/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.h b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.h new file mode 100644 index 000000000..3043c607c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/flightdatamodel.h @@ -0,0 +1,82 @@ +/** + ****************************************************************************** + * + * @file flightdatamodel.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 FLIGHTDATAMODEL_H +#define FLIGHTDATAMODEL_H +#include +#include "opmapcontrol/opmapcontrol.h" + +struct pathPlanData +{ + QString wpDescritption; + double latPosition; + double lngPosition; + double disRelative; + double beaRelative; + double altitudeRelative; + bool isRelative; + double altitude; + float velocity; + int mode; + float mode_params[4]; + int condition; + float condition_params[4]; + int command; + int jumpdestination; + int errordestination; + bool locked; +}; + +class flightDataModel:public QAbstractTableModel +{ + Q_OBJECT +public: + enum pathPlanDataEnum + { + WPDESCRITPTION,LATPOSITION,LNGPOSITION,DISRELATIVE,BEARELATIVE,ALTITUDERELATIVE,ISRELATIVE,ALTITUDE, + VELOCITY,MODE,MODE_PARAMS0,MODE_PARAMS1,MODE_PARAMS2,MODE_PARAMS3, + CONDITION,CONDITION_PARAMS0,CONDITION_PARAMS1,CONDITION_PARAMS2,CONDITION_PARAMS3, + COMMAND,JUMPDESTINATION,ERRORDESTINATION,LOCKED + }; + flightDataModel(QObject *parent); + int rowCount(const QModelIndex &parent = QModelIndex()) const ; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex & index) const ; + bool insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() ); + bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ); + bool writeToFile(QString filename); + void readFromFile(QString fileName); +private: + QList dataStorage; + QVariant getColumnByIndex(const pathPlanData *row, const int index) const; + bool setColumnByIndex(pathPlanData *row, const int index, const QVariant value); +}; + +#endif // FLIGHTDATAMODEL_H diff --git a/ground/openpilotgcs/src/plugins/opmap/homeeditor.cpp b/ground/openpilotgcs/src/plugins/opmap/homeeditor.cpp new file mode 100644 index 000000000..47b5466f0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/homeeditor.cpp @@ -0,0 +1,62 @@ +/** + ****************************************************************************** + * + * @file homeeditor.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "homeeditor.h" +#include "ui_homeeditor.h" + +homeEditor::homeEditor(HomeItem *home, QWidget *parent) : + QDialog(parent), + ui(new Ui::homeEditor), + myhome(home) +{ + if(!home) + { + deleteLater(); + return; + } + ui->setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + ui->altitude->setValue(home->Altitude()); + ui->latitude->setValue(home->Coord().Lat()); + ui->longitude->setValue(home->Coord().Lng()); + this->show(); +} + +homeEditor::~homeEditor() +{ + delete ui; +} + +void homeEditor::on_buttonBox_accepted() +{ + myhome->SetCoord(internals::PointLatLng(ui->latitude->value(),ui->longitude->value())); + myhome->SetAltitude(ui->altitude->value()); +} + +void homeEditor::on_buttonBox_rejected() +{ + this->close(); +} diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_overlay_widget.h b/ground/openpilotgcs/src/plugins/opmap/homeeditor.h similarity index 68% rename from ground/openpilotgcs/src/plugins/opmap/opmap_overlay_widget.h rename to ground/openpilotgcs/src/plugins/opmap/homeeditor.h index e10525d3d..e0404e6b9 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_overlay_widget.h +++ b/ground/openpilotgcs/src/plugins/opmap/homeeditor.h @@ -1,49 +1,57 @@ -/** - ****************************************************************************** - * - * @file opmap_overlay_widget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup OPMapPlugin OpenPilot Map Plugin - * @{ - * @brief The OpenPilot Map plugin - *****************************************************************************/ -/* - * 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 OPMAP_OVERLAY_WIDGET_H -#define OPMAP_OVERLAY_WIDGET_H - -#include - -namespace Ui { - class opmap_overlay_widget; -} - -class opmap_overlay_widget : public QWidget -{ - Q_OBJECT - -public: - explicit opmap_overlay_widget(QWidget *parent = 0); - ~opmap_overlay_widget(); - -private: - Ui::opmap_overlay_widget *ui; -}; - -#endif // OPMAP_OVERLAY_WIDGET_H +/** + ****************************************************************************** + * + * @file homeeditor.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 HOMEEDITOR_H +#define HOMEEDITOR_H + +#include +#include "opmapcontrol/opmapcontrol.h" + +using namespace mapcontrol; + +namespace Ui { +class homeEditor; +} + +class homeEditor : public QDialog +{ + Q_OBJECT + +public: + explicit homeEditor(HomeItem * home,QWidget *parent = 0); + ~homeEditor(); + +private slots: + void on_buttonBox_accepted(); + + void on_buttonBox_rejected(); + +private: + Ui::homeEditor *ui; + HomeItem * myhome; +}; + +#endif // HOMEEDITOR_H diff --git a/ground/openpilotgcs/src/plugins/opmap/homeeditor.ui b/ground/openpilotgcs/src/plugins/opmap/homeeditor.ui new file mode 100644 index 000000000..98f5acc58 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/homeeditor.ui @@ -0,0 +1,151 @@ + + + homeEditor + + + + 0 + 0 + 295 + 159 + + + + Dialog + + + + + + Latitude: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Longitude: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Altitude: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.100000000000000 + + + + + + + 8 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.100000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + 8 + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + homeEditor + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + homeEditor + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/ground/openpilotgcs/src/plugins/opmap/images/Ekisho Deep Ocean HD1.png b/ground/openpilotgcs/src/plugins/opmap/images/Ekisho Deep Ocean HD1.png new file mode 100644 index 000000000..54cd51b00 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/Ekisho Deep Ocean HD1.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/down_alt.png b/ground/openpilotgcs/src/plugins/opmap/images/down_alt.png new file mode 100644 index 000000000..b77135526 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/down_alt.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/down_alt2.png b/ground/openpilotgcs/src/plugins/opmap/images/down_alt2.png new file mode 100644 index 000000000..b77135526 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/down_alt2.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/forward button white.png b/ground/openpilotgcs/src/plugins/opmap/images/forward button white.png new file mode 100644 index 000000000..e34adc93a Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/forward button white.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/forward_alt.png b/ground/openpilotgcs/src/plugins/opmap/images/forward_alt.png new file mode 100644 index 000000000..ddd2e4261 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/forward_alt.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/new archive.png b/ground/openpilotgcs/src/plugins/opmap/images/new archive.png new file mode 100644 index 000000000..326c2bb3a Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/new archive.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/plus3.png b/ground/openpilotgcs/src/plugins/opmap/images/plus3.png new file mode 100644 index 000000000..63ce12ba2 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/plus3.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/rewind button white.png b/ground/openpilotgcs/src/plugins/opmap/images/rewind button white.png new file mode 100644 index 000000000..549bd8057 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/rewind button white.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/star.png b/ground/openpilotgcs/src/plugins/opmap/images/star.png new file mode 100644 index 000000000..25ef8b290 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/star.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/stopb.png b/ground/openpilotgcs/src/plugins/opmap/images/stopb.png new file mode 100644 index 000000000..5dad7cdac Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/stopb.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/unarchive.png b/ground/openpilotgcs/src/plugins/opmap/images/unarchive.png new file mode 100644 index 000000000..e74f0a31c Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/unarchive.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/images/up_alt.png b/ground/openpilotgcs/src/plugins/opmap/images/up_alt.png new file mode 100644 index 000000000..4d8b67f59 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/opmap/images/up_alt.png differ diff --git a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp new file mode 100644 index 000000000..406d8e23d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp @@ -0,0 +1,342 @@ +/** + ****************************************************************************** + * + * @file modelmapproxy.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "modelmapproxy.h" + +modelMapProxy::modelMapProxy(QObject *parent,OPMapWidget *map,flightDataModel * model,QItemSelectionModel * selectionModel):QObject(parent),myMap(map),model(model),selection(selectionModel) +{ + connect(model,SIGNAL(rowsInserted(const QModelIndex&,int,int)),this,SLOT(rowsInserted(const QModelIndex&,int,int))); + connect(model,SIGNAL(rowsRemoved(const QModelIndex&,int,int)),this,SLOT(rowsRemoved(const QModelIndex&,int,int))); + connect(selection,SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(currentRowChanged(QModelIndex,QModelIndex))); + connect(model,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(dataChanged(QModelIndex,QModelIndex))); + connect(myMap,SIGNAL(selectedWPChanged(QList)),this,SLOT(selectedWPChanged(QList))); + connect(myMap,SIGNAL(WPValuesChanged(WayPointItem*)),this,SLOT(WPValuesChanged(WayPointItem*))); +} + +void modelMapProxy::WPValuesChanged(WayPointItem * wp) +{ + QModelIndex index; + index=model->index(wp->Number(),flightDataModel::LATPOSITION); + if(!index.isValid()) + return; + model->setData(index,wp->Coord().Lat(),Qt::EditRole); + index=model->index(wp->Number(),flightDataModel::LNGPOSITION); + model->setData(index,wp->Coord().Lng(),Qt::EditRole); + + index=model->index(wp->Number(),flightDataModel::ALTITUDE); + model->setData(index,wp->Altitude(),Qt::EditRole); + + index=model->index(wp->Number(),flightDataModel::DISRELATIVE); + model->setData(index,wp->getRelativeCoord().distance,Qt::EditRole); + index=model->index(wp->Number(),flightDataModel::BEARELATIVE); + model->setData(index,wp->getRelativeCoord().bearingToDegrees(),Qt::EditRole); + index=model->index(wp->Number(),flightDataModel::ALTITUDERELATIVE); + model->setData(index,wp->getRelativeCoord().altitudeRelative,Qt::EditRole); +} + +void modelMapProxy::currentRowChanged(QModelIndex current, QModelIndex previous) +{ + QList list; + WayPointItem * wp=findWayPointNumber(current.row()); + if(!wp) + return; + list.append(wp); + myMap->setSelectedWP(list); +} + +void modelMapProxy::selectedWPChanged(QList list) +{ + selection->clearSelection(); + foreach(WayPointItem * wp,list) + { + QModelIndex index=model->index(wp->Number(),0); + selection->setCurrentIndex(index,QItemSelectionModel::Select | QItemSelectionModel::Rows); + } +} + +modelMapProxy::overlayType modelMapProxy::overlayTranslate(int type) +{ + switch(type) + { + case MapDataDelegate::MODE_FLYENDPOINT: + case MapDataDelegate::MODE_FLYVECTOR: + case MapDataDelegate::MODE_DRIVEENDPOINT: + case MapDataDelegate::MODE_DRIVEVECTOR: + return OVERLAY_LINE; + break; + case MapDataDelegate::MODE_FLYCIRCLERIGHT: + case MapDataDelegate::MODE_DRIVECIRCLERIGHT: + return OVERLAY_CIRCLE_RIGHT; + break; + case MapDataDelegate::MODE_FLYCIRCLELEFT: + case MapDataDelegate::MODE_DRIVECIRCLELEFT: + return OVERLAY_CIRCLE_LEFT; + break; + default: + break; + } +} + +void modelMapProxy::createOverlay(WayPointItem *from, WayPointItem *to, modelMapProxy::overlayType type,QColor color) +{ + if(from==NULL || to==NULL || from==to) + return; + switch(type) + { + case OVERLAY_LINE: + myMap->WPLineCreate(from,to,color); + break; + case OVERLAY_CIRCLE_RIGHT: + myMap->WPCircleCreate(to,from,true,color); + break; + case OVERLAY_CIRCLE_LEFT: + myMap->WPCircleCreate(to,from,false,color); + break; + default: + break; + + } +} +void modelMapProxy::createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type,QColor color) +{ + if(from==NULL || to==NULL) + return; + switch(type) + { + case OVERLAY_LINE: + myMap->WPLineCreate(to,from,color); + break; + case OVERLAY_CIRCLE_RIGHT: + myMap->WPCircleCreate(to,from,true,color); + break; + case OVERLAY_CIRCLE_LEFT: + myMap->WPCircleCreate(to,from,false,color); + break; + default: + break; + + } +} +void modelMapProxy::refreshOverlays() +{ + myMap->deleteAllOverlays(); + if(model->rowCount()<1) + return; + WayPointItem * wp_current=NULL; + WayPointItem * wp_next=NULL; + int wp_jump; + int wp_error; + overlayType wp_next_overlay; + overlayType wp_jump_overlay; + overlayType wp_error_overlay; + wp_current=findWayPointNumber(0); + overlayType wp_current_overlay=overlayTranslate(model->data(model->index(0,flightDataModel::MODE)).toInt()); + createOverlay(wp_current,myMap->Home,wp_current_overlay,Qt::green); + for(int x=0;xrowCount();++x) + { + wp_current=findWayPointNumber(x); + wp_jump=model->data(model->index(x,flightDataModel::JUMPDESTINATION)).toInt()-1; + wp_error=model->data(model->index(x,flightDataModel::ERRORDESTINATION)).toInt()-1; + wp_next_overlay=overlayTranslate(model->data(model->index(x+1,flightDataModel::MODE)).toInt()); + wp_jump_overlay=overlayTranslate(model->data(model->index(wp_jump,flightDataModel::MODE)).toInt()); + wp_error_overlay=overlayTranslate(model->data(model->index(wp_error,flightDataModel::MODE)).toInt()); + createOverlay(wp_current,findWayPointNumber(wp_error),wp_error_overlay,Qt::red); + switch(model->data(model->index(x,flightDataModel::COMMAND)).toInt()) + { + case MapDataDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT: + wp_next=findWayPointNumber(x+1); + createOverlay(wp_current,wp_next,wp_next_overlay,Qt::green); + break; + case MapDataDelegate::COMMAND_ONCONDITIONJUMPWAYPOINT: + wp_next=findWayPointNumber(wp_jump); + createOverlay(wp_current,wp_next,wp_jump_overlay,Qt::green); + break; + case MapDataDelegate::COMMAND_ONNOTCONDITIONJUMPWAYPOINT: + wp_next=findWayPointNumber(wp_jump); + createOverlay(wp_current,wp_next,wp_jump_overlay,Qt::yellow); + break; + case MapDataDelegate::COMMAND_ONNOTCONDITIONNEXTWAYPOINT: + wp_next=findWayPointNumber(x+1); + createOverlay(wp_current,wp_next,wp_next_overlay,Qt::yellow); + break; + case MapDataDelegate::COMMAND_IFCONDITIONJUMPWAYPOINTELSENEXTWAYPOINT: + wp_next=findWayPointNumber(wp_jump); + createOverlay(wp_current,wp_next,wp_jump_overlay,Qt::green); + wp_next=findWayPointNumber(x+1); + createOverlay(wp_current,wp_next,wp_next_overlay,Qt::green); + break; + } + } +} + +WayPointItem * modelMapProxy::findWayPointNumber(int number) +{ + if(number<0) + return NULL; + return myMap->WPFind(number); +} + +void modelMapProxy::rowsRemoved(const QModelIndex &parent, int first, int last) +{ + for(int x=last;x>first-1;x--) + { + myMap->WPDelete(x); + } + refreshOverlays(); +} + +void modelMapProxy::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + WayPointItem * item=findWayPointNumber(topLeft.row()); + if(!item) + return; + internals::PointLatLng latlng; + int x=topLeft.row(); + distBearingAltitude distBearing; + double altitude; + bool relative; + QModelIndex index; + QString desc; + switch(topLeft.column()) + { + case flightDataModel::COMMAND: + case flightDataModel::CONDITION: + case flightDataModel::JUMPDESTINATION: + case flightDataModel::ERRORDESTINATION: + case flightDataModel::MODE: + refreshOverlays(); + break; + case flightDataModel::WPDESCRITPTION: + index=model->index(x,flightDataModel::WPDESCRITPTION); + desc=index.data(Qt::DisplayRole).toString(); + item->SetDescription(desc); + break; + case flightDataModel::LATPOSITION: + latlng=item->Coord(); + index=model->index(x,flightDataModel::LATPOSITION); + latlng.SetLat(index.data(Qt::DisplayRole).toDouble()); + item->SetCoord(latlng); + break; + case flightDataModel::LNGPOSITION: + latlng=item->Coord(); + index=model->index(x,flightDataModel::LNGPOSITION); + latlng.SetLng(index.data(Qt::DisplayRole).toDouble()); + item->SetCoord(latlng); + break; + case flightDataModel::BEARELATIVE: + distBearing=item->getRelativeCoord(); + index=model->index(x,flightDataModel::BEARELATIVE); + distBearing.setBearingFromDegrees(index.data(Qt::DisplayRole).toDouble()); + item->setRelativeCoord(distBearing); + break; + case flightDataModel::DISRELATIVE: + distBearing=item->getRelativeCoord(); + index=model->index(x,flightDataModel::DISRELATIVE); + distBearing.distance=index.data(Qt::DisplayRole).toDouble(); + item->setRelativeCoord(distBearing); + break; + case flightDataModel::ALTITUDERELATIVE: + distBearing=item->getRelativeCoord(); + index=model->index(x,flightDataModel::ALTITUDERELATIVE); + distBearing.altitudeRelative=index.data(Qt::DisplayRole).toFloat(); + item->setRelativeCoord(distBearing); + break; + case flightDataModel::ISRELATIVE: + index=model->index(x,flightDataModel::ISRELATIVE); + relative=index.data(Qt::DisplayRole).toBool(); + if(relative) + item->setWPType(mapcontrol::WayPointItem::relative); + else + item->setWPType(mapcontrol::WayPointItem::absolute); + break; + case flightDataModel::ALTITUDE: + index=model->index(x,flightDataModel::ALTITUDE); + altitude=index.data(Qt::DisplayRole).toDouble(); + item->SetAltitude(altitude); + break; + case flightDataModel::LOCKED: + index=model->index(x,flightDataModel::LOCKED); + item->setFlag(QGraphicsItem::ItemIsMovable,!index.data(Qt::DisplayRole).toBool()); + break; + } +} + +void modelMapProxy::rowsInserted(const QModelIndex &parent, int first, int last) +{ + Q_UNUSED(parent); + for(int x=first;xindex(x,flightDataModel::WPDESCRITPTION); + QString desc=index.data(Qt::DisplayRole).toString(); + index=model->index(x,flightDataModel::LATPOSITION); + latlng.SetLat(index.data(Qt::DisplayRole).toDouble()); + index=model->index(x,flightDataModel::LNGPOSITION); + latlng.SetLng(index.data(Qt::DisplayRole).toDouble()); + index=model->index(x,flightDataModel::DISRELATIVE); + distBearing.distance=index.data(Qt::DisplayRole).toDouble(); + index=model->index(x,flightDataModel::BEARELATIVE); + distBearing.setBearingFromDegrees(index.data(Qt::DisplayRole).toDouble()); + index=model->index(x,flightDataModel::ALTITUDERELATIVE); + distBearing.altitudeRelative=index.data(Qt::DisplayRole).toFloat(); + index=model->index(x,flightDataModel::ISRELATIVE); + relative=index.data(Qt::DisplayRole).toBool(); + index=model->index(x,flightDataModel::ALTITUDE); + altitude=index.data(Qt::DisplayRole).toDouble(); + if(relative) + item=myMap->WPInsert(distBearing,desc,x); + else + item=myMap->WPInsert(latlng,altitude,desc,x); + } + refreshOverlays(); +} +void modelMapProxy::deleteWayPoint(int number) +{ + model->removeRow(number,QModelIndex()); +} + +void modelMapProxy::createWayPoint(internals::PointLatLng coord) +{ + model->insertRow(model->rowCount(),QModelIndex()); + QModelIndex index=model->index(model->rowCount()-1,flightDataModel::LATPOSITION,QModelIndex()); + model->setData(index,coord.Lat(),Qt::EditRole); + index=model->index(model->rowCount()-1,flightDataModel::LNGPOSITION,QModelIndex()); + model->setData(index,coord.Lng(),Qt::EditRole); + index=model->index(model->rowCount()-1,flightDataModel::JUMPDESTINATION,QModelIndex()); + model->setData(index,1,Qt::EditRole); + index=model->index(model->rowCount()-1,flightDataModel::ERRORDESTINATION,QModelIndex()); + model->setData(index,1,Qt::EditRole); +} +void modelMapProxy::deleteAll() +{ + model->removeRows(0,model->rowCount(),QModelIndex()); +} diff --git a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h new file mode 100644 index 000000000..29c61c9b1 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h @@ -0,0 +1,68 @@ +/** + ****************************************************************************** + * + * @file modelmapproxy.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 MODELMAPPROXY_H +#define MODELMAPPROXY_H +#include +#include "opmapcontrol/opmapcontrol.h" +#include "pathaction.h" +#include "waypoint.h" +#include "QMutexLocker" +#include "QPointer" +#include "flightdatamodel.h" +#include +#include + + +using namespace mapcontrol; +class modelMapProxy:public QObject +{ + typedef enum {OVERLAY_LINE,OVERLAY_CIRCLE_RIGHT,OVERLAY_CIRCLE_LEFT} overlayType; + Q_OBJECT +public: + explicit modelMapProxy(QObject *parent,OPMapWidget * map,flightDataModel * model,QItemSelectionModel * selectionModel); + WayPointItem *findWayPointNumber(int number); + void createWayPoint(internals::PointLatLng coord); + void deleteWayPoint(int number); + void deleteAll(); +private slots: + void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); + void rowsInserted ( const QModelIndex & parent, int first, int last ); + void rowsRemoved ( const QModelIndex & parent, int first, int last ); + void WPValuesChanged(WayPointItem *wp); + void currentRowChanged(QModelIndex,QModelIndex); + void selectedWPChanged(QList); +private: + overlayType overlayTranslate(int type); + void createOverlay(WayPointItem * from,WayPointItem * to,overlayType type,QColor color); + void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color); + OPMapWidget * myMap; + flightDataModel * model; + void refreshOverlays(); + QItemSelectionModel * selection; +}; + +#endif // MODELMAPPROXY_H diff --git a/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp new file mode 100644 index 000000000..d11ee753b --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/modeluavoproxy.cpp @@ -0,0 +1,248 @@ +/** + ****************************************************************************** + * + * @file modeluavproxy.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "modeluavoproxy.h" +#include "extensionsystem/pluginmanager.h" +#include +modelUavoProxy::modelUavoProxy(QObject *parent,flightDataModel * model):QObject(parent),myModel(model) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm != NULL); + objManager = pm->getObject(); + Q_ASSERT(objManager != NULL); + waypointObj = Waypoint::GetInstance(objManager); + Q_ASSERT(waypointObj != NULL); + pathactionObj=PathAction::GetInstance(objManager); + Q_ASSERT(pathactionObj != NULL); +} +void modelUavoProxy::modelToObjects() +{ + PathAction * act=NULL; + Waypoint * wp=NULL; + QModelIndex index; + double distance; + double bearing; + double altitude; + int lastaction=-1; + for(int x=0;xrowCount();++x) + { + int instances=objManager->getNumInstances(waypointObj->getObjID()); + if(x>instances-1) + { + wp=new Waypoint; + wp->initialize(x,wp->getMetaObject()); + objManager->registerObject(wp); + } + else + { + wp=Waypoint::GetInstance(objManager,x); + } + act=new PathAction; + Q_ASSERT(act); + Q_ASSERT(wp); + Waypoint::DataFields waypoint = wp->getData(); + PathAction::DataFields action = act->getData(); + + ///Waypoint object data + index=myModel->index(x,flightDataModel::DISRELATIVE); + distance=myModel->data(index).toDouble(); + index=myModel->index(x,flightDataModel::BEARELATIVE); + bearing=myModel->data(index).toDouble(); + index=myModel->index(x,flightDataModel::ALTITUDERELATIVE); + altitude=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::VELOCITY); + waypoint.Velocity=myModel->data(index).toFloat(); + + waypoint.Position[Waypoint::POSITION_NORTH]=distance*cos(bearing/180*M_PI); + waypoint.Position[Waypoint::POSITION_EAST]=distance*sin(bearing/180*M_PI); + waypoint.Position[Waypoint::POSITION_DOWN]=(-1.0f)*altitude; + + ///PathAction object data + index=myModel->index(x,flightDataModel::MODE); + action.Mode=myModel->data(index).toInt(); + index=myModel->index(x,flightDataModel::MODE_PARAMS0); + action.ModeParameters[0]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::MODE_PARAMS1); + action.ModeParameters[1]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::MODE_PARAMS2); + action.ModeParameters[2]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::MODE_PARAMS3); + action.ModeParameters[3]=myModel->data(index).toFloat(); + + index=myModel->index(x,flightDataModel::CONDITION); + action.EndCondition=myModel->data(index).toInt(); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS0); + action.ConditionParameters[0]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS1); + action.ConditionParameters[1]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS2); + action.ConditionParameters[2]=myModel->data(index).toFloat(); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS3); + action.ConditionParameters[3]=myModel->data(index).toFloat(); + + index=myModel->index(x,flightDataModel::COMMAND); + action.Command=myModel->data(index).toInt(); + index=myModel->index(x,flightDataModel::JUMPDESTINATION); + action.JumpDestination=myModel->data(index).toInt()-1; + index=myModel->index(x,flightDataModel::ERRORDESTINATION); + action.ErrorDestination=myModel->data(index).toInt()-1; + + int actionNumber=addAction(act,action,lastaction); + if(actionNumber>lastaction) + lastaction=actionNumber; + waypoint.Action=actionNumber; + wp->setData(waypoint); + wp->updated(); + } +} + +void modelUavoProxy::objectsToModel() +{ + Waypoint * wp; + Waypoint::DataFields wpfields; + PathAction * action; + QModelIndex index; + double distance; + double bearing; + + PathAction::DataFields actionfields; + + myModel->removeRows(0,myModel->rowCount()); + for(int x=0;xgetNumInstances(waypointObj->getObjID());++x) + { + wp=Waypoint::GetInstance(objManager,x); + Q_ASSERT(wp); + if(!wp) + continue; + wpfields=wp->getData(); + myModel->insertRow(x); + index=myModel->index(x,flightDataModel::VELOCITY); + myModel->setData(index,wpfields.Velocity); + distance=sqrt(wpfields.Position[Waypoint::POSITION_NORTH]*wpfields.Position[Waypoint::POSITION_NORTH]+ + wpfields.Position[Waypoint::POSITION_EAST]*wpfields.Position[Waypoint::POSITION_EAST]); + bearing=acos(wpfields.Position[Waypoint::POSITION_NORTH]/wpfields.Position[Waypoint::POSITION_EAST])*180/M_PI; + if(bearing!=bearing) + bearing=0; + index=myModel->index(x,flightDataModel::DISRELATIVE); + myModel->setData(index,distance); + index=myModel->index(x,flightDataModel::BEARELATIVE); + myModel->setData(index,bearing); + index=myModel->index(x,flightDataModel::ALTITUDERELATIVE); + myModel->setData(index,(-1.0f)*wpfields.Position[Waypoint::POSITION_DOWN]); + + action=PathAction::GetInstance(objManager,wpfields.Action); + Q_ASSERT(action); + if(!action) + continue; + actionfields=action->getData(); + + index=myModel->index(x,flightDataModel::ISRELATIVE); + myModel->setData(index,true); + + index=myModel->index(x,flightDataModel::COMMAND); + myModel->setData(index,actionfields.Command); + + index=myModel->index(x,flightDataModel::CONDITION_PARAMS0); + myModel->setData(index,actionfields.ConditionParameters[0]); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS1); + myModel->setData(index,actionfields.ConditionParameters[1]); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS2); + myModel->setData(index,actionfields.ConditionParameters[2]); + index=myModel->index(x,flightDataModel::CONDITION_PARAMS3); + myModel->setData(index,actionfields.ConditionParameters[3]); + + index=myModel->index(x,flightDataModel::CONDITION); + myModel->setData(index,actionfields.EndCondition); + + index=myModel->index(x,flightDataModel::ERRORDESTINATION); + myModel->setData(index,actionfields.ErrorDestination+1); + + index=myModel->index(x,flightDataModel::JUMPDESTINATION); + myModel->setData(index,actionfields.JumpDestination+1); + + index=myModel->index(x,flightDataModel::MODE); + myModel->setData(index,actionfields.Mode); + + index=myModel->index(x,flightDataModel::MODE_PARAMS0); + myModel->setData(index,actionfields.ModeParameters[0]); + index=myModel->index(x,flightDataModel::MODE_PARAMS1); + myModel->setData(index,actionfields.ModeParameters[1]); + index=myModel->index(x,flightDataModel::MODE_PARAMS2); + myModel->setData(index,actionfields.ModeParameters[2]); + index=myModel->index(x,flightDataModel::MODE_PARAMS3); + myModel->setData(index,actionfields.ModeParameters[3]); + } +} +int modelUavoProxy::addAction(PathAction * actionObj,PathAction::DataFields actionFields,int lastaction) +{ + //check if a similar action already exhists + int instances=objManager->getNumInstances(pathactionObj->getObjID()); + for(int x=0;xgetData(); + if(fields.Command==actionFields.Command + && fields.ConditionParameters[0]==actionFields.ConditionParameters[0] + && fields.ConditionParameters[1]==actionFields.ConditionParameters[1] + && fields.ConditionParameters[2]==actionFields.ConditionParameters[2] + &&fields.EndCondition==actionFields.EndCondition + &&fields.ErrorDestination==actionFields.ErrorDestination + &&fields.JumpDestination==actionFields.JumpDestination + &&fields.Mode==actionFields.Mode + &&fields.ModeParameters[0]==actionFields.ModeParameters[0] + &&fields.ModeParameters[1]==actionFields.ModeParameters[1] + &&fields.ModeParameters[2]==actionFields.ModeParameters[2]) + { + qDebug()<<"ModelUAVProxy:"<<"found similar action instance:"<deleteLater(); + return x; + } + } + //if we get here it means no similar action was found, we have to create it + if(instancesinitialize(instances,actionObj->getMetaObject()); + objManager->registerObject(actionObj); + actionObj->setData(actionFields); + actionObj->updated(); + qDebug()<<"ModelUAVProxy:"<<"created new action instance:"<setData(actionFields); + action->updated(); + actionObj->deleteLater(); + qDebug()<<"ModelUAVProxy:"<<"reused action instance:"<setupUi(this); -} - -opmap_overlay_widget::~opmap_overlay_widget() -{ - delete ui; -} +/** + ****************************************************************************** + * + * @file modeluavproxy.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 MODELUAVOPROXY_H +#define MODELUAVOPROXY_H + +#include +#include "flightdatamodel.h" +#include "pathaction.h" +#include "waypoint.h" + +class modelUavoProxy:public QObject +{ + Q_OBJECT +public: + explicit modelUavoProxy(QObject *parent, flightDataModel *model); + int addAction(PathAction *actionObj, PathAction::DataFields actionFields,int lastaction); +public slots: + void modelToObjects(); + void objectsToModel(); +private: + UAVObjectManager *objManager; + Waypoint * waypointObj; + PathAction * pathactionObj; + flightDataModel * myModel; +}; + +#endif // MODELUAVOPROXY_H diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap.pro b/ground/openpilotgcs/src/plugins/opmap/opmap.pro index 5bb709d01..6b30dfe97 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap.pro +++ b/ground/openpilotgcs/src/plugins/opmap/opmap.pro @@ -1,46 +1,55 @@ -TEMPLATE = lib -TARGET = OPMapGadget - -include(../../openpilotgcsplugin.pri) -include(../../plugins/coreplugin/coreplugin.pri) -include(../../libs/opmapcontrol/opmapcontrol.pri) -include(../../plugins/uavobjects/uavobjects.pri) -include(../../plugins/uavobjectutil/uavobjectutil.pri) -include(../../plugins/uavtalk/uavtalk.pri) -include(../../libs/utils/utils.pri) - -HEADERS += opmapplugin.h \ - opmapgadgetoptionspage.h \ - opmapgadgetfactory.h \ - opmapgadgetconfiguration.h \ - opmapgadget.h \ - opmapgadgetwidget.h \ -# opmap_waypointeditor_dialog.h \ -# opmap_edit_waypoint_dialog.h \ - opmap_zoom_slider_widget.h \ - opmap_statusbar_widget.h \ - opmap_overlay_widget.h - -SOURCES += opmapplugin.cpp \ - opmapgadgetwidget.cpp \ - opmapgadgetoptionspage.cpp \ - opmapgadgetfactory.cpp \ - opmapgadgetconfiguration.cpp \ - opmapgadget.cpp \ - # opmap_waypointeditor_dialog.cpp \ - # opmap_edit_waypoint_dialog.cpp \ - opmap_zoom_slider_widget.cpp \ - opmap_statusbar_widget.cpp \ - opmap_overlay_widget.cpp - -OTHER_FILES += OPMapGadget.pluginspec - -FORMS += opmapgadgetoptionspage.ui \ - opmap_widget.ui \ - # opmap_waypointeditor_dialog.ui \ - # opmap_edit_waypoint_dialog.ui \ - opmap_zoom_slider_widget.ui \ - opmap_statusbar_widget.ui \ - opmap_overlay_widget.ui - -RESOURCES += opmap.qrc +QT += xml +TEMPLATE = lib +TARGET = OPMapGadget +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../libs/opmapcontrol/opmapcontrol.pri) +include(../../plugins/uavobjects/uavobjects.pri) +include(../../plugins/uavobjectutil/uavobjectutil.pri) +include(../../plugins/uavtalk/uavtalk.pri) +include(../../libs/utils/utils.pri) + +HEADERS += opmapplugin.h \ + opmapgadgetoptionspage.h \ + opmapgadgetfactory.h \ + opmapgadgetconfiguration.h \ + opmapgadget.h \ + opmapgadgetwidget.h \ + opmap_edit_waypoint_dialog.h \ + opmap_zoom_slider_widget.h \ + opmap_statusbar_widget.h \ + flightdatamodel.h \ + modelmapproxy.h \ + widgetdelegates.h \ + pathplanner.h \ + modeluavoproxy.h \ + homeeditor.h + +SOURCES += opmapplugin.cpp \ + opmapgadgetwidget.cpp \ + opmapgadgetoptionspage.cpp \ + opmapgadgetfactory.cpp \ + opmapgadgetconfiguration.cpp \ + opmapgadget.cpp \ + opmap_edit_waypoint_dialog.cpp \ + opmap_zoom_slider_widget.cpp \ + opmap_statusbar_widget.cpp \ + flightdatamodel.cpp \ + modelmapproxy.cpp \ + widgetdelegates.cpp \ + pathplanner.cpp \ + modeluavoproxy.cpp \ + homeeditor.cpp + +OTHER_FILES += OPMapGadget.pluginspec + +FORMS += opmapgadgetoptionspage.ui \ + opmap_widget.ui \ + opmap_edit_waypoint_dialog.ui \ + opmap_zoom_slider_widget.ui \ + opmap_statusbar_widget.ui \ + opmap_overlay_widget.ui \ + pathplanner.ui \ + homeeditor.ui + +RESOURCES += opmap.qrc diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap.qrc b/ground/openpilotgcs/src/plugins/opmap/opmap.qrc index eae9fc9cd..10073e59e 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap.qrc +++ b/ground/openpilotgcs/src/plugins/opmap/opmap.qrc @@ -25,5 +25,16 @@ images/home_wp.png images/move_to_wp.png images/center_wp.png + images/Ekisho Deep Ocean HD1.png + images/forward button white.png + images/new archive.png + images/rewind button white.png + images/stopb.png + images/unarchive.png + images/up_alt.png + images/plus3.png + images/forward_alt.png + images/star.png + images/down_alt.png diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp index c7cbb53b0..cab739b8e 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmap_edit_waypoint_dialog.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -27,131 +27,265 @@ #include "opmap_edit_waypoint_dialog.h" #include "ui_opmap_edit_waypoint_dialog.h" - +#include "opmapcontrol/opmapcontrol.h" +#include "widgetdelegates.h" // ********************************************************************* // constructor -opmap_edit_waypoint_dialog::opmap_edit_waypoint_dialog(QWidget *parent) : - QDialog(parent, Qt::Dialog), +opmap_edit_waypoint_dialog::opmap_edit_waypoint_dialog(QWidget *parent,QAbstractItemModel * model,QItemSelectionModel * selection) : + QWidget(parent,Qt::Window),model(model),itemSelection(selection), ui(new Ui::opmap_edit_waypoint_dialog) -{ +{ ui->setupUi(this); + connect(ui->checkBoxLocked,SIGNAL(toggled(bool)),this,SLOT(enableEditWidgets(bool))); + connect(ui->cbMode,SIGNAL(currentIndexChanged(int)),this,SLOT(setupModeWidgets())); + connect(ui->cbCondition,SIGNAL(currentIndexChanged(int)),this,SLOT(setupConditionWidgets())); + connect(ui->pushButtonApply,SIGNAL(clicked()),this,SLOT(pushButtonApply_clicked())); + connect(ui->pushButtonCancel,SIGNAL(clicked()),this,SLOT(pushButtonCancel_clicked())); + MapDataDelegate::loadComboBox(ui->cbMode,flightDataModel::MODE); + MapDataDelegate::loadComboBox(ui->cbCondition,flightDataModel::CONDITION); + MapDataDelegate::loadComboBox(ui->cbCommand,flightDataModel::COMMAND); + mapper = new QDataWidgetMapper(this); - waypoint_item = NULL; + mapper->setItemDelegate(new MapDataDelegate(this)); + connect(mapper,SIGNAL(currentIndexChanged(int)),this,SLOT(currentIndexChanged(int))); + mapper->setModel(model); + mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); + mapper->addMapping(ui->checkBoxLocked,flightDataModel::LOCKED); + mapper->addMapping(ui->doubleSpinBoxLatitude,flightDataModel::LATPOSITION); + mapper->addMapping(ui->doubleSpinBoxLongitude,flightDataModel::LNGPOSITION); + mapper->addMapping(ui->doubleSpinBoxAltitude,flightDataModel::ALTITUDE); + mapper->addMapping(ui->lineEditDescription,flightDataModel::WPDESCRITPTION); + mapper->addMapping(ui->checkBoxRelative,flightDataModel::ISRELATIVE); + mapper->addMapping(ui->doubleSpinBoxBearing,flightDataModel::BEARELATIVE); + mapper->addMapping(ui->doubleSpinBoxVelocity,flightDataModel::VELOCITY); + mapper->addMapping(ui->doubleSpinBoxDistance,flightDataModel::DISRELATIVE); + mapper->addMapping(ui->doubleSpinBoxRelativeAltitude,flightDataModel::ALTITUDERELATIVE); + mapper->addMapping(ui->cbMode,flightDataModel::MODE); + mapper->addMapping(ui->dsb_modeParam1,flightDataModel::MODE_PARAMS0); + mapper->addMapping(ui->dsb_modeParam2,flightDataModel::MODE_PARAMS1); + mapper->addMapping(ui->dsb_modeParam3,flightDataModel::MODE_PARAMS2); + mapper->addMapping(ui->dsb_modeParam4,flightDataModel::MODE_PARAMS3); + + mapper->addMapping(ui->cbCondition,flightDataModel::CONDITION); + mapper->addMapping(ui->dsb_condParam1,flightDataModel::CONDITION_PARAMS0); + mapper->addMapping(ui->dsb_condParam2,flightDataModel::CONDITION_PARAMS1); + mapper->addMapping(ui->dsb_condParam3,flightDataModel::CONDITION_PARAMS2); + mapper->addMapping(ui->dsb_condParam4,flightDataModel::CONDITION_PARAMS0); + + mapper->addMapping(ui->cbCommand,flightDataModel::COMMAND); + mapper->addMapping(ui->sbJump,flightDataModel::JUMPDESTINATION); + mapper->addMapping(ui->sbError,flightDataModel::ERRORDESTINATION); + connect(itemSelection,SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(currentRowChanged(QModelIndex,QModelIndex))); +} +void opmap_edit_waypoint_dialog::currentIndexChanged(int index) +{ + ui->lbNumber->setText(QString::number(index+1)); + QModelIndex idx=mapper->model()->index(index,0); + if(index==itemSelection->currentIndex().row()) + return; + itemSelection->clear(); + itemSelection->setCurrentIndex(idx,QItemSelectionModel::Select | QItemSelectionModel::Rows); } -// destrutor opmap_edit_waypoint_dialog::~opmap_edit_waypoint_dialog() { delete ui; } -// ********************************************************************* - -void opmap_edit_waypoint_dialog::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - void opmap_edit_waypoint_dialog::on_pushButtonOK_clicked() { - int res = saveSettings(); - if (res < 0) return; - - waypoint_item = NULL; - + mapper->submit(); close(); } -void opmap_edit_waypoint_dialog::on_pushButtonApply_clicked() +void opmap_edit_waypoint_dialog::setupModeWidgets() { - saveSettings(); -} - -void opmap_edit_waypoint_dialog::on_pushButtonRevert_clicked() -{ - ui->checkBoxLocked->setChecked(original_locked); - ui->spinBoxNumber->setValue(original_number); - ui->doubleSpinBoxLatitude->setValue(original_coord.Lat()); - ui->doubleSpinBoxLongitude->setValue(original_coord.Lng()); - ui->doubleSpinBoxAltitude->setValue(original_altitude); - ui->lineEditDescription->setText(original_description); - - saveSettings(); -} - -void opmap_edit_waypoint_dialog::on_pushButtonCancel_clicked() -{ - waypoint_item = NULL; - close(); -} - -// ********************************************************************* - -int opmap_edit_waypoint_dialog::saveSettings() -{ - // ******************** - // fetch the various ui item values - - bool locked = ui->checkBoxLocked->isChecked(); - - int number = ui->spinBoxNumber->value(); - if (number < 0) + MapDataDelegate::ModeOptions mode=(MapDataDelegate::ModeOptions)ui->cbMode->itemData(ui->cbMode->currentIndex()).toInt(); + switch(mode) { - return -1; + case MapDataDelegate::MODE_FLYENDPOINT: + case MapDataDelegate::MODE_FLYVECTOR: + case MapDataDelegate::MODE_FLYCIRCLERIGHT: + case MapDataDelegate::MODE_FLYCIRCLELEFT: + case MapDataDelegate::MODE_DRIVEENDPOINT: + case MapDataDelegate::MODE_DRIVEVECTOR: + case MapDataDelegate::MODE_DRIVECIRCLELEFT: + case MapDataDelegate::MODE_DRIVECIRCLERIGHT: + case MapDataDelegate::MODE_DISARMALARM: + ui->modeParam1->setVisible(false); + ui->modeParam2->setVisible(false); + ui->modeParam3->setVisible(false); + ui->modeParam4->setVisible(false); + ui->dsb_modeParam1->setVisible(false); + ui->dsb_modeParam2->setVisible(false); + ui->dsb_modeParam3->setVisible(false); + ui->dsb_modeParam4->setVisible(false); + break; + case MapDataDelegate::MODE_FIXEDATTITUDE: + ui->modeParam1->setText("pitch"); + ui->modeParam2->setText("roll"); + ui->modeParam3->setText("yaw"); + ui->modeParam4->setText("throttle"); + ui->modeParam1->setVisible(true); + ui->modeParam2->setVisible(true); + ui->modeParam3->setVisible(true); + ui->modeParam4->setVisible(true); + ui->dsb_modeParam1->setVisible(true); + ui->dsb_modeParam2->setVisible(true); + ui->dsb_modeParam3->setVisible(true); + ui->dsb_modeParam4->setVisible(true); + break; + case MapDataDelegate::MODE_SETACCESSORY: + ui->modeParam1->setText("Acc.channel"); + ui->modeParam2->setText("Value"); + ui->modeParam1->setVisible(true); + ui->modeParam2->setVisible(true); + ui->modeParam3->setVisible(false); + ui->modeParam4->setVisible(false); + ui->dsb_modeParam1->setVisible(true); + ui->dsb_modeParam2->setVisible(true); + ui->dsb_modeParam3->setVisible(false); + ui->dsb_modeParam4->setVisible(false); + break; } +} +void opmap_edit_waypoint_dialog::setupConditionWidgets() +{ + MapDataDelegate::EndConditionOptions mode=(MapDataDelegate::EndConditionOptions)ui->cbCondition->itemData(ui->cbCondition->currentIndex()).toInt(); + switch(mode) + { + case MapDataDelegate::ENDCONDITION_NONE: + case MapDataDelegate::ENDCONDITION_IMMEDIATE: + case MapDataDelegate::ENDCONDITION_PYTHONSCRIPT: + ui->condParam1->setVisible(false); + ui->condParam2->setVisible(false); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(false); + ui->dsb_condParam2->setVisible(false); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + break; + case MapDataDelegate::ENDCONDITION_TIMEOUT: + ui->condParam1->setVisible(true); + ui->condParam2->setVisible(false); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(true); + ui->dsb_condParam2->setVisible(false); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + ui->condParam1->setText("Timeout(ms)"); + break; + case MapDataDelegate::ENDCONDITION_DISTANCETOTARGET: + ui->condParam1->setVisible(true); + ui->condParam2->setVisible(true); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(true); + ui->dsb_condParam2->setVisible(true); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + ui->condParam1->setText("Distance(m)"); + ui->condParam2->setText("Flag(0=2D,1=3D)");//FIXME + break; + case MapDataDelegate::ENDCONDITION_LEGREMAINING: + ui->condParam1->setVisible(true); + ui->condParam2->setVisible(false); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(true); + ui->dsb_condParam2->setVisible(false); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + ui->condParam1->setText("Relative Distance(0=complete,1=just starting)"); + break; + case MapDataDelegate::ENDCONDITION_ABOVEALTITUDE: + ui->condParam1->setVisible(true); + ui->condParam2->setVisible(false); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(true); + ui->dsb_condParam2->setVisible(false); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + ui->condParam1->setText("Altitude in meters (negative)"); + break; + case MapDataDelegate::ENDCONDITION_POINTINGTOWARDSNEXT: + ui->condParam1->setVisible(true); + ui->condParam2->setVisible(false); + ui->condParam3->setVisible(false); + ui->condParam4->setVisible(false); + ui->dsb_condParam1->setVisible(true); + ui->dsb_condParam2->setVisible(false); + ui->dsb_condParam3->setVisible(false); + ui->dsb_condParam4->setVisible(false); + ui->condParam1->setText("Degrees variation allowed"); + break; + default: - double latitude = ui->doubleSpinBoxLatitude->value(); - double longitude = ui->doubleSpinBoxLongitude->value(); - - double altitude = ui->doubleSpinBoxAltitude->value(); - - QString description = ui->lineEditDescription->displayText().simplified(); - - // ******************** - // transfer the settings to the actual waypoint - - waypoint_item->SetNumber(number); - waypoint_item->SetCoord(internals::PointLatLng(latitude, longitude)); - waypoint_item->SetAltitude(altitude); - waypoint_item->SetDescription(description); - waypoint_item->setFlag(QGraphicsItem::ItemIsMovable, !locked); - - // ******************** - - return 0; // all ok + break; + } } -// ********************************************************************* -// public functions - +void opmap_edit_waypoint_dialog::pushButtonCancel_clicked() +{ + mapper->revert(); + close(); +} +void opmap_edit_waypoint_dialog::pushButtonApply_clicked() +{ + mapper->submit(); +} void opmap_edit_waypoint_dialog::editWaypoint(mapcontrol::WayPointItem *waypoint_item) { if (!waypoint_item) return; - - this->waypoint_item = waypoint_item; - - original_number = this->waypoint_item->Number(); - original_locked = (this->waypoint_item->flags() & QGraphicsItem::ItemIsMovable) == 0; - original_coord = this->waypoint_item->Coord(); - original_altitude = this->waypoint_item->Altitude(); - original_description = this->waypoint_item->Description().simplified(); - - ui->checkBoxLocked->setChecked(original_locked); - ui->spinBoxNumber->setValue(original_number); - ui->doubleSpinBoxLatitude->setValue(original_coord.Lat()); - ui->doubleSpinBoxLongitude->setValue(original_coord.Lng()); - ui->doubleSpinBoxAltitude->setValue(original_altitude); - ui->lineEditDescription->setText(original_description); - - show(); + if(!isVisible()) + show(); + if(isMinimized()) + showNormal(); + if(!isActiveWindow()) + activateWindow(); + raise(); + setFocus(Qt::OtherFocusReason); + mapper->setCurrentIndex(waypoint_item->Number()); } -// ********************************************************************* +void opmap_edit_waypoint_dialog::on_pushButton_clicked() +{ + mapper->toPrevious(); +} + +void opmap_edit_waypoint_dialog::on_pushButton_2_clicked() +{ + mapper->toNext(); +} + +void opmap_edit_waypoint_dialog::enableEditWidgets(bool value) +{ + QWidget * w; + foreach(QWidget * obj,this->findChildren()) + { + w=qobject_cast(obj); + if(w) + w->setEnabled(!value); + w=qobject_cast(obj); + if(w) + w->setEnabled(!value); + w=qobject_cast(obj); + if(w) + w->setEnabled(!value); + w=qobject_cast(obj); + if(w && w!=ui->checkBoxLocked) + w->setEnabled(!value); + w=qobject_cast(obj); + if(w) + w->setEnabled(!value); + } +} + +void opmap_edit_waypoint_dialog::currentRowChanged(QModelIndex current, QModelIndex previous) +{ + mapper->setCurrentIndex(current.row()); +} diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.h b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.h index 062590fdd..2219de69e 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.h @@ -1,8 +1,8 @@ /** ****************************************************************************** * - * @file opmap_edit_waypoint_dialog.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @file opmap_edit_waypoint_dialog.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -29,18 +29,19 @@ #define OPMAP_EDIT_WAYPOINT_DIALOG_H #include - +#include #include "opmapcontrol/opmapcontrol.h" - +#include "flightdatamodel.h" namespace Ui { class opmap_edit_waypoint_dialog; } +using namespace mapcontrol; -class opmap_edit_waypoint_dialog : public QDialog +class opmap_edit_waypoint_dialog : public QWidget { Q_OBJECT public: - opmap_edit_waypoint_dialog(QWidget *parent = 0); + opmap_edit_waypoint_dialog(QWidget *parent,QAbstractItemModel * model,QItemSelectionModel * selection); ~opmap_edit_waypoint_dialog(); /** @@ -50,29 +51,24 @@ public: */ void editWaypoint(mapcontrol::WayPointItem *waypoint_item); -protected: - void changeEvent(QEvent *e); - private: Ui::opmap_edit_waypoint_dialog *ui; - - int original_number; - bool original_locked; - internals::PointLatLng original_coord; - double original_altitude; - QString original_description; - - mapcontrol::WayPointItem *waypoint_item; - - int saveSettings(); - + QDataWidgetMapper *mapper; + QAbstractItemModel * model; + QItemSelectionModel * itemSelection; private slots: private slots: - void on_pushButtonCancel_clicked(); - void on_pushButtonRevert_clicked(); - void on_pushButtonApply_clicked(); + void currentIndexChanged(int index); + void setupModeWidgets(); + void setupConditionWidgets(); + void pushButtonCancel_clicked(); void on_pushButtonOK_clicked(); + void pushButtonApply_clicked(); + void on_pushButton_clicked(); + void on_pushButton_2_clicked(); + void enableEditWidgets(bool); + void currentRowChanged(QModelIndex,QModelIndex); }; #endif // OPMAP_EDIT_WAYPOINT_DIALOG_H diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.ui b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.ui index 62d228782..13ae47eba 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.ui +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_edit_waypoint_dialog.ui @@ -1,36 +1,27 @@ opmap_edit_waypoint_dialog - + + + false + - Qt::ApplicationModal + Qt::NonModal 0 0 - 500 - 187 + 606 + 420 - + 0 0 - - - 500 - 187 - - - - - 500 - 187 - - OpenPilot GCS Edit Waypoint @@ -38,179 +29,755 @@ :/core/images/openpilot_logo_128.png:/core/images/openpilot_logo_128.png - - true - - - - - - - 0 - 0 - - - - Number - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Latitude - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Longitude - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Altitude - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - meters - - - - - - - - 0 - 0 - - - - Description - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Qt::RightToLeft - - - Locked - - - - - - - 200 - - - - - - - - 0 - 0 - - - - 7 - - - -90.000000000000000 - - - 90.000000000000000 - - - - - - - 7 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - -5000.000000000000000 - - - 5000.000000000000000 - - - - - - - degrees - - - - - - - degrees - - - - + + + + 0 + 0 + + + + 0 + + + + Position + + + + + + + + + 0 + 0 + + + + Latitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + 0 + 0 + + + + Longitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Description + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + 5 + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + 5 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + degrees + + + + + + + degrees + + + + + + + + 0 + 0 + + + + Relative to Home + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + meters + + + + + + + degrees + + + + + + + Bearing + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 2 + + + 360.000000000000000 + + + + + + + + 0 + 0 + + + + Distance + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::LeftToRight + + + Locked + + + + + + + Number + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + + + + + + + + + + + + + + Velocity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 999999999.000000000000000 + + + + + + + + 0 + 0 + + + + Altitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + meters + + + + + + + Relative altitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -999999999.000000000000000 + + + 999999999.000000000000000 + + + + + + + meters + + + + + + + 2 + + + 999999999.000000000000000 + + + + + + + -5000.000000000000000 + + + 5000.000000000000000 + + + + + + + m/s + + + + + + + + + + Mode + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + Qt::LeftToRight + + + Mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 999999999.000000000000000 + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param3 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param4 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 999999999.000000000000000 + + + + + + + 999999999.000000000000000 + + + + + + + 999999999.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + End condition + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + Qt::LeftToRight + + + Condition + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 999999999.000000000000000 + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param3 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + param4 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 999999999.000000000000000 + + + + + + + 999999999.000000000000000 + + + + + + + 999999999.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Command + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + Qt::LeftToRight + + + Command + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Jump Destination + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Error Destination + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + Previous + + + + + + + Next + + + @@ -238,13 +805,6 @@ - - - - Revert - - - diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.cpp index 4a8740794..a4135467d 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmap_statusbar_widget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.h b/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.h index ecb2d6206..705961b48 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_statusbar_widget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmap_statusbar_widget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.cpp b/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.cpp deleted file mode 100644 index 64ce36c23..000000000 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/** - ****************************************************************************** - * - * @file opmap_waypointeditor_dialog.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup OPMapPlugin OpenPilot Map Plugin - * @{ - * @brief The OpenPilot Map plugin - *****************************************************************************/ -/* - * 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 -#include - -#include "opmap_waypointeditor_dialog.h" -#include "ui_opmap_waypointeditor_dialog.h" - -#include "extensionsystem/pluginmanager.h" - -// *************************************************************** -// Waypoint object - -WaypointItem::WaypointItem(QString name, double latitude, double longitude, double height, int time, int hold) : - waypoint_name(name), - latitude_degress(latitude), - longitude_degress(longitude), - height_feet(height), - time_seconds(time), - hold_seconds(hold) -{ - setToolTip(waypoint_name); - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - - pixmap.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png")); -} - -QRectF WaypointItem::boundingRect() const -{ -// return QRectF(-6, -10, 12, 20); - return QRectF(-pixmap.width() / 2, -pixmap.height(), pixmap.width(), pixmap.height()); -} -/* -QPainterPath WaypointItem::shape() const -{ - QPainterPath path; -// path.addEllipse(QPointF(0, 0), 6, 10); - path.addRect(pixmap.rect()); - return path; -} -*/ - void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ -// painter->setPen(Qt::black); -// painter->setBrush(QColor(255, 0, 0, 128)); -// painter->drawEllipse(QPointF(0, 0), 6, 10); - - painter->drawPixmap(-pixmap.width() / 2, -pixmap.height(), pixmap); -} - -void WaypointItem::setPixmap(QPixmap pixmap) -{ - this->pixmap = pixmap.copy(pixmap.rect()); -} - -// *************************************************************** -// Scene object - -OurScene::OurScene(QObject *parent) : QGraphicsScene(parent) -{ - movingItem = 0; -} - -void OurScene::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - QPointF mousePos(event->buttonDownScenePos(Qt::LeftButton).x(), event->buttonDownScenePos(Qt::LeftButton).y()); - - movingItem = itemAt(mousePos.x(), mousePos.y()); - - if (movingItem != 0 && event->button() == Qt::LeftButton) - { - oldPos = movingItem->pos(); - } - - clearSelection(); - - QGraphicsScene::mousePressEvent(event); - } - - void OurScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) - { - if (movingItem != 0 && event->button() == Qt::LeftButton) - { - if (oldPos != movingItem->pos()) - emit itemMoved(qgraphicsitem_cast(movingItem), oldPos); - - movingItem = 0; - } - - QGraphicsScene::mouseReleaseEvent(event); - } - -// *************************************************************** -// main dialogue - -opmap_waypointeditor_dialog::opmap_waypointeditor_dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::opmap_waypointeditor_dialog) -{ - ui->setupUi(this); - setWindowFlags(Qt::Dialog); - - view = ui->graphicsViewWaypointHeightAndTimeline; - - scene = new OurScene(); - scene->setSceneRect(QRect(0, 0, 500, 500)); - view->setScene(scene); - - waypoint_pixmap1.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png")); - waypoint_pixmap2.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png")); - - undoStack = new QUndoStack(); - - connect(scene, SIGNAL(itemMoved(WaypointItem *, const QPointF &)), this, SLOT(itemMoved(WaypointItem *, const QPointF &))); - - // ***** - // test - - WaypointItem *waypoint1 = new WaypointItem(tr("Waypoint 1"), 0, 0, 10, 5, 10); - waypoint1->setPos(scene->width() / 2, scene->height() / 2); - scene->addItem(waypoint1); - - WaypointItem *waypoint2 = new WaypointItem(tr("Waypoint 2"), 0, 0, 50, 8, 5); - waypoint2->setPos(scene->width() / 2 + 30, scene->height() / 2); - scene->addItem(waypoint2); - - WaypointItem *waypoint3 = new WaypointItem(tr("Waypoint 3"), 0, 0, 100, 8, 5); - waypoint3->setPixmap(waypoint_pixmap2); - waypoint3->setPos(scene->width() / 2 + 60, scene->height() / 2); - scene->addItem(waypoint3); - - // ***** -} - -opmap_waypointeditor_dialog::~opmap_waypointeditor_dialog() -{ - delete ui; -} - -void opmap_waypointeditor_dialog::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -void opmap_waypointeditor_dialog::itemMoved(WaypointItem *movedItem, const QPointF &oldPosition) -{ -// undoStack->push(new MoveCommand(movedItem, oldPosition)); -} - -// *************************************************************** diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.h b/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.h deleted file mode 100644 index fd1ae72ea..000000000 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - ****************************************************************************** - * - * @file opmap_waypointeditor_dialog.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup OPMapPlugin OpenPilot Map Plugin - * @{ - * @brief The OpenPilot Map plugin - *****************************************************************************/ -/* - * 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 OPMAP_WAYPOINTEDITOR_DIALOG_H -#define OPMAP_WAYPOINTEDITOR_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uavobjectmanager.h" -#include "positionactual.h" - -namespace Ui { - class opmap_waypointeditor_dialog; -} - -// *************************************************************** -// Waypoint object - -class WaypointItem : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - - public: - WaypointItem(QString name = "", double latitude = 0, double longitude = 0, double height_feet = 0, int time_seconds = 0, int hold_seconds = 0); - - void setPixmap(QPixmap pixmap); - - QString waypoint_name; - double latitude_degress; - double longitude_degress; - double height_feet; - int time_seconds; - int hold_seconds; - - QPixmap pixmap; - - protected: - QRectF boundingRect() const; -// QPainterPath shape() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -// void timerEvent(QTimerEvent *event); - - private: - -}; - -// *************************************************************** - -class OurScene : public QGraphicsScene - { - Q_OBJECT - - public: - OurScene(QObject *parent = 0); - - signals: - void itemMoved(WaypointItem *movedItem, const QPointF &movedFromPosition); - - protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - - private: - QGraphicsItem *movingItem; - QPointF oldPos; - }; - -// *************************************************************** -// main dialog widget - -class opmap_waypointeditor_dialog : public QDialog -{ - Q_OBJECT -public: - opmap_waypointeditor_dialog(QWidget *parent = 0); - ~opmap_waypointeditor_dialog(); - - public slots: - void itemMoved(WaypointItem *movedDiagram, const QPointF &moveStartPosition); - -protected: - void changeEvent(QEvent *e); - -private: - QPixmap waypoint_pixmap1; - QPixmap waypoint_pixmap2; - - QGraphicsView *view; - QGraphicsScene *scene; - - QUndoStack *undoStack; - - Ui::opmap_waypointeditor_dialog *ui; -}; - -// *************************************************************** - -#endif // OPMAP_WAYPOINTEDITOR_DIALOG_H diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.ui b/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.ui deleted file mode 100644 index ea9b65189..000000000 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_waypointeditor_dialog.ui +++ /dev/null @@ -1,248 +0,0 @@ - - - opmap_waypointeditor_dialog - - - - 0 - 0 - 561 - 511 - - - - - 0 - 0 - - - - - 300 - 0 - - - - OpenPilot GCS Waypoint Editor - - - - :/core/images/openpilot_logo_128.png:/core/images/openpilot_logo_128.png - - - true - - - - - - - - QSplitter::handle { -/* image: url(images/splitter.png); */ - background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(255, 255, 255, 80), stop:1 rgba(0, 0, 0, 80)); -} - -QSplitter::handle:horizontal { - height: 5px; -} - -QSplitter::handle:vertical { - width: 5px; -} - - - QFrame::NoFrame - - - Qt::Vertical - - - true - - - 5 - - - false - - - - - 0 - 130 - - - - Waypoints - - - true - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 50 - - - - true - - - false - - - false - - - - Num - - - - - Locked - - - - - Latitude - - - - - Longitude - - - - - Altitude - - - - - Time - - - - - Hold Time - - - - - - - - - Height and Timeline - - - true - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 50 - - - - background-color: rgb(191, 191, 191); - - - QFrame::Sunken - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - - - buttonBox - accepted() - opmap_waypointeditor_dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - opmap_waypointeditor_dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_widget.ui b/ground/openpilotgcs/src/plugins/opmap/opmap_widget.ui index b42b7fe0a..ece39e353 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_widget.ui +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_widget.ui @@ -49,7 +49,7 @@ 16777215 - 16777215 + 40 @@ -357,6 +357,32 @@ border-radius: 2px; + + + + + 8 + + + + Go To Place: + + + + + + + + + + ... + + + + :/opmap/images/waypoint.png:/opmap/images/waypoint.png + + + @@ -370,6 +396,18 @@ border-radius: 2px; + + + + + 8 + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.cpp index e73b054ed..dcbdf6a06 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmap_zoom_slider_widget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.h b/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.h index 83087413e..41b9ff10d 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmap_zoom_slider_widget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmap_zoom_slider_widget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadget.cpp index be2a4e476..a0a92cdc8 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -26,31 +26,50 @@ */ #include "opmapgadget.h" #include "opmapgadgetwidget.h" -#include "opmapgadgetconfiguration.h" OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) : IUAVGadget(classId, parent), - m_widget(widget) + m_widget(widget),m_config(NULL) { + connect(m_widget,SIGNAL(defaultLocationAndZoomChanged(double,double,double)),this,SLOT(saveDefaultLocation(double,double,double))); + connect(m_widget,SIGNAL(overlayOpacityChanged(qreal)),this,SLOT(saveOpacity(qreal))); } OPMapGadget::~OPMapGadget() { delete m_widget; } - -void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config) +void OPMapGadget::saveDefaultLocation(double lng,double lat,double zoom) { - OPMapGadgetConfiguration *m = qobject_cast(config); - - m_widget->setMapProvider(m->mapProvider()); - m_widget->setZoom(m->zoom()); - m_widget->setPosition(QPointF(m->longitude(), m->latitude())); - m_widget->setUseOpenGL(m->useOpenGL()); - m_widget->setShowTileGridLines(m->showTileGridLines()); - m_widget->setAccessMode(m->accessMode()); - m_widget->setUseMemoryCache(m->useMemoryCache()); - m_widget->setCacheLocation(m->cacheLocation()); - m_widget->SetUavPic(m->uavSymbol()); + if(m_config) + { + m_config->setLatitude(lat); + m_config->setLongitude(lng); + m_config->setZoom(zoom); + m_config->saveConfig(); + } +} + +void OPMapGadget::saveOpacity(qreal value) +{ + if(m_config) + { + m_config->setOpacity(value); + } +} +void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config) +{ + m_config = qobject_cast(config); + m_widget->setMapProvider(m_config->mapProvider()); + m_widget->setUseOpenGL(m_config->useOpenGL()); + m_widget->setShowTileGridLines(m_config->showTileGridLines()); + m_widget->setAccessMode(m_config->accessMode()); + m_widget->setUseMemoryCache(m_config->useMemoryCache()); + m_widget->setCacheLocation(m_config->cacheLocation()); + m_widget->SetUavPic(m_config->uavSymbol()); + m_widget->setZoom(m_config->zoom()); + m_widget->setPosition(QPointF(m_config->longitude(), m_config->latitude())); + m_widget->setHomePosition(QPointF(m_config->longitude(), m_config->latitude())); + m_widget->setOverlayOpacity(m_config->opacity()); } diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadget.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadget.h index 030caf986..323e61e5e 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadget.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -30,9 +30,9 @@ #include #include "opmapgadgetwidget.h" +#include "opmapgadgetconfiguration.h" class IUAVGadget; -//class QList; class QWidget; class QString; class OPMapGadgetWidget; @@ -47,10 +47,13 @@ public: ~OPMapGadget(); QWidget *widget() { return m_widget; } - void loadConfiguration(IUAVGadgetConfiguration* config); - + void loadConfiguration(IUAVGadgetConfiguration* m_config); private: OPMapGadgetWidget *m_widget; + OPMapGadgetConfiguration *m_config; +private slots: + void saveOpacity(qreal value); + void saveDefaultLocation(double lng, double lat, double zoom); }; diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.cpp index 67d1d1f98..b9dec0c97 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetconfiguration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -41,7 +41,9 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings* m_useMemoryCache(true), m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator()), m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png")), - m_maxUpdateRate(2000) // ms + m_maxUpdateRate(2000), // ms + m_settings(qSettings), + m_opacity(1) { //if a saved configuration exists load it @@ -59,6 +61,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings* QString uavSymbol=qSettings->value("uavSymbol").toString(); int max_update_rate = qSettings->value("maxUpdateRate").toInt(); + m_opacity=qSettings->value("overlayOpacity",1).toReal(); + if (!mapProvider.isEmpty()) m_mapProvider = mapProvider; m_defaultZoom = zoom; m_defaultLatitude = latitude; @@ -94,10 +98,26 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone() m->m_cacheLocation = m_cacheLocation; m->m_uavSymbol = m_uavSymbol; m->m_maxUpdateRate = m_maxUpdateRate; + m->m_opacity=m_opacity; return m; } - +void OPMapGadgetConfiguration::saveConfig() const { + if(!m_settings) + return; + m_settings->setValue("mapProvider", m_mapProvider); + m_settings->setValue("defaultZoom", m_defaultZoom); + m_settings->setValue("defaultLatitude", m_defaultLatitude); + m_settings->setValue("defaultLongitude", m_defaultLongitude); + m_settings->setValue("useOpenGL", m_useOpenGL); + m_settings->setValue("showTileGridLines", m_showTileGridLines); + m_settings->setValue("accessMode", m_accessMode); + m_settings->setValue("useMemoryCache", m_useMemoryCache); + m_settings->setValue("uavSymbol", m_uavSymbol); + m_settings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation)); + m_settings->setValue("maxUpdateRate", m_maxUpdateRate); + m_settings->setValue("overlayOpacity",m_opacity); +} void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const { qSettings->setValue("mapProvider", m_mapProvider); qSettings->setValue("defaultZoom", m_defaultZoom); @@ -110,6 +130,7 @@ void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const { qSettings->setValue("uavSymbol", m_uavSymbol); qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation)); qSettings->setValue("maxUpdateRate", m_maxUpdateRate); + qSettings->setValue("overlayOpacity",m_opacity); } void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation){ m_cacheLocation = cacheLocation; diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.h index 1e630dc00..9a8a9bd75 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetconfiguration.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetconfiguration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -48,6 +48,7 @@ Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache) Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation) Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol) Q_PROPERTY(int maxUpdateRate READ maxUpdateRate WRITE setMaxUpdateRate) +Q_PROPERTY(qreal overlayOpacity READ opacity WRITE setOpacity) public: explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); @@ -65,12 +66,14 @@ public: bool useMemoryCache() const { return m_useMemoryCache; } QString cacheLocation() const { return m_cacheLocation; } QString uavSymbol() const { return m_uavSymbol; } - int maxUpdateRate() const { return m_maxUpdateRate; } - + int maxUpdateRate() const { return m_maxUpdateRate; } + qreal opacity() const { return m_opacity; } + void saveConfig() const; public slots: void setMapProvider(QString provider) { m_mapProvider = provider; } void setZoom(int zoom) { m_defaultZoom = zoom; } void setLatitude(double latitude) { m_defaultLatitude = latitude; } + void setOpacity(qreal value) { m_opacity = value; } void setLongitude(double longitude) { m_defaultLongitude = longitude; } void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; } void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; } @@ -92,6 +95,8 @@ private: QString m_cacheLocation; QString m_uavSymbol; int m_maxUpdateRate; + QSettings * m_settings; + qreal m_opacity; }; #endif // OPMAP_GADGETCONFIGURATION_H diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.cpp index 5a3908c89..fb4b73efa 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetfactory.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.h index 4caf96e84..138efcb90 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetfactory.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetfactory.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.cpp index 2136a24d0..92d676e10 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetoptionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.h index 1deb13617..85a9433db 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetoptionspage.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetoptionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp index abc51de20..b5fb5b273 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetwidget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -45,9 +45,16 @@ #include "utils/worldmagmodel.h" #include "uavtalk/telemetrymanager.h" +#include "uavobject.h" +#include "uavobjectmanager.h" #include "positionactual.h" #include "homelocation.h" +#include "gpsposition.h" +#include "gyros.h" +#include "attitudeactual.h" +#include "positionactual.h" +#include "velocityactual.h" #define allow_manual_home_location_move @@ -97,7 +104,7 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_map_mode = Normal_MapMode; - m_maxUpdateRate = max_update_rate_list[4]; // 2 seconds + m_maxUpdateRate = max_update_rate_list[4]; // 2 seconds //SHOULDN'T THIS BE LOADED FROM THE USER PREFERENCES? m_telemetry_connected = false; @@ -131,17 +138,6 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_home_position.altitude = altitude; m_home_position.locked = false; - // ************** - // default magic waypoint params - - m_magic_waypoint.map_wp_item = NULL; - m_magic_waypoint.coord = m_home_position.coord; - m_magic_waypoint.altitude = altitude; - m_magic_waypoint.description = "Magic waypoint"; - m_magic_waypoint.locked = false; - m_magic_waypoint.time_seconds = 0; - m_magic_waypoint.hold_time_seconds = 0; - // ************** // create the widget that holds the user controls and the map @@ -170,21 +166,23 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_map->SetShowHome(true); // display the HOME position on the map m_map->SetShowUAV(true); // display the UAV position on the map - m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters) - m_map->Home->SetShowSafeArea(true); // show the safe area + m_map->Home->SetSafeArea(safe_area_radius_list[0]); // set radius (meters) //SHOULDN'T THE DEFAULT BE USER DEFINED? + m_map->Home->SetShowSafeArea(true); // show the safe area //SHOULDN'T THE DEFAULT BE USER DEFINED? + m_map->Home->SetToggleRefresh(true); + if(m_map->Home) + connect(m_map->Home,SIGNAL(homedoubleclick(HomeItem*)),this,SLOT(onHomeDoubleClick(HomeItem*))); m_map->UAV->SetTrailTime(uav_trail_time_list[0]); // seconds m_map->UAV->SetTrailDistance(uav_trail_distance_list[1]); // meters m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed); -// m_map->UAV->SetTrailType(UAVTrailType::ByDistance); - - m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds - m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters - - m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed); -// m_map->GPS->SetTrailType(UAVTrailType::ByDistance); + if(m_map->GPS) + { + m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds + m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters + m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed); + } // ************** setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -195,81 +193,44 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) layout->addWidget(m_map); m_widget->mapWidget->setLayout(layout); - // ************** - // set the user control options - - // TODO: this switch does not make sense, does it?? - - switch (m_map_mode) - { - case Normal_MapMode: m_widget->toolButtonMagicWaypointMapMode->setChecked(false); m_widget->toolButtonNormalMapMode->setChecked(true); hideMagicWaypointControls(); - break; - - case MagicWaypoint_MapMode: - m_widget->toolButtonNormalMapMode->setChecked(false); - m_widget->toolButtonMagicWaypointMapMode->setChecked(true); - showMagicWaypointControls(); - break; - - default: - m_map_mode = Normal_MapMode; - m_widget->toolButtonMagicWaypointMapMode->setChecked(false); - m_widget->toolButtonNormalMapMode->setChecked(true); - hideMagicWaypointControls(); - break; - } m_widget->labelUAVPos->setText("---"); m_widget->labelMapPos->setText("---"); m_widget->labelMousePos->setText("---"); m_widget->labelMapZoom->setText("---"); - - // Splitter is not used at the moment: - // m_widget->splitter->setCollapsible(1, false); - - // set the size of the collapsable widgets - //QList m_SizeList; - //m_SizeList << 0 << 0 << 0; - //m_widget->splitter->setSizes(m_SizeList); - m_widget->progressBarMap->setMaximum(1); -/* - #if defined(Q_OS_MAC) - #elif defined(Q_OS_WIN) - m_widget->comboBoxFindPlace->clear(); - loadComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt"); - m_widget->comboBoxFindPlace->setCurrentIndex(-1); - #else - #endif -*/ - - - // ************** - // map stuff - connect(m_map, SIGNAL(zoomChanged(double, double, double)), this, SLOT(zoomChanged(double, double, double))); // map zoom change signals connect(m_map, SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)), this, SLOT(OnCurrentPositionChanged(internals::PointLatLng))); // map poisition change signals connect(m_map, SIGNAL(OnTileLoadComplete()), this, SLOT(OnTileLoadComplete())); // tile loading stop signals connect(m_map, SIGNAL(OnTileLoadStart()), this, SLOT(OnTileLoadStart())); // tile loading start signals - connect(m_map, SIGNAL(OnMapDrag()), this, SLOT(OnMapDrag())); // map drag signals - connect(m_map, SIGNAL(OnMapZoomChanged()), this, SLOT(OnMapZoomChanged())); // map zoom changed - connect(m_map, SIGNAL(OnMapTypeChanged(MapType::Types)), this, SLOT(OnMapTypeChanged(MapType::Types))); // map type changed - connect(m_map, SIGNAL(OnEmptyTileError(int, core::Point)), this, SLOT(OnEmptyTileError(int, core::Point))); // tile error connect(m_map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(OnTilesStillToLoad(int))); // tile loading signals - connect(m_map, SIGNAL(WPNumberChanged(int const&,int const&,WayPointItem*)), this, SLOT(WPNumberChanged(int const&,int const&,WayPointItem*))); - connect(m_map, SIGNAL(WPValuesChanged(WayPointItem*)), this, SLOT(WPValuesChanged(WayPointItem*))); - connect(m_map, SIGNAL(WPInserted(int const&, WayPointItem*)), this, SLOT(WPInserted(int const&, WayPointItem*))); - connect(m_map, SIGNAL(WPDeleted(int const&)), this, SLOT(WPDeleted(int const&))); - + connect(m_map,SIGNAL(OnWayPointDoubleClicked(WayPointItem*)),this,SLOT(wpDoubleClickEvent(WayPointItem*))); m_map->SetCurrentPosition(m_home_position.coord); // set the map position m_map->Home->SetCoord(m_home_position.coord); // set the HOME position m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position - m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position + m_map->UAV->update(); + if(m_map->GPS) + m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the GPS position +#ifdef USE_PATHPLANNER + model=new flightDataModel(this); + table=new pathPlanner(); + selectionModel=new QItemSelectionModel(model); + mapProxy=new modelMapProxy(this,m_map,model,selectionModel); + table->setModel(model,selectionModel); + waypoint_edit_dialog=new opmap_edit_waypoint_dialog(this,model,selectionModel); + UAVProxy=new modelUavoProxy(this,model); + connect(table,SIGNAL(sendPathPlanToUAV()),UAVProxy,SLOT(modelToObjects())); + connect(table,SIGNAL(receivePathPlanFromUAV()),UAVProxy,SLOT(objectsToModel())); +#endif + magicWayPoint=m_map->magicWPCreate(); + magicWayPoint->setVisible(false); + + m_map->setOverlayOpacity(0.5); // ************** // create various context menu (mouse right click menu) actions @@ -310,10 +271,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) m_statusUpdateTimer = new QTimer(); m_statusUpdateTimer->setInterval(200); -// m_statusUpdateTimer->setInterval(m_maxUpdateRate); connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos())); m_statusUpdateTimer->start(); - // ************** m_map->setFocus(); @@ -329,34 +288,23 @@ OPMapGadgetWidget::~OPMapGadgetWidget() m_map->SetShowUAV(false); // " " } - - // this destructor doesn't appear to be called at shutdown??? - -// #if defined(Q_OS_MAC) -// #elif defined(Q_OS_WIN) -// saveComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt"); -// #else -// #endif - - m_waypoint_list_mutex.lock(); - foreach (t_waypoint *wp, m_waypoint_list) - { - if (!wp) continue; - - - // todo: - - - delete wp->map_wp_item; - } - m_waypoint_list_mutex.unlock(); - m_waypoint_list.clear(); - if (m_map) { delete m_map; m_map = NULL; } + if(!model.isNull()) + delete model; + if(!table.isNull()) + delete table; + if(!selectionModel.isNull()) + delete selectionModel; + if(!mapProxy.isNull()) + delete mapProxy; + if(!waypoint_edit_dialog.isNull()) + delete waypoint_edit_dialog; + if(!UAVProxy.isNull()) + delete UAVProxy; } // ************************************************************************************* @@ -364,48 +312,46 @@ OPMapGadgetWidget::~OPMapGadgetWidget() void OPMapGadgetWidget::resizeEvent(QResizeEvent *event) { - qDebug("opmap: resizeEvent"); - QWidget::resizeEvent(event); } void OPMapGadgetWidget::mouseMoveEvent(QMouseEvent *event) { - qDebug("opmap: mouseMoveEvent"); - if (m_widget && m_map) { } if (event->buttons() & Qt::LeftButton) { -// QPoint pos = event->pos(); } - QWidget::mouseMoveEvent(event); } +void OPMapGadgetWidget::wpDoubleClickEvent(WayPointItem *wp) +{ + m_mouse_waypoint = wp; + onEditWayPointAct_triggered(); +} void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) { // the user has right clicked on the map - create the pop-up context menu and display it QString s; - if (!m_widget || !m_map) - return; + if (!m_widget || !m_map) + return; if (event->reason() != QContextMenuEvent::Mouse) return; // not a mouse click event // current mouse position QPoint p = m_map->mapFromGlobal(event->globalPos()); - m_context_menu_lat_lon = m_map->GetFromLocalToLatLng(p); -// m_context_menu_lat_lon = m_map->currentMousePosition(); + m_context_menu_lat_lon = m_map->GetFromLocalToLatLng(p); if (!m_map->contentsRect().contains(p)) return; // the mouse click was not on the map // show the mouse position - s = QString::number(m_context_menu_lat_lon.Lat(), 'f', 7) + " " + QString::number(m_context_menu_lat_lon.Lng(), 'f', 7); + s = QString::number(m_context_menu_lat_lon.Lat(), 'f', 7) + " " + QString::number(m_context_menu_lat_lon.Lng(), 'f', 7); m_widget->labelMousePos->setText(s); // find out if we have a waypoint under the mouse cursor @@ -420,22 +366,19 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) // **************** // Dynamically create the popup menu - QMenu menu(this); + contextMenu.addAction(closeAct1); + contextMenu.addSeparator(); + contextMenu.addAction(reloadAct); + contextMenu.addSeparator(); + contextMenu.addAction(ripAct); + contextMenu.addSeparator(); - menu.addAction(closeAct1); + QMenu maxUpdateRateSubMenu(tr("&Max Update Rate ") + "(" + QString::number(m_maxUpdateRate) + " ms)", this); + for (int i = 0; i < maxUpdateRateAct.count(); i++) + maxUpdateRateSubMenu.addAction(maxUpdateRateAct.at(i)); + contextMenu.addMenu(&maxUpdateRateSubMenu); - menu.addSeparator(); - - menu.addAction(reloadAct); - - menu.addSeparator(); - - QMenu maxUpdateRateSubMenu(tr("&Max Update Rate ") + "(" + QString::number(m_maxUpdateRate) + " ms)", this); - for (int i = 0; i < maxUpdateRateAct.count(); i++) - maxUpdateRateSubMenu.addAction(maxUpdateRateAct.at(i)); - menu.addMenu(&maxUpdateRateSubMenu); - - menu.addSeparator(); + contextMenu.addSeparator(); switch (m_map_mode) { @@ -453,185 +396,154 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) QMenu mapModeSubMenu(tr("Map mode") + s, this); for (int i = 0; i < mapModeAct.count(); i++) mapModeSubMenu.addAction(mapModeAct.at(i)); - menu.addMenu(&mapModeSubMenu); + contextMenu.addMenu(&mapModeSubMenu); - menu.addSeparator(); + contextMenu.addSeparator(); QMenu copySubMenu(tr("Copy"), this); copySubMenu.addAction(copyMouseLatLonToClipAct); copySubMenu.addAction(copyMouseLatToClipAct); copySubMenu.addAction(copyMouseLonToClipAct); - menu.addMenu(©SubMenu); + contextMenu.addMenu(©SubMenu); - menu.addSeparator(); + contextMenu.addSeparator(); + contextMenu.addAction(changeDefaultLocalAndZoom); + contextMenu.addSeparator(); - /* - menu.addAction(findPlaceAct); - - menu.addSeparator(); - */ - - menu.addAction(showSafeAreaAct); + QMenu safeArea("Safety Area definitions"); + // menu.addAction(showSafeAreaAct); QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this); for (int i = 0; i < safeAreaAct.count(); i++) safeAreaSubMenu.addAction(safeAreaAct.at(i)); - menu.addMenu(&safeAreaSubMenu); + safeArea.addMenu(&safeAreaSubMenu); + safeArea.addAction(showSafeAreaAct); + contextMenu.addMenu(&safeArea); - menu.addSeparator(); + contextMenu.addSeparator(); - menu.addAction(showCompassAct); + contextMenu.addAction(showCompassAct); - menu.addAction(showDiagnostics); + contextMenu.addAction(showDiagnostics); - menu.addSeparator()->setText(tr("Zoom")); + contextMenu.addAction(showUAVInfo); - menu.addAction(zoomInAct); - menu.addAction(zoomOutAct); + contextMenu.addSeparator()->setText(tr("Zoom")); + + contextMenu.addAction(zoomInAct); + contextMenu.addAction(zoomOutAct); QMenu zoomSubMenu(tr("&Zoom ") + "(" + QString::number(m_map->ZoomTotal()) + ")", this); for (int i = 0; i < zoomAct.count(); i++) zoomSubMenu.addAction(zoomAct.at(i)); - menu.addMenu(&zoomSubMenu); + contextMenu.addMenu(&zoomSubMenu); - menu.addSeparator(); + contextMenu.addSeparator(); - menu.addAction(goMouseClickAct); + contextMenu.addAction(goMouseClickAct); - menu.addSeparator()->setText(tr("HOME")); + contextMenu.addSeparator()->setText(tr("HOME")); - menu.addAction(setHomeAct); - menu.addAction(showHomeAct); - menu.addAction(goHomeAct); + contextMenu.addAction(setHomeAct); + contextMenu.addAction(showHomeAct); + contextMenu.addAction(goHomeAct); // **** // uav trails - - menu.addSeparator()->setText(tr("UAV Trail")); - + QMenu uav_menu(tr("UAV")); + uav_menu.addSeparator()->setText(tr("UAV Trail")); + contextMenu.addMenu(&uav_menu); QMenu uavTrailTypeSubMenu(tr("UAV trail type") + " (" + mapcontrol::Helper::StrFromUAVTrailType(m_map->UAV->GetTrailType()) + ")", this); for (int i = 0; i < uavTrailTypeAct.count(); i++) uavTrailTypeSubMenu.addAction(uavTrailTypeAct.at(i)); - menu.addMenu(&uavTrailTypeSubMenu); + uav_menu.addMenu(&uavTrailTypeSubMenu); QMenu uavTrailTimeSubMenu(tr("UAV trail time") + " (" + QString::number(m_map->UAV->TrailTime()) + " sec)", this); for (int i = 0; i < uavTrailTimeAct.count(); i++) uavTrailTimeSubMenu.addAction(uavTrailTimeAct.at(i)); - menu.addMenu(&uavTrailTimeSubMenu); + uav_menu.addMenu(&uavTrailTimeSubMenu); QMenu uavTrailDistanceSubMenu(tr("UAV trail distance") + " (" + QString::number(m_map->UAV->TrailDistance()) + " meters)", this); for (int i = 0; i < uavTrailDistanceAct.count(); i++) uavTrailDistanceSubMenu.addAction(uavTrailDistanceAct.at(i)); - menu.addMenu(&uavTrailDistanceSubMenu); + uav_menu.addMenu(&uavTrailDistanceSubMenu); - menu.addAction(showTrailAct); + uav_menu.addAction(showTrailAct); - menu.addAction(showTrailLineAct); + uav_menu.addAction(showTrailLineAct); - menu.addAction(clearUAVtrailAct); + uav_menu.addAction(clearUAVtrailAct); // **** - menu.addSeparator()->setText(tr("UAV")); + uav_menu.addSeparator()->setText(tr("UAV")); - menu.addAction(showUAVAct); - menu.addAction(followUAVpositionAct); - menu.addAction(followUAVheadingAct); - menu.addAction(goUAVAct); + uav_menu.addAction(showUAVAct); + uav_menu.addAction(followUAVpositionAct); + uav_menu.addAction(followUAVheadingAct); + uav_menu.addAction(goUAVAct); // ********* - +#ifdef USE_PATHPLANNER switch (m_map_mode) { case Normal_MapMode: // only show the waypoint stuff if not in 'magic waypoint' mode - /* - menu.addSeparator()->setText(tr("Waypoints")); - menu.addAction(wayPointEditorAct); - menu.addAction(addWayPointAct); + contextMenu.addSeparator()->setText(tr("Waypoints")); + + contextMenu.addAction(wayPointEditorAct); + contextMenu.addAction(addWayPointActFromContextMenu); if (m_mouse_waypoint) { // we have a waypoint under the mouse - menu.addAction(editWayPointAct); + contextMenu.addAction(editWayPointAct); lockWayPointAct->setChecked(waypoint_locked); - menu.addAction(lockWayPointAct); + contextMenu.addAction(lockWayPointAct); if (!waypoint_locked) - menu.addAction(deleteWayPointAct); + contextMenu.addAction(deleteWayPointAct); } - m_waypoint_list_mutex.lock(); - if (m_waypoint_list.count() > 0) - menu.addAction(clearWayPointsAct); // we have waypoints - m_waypoint_list_mutex.unlock(); - */ + if (m_map->WPPresent()) + contextMenu.addAction(clearWayPointsAct); // we have waypoints break; case MagicWaypoint_MapMode: - menu.addSeparator()->setText(tr("Waypoints")); - menu.addAction(homeMagicWaypointAct); + contextMenu.addSeparator()->setText(tr("Waypoints")); + contextMenu.addAction(homeMagicWaypointAct); break; } - +#endif // ********* - menu.addSeparator(); + QMenu overlaySubMenu(tr("&Overlay Opacity "),this); + for (int i = 0; i < overlayOpacityAct.count(); i++) + overlaySubMenu.addAction(overlayOpacityAct.at(i)); + contextMenu.addMenu(&overlaySubMenu); + contextMenu.addSeparator(); - menu.addAction(closeAct2); + contextMenu.addAction(closeAct2); - menu.exec(event->globalPos()); // popup the menu + contextMenu.exec(event->globalPos()); // popup the menu // **************** } -void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) +void OPMapGadgetWidget::closeEvent(QCloseEvent *event) { - qDebug() << "opmap: keyPressEvent, key =" << event->key() << endl; - - switch (event->key()) - { - case Qt::Key_Escape: - break; - - case Qt::Key_F1: - break; - - case Qt::Key_F2: - break; - - case Qt::Key_Up: - break; - - case Qt::Key_Down: - break; - - case Qt::Key_Left: - break; - - case Qt::Key_Right: - break; - - case Qt::Key_PageUp: - break; - - case Qt::Key_PageDown: - break; - } + table->close(); + QWidget::closeEvent(event); } // ************************************************************************************* // timer signals /** - Updates the UAV position on the map. It is called every 200ms - by a timer. - - TODO: consider updating upon object update, not timer. - - from Pip: No don't update on object update - had reports that peoples PC's can't cope with high update rates - have had to allow user to set map update from 100ms to 5 seconds (depending on their PC's graphics processing ability), so this needs to be kept on a timer. - */ + Updates the UAV position on the map. It is called at a user-defined frequency, + as set inside the map widget. +*/ void OPMapGadgetWidget::updatePosition() { double uav_latitude, uav_longitude, uav_altitude, uav_yaw; @@ -644,10 +556,6 @@ void OPMapGadgetWidget::updatePosition() return; QMutexLocker locker(&m_map_mutex); -// Pip I'm sorry, I know this was here with a purpose vvv -// from Pip: let you off :) - //if (!telemetry_connected) - // return; // ************* // get the current UAV details @@ -662,19 +570,50 @@ void OPMapGadgetWidget::updatePosition() uav_pos = internals::PointLatLng(uav_latitude, uav_longitude); // ************* - // get the current GPS details + // get the current GPS position and heading + GPSPosition *gpsPositionObj = GPSPosition::GetInstance(obm); + Q_ASSERT(gpsPositionObj); - // get current GPS position - if (!getGPSPosition(gps_latitude, gps_longitude, gps_altitude)) - return; + GPSPosition::DataFields gpsPositionData = gpsPositionObj->getData(); - // get current GPS heading -// gps_heading = getGPS_Heading(); - gps_heading = 0; + gps_heading = gpsPositionData.Heading; + gps_latitude = gpsPositionData.Latitude; + gps_longitude = gpsPositionData.Longitude; + gps_altitude = gpsPositionData.Altitude; gps_pos = internals::PointLatLng(gps_latitude, gps_longitude); - // ************* + //********************** + // get the current position and heading estimates + AttitudeActual *attitudeActualObj = AttitudeActual::GetInstance(obm); + PositionActual *positionActualObj = PositionActual::GetInstance(obm); + VelocityActual *velocityActualObj = VelocityActual::GetInstance(obm); + Gyros *gyrosObj = Gyros::GetInstance(obm); + + Q_ASSERT(positionActualObj); + Q_ASSERT(velocityActualObj); + Q_ASSERT(gyrosObj); + + AttitudeActual::DataFields attitudeActualData = attitudeActualObj->getData(); + PositionActual::DataFields positionActualData = positionActualObj->getData(); + VelocityActual::DataFields velocityActualData = velocityActualObj->getData(); + Gyros::DataFields gyrosData = gyrosObj->getData(); + + double NED[3]={positionActualData.North, positionActualData.East, positionActualData.Down}; + double vNED[3]={velocityActualData.North, velocityActualData.East, velocityActualData.Down}; + + //Set the position and heading estimates in the painter module + m_map->UAV->SetNED(NED); + m_map->UAV->SetCAS(-1); //THIS NEEDS TO BECOME AIRSPEED, ONCE WE SETTLE ON A UAVO + m_map->UAV->SetGroundspeed(vNED, m_maxUpdateRate); + + //Convert angular velocities into a rotationg rate around the world-frame yaw axis. This is found by simply taking the dot product of the angular Euler-rate matrix with the angular rates. + float psiRate_dps=0*gyrosData.z + sin(attitudeActualData.Roll*deg_to_rad)/cos(attitudeActualData.Pitch*deg_to_rad)*gyrosData.y + cos(attitudeActualData.Roll*deg_to_rad)/cos(attitudeActualData.Pitch*deg_to_rad)*gyrosData.z; + + //Set the angular rate in the painter module + m_map->UAV->SetYawRate(psiRate_dps); //Not correct, but I'm being lazy right now. + + // ************* // display the UAV position QString str = @@ -694,10 +633,13 @@ void OPMapGadgetWidget::updatePosition() // ************* // set the GPS icon position on the map - - m_map->GPS->SetUAVPos(gps_pos, gps_altitude); // set the maps GPS position - m_map->GPS->SetUAVHeading(gps_heading); // set the maps GPS heading - + if(m_map->GPS) + { + m_map->GPS->SetUAVPos(gps_pos, gps_altitude); // set the maps GPS position + m_map->GPS->SetUAVHeading(gps_heading); // set the maps GPS heading + } + m_map->UAV->updateTextOverlay(); + m_map->UAV->update(); // ************* } @@ -714,7 +656,7 @@ void OPMapGadgetWidget::updateMousePos() QPoint p = m_map->mapFromGlobal(QCursor::pos()); internals::PointLatLng lat_lon = m_map->GetFromLocalToLatLng(p); // fetch the current lat/lon mouse position - + lastLatLngMouse=lat_lon; if (!m_map->contentsRect().contains(p)) return; // the mouse is not on the map @@ -725,9 +667,6 @@ void OPMapGadgetWidget::updateMousePos() // find out if we are over the home position mapcontrol::HomeItem *home = qgraphicsitem_cast(item); - // find out if we are over the UAV - mapcontrol::UAVItem *uav = qgraphicsitem_cast(item); - // find out if we have a waypoint under the mouse cursor mapcontrol::WayPointItem *wp = qgraphicsitem_cast(item); @@ -741,7 +680,7 @@ void OPMapGadgetWidget::updateMousePos() QString s = QString::number(m_mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(m_mouse_lat_lon.Lng(), 'f', 7); if (wp) { - s += " wp[" + QString::number(wp->Number()) + "]"; + s += " wp[" + QString::number(wp->numberAdjusted()) + "]"; double dist = distance(home_lat_lon, wp->Coord()); double bear = bearing(home_lat_lon, wp->Coord()); @@ -758,24 +697,6 @@ void OPMapGadgetWidget::updateMousePos() s += " " + QString::number(dist * 1000, 'f', 1) + "m"; s += " " + QString::number(bear, 'f', 1) + "deg"; } - else - if (uav) - { - s += " uav"; - - double latitude; - double longitude; - double altitude; - if (getUAVPosition(latitude, longitude, altitude)) // get current UAV position - { - internals::PointLatLng uav_pos = internals::PointLatLng(latitude, longitude); - -// double dist = distance(home_lat_lon, uav_pos); -// double bear = bearing(home_lat_lon, uav_pos); -// s += " " + QString::number(dist * 1000, 'f', 1) + "m"; -// s += " " + QString::number(bear, 'f', 1) + "deg"; - } - } m_widget->labelMousePos->setText(s); } @@ -805,11 +726,7 @@ void OPMapGadgetWidget::zoomChanged(double zoomt, double zoom, double zoomd) int index0_zoom = i_zoom - m_min_zoom; // zoom level starting at index level '0' if (index0_zoom < zoomAct.count()) - zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level -} - -void OPMapGadgetWidget::OnMapDrag() -{ + zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level } void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point) @@ -829,16 +746,11 @@ void OPMapGadgetWidget::OnTilesStillToLoad(int number) if (!m_widget || !m_map) return; -// if (prev_tile_number < number || m_widget->progressBarMap->maximum() < number) -// m_widget->progressBarMap->setMaximum(number); - if (m_widget->progressBarMap->maximum() < number) m_widget->progressBarMap->setMaximum(number); m_widget->progressBarMap->setValue(m_widget->progressBarMap->maximum() - number); // update the progress bar -// m_widget->labelNumTilesToLoad->setText(QString::number(number)); - m_prev_tile_number = number; } @@ -849,7 +761,6 @@ void OPMapGadgetWidget::OnTileLoadStart() { if (!m_widget || !m_map) return; - m_widget->progressBarMap->setVisible(true); } @@ -867,84 +778,6 @@ void OPMapGadgetWidget::OnTileLoadComplete() m_widget->progressBarMap->setVisible(false); } -void OPMapGadgetWidget::OnMapZoomChanged() -{ -} - -void OPMapGadgetWidget::OnMapTypeChanged(MapType::Types type) -{ - Q_UNUSED(type); -} - -void OPMapGadgetWidget::OnEmptyTileError(int zoom, core::Point pos) -{ - Q_UNUSED(zoom); - Q_UNUSED(pos); -} - -void OPMapGadgetWidget::WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint) -{ - Q_UNUSED(oldnumber); - Q_UNUSED(newnumber); - Q_UNUSED(waypoint); -} - -void OPMapGadgetWidget::WPValuesChanged(WayPointItem *waypoint) -{ -// qDebug("opmap: WPValuesChanged"); - - switch (m_map_mode) - { - case Normal_MapMode: - m_waypoint_list_mutex.lock(); - foreach (t_waypoint *wp, m_waypoint_list) - { // search for the waypoint in our own waypoint list and update it - if (!wp) continue; - if (!wp->map_wp_item) continue; - if (wp->map_wp_item != waypoint) continue; - // found the waypoint in our list - wp->coord = waypoint->Coord(); - wp->altitude = waypoint->Altitude(); - wp->description = waypoint->Description(); - break; - } - m_waypoint_list_mutex.unlock(); - break; - - case MagicWaypoint_MapMode: - // update our copy of the magic waypoint - if (m_magic_waypoint.map_wp_item && m_magic_waypoint.map_wp_item == waypoint) - { - m_magic_waypoint.coord = waypoint->Coord(); - m_magic_waypoint.altitude = waypoint->Altitude(); - m_magic_waypoint.description = waypoint->Description(); - - // move the UAV to the magic waypoint position - // moveToMagicWaypointPosition(); - } - break; - } - -} - -/** - TODO: slot to do something upon Waypoint insertion - */ -void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint) -{ - Q_UNUSED(number); - Q_UNUSED(waypoint); -} - -/** - TODO: slot to do something upon Waypoint deletion - */ -void OPMapGadgetWidget::WPDeleted(int const &number) -{ - Q_UNUSED(number); -} - - void OPMapGadgetWidget::on_toolButtonZoomP_clicked() { QMutexLocker locker(&m_map_mutex); @@ -1030,7 +863,7 @@ void OPMapGadgetWidget::onTelemetryConnect() if (obum->getHomeLocation(set, LLA) < 0) return; // error - setHome(internals::PointLatLng(LLA[0], LLA[1])); + setHome(internals::PointLatLng(LLA[0], LLA[1]),LLA[2]); if (m_map) m_map->SetCurrentPosition(m_home_position.coord); // set the map position @@ -1046,12 +879,14 @@ void OPMapGadgetWidget::onTelemetryDisconnect() // Updates the Home position icon whenever the HomePosition object is updated void OPMapGadgetWidget::homePositionUpdated(UAVObject *hp) { - if (!hp) - return; + Q_UNUSED(hp); + if (!obum) return; + bool set; + double LLA[3]; + if (obum->getHomeLocation(set, LLA) < 0) + return; // error + setHome(internals::PointLatLng(LLA[0], LLA[1]),LLA[2]); - double lat = hp->getField("Latitude")->getDouble() * 1e-7; - double lon = hp->getField("Longitude")->getDouble() * 1e-7; - setHome(internals::PointLatLng(lat, lon)); } // ************************************************************************************* @@ -1078,13 +913,13 @@ void OPMapGadgetWidget::setHome(QPointF pos) else if (longitude < -180) longitude = -180; - setHome(internals::PointLatLng(latitude, longitude)); + setHome(internals::PointLatLng(latitude, longitude),0); } /** Sets the home position on the map widget */ -void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon) +void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon,double altitude) { if (!m_widget || !m_map) return; @@ -1106,12 +941,14 @@ void OPMapGadgetWidget::setHome(internals::PointLatLng pos_lat_lon) if (longitude > 180) longitude = 180; else if (longitude < -180) longitude = -180; + else if(altitude != altitude) altitude=0; // ********* m_home_position.coord = internals::PointLatLng(latitude, longitude); m_map->Home->SetCoord(m_home_position.coord); + m_map->Home->SetAltitude(altitude); m_map->Home->RefreshPos(); // move the magic waypoint to keep it within the safe area boundry @@ -1200,6 +1037,35 @@ void OPMapGadgetWidget::setZoom(int zoom) m_map->SetMouseWheelZoomType(zoom_type); } +void OPMapGadgetWidget::setOverlayOpacity(qreal value) +{ + if (!m_widget || !m_map) + return; + m_map->setOverlayOpacity(value); + overlayOpacityAct.at(value*10)->setChecked(true); +} + +void OPMapGadgetWidget::setHomePosition(QPointF pos) +{ + if (!m_widget || !m_map) + return; + + double latitude = pos.y(); + double longitude = pos.x(); + + if (latitude != latitude || longitude != longitude) + return; // nan prevention + + if (latitude > 90) latitude = 90; + else + if (latitude < -90) latitude = -90; + + if (longitude > 180) longitude = 180; + else + if (longitude < -180) longitude = -180; + + m_map->Home->SetCoord(internals::PointLatLng(latitude, longitude)); +} void OPMapGadgetWidget::setPosition(QPointF pos) { @@ -1272,21 +1138,12 @@ void OPMapGadgetWidget::setCacheLocation(QString cacheLocation) if (cacheLocation.isEmpty()) return; -// #if defined(Q_WS_WIN) -// if (!cacheLocation.endsWith('\\')) cacheLocation += '\\'; -// #elif defined(Q_WS_X11) - if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator(); -// #elif defined(Q_WS_MAC) -// if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator(); -// #endif + if (!cacheLocation.endsWith(QDir::separator())) cacheLocation += QDir::separator(); QDir dir; if (!dir.exists(cacheLocation)) if (!dir.mkpath(cacheLocation)) return; - -// qDebug() << "opmap: map cache dir: " << cacheLocation; - m_map->configuration->SetCacheLocation(cacheLocation); } @@ -1324,32 +1181,8 @@ void OPMapGadgetWidget::setMapMode(opMapModeType mode) hideMagicWaypointControls(); - // delete the magic waypoint from the map - if (m_magic_waypoint.map_wp_item) - { - m_magic_waypoint.coord = m_magic_waypoint.map_wp_item->Coord(); - m_magic_waypoint.altitude = m_magic_waypoint.map_wp_item->Altitude(); - m_magic_waypoint.description = m_magic_waypoint.map_wp_item->Description(); - m_magic_waypoint.map_wp_item = NULL; - } - m_map->WPDeleteAll(); - - // restore the normal waypoints on the map - m_waypoint_list_mutex.lock(); - foreach (t_waypoint *wp, m_waypoint_list) - { - if (!wp) continue; - wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description); - if (!wp->map_wp_item) continue; - wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number()); - wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked); - if (!wp->locked) - wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png")); - else - wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png")); - wp->map_wp_item->update(); - } - m_waypoint_list_mutex.unlock(); + magicWayPoint->setVisible(false); + m_map->WPSetVisibleAll(true); break; @@ -1362,25 +1195,9 @@ void OPMapGadgetWidget::setMapMode(opMapModeType mode) showMagicWaypointControls(); // delete the normal waypoints from the map - m_waypoint_list_mutex.lock(); - foreach (t_waypoint *wp, m_waypoint_list) - { - if (!wp) continue; - if (!wp->map_wp_item) continue; - wp->coord = wp->map_wp_item->Coord(); - wp->altitude = wp->map_wp_item->Altitude(); - wp->description = wp->map_wp_item->Description(); - wp->locked = (wp->map_wp_item->flags() & QGraphicsItem::ItemIsMovable) == 0; - wp->map_wp_item = NULL; - } - m_map->WPDeleteAll(); - m_waypoint_list_mutex.unlock(); - // restore the magic waypoint on the map - m_magic_waypoint.map_wp_item = m_map->WPCreate(m_magic_waypoint.coord, m_magic_waypoint.altitude, m_magic_waypoint.description); - m_magic_waypoint.map_wp_item->setZValue(10 + m_magic_waypoint.map_wp_item->Number()); - m_magic_waypoint.map_wp_item->SetShowNumber(false); - m_magic_waypoint.map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png")); + m_map->WPSetVisibleAll(false); + magicWayPoint->setVisible(true); break; } @@ -1409,6 +1226,10 @@ void OPMapGadgetWidget::createActions() reloadAct->setShortcut(tr("F5")); reloadAct->setStatusTip(tr("Reload the map tiles")); connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered())); + this->addAction(reloadAct); + ripAct = new QAction(tr("&Rip map"), this); + ripAct->setStatusTip(tr("Rip the map tiles")); + connect(ripAct, SIGNAL(triggered()), this, SLOT(onRipAct_triggered())); copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this); copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard")); @@ -1422,13 +1243,6 @@ void OPMapGadgetWidget::createActions() copyMouseLonToClipAct->setStatusTip(tr("Copy the mouse longitude to the clipboard")); connect(copyMouseLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLonToClipAct_triggered())); - /* - findPlaceAct = new QAction(tr("&Find place"), this); - findPlaceAct->setShortcut(tr("Ctrl+F")); - findPlaceAct->setStatusTip(tr("Find a location")); - connect(findPlaceAct, SIGNAL(triggered()), this, SLOT(onFindPlaceAct_triggered())); - */ - showCompassAct = new QAction(tr("Show compass"), this); showCompassAct->setStatusTip(tr("Show/Hide the compass")); showCompassAct->setCheckable(true); @@ -1441,6 +1255,12 @@ void OPMapGadgetWidget::createActions() showDiagnostics->setChecked(false); connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool))); + showUAVInfo = new QAction(tr("Show UAV Info"), this); + showUAVInfo->setStatusTip(tr("Show/Hide the UAV info")); + showUAVInfo->setCheckable(true); + showUAVInfo->setChecked(false); + connect(showUAVInfo, SIGNAL(toggled(bool)), this, SLOT(onShowUAVInfo_toggled(bool))); + showHomeAct = new QAction(tr("Show Home"), this); showHomeAct->setStatusTip(tr("Show/Hide the Home location")); showHomeAct->setCheckable(true); @@ -1453,15 +1273,21 @@ void OPMapGadgetWidget::createActions() showUAVAct->setChecked(true); connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool))); + changeDefaultLocalAndZoom = new QAction(tr("Set default zoom and location"), this); + changeDefaultLocalAndZoom->setStatusTip(tr("Changes the map default zoom and location to the current values")); + connect(changeDefaultLocalAndZoom, SIGNAL(triggered()), this, SLOT(onChangeDefaultLocalAndZoom())); + zoomInAct = new QAction(tr("Zoom &In"), this); zoomInAct->setShortcut(Qt::Key_PageUp); zoomInAct->setStatusTip(tr("Zoom the map in")); connect(zoomInAct, SIGNAL(triggered()), this, SLOT(onGoZoomInAct_triggered())); + this->addAction(zoomInAct); zoomOutAct = new QAction(tr("Zoom &Out"), this); zoomOutAct->setShortcut(Qt::Key_PageDown); zoomOutAct->setStatusTip(tr("Zoom the map out")); connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(onGoZoomOutAct_triggered())); + this->addAction(zoomOutAct); goMouseClickAct = new QAction(tr("Go to where you right clicked the mouse"), this); goMouseClickAct->setStatusTip(tr("Center the map onto where you right clicked the mouse")); @@ -1502,17 +1328,22 @@ void OPMapGadgetWidget::createActions() TODO: Waypoint support is disabled for v1.0 */ - /* +#ifdef USE_PATHPLANNER wayPointEditorAct = new QAction(tr("&Waypoint editor"), this); wayPointEditorAct->setShortcut(tr("Ctrl+W")); wayPointEditorAct->setStatusTip(tr("Open the waypoint editor")); - wayPointEditorAct->setEnabled(false); // temporary connect(wayPointEditorAct, SIGNAL(triggered()), this, SLOT(onOpenWayPointEditorAct_triggered())); - addWayPointAct = new QAction(tr("&Add waypoint"), this); - addWayPointAct->setShortcut(tr("Ctrl+A")); - addWayPointAct->setStatusTip(tr("Add waypoint")); - connect(addWayPointAct, SIGNAL(triggered()), this, SLOT(onAddWayPointAct_triggered())); + addWayPointActFromContextMenu = new QAction(tr("&Add waypoint"), this); + addWayPointActFromContextMenu->setShortcut(tr("Ctrl+A")); + addWayPointActFromContextMenu->setStatusTip(tr("Add waypoint")); + connect(addWayPointActFromContextMenu, SIGNAL(triggered()), this, SLOT(onAddWayPointAct_triggeredFromContextMenu())); + + addWayPointActFromThis = new QAction(tr("&Add waypoint"), this); + addWayPointActFromThis->setShortcut(tr("Ctrl+A")); + addWayPointActFromThis->setStatusTip(tr("Add waypoint")); + connect(addWayPointActFromThis, SIGNAL(triggered()), this, SLOT(onAddWayPointAct_triggeredFromThis())); + this->addAction(addWayPointActFromThis); editWayPointAct = new QAction(tr("&Edit waypoint"), this); editWayPointAct->setShortcut(tr("Ctrl+E")); @@ -1534,7 +1365,17 @@ void OPMapGadgetWidget::createActions() clearWayPointsAct->setShortcut(tr("Ctrl+C")); clearWayPointsAct->setStatusTip(tr("Clear waypoints")); connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered())); - */ +#endif + overlayOpacityActGroup = new QActionGroup(this); + connect(overlayOpacityActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onOverlayOpacityActGroup_triggered(QAction *))); + overlayOpacityAct.clear(); + for (int i = 0; i <= 10; i++) + { + QAction *overlayAct = new QAction(QString::number(i*10), overlayOpacityActGroup); + overlayAct->setCheckable(true); + overlayAct->setData(i*10); + overlayOpacityAct.append(overlayAct); + } homeMagicWaypointAct = new QAction(tr("Home magic waypoint"), this); homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position")); @@ -1668,10 +1509,6 @@ void OPMapGadgetWidget::createActions() uavTrailDistance_act->setData(uav_trail_distance); uavTrailDistanceAct.append(uavTrailDistance_act); } - - // ***** - - // *********************** } void OPMapGadgetWidget::onReloadAct_triggered() @@ -1682,6 +1519,11 @@ void OPMapGadgetWidget::onReloadAct_triggered() m_map->ReloadMap(); } +void OPMapGadgetWidget::onRipAct_triggered() +{ + m_map->RipMap(); +} + void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered() { QClipboard *clipboard = QApplication::clipboard(); @@ -1711,12 +1553,20 @@ void OPMapGadgetWidget::onShowCompassAct_toggled(bool show) void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show) { - if (!m_widget || !m_map) + if (!m_widget || !m_map) return; m_map->SetShowDiagnostics(show); } +void OPMapGadgetWidget::onShowUAVInfo_toggled(bool show) +{ + if (!m_widget || !m_map) + return; + + m_map->UAV->SetShowUAVInfo(show); +} + void OPMapGadgetWidget::onShowHomeAct_toggled(bool show) { if (!m_widget || !m_map) @@ -1731,7 +1581,8 @@ void OPMapGadgetWidget::onShowUAVAct_toggled(bool show) return; m_map->UAV->setVisible(show); - m_map->GPS->setVisible(show); + if(m_map->GPS) + m_map->GPS->setVisible(show); } void OPMapGadgetWidget::onShowTrailAct_toggled(bool show) @@ -1740,7 +1591,8 @@ void OPMapGadgetWidget::onShowTrailAct_toggled(bool show) return; m_map->UAV->SetShowTrail(show); - m_map->GPS->SetShowTrail(show); + if(m_map->GPS) + m_map->GPS->SetShowTrail(show); } void OPMapGadgetWidget::onShowTrailLineAct_toggled(bool show) @@ -1749,7 +1601,8 @@ void OPMapGadgetWidget::onShowTrailLineAct_toggled(bool show) return; m_map->UAV->SetShowTrailLine(show); - m_map->GPS->SetShowTrailLine(show); + if(m_map->GPS) + m_map->GPS->SetShowTrailLine(show); } void OPMapGadgetWidget::onMapModeActGroup_triggered(QAction *action) @@ -1785,7 +1638,12 @@ void OPMapGadgetWidget::onMaxUpdateRateActGroup_triggered(QAction *action) if (!m_widget || !m_map || !action) return; - setMaxUpdateRate(action->data().toInt()); + setMaxUpdateRate(action->data().toInt()); +} + +void OPMapGadgetWidget::onChangeDefaultLocalAndZoom() +{ + emit defaultLocationAndZoomChanged(m_map->CurrentPosition().Lng(),m_map->CurrentPosition().Lat(),m_map->ZoomTotal()); } void OPMapGadgetWidget::onGoMouseClickAct_triggered() @@ -1801,7 +1659,7 @@ void OPMapGadgetWidget::onSetHomeAct_triggered() if (!m_widget || !m_map) return; - setHome(m_context_menu_lat_lon); + setHome(m_context_menu_lat_lon,0); setHomeLocationObject(); // update the HomeLocation UAVObject } @@ -1871,7 +1729,8 @@ void OPMapGadgetWidget::onClearUAVtrailAct_triggered() return; m_map->UAV->DeleteTrail(); - m_map->GPS->DeleteTrail(); + if(m_map->GPS) + m_map->GPS->DeleteTrail(); } void OPMapGadgetWidget::onUAVTrailTimeActGroup_triggered(QAction *action) @@ -1894,50 +1753,30 @@ void OPMapGadgetWidget::onUAVTrailDistanceActGroup_triggered(QAction *action) m_map->UAV->SetTrailDistance(trail_distance); } -/** - * TODO: unused for v1.0 - **/ -/* -void OPMapGadgetWidget::onAddWayPointAct_triggered() +void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered() +{ + table->show(); +} +void OPMapGadgetWidget::onAddWayPointAct_triggeredFromContextMenu() +{ + onAddWayPointAct_triggered(m_context_menu_lat_lon); +} +void OPMapGadgetWidget::onAddWayPointAct_triggeredFromThis() +{ + onAddWayPointAct_triggered(lastLatLngMouse); +} + +void OPMapGadgetWidget::onAddWayPointAct_triggered(internals::PointLatLng coord) { if (!m_widget || !m_map) return; if (m_map_mode != Normal_MapMode) return; - - m_waypoint_list_mutex.lock(); - - // create a waypoint on the map at the last known mouse position - t_waypoint *wp = new t_waypoint; - wp->map_wp_item = NULL; - wp->coord = context_menu_lat_lon; - wp->altitude = 0; - wp->description = ""; - wp->locked = false; - wp->time_seconds = 0; - wp->hold_time_seconds = 0; - wp->map_wp_item = m_map->WPCreate(wp->coord, wp->altitude, wp->description); - - wp->map_wp_item->setZValue(10 + wp->map_wp_item->Number()); - - wp->map_wp_item->setFlag(QGraphicsItem::ItemIsMovable, !wp->locked); - - if (wp->map_wp_item) - { - if (!wp->locked) - wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker1.png")); - else - wp->map_wp_item->picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker2.png")); - wp->map_wp_item->update(); - } - - // and remember it in our own local waypoint list - m_waypoint_list.append(wp); - - m_waypoint_list_mutex.unlock(); + float alt=15; + mapProxy->createWayPoint(coord); } -*/ + /** * Called when the user asks to edit a waypoint from the map @@ -1945,7 +1784,7 @@ void OPMapGadgetWidget::onAddWayPointAct_triggered() * TODO: should open an interface to edit waypoint properties, or * propagate the signal to a specific WP plugin (tbd). **/ -/* + void OPMapGadgetWidget::onEditWayPointAct_triggered() { if (!m_widget || !m_map) @@ -1957,16 +1796,15 @@ void OPMapGadgetWidget::onEditWayPointAct_triggered() if (!m_mouse_waypoint) return; - //waypoint_edit_dialog.editWaypoint(m_mouse_waypoint); - + waypoint_edit_dialog->editWaypoint(m_mouse_waypoint); m_mouse_waypoint = NULL; } -*/ + /** * TODO: unused for v1.0 */ -/* + void OPMapGadgetWidget::onLockWayPointAct_triggered() { if (!m_widget || !m_map || !m_mouse_waypoint) @@ -1986,12 +1824,7 @@ void OPMapGadgetWidget::onLockWayPointAct_triggered() m_mouse_waypoint = NULL; } -*/ -/** - * TODO: unused for v1.0 - */ -/* void OPMapGadgetWidget::onDeleteWayPointAct_triggered() { if (!m_widget || !m_map) @@ -2003,77 +1836,34 @@ void OPMapGadgetWidget::onDeleteWayPointAct_triggered() if (!m_mouse_waypoint) return; - bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; - - if (locked) return; // waypoint is locked - - QMutexLocker locker(&m_waypoint_list_mutex); - - for (int i = 0; i < m_waypoint_list.count(); i++) - { - t_waypoint *wp = m_waypoint_list.at(i); - if (!wp) continue; - if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue; - - // delete the waypoint from the map - m_map->WPDelete(wp->map_wp_item); - - // delete the waypoint from our local waypoint list - m_waypoint_list.removeAt(i); - - delete wp; - - break; - } -// -// foreach (t_waypoint *wp, m_waypoint_list) -// { -// if (!wp) continue; -// if (!wp->map_wp_item || wp->map_wp_item != m_mouse_waypoint) continue; -// -// // delete the waypoint from the map -// m_map->WPDelete(wp->map_wp_item); -// -// // delete the waypoint from our local waypoint list -// m_waypoint_list.removeOne(wp); -// -// delete wp; -// -// break; -// } - - m_mouse_waypoint = NULL; + mapProxy->deleteWayPoint(m_mouse_waypoint->Number()); } -*/ -/** - * TODO: No Waypoint support in v1.0 - */ -/* void OPMapGadgetWidget::onClearWayPointsAct_triggered() { + + //First, ask to ensure this is what the user wants to do + QMessageBox msgBox; + msgBox.setText(tr("Are you sure you want to clear waypoints?")); + msgBox.setInformativeText(tr("All associated data will be lost.")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + int ret = msgBox.exec(); + + if (ret == QMessageBox::No) + { + return; + } + if (!m_widget || !m_map) return; if (m_map_mode != Normal_MapMode) return; - QMutexLocker locker(&m_waypoint_list_mutex); + mapProxy->deleteAll(); - m_map->WPDeleteAll(); + } - foreach (t_waypoint *wp, m_waypoint_list) - { - if (wp) - { - delete wp; - wp = NULL; - } - } - - m_waypoint_list.clear(); -} -*/ void OPMapGadgetWidget::onHomeMagicWaypointAct_triggered() { @@ -2087,6 +1877,7 @@ void OPMapGadgetWidget::onShowSafeAreaAct_toggled(bool show) return; m_map->Home->SetShowSafeArea(show); // show the safe area + m_map->Home->SetToggleRefresh(true); m_map->Home->RefreshPos(); } @@ -2115,10 +1906,7 @@ void OPMapGadgetWidget::homeMagicWaypoint() if (m_map_mode != MagicWaypoint_MapMode) return; - m_magic_waypoint.coord = m_home_position.coord; - - if (m_magic_waypoint.map_wp_item) - m_magic_waypoint.map_wp_item->SetCoord(m_magic_waypoint.coord); + magicWayPoint->SetCoord(m_home_position.coord); } // ************************************************************************************* @@ -2131,60 +1919,6 @@ void OPMapGadgetWidget::moveToMagicWaypointPosition() if (m_map_mode != MagicWaypoint_MapMode) return; - -// internals::PointLatLng coord = magic_waypoint.coord; -// double altitude = magic_waypoint.altitude; - - - // ToDo: - -} - -// ************************************************************************************* -// temporary until an object is created for managing the save/restore - -// load the contents of a simple text file into a combobox -void OPMapGadgetWidget::loadComboBoxLines(QComboBox *comboBox, QString filename) -{ - if (!comboBox) return; - if (filename.isNull() || filename.isEmpty()) return; - - QFile file(filename); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return; - - QTextStream in(&file); - - while (!in.atEnd()) - { - QString line = in.readLine().simplified(); - if (line.isNull() || line.isEmpty()) continue; - comboBox->addItem(line); - } - - file.close(); -} - -// save a combobox text contents to a simple text file -void OPMapGadgetWidget::saveComboBoxLines(QComboBox *comboBox, QString filename) -{ - if (!comboBox) return; - if (filename.isNull() || filename.isEmpty()) return; - - QFile file(filename); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - - QTextStream out(&file); - - for (int i = 0; i < comboBox->count(); i++) - { - QString line = comboBox->itemText(i).simplified(); - if (line.isNull() || line.isEmpty()) continue; - out << line << "\n"; - } - - file.close(); } // ************************************************************************************* @@ -2216,25 +1950,20 @@ void OPMapGadgetWidget::keepMagicWaypointWithInSafeArea() { // calcute the bearing and distance from the home position to the magic waypoint - double dist = distance(m_home_position.coord, m_magic_waypoint.coord); - double bear = bearing(m_home_position.coord, m_magic_waypoint.coord); + double dist = distance(m_home_position.coord, magicWayPoint->Coord()); + double bear = bearing(m_home_position.coord, magicWayPoint->Coord()); // get the maximum safe distance - in kilometers double boundry_dist = (double)m_map->Home->SafeArea() / 1000; -// if (dist <= boundry_dist) -// return; // the magic waypoint is still within the safe area, don't move it - if (dist > boundry_dist) dist = boundry_dist; - // move the magic waypoint - - m_magic_waypoint.coord = destPoint(m_home_position.coord, bear, dist); + // move the magic waypoint; if (m_map_mode == MagicWaypoint_MapMode) { // move the on-screen waypoint - if (m_magic_waypoint.map_wp_item) - m_magic_waypoint.map_wp_item->SetCoord(m_magic_waypoint.coord); + if (magicWayPoint) + magicWayPoint->SetCoord(destPoint(m_home_position.coord, bear, dist)); } } @@ -2249,22 +1978,6 @@ double OPMapGadgetWidget::distance(internals::PointLatLng from, internals::Point double lat2 = to.Lat() * deg_to_rad; double lon2 = to.Lng() * deg_to_rad; - // *********************** - // Haversine formula -/* - double delta_lat = lat2 - lat1; - double delta_lon = lon2 - lon1; - - double t1 = sin(delta_lat / 2); - double t2 = sin(delta_lon / 2); - double a = (t1 * t1) + cos(lat1) * cos(lat2) * (t2 * t2); - double c = 2 * atan2(sqrt(a), sqrt(1 - a)); - - return (earth_mean_radius * c); -*/ - // *********************** - // Spherical Law of Cosines - return (acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)) * earth_mean_radius); // *********************** @@ -2317,54 +2030,41 @@ internals::PointLatLng OPMapGadgetWidget::destPoint(internals::PointLatLng sourc bool OPMapGadgetWidget::getUAVPosition(double &latitude, double &longitude, double &altitude) { - double BaseECEF[3]; double NED[3]; double LLA[3]; - UAVObject *obj; + double homeLLA[3]; - if (!obm) - return false; + Q_ASSERT(obm != NULL); - obj = dynamic_cast(obm->getObject(QString("HomeLocation"))); - if (!obj) return false; - BaseECEF[0] = obj->getField(QString("ECEF"))->getDouble(0) / 100; - BaseECEF[1] = obj->getField(QString("ECEF"))->getDouble(1) / 100; - BaseECEF[2] = obj->getField(QString("ECEF"))->getDouble(2) / 100; + HomeLocation *homeLocation = HomeLocation::GetInstance(obm); + Q_ASSERT(homeLocation != NULL); + HomeLocation::DataFields homeLocationData = homeLocation->getData(); - obj = dynamic_cast(obm->getObject(QString("PositionActual"))); - if (!obj) return false; - NED[0] = obj->getField(QString("North"))->getDouble() / 100; - NED[1] = obj->getField(QString("East"))->getDouble() / 100; - NED[2] = obj->getField(QString("Down"))->getDouble() / 100; + homeLLA[0] = homeLocationData.Latitude / 1e7; + homeLLA[1] = homeLocationData.Longitude / 1e7; + homeLLA[2] = homeLocationData.Altitude; -// obj = dynamic_cast(om->getObject(QString("PositionDesired"))); + PositionActual *positionActual = PositionActual::GetInstance(obm); + Q_ASSERT(positionActual != NULL); + PositionActual::DataFields positionActualData = positionActual->getData(); -// obj = dynamic_cast(objManager->getObject("VelocityActual")); // air speed + NED[0] = positionActualData.North; + NED[1] = positionActualData.East; + NED[2] = positionActualData.Down; - Utils::CoordinateConversions().GetLLA(BaseECEF, NED, LLA); + Utils::CoordinateConversions().NED2LLA_HomeLLA(homeLLA, NED, LLA); latitude = LLA[0]; longitude = LLA[1]; altitude = LLA[2]; if (latitude != latitude) latitude = 0; // nan detection -// if (isNan(latitude)) latitude = 0; // nan detection - else -// if (!isFinite(latitude)) latitude = 0; -// else - if (latitude > 90) latitude = 90; - else - if (latitude < -90) latitude = -90; + else if (latitude > 90) latitude = 90; + else if (latitude < -90) latitude = -90; if (longitude != longitude) longitude = 0; // nan detection - else -// if (longitude > std::numeric_limits::max()) longitude = 0; // +infinite -// else -// if (longitude < -std::numeric_limits::max()) longitude = 0; // -infinite -// else - if (longitude > 180) longitude = 180; - else - if (longitude < -180) longitude = -180; + else if (longitude > 180) longitude = 180; + else if (longitude < -180) longitude = -180; if (altitude != altitude) altitude = 0; // nan detection @@ -2449,3 +2149,34 @@ void OPMapGadgetWidget::SetUavPic(QString UAVPic) { m_map->SetUavPic(UAVPic); } + +void OPMapGadgetWidget::on_tbFind_clicked() +{ + QPalette pal = m_widget->leFind->palette(); + + int result=m_map->SetCurrentPositionByKeywords(m_widget->leFind->text()); + if(result==core::GeoCoderStatusCode::G_GEO_SUCCESS) + { + pal.setColor( m_widget->leFind->backgroundRole(), Qt::green); + m_widget->leFind->setPalette(pal); + } + else + { + pal.setColor( m_widget->leFind->backgroundRole(), Qt::red); + m_widget->leFind->setPalette(pal); + } +} + +void OPMapGadgetWidget::onHomeDoubleClick(HomeItem *) +{ + new homeEditor(m_map->Home,this); +} + +void OPMapGadgetWidget::onOverlayOpacityActGroup_triggered(QAction *action) +{ + if (!m_widget || !m_map || !action) + return; + + m_map->setOverlayOpacity(action->data().toReal()/100); + emit overlayOpacityChanged(action->data().toReal()/100); +} diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h index 24f638a80..a1c5bcdd2 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapgadgetwidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin @@ -30,6 +30,12 @@ // ****************************************************** + +#include "flightdatamodel.h" +#include "pathplanner.h" +#include "modelmapproxy.h" +#include "modeluavoproxy.h" + #include #include #include @@ -41,7 +47,6 @@ #include "opmapcontrol/opmapcontrol.h" -#include "opmap_overlay_widget.h" #include "opmap_zoom_slider_widget.h" #include "opmap_statusbar_widget.h" @@ -52,6 +57,10 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "objectpersistence.h" +#include +#include "opmap_edit_waypoint_dialog.h" + +#include "homeeditor.h" // ****************************************************** @@ -71,18 +80,6 @@ typedef struct t_home bool locked; } t_home; -// local waypoint list item structure -typedef struct t_waypoint -{ - mapcontrol::WayPointItem *map_wp_item; - internals::PointLatLng coord; - double altitude; - QString description; - bool locked; - int time_seconds; - int hold_time_seconds; -} t_waypoint; - // ****************************************************** enum opMapModeType { Normal_MapMode = 0, @@ -104,7 +101,7 @@ public: * @param */ void setHome(QPointF pos); - void setHome(internals::PointLatLng pos_lat_lon); + void setHome(internals::PointLatLng pos_lat_lon, double altitude); void goHome(); void setZoom(int zoom); void setPosition(QPointF pos); @@ -116,7 +113,12 @@ public: void setCacheLocation(QString cacheLocation); void setMapMode(opMapModeType mode); void SetUavPic(QString UAVPic); - void setMaxUpdateRate(int update_rate); + void setMaxUpdateRate(int update_rate); + void setHomePosition(QPointF pos); + void setOverlayOpacity(qreal value); +signals: + void defaultLocationAndZoomChanged(double lng,double lat,double zoom); + void overlayOpacityChanged(qreal); public slots: void homePositionUpdated(UAVObject *); @@ -127,9 +129,9 @@ protected: void resizeEvent(QResizeEvent *event); void mouseMoveEvent(QMouseEvent *event); void contextMenuEvent(QContextMenuEvent *event); - void keyPressEvent(QKeyEvent* event); - + void closeEvent(QCloseEvent *); private slots: + void wpDoubleClickEvent(WayPointItem *wp); void updatePosition(); void updateMousePos(); @@ -142,21 +144,12 @@ private slots: * * Some are currently disabled for the v1.0 plugin version. */ -// void comboBoxFindPlace_returnPressed(); -// void on_toolButtonFindPlace_clicked(); void on_toolButtonZoomM_clicked(); void on_toolButtonZoomP_clicked(); void on_toolButtonMapHome_clicked(); void on_toolButtonMapUAV_clicked(); void on_toolButtonMapUAVheading_clicked(); void on_horizontalSliderZoom_sliderMoved(int position); -// void on_toolButtonAddWaypoint_clicked(); -// void on_treeViewWaypoints_clicked(QModelIndex index); -// void on_toolButtonHome_clicked(); -// void on_toolButtonNextWaypoint_clicked(); -// void on_toolButtonPrevWaypoint_clicked(); -// void on_toolButtonHoldPosition_clicked(); -// void on_toolButtonGo_clicked(); void on_toolButtonMagicWaypointMapMode_clicked(); void on_toolButtonNormalMapMode_clicked(); void on_toolButtonHomeWaypoint_clicked(); @@ -169,30 +162,19 @@ private slots: void OnCurrentPositionChanged(internals::PointLatLng point); void OnTileLoadComplete(); void OnTileLoadStart(); - void OnMapDrag(); - void OnMapZoomChanged(); - void OnMapTypeChanged(MapType::Types type); - void OnEmptyTileError(int zoom, core::Point pos); void OnTilesStillToLoad(int number); - /** - * Unused for now, hooks for future waypoint support - */ - void WPNumberChanged(int const& oldnumber,int const& newnumber, WayPointItem* waypoint); - void WPValuesChanged(WayPointItem* waypoint); - void WPInserted(int const& number, WayPointItem* waypoint); - void WPDeleted(int const& number); - /** * @brief mouse right click context menu signals */ void onReloadAct_triggered(); + void onRipAct_triggered(); void onCopyMouseLatLonToClipAct_triggered(); void onCopyMouseLatToClipAct_triggered(); void onCopyMouseLonToClipAct_triggered(); -// void onFindPlaceAct_triggered(); void onShowCompassAct_toggled(bool show); void onShowDiagnostics_toggled(bool show); + void onShowUAVInfo_toggled(bool show); void onShowUAVAct_toggled(bool show); void onShowHomeAct_toggled(bool show); void onShowTrailLineAct_toggled(bool show); @@ -205,14 +187,16 @@ private slots: void onGoUAVAct_triggered(); void onFollowUAVpositionAct_toggled(bool checked); void onFollowUAVheadingAct_toggled(bool checked); -/* + void onOpenWayPointEditorAct_triggered(); - void onAddWayPointAct_triggered(); + void onAddWayPointAct_triggeredFromContextMenu(); + void onAddWayPointAct_triggeredFromThis(); + void onAddWayPointAct_triggered(internals::PointLatLng coord); void onEditWayPointAct_triggered(); void onLockWayPointAct_triggered(); void onDeleteWayPointAct_triggered(); void onClearWayPointsAct_triggered(); -*/ + void onMapModeActGroup_triggered(QAction *action); void onZoomActGroup_triggered(QAction *action); void onHomeMagicWaypointAct_triggered(); @@ -223,71 +207,45 @@ private slots: void onUAVTrailTimeActGroup_triggered(QAction *action); void onUAVTrailDistanceActGroup_triggered(QAction *action); void onMaxUpdateRateActGroup_triggered(QAction *action); - + void onChangeDefaultLocalAndZoom(); + void on_tbFind_clicked(); + void onHomeDoubleClick(HomeItem*); + void onOverlayOpacityActGroup_triggered(QAction *action); private: - - // ***** - int m_min_zoom; int m_max_zoom; - double m_heading; // uav heading - internals::PointLatLng m_mouse_lat_lon; internals::PointLatLng m_context_menu_lat_lon; - int m_prev_tile_number; - opMapModeType m_map_mode; - int m_maxUpdateRate; - t_home m_home_position; - - t_waypoint m_magic_waypoint; - QStringList findPlaceWordList; QCompleter *findPlaceCompleter; - QTimer *m_updateTimer; QTimer *m_statusUpdateTimer; - Ui::OPMap_Widget *m_widget; - mapcontrol::OPMapWidget *m_map; - ExtensionSystem::PluginManager *pm; UAVObjectManager *obm; UAVObjectUtilManager *obum; - - //opmap_waypointeditor_dialog waypoint_editor_dialog; - - //opmap_edit_waypoint_dialog waypoint_edit_dialog; - + QPointer waypoint_edit_dialog; QStandardItemModel wayPoint_treeView_model; - mapcontrol::WayPointItem *m_mouse_waypoint; - - QList m_waypoint_list; - QMutex m_waypoint_list_mutex; - + QPointer UAVProxy; QMutex m_map_mutex; - bool m_telemetry_connected; - - // ***** - - void createActions(); - QAction *closeAct1; QAction *closeAct2; QAction *reloadAct; + QAction *ripAct; QAction *copyMouseLatLonToClipAct; QAction *copyMouseLatToClipAct; QAction *copyMouseLonToClipAct; - QAction *findPlaceAct; QAction *showCompassAct; QAction *showDiagnostics; + QAction *showUAVInfo; QAction *showHomeAct; QAction *showUAVAct; QAction *zoomInAct; @@ -298,17 +256,19 @@ private: QAction *goUAVAct; QAction *followUAVpositionAct; QAction *followUAVheadingAct; - /* + QAction *wayPointEditorAct; - QAction *addWayPointAct; + QAction *addWayPointActFromThis; + QAction *addWayPointActFromContextMenu; QAction *editWayPointAct; QAction *lockWayPointAct; QAction *deleteWayPointAct; QAction *clearWayPointsAct; - */ + QAction *homeMagicWaypointAct; QAction *showSafeAreaAct; + QAction *changeDefaultLocalAndZoom; QActionGroup *safeAreaActGroup; QList safeAreaAct; @@ -326,23 +286,18 @@ private: QList mapModeAct; QActionGroup *zoomActGroup; + QActionGroup *overlayOpacityActGroup; QList zoomAct; + QList overlayOpacityAct; QActionGroup *maxUpdateRateActGroup; QList maxUpdateRateAct; - // ***** - + void createActions(); void homeMagicWaypoint(); - void moveToMagicWaypointPosition(); - - void loadComboBoxLines(QComboBox *comboBox, QString filename); - void saveComboBoxLines(QComboBox *comboBox, QString filename); - void hideMagicWaypointControls(); void showMagicWaypointControls(); - void keepMagicWaypointWithInSafeArea(); double distance(internals::PointLatLng from, internals::PointLatLng to); @@ -356,6 +311,14 @@ private: void setMapFollowingMode(); bool setHomeLocationObject(); + QMenu contextMenu; + internals::PointLatLng lastLatLngMouse; + WayPointItem * magicWayPoint; + + QPointer model; + QPointer table; + QPointer mapProxy; + QPointer selectionModel; }; #endif /* OPMAP_GADGETWIDGET_H_ */ diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapplugin.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapplugin.cpp index 5f78b8bf8..1c0f5e057 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapplugin.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapplugin.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapplugin.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapplugin.h b/ground/openpilotgcs/src/plugins/opmap/opmapplugin.h index 93b9351ac..3da9926cf 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapplugin.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapplugin.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file opmapplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup OPMapPlugin OpenPilot Map Plugin diff --git a/ground/openpilotgcs/src/plugins/opmap/pathplanner.cpp b/ground/openpilotgcs/src/plugins/opmap/pathplanner.cpp new file mode 100644 index 000000000..aed5eed6e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/pathplanner.cpp @@ -0,0 +1,119 @@ +/** + ****************************************************************************** + * + * @file pathplanner.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "pathplanner.h" +#include "ui_pathplanner.h" +#include "widgetdelegates.h" +#include +#include + +pathPlanner::pathPlanner(QWidget *parent) : + QWidget(parent), + ui(new Ui::pathPlannerUI),wid(NULL),myModel(NULL) +{ + ui->setupUi(this); +} + +pathPlanner::~pathPlanner() +{ + delete ui; + if(wid) + delete wid; +} +void pathPlanner::setModel(flightDataModel *model,QItemSelectionModel *selection) +{ + myModel=model; + ui->tableView->setModel(model); + ui->tableView->setSelectionModel(selection); + ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); + ui->tableView->setItemDelegate(new MapDataDelegate(this)); + connect(model,SIGNAL(rowsInserted(const QModelIndex&,int,int)),this,SLOT(rowsInserted(const QModelIndex&,int,int))); + wid=new opmap_edit_waypoint_dialog(NULL,model,selection); + ui->tableView->resizeColumnsToContents(); +} + +void pathPlanner::rowsInserted ( const QModelIndex & parent, int start, int end ) +{ + Q_UNUSED(parent); + for(int x=start;xtableView->model()->index(x,flightDataModel::MODE); + ui->tableView->openPersistentEditor(index); + index=ui->tableView->model()->index(x,flightDataModel::CONDITION); + ui->tableView->openPersistentEditor(index); + index=ui->tableView->model()->index(x,flightDataModel::COMMAND); + ui->tableView->openPersistentEditor(index); + ui->tableView->size().setHeight(10); + } +} + +void pathPlanner::on_tbAdd_clicked() +{ + ui->tableView->model()->insertRow(ui->tableView->model()->rowCount()); +} + +void pathPlanner::on_tbDelete_clicked() +{ + ui->tableView->model()->removeRow(ui->tableView->selectionModel()->currentIndex().row()); +} + +void pathPlanner::on_tbInsert_clicked() +{ + ui->tableView->model()->insertRow(ui->tableView->selectionModel()->currentIndex().row()); +} + +void pathPlanner::on_tbReadFromFile_clicked() +{ + if(!myModel) + return; + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File")); + myModel->readFromFile(fileName); +} + +void pathPlanner::on_tbSaveToFile_clicked() +{ + if(!myModel) + return; + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File")); + myModel->writeToFile(fileName); +} + +void pathPlanner::on_tbDetails_clicked() +{ + if(wid) + wid->show(); +} + +void pathPlanner::on_tbSendToUAV_clicked() +{ + emit sendPathPlanToUAV(); +} + +void pathPlanner::on_tbFetchFromUAV_clicked() +{ + emit receivePathPlanFromUAV(); +} diff --git a/ground/openpilotgcs/src/plugins/opmap/pathplanner.h b/ground/openpilotgcs/src/plugins/opmap/pathplanner.h new file mode 100644 index 000000000..274e0ae67 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/pathplanner.h @@ -0,0 +1,75 @@ +/** + ****************************************************************************** + * + * @file pathplanner.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 PATHPLANNER_H +#define PATHPLANNER_H + +#include +#include "flightdatamodel.h" +#include "opmap_edit_waypoint_dialog.h" +namespace Ui { +class pathPlannerUI; +} + +class pathPlanner : public QWidget +{ + Q_OBJECT + +public: + explicit pathPlanner(QWidget *parent = 0); + ~pathPlanner(); + + void setModel(flightDataModel *model,QItemSelectionModel *selection); +private slots: + void rowsInserted ( const QModelIndex & parent, int start, int end ); + + void on_tbAdd_clicked(); + + void on_tbDelete_clicked(); + + void on_tbInsert_clicked(); + + void on_tbReadFromFile_clicked(); + + void on_tbSaveToFile_clicked(); + + void on_tbDetails_clicked(); + + void on_tbSendToUAV_clicked(); + + void on_tbFetchFromUAV_clicked(); + +private: + Ui::pathPlannerUI *ui; + opmap_edit_waypoint_dialog * wid; + flightDataModel * myModel; +signals: + void sendPathPlanToUAV(); + void receivePathPlanFromUAV(); +}; + +#endif // PATHPLANNER_H diff --git a/ground/openpilotgcs/src/plugins/opmap/pathplanner.ui b/ground/openpilotgcs/src/plugins/opmap/pathplanner.ui new file mode 100644 index 000000000..fbb59a4e3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/pathplanner.ui @@ -0,0 +1,164 @@ + + + pathPlannerUI + + + + 0 + 0 + 536 + 262 + + + + PathPlanner + + + + :/core/images/openpilot_logo_64.png:/core/images/openpilot_logo_64.png + + + + + + + + Add Leg + + + ... + + + + :/opmap/images/plus3.png:/opmap/images/plus3.png + + + + + + + Delete Leg + + + ... + + + + :/opmap/images/stopb.png:/opmap/images/stopb.png + + + + + + + Insert Leg + + + ... + + + + :/opmap/images/forward_alt.png:/opmap/images/forward_alt.png + + + + + + + Read from file + + + ... + + + + :/opmap/images/unarchive.png:/opmap/images/unarchive.png + + + + + + + Save to file + + + ... + + + + :/opmap/images/Ekisho Deep Ocean HD1.png:/opmap/images/Ekisho Deep Ocean HD1.png + + + + + + + Send to UAV + + + ... + + + + :/opmap/images/up_alt.png:/opmap/images/up_alt.png + + + + + + + Fetch from UAV + + + ... + + + + :/opmap/images/down_alt.png:/opmap/images/down_alt.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Open Details + + + ... + + + + :/opmap/images/star.png:/opmap/images/star.png + + + + + + + + + QAbstractItemView::SelectRows + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.cpp b/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.cpp new file mode 100644 index 000000000..7bd385842 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.cpp @@ -0,0 +1,143 @@ +/** + ****************************************************************************** + * + * @file widgetdelegates.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 "widgetdelegates.h" +#include +#include +#include +QWidget *MapDataDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem & option, + const QModelIndex & index) const +{ + int column=index.column(); + QComboBox * box; + switch(column) + { + case flightDataModel::MODE: + box=new QComboBox(parent); + MapDataDelegate::loadComboBox(box,flightDataModel::MODE); + return box; + break; + case flightDataModel::CONDITION: + box=new QComboBox(parent); + MapDataDelegate::loadComboBox(box,flightDataModel::CONDITION); + return box; + break; + + case flightDataModel::COMMAND: + box=new QComboBox(parent); + MapDataDelegate::loadComboBox(box,flightDataModel::COMMAND); + return box; + break; + default: + return QItemDelegate::createEditor(parent,option,index); + break; + } + + QComboBox *editor = new QComboBox(parent); + return editor; +} + +void MapDataDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + if(!index.isValid()) + return; + QString className=editor->metaObject()->className(); + if (className.contains("QComboBox")) { + int value = index.model()->data(index, Qt::EditRole).toInt(); + QComboBox *comboBox = static_cast(editor); + int x=comboBox->findData(value); + qDebug()<<"VALUE="<setCurrentIndex(x); + } + else + QItemDelegate::setEditorData(editor, index); +} + +void MapDataDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + QString className=editor->metaObject()->className(); + if (className.contains("QComboBox")) { + QComboBox *comboBox = static_cast(editor); + int value = comboBox->itemData(comboBox->currentIndex()).toInt(); + model->setData(index, value, Qt::EditRole); + } + else + QItemDelegate::setModelData(editor,model,index); +} + +void MapDataDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + +void MapDataDelegate::loadComboBox(QComboBox *combo, flightDataModel::pathPlanDataEnum type) +{ + switch(type) + { + case flightDataModel::MODE: + combo->addItem("Fly Direct",MODE_FLYENDPOINT); + combo->addItem("Fly Vector",MODE_FLYVECTOR); + combo->addItem("Fly Circle Right",MODE_FLYCIRCLERIGHT); + combo->addItem("Fly Circle Left",MODE_FLYCIRCLELEFT); + + combo->addItem("Drive Direct",MODE_DRIVEENDPOINT); + combo->addItem("Drive Vector",MODE_DRIVEVECTOR); + combo->addItem("Drive Circle Right",MODE_DRIVECIRCLELEFT); + combo->addItem("Drive Circle Left",MODE_DRIVECIRCLERIGHT); + + combo->addItem("Fixed Attitude",MODE_FIXEDATTITUDE); + combo->addItem("Set Accessory",MODE_SETACCESSORY); + combo->addItem("Disarm Alarm",MODE_DISARMALARM); + break; + case flightDataModel::CONDITION: + combo->addItem("None",ENDCONDITION_NONE); + combo->addItem("Timeout",ENDCONDITION_TIMEOUT); + combo->addItem("Distance to tgt",ENDCONDITION_DISTANCETOTARGET); + combo->addItem("Leg remaining",ENDCONDITION_LEGREMAINING); + combo->addItem("Above Altitude",ENDCONDITION_ABOVEALTITUDE); + combo->addItem("Pointing towards next",ENDCONDITION_POINTINGTOWARDSNEXT); + combo->addItem("Python script",ENDCONDITION_PYTHONSCRIPT); + combo->addItem("Immediate",ENDCONDITION_IMMEDIATE); + break; + case flightDataModel::COMMAND: + combo->addItem("On conditon next wp",COMMAND_ONCONDITIONNEXTWAYPOINT); + combo->addItem("On NOT conditon next wp",COMMAND_ONNOTCONDITIONNEXTWAYPOINT); + combo->addItem("On conditon jump wp",COMMAND_ONCONDITIONJUMPWAYPOINT); + combo->addItem("On NOT conditon jump wp",COMMAND_ONNOTCONDITIONJUMPWAYPOINT); + combo->addItem("On conditon jump wp else next wp",COMMAND_IFCONDITIONJUMPWAYPOINTELSENEXTWAYPOINT); + break; + default: + break; + } +} + +MapDataDelegate::MapDataDelegate(QObject *parent):QItemDelegate(parent) +{ +} diff --git a/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.h b/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.h new file mode 100644 index 000000000..ae29bc975 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/opmap/widgetdelegates.h @@ -0,0 +1,64 @@ +/** + ****************************************************************************** + * + * @file widgetdelegates.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup OPMapPlugin OpenPilot Map Plugin + * @{ + * @brief The OpenPilot Map plugin + *****************************************************************************/ +/* + * 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 WIDGETDELEGATES_H +#define WIDGETDELEGATES_H +#include +#include +#include "flightdatamodel.h" + + +class MapDataDelegate : public QItemDelegate + { + Q_OBJECT + + public: + typedef enum { MODE_FLYENDPOINT=0, MODE_FLYVECTOR=1, MODE_FLYCIRCLERIGHT=2, MODE_FLYCIRCLELEFT=3, + MODE_DRIVEENDPOINT=4, MODE_DRIVEVECTOR=5, MODE_DRIVECIRCLELEFT=6, MODE_DRIVECIRCLERIGHT=7, + MODE_FIXEDATTITUDE=8, MODE_SETACCESSORY=9, MODE_DISARMALARM=10 } ModeOptions; + typedef enum { ENDCONDITION_NONE=0, ENDCONDITION_TIMEOUT=1, ENDCONDITION_DISTANCETOTARGET=2, + ENDCONDITION_LEGREMAINING=3, ENDCONDITION_ABOVEALTITUDE=4, ENDCONDITION_POINTINGTOWARDSNEXT=5, + ENDCONDITION_PYTHONSCRIPT=6, ENDCONDITION_IMMEDIATE=7 } EndConditionOptions; + typedef enum { COMMAND_ONCONDITIONNEXTWAYPOINT=0, COMMAND_ONNOTCONDITIONNEXTWAYPOINT=1, + COMMAND_ONCONDITIONJUMPWAYPOINT=2, COMMAND_ONNOTCONDITIONJUMPWAYPOINT=3, + COMMAND_IFCONDITIONJUMPWAYPOINTELSENEXTWAYPOINT=4 } CommandOptions; + + MapDataDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; + static void loadComboBox(QComboBox * combo,flightDataModel::pathPlanDataEnum type); + }; + +#endif // WIDGETDELEGATES_H diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp index d01caba21..101ce5d54 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp @@ -485,6 +485,14 @@ void UAVObject::emitTransactionCompleted(bool success) emit transactionCompleted(this, success); } +/** + * Emit the newInstance event + */ +void UAVObject::emitNewInstance(UAVObject * obj) +{ + emit newInstance(obj); +} + /** * Initialize a UAVObjMetadata object. * \param[in] metadata The metadata object diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h index d092c6731..cae6d95a0 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h @@ -126,6 +126,7 @@ public: QString toStringBrief(); QString toStringData(); void emitTransactionCompleted(bool success); + void emitNewInstance(UAVObject *); // Metadata accessors static void MetadataInitialize(Metadata& meta); @@ -154,6 +155,7 @@ signals: void objectUnpacked(UAVObject* obj); void updateRequested(UAVObject* obj); void transactionCompleted(UAVObject* obj, bool success); + void newInstance(UAVObject* obj); private slots: void fieldUpdated(UAVObjectField* field); diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectmanager.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectmanager.cpp index c4f6f656e..5038b7bba 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectmanager.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectmanager.cpp @@ -89,6 +89,7 @@ bool UAVObjectManager::registerObject(UAVDataObject* obj) UAVDataObject* cobj = obj->clone(instidx); cobj->initialize(mobj); objects[objidx].append(cobj); + getObject(cobj->getObjID())->emitNewInstance(cobj); emit newInstance(cobj); } // Finally, initialize the actual object instance @@ -105,6 +106,7 @@ bool UAVObjectManager::registerObject(UAVDataObject* obj) } // Add the actual object instance in the list objects[objidx].append(obj); + getObject(obj->getObjID())->emitNewInstance(obj); emit newInstance(obj); return true; } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index 720d36ebd..9e7a27e5d 100755 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -83,7 +83,10 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/cameradesired.h \ $$UAVOBJECT_SYNTHETICS/faultsettings.h \ $$UAVOBJECT_SYNTHETICS/pipxsettings.h \ - $$UAVOBJECT_SYNTHETICS/pipxstatus.h + $$UAVOBJECT_SYNTHETICS/pipxstatus.h \ + $$UAVOBJECT_SYNTHETICS/waypoint.h \ + $$UAVOBJECT_SYNTHETICS/waypointactive.h \ + $$UAVOBJECT_SYNTHETICS/pathaction.h SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/baroaltitude.cpp \ @@ -146,4 +149,7 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/cameradesired.cpp \ $$UAVOBJECT_SYNTHETICS/faultsettings.cpp \ $$UAVOBJECT_SYNTHETICS/pipxsettings.cpp \ - $$UAVOBJECT_SYNTHETICS/pipxstatus.cpp + $$UAVOBJECT_SYNTHETICS/pipxstatus.cpp \ + $$UAVOBJECT_SYNTHETICS/waypoint.cpp \ + $$UAVOBJECT_SYNTHETICS/waypointactive.cpp \ + $$UAVOBJECT_SYNTHETICS/pathaction.cpp diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurveline.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurveline.h index 80fb50e0c..417f5b1ca 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurveline.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurveline.h @@ -51,7 +51,7 @@ public: void adjust(); - enum { Type = UserType + 2 }; + enum { Type = UserType + 12 }; int type() const { return Type; } protected: diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h index eca445d32..8c658b993 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvepoint.h @@ -45,7 +45,7 @@ public: void addEdge(Edge *edge); QList edges() const; - enum { Type = UserType + 1 }; + enum { Type = UserType + 10 }; int type() const { return Type; } diff --git a/shared/uavobjectdefinition/pathaction.xml b/shared/uavobjectdefinition/pathaction.xml new file mode 100644 index 000000000..8261c170c --- /dev/null +++ b/shared/uavobjectdefinition/pathaction.xml @@ -0,0 +1,30 @@ + + + A waypoint command the pathplanner is to use at a certain waypoint + + + + + + + + + + + + + + + + diff --git a/shared/uavobjectdefinition/waypoint.xml b/shared/uavobjectdefinition/waypoint.xml new file mode 100644 index 000000000..45107e7d4 --- /dev/null +++ b/shared/uavobjectdefinition/waypoint.xml @@ -0,0 +1,12 @@ + + + A waypoint the aircraft can try and hit. Used by the @ref PathPlanner module + + + + + + + + + diff --git a/shared/uavobjectdefinition/waypointactive.xml b/shared/uavobjectdefinition/waypointactive.xml new file mode 100644 index 000000000..b0e2f3785 --- /dev/null +++ b/shared/uavobjectdefinition/waypointactive.xml @@ -0,0 +1,10 @@ + + + Indicates the currently active waypoint + + + + + + +