From 7cb291a1402ea3301990b9a6c94de8f80c9d00f3 Mon Sep 17 00:00:00 2001 From: dankers Date: Fri, 16 Jul 2010 14:06:09 +0000 Subject: [PATCH] More doxygen header updates, I hate my life... git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1114 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/hitlil2/hitlil2widget.h | 2 +- ground/src/plugins/hitlil2/il2bridge.cpp | 2 +- .../src/plugins/modelview/modelviewgadget.cpp | 8 +- .../src/plugins/modelview/modelviewgadget.h | 8 +- .../modelviewgadgetconfiguration.cpp | 10 +- .../modelview/modelviewgadgetconfiguration.h | 10 +- .../modelview/modelviewgadgetfactory.cpp | 8 +- .../modelview/modelviewgadgetfactory.h | 8 +- .../modelview/modelviewgadgetoptionspage.cpp | 10 +- .../modelview/modelviewgadgetoptionspage.h | 10 +- .../modelview/modelviewgadgetwidget.cpp | 8 +- .../plugins/modelview/modelviewgadgetwidget.h | 8 +- .../src/plugins/modelview/modelviewplugin.cpp | 8 +- .../src/plugins/modelview/modelviewplugin.h | 8 +- .../opmap/opmap_edit_waypoint_dialog.cpp | 8 +- .../opmap/opmap_edit_waypoint_dialog.h | 8 +- .../plugins/opmap/opmap_overlay_widget.cpp | 27 + .../src/plugins/opmap/opmap_overlay_widget.h | 27 + .../plugins/opmap/opmap_statusbar_widget.cpp | 27 + .../plugins/opmap/opmap_statusbar_widget.h | 27 + .../opmap/opmap_waypointeditor_dialog.cpp | 8 +- .../opmap/opmap_waypointeditor_dialog.h | 8 +- .../opmap/opmap_zoom_slider_widget.cpp | 27 + .../plugins/opmap/opmap_zoom_slider_widget.h | 27 + ground/src/plugins/opmap/opmapgadget.cpp | 108 +- ground/src/plugins/opmap/opmapgadget.h | 114 +- .../opmap/opmapgadgetconfiguration.cpp | 228 +- .../plugins/opmap/opmapgadgetconfiguration.h | 178 +- .../src/plugins/opmap/opmapgadgetfactory.cpp | 116 +- ground/src/plugins/opmap/opmapgadgetfactory.h | 104 +- .../plugins/opmap/opmapgadgetoptionspage.cpp | 256 +- .../plugins/opmap/opmapgadgetoptionspage.h | 136 +- .../src/plugins/opmap/opmapgadgetwidget.cpp | 2630 ++++++++--------- ground/src/plugins/opmap/opmapgadgetwidget.h | 504 ++-- ground/src/plugins/opmap/opmapplugin.cpp | 8 +- ground/src/plugins/opmap/opmapplugin.h | 8 +- 36 files changed, 2427 insertions(+), 2265 deletions(-) diff --git a/ground/src/plugins/hitlil2/hitlil2widget.h b/ground/src/plugins/hitlil2/hitlil2widget.h index 6638b7f5c..8c0d75a46 100644 --- a/ground/src/plugins/hitlil2/hitlil2widget.h +++ b/ground/src/plugins/hitlil2/hitlil2widget.h @@ -5,7 +5,7 @@ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlplugin + * @defgroup hitlil2plugin * @{ * *****************************************************************************/ diff --git a/ground/src/plugins/hitlil2/il2bridge.cpp b/ground/src/plugins/hitlil2/il2bridge.cpp index c2c0992c8..d1391a054 100644 --- a/ground/src/plugins/hitlil2/il2bridge.cpp +++ b/ground/src/plugins/hitlil2/il2bridge.cpp @@ -5,7 +5,7 @@ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief * @see The GNU Public License (GPL) Version 3 - * @defgroup hitlplugin + * @defgroup hitlil2plugin * @{ * *****************************************************************************/ diff --git a/ground/src/plugins/modelview/modelviewgadget.cpp b/ground/src/plugins/modelview/modelviewgadget.cpp index 69e039907..8842c781d 100644 --- a/ground/src/plugins/modelview/modelviewgadget.cpp +++ b/ground/src/plugins/modelview/modelviewgadget.cpp @@ -3,11 +3,11 @@ * * @file modelviewgadget.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewgadget.h b/ground/src/plugins/modelview/modelviewgadget.h index c323e0d07..7e0aa975b 100644 --- a/ground/src/plugins/modelview/modelviewgadget.h +++ b/ground/src/plugins/modelview/modelviewgadget.h @@ -3,11 +3,11 @@ * * @file modelviewgadget.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp b/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp index d2cfaac17..2a13d64ce 100644 --- a/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp +++ b/ground/src/plugins/modelview/modelviewgadgetconfiguration.cpp @@ -3,13 +3,13 @@ * * @file modelviewgadgetconfiguration.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ -/* +/* * 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 diff --git a/ground/src/plugins/modelview/modelviewgadgetconfiguration.h b/ground/src/plugins/modelview/modelviewgadgetconfiguration.h index f975ce920..6ffcf0738 100644 --- a/ground/src/plugins/modelview/modelviewgadgetconfiguration.h +++ b/ground/src/plugins/modelview/modelviewgadgetconfiguration.h @@ -3,13 +3,13 @@ * * @file modelviewgadgetconfiguration.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ -/* +/* * 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 diff --git a/ground/src/plugins/modelview/modelviewgadgetfactory.cpp b/ground/src/plugins/modelview/modelviewgadgetfactory.cpp index f0bfa6b1e..4ef9986e6 100644 --- a/ground/src/plugins/modelview/modelviewgadgetfactory.cpp +++ b/ground/src/plugins/modelview/modelviewgadgetfactory.cpp @@ -3,11 +3,11 @@ * * @file modelviewgadgetfactory.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewgadgetfactory.h b/ground/src/plugins/modelview/modelviewgadgetfactory.h index d834ae86b..750c78798 100644 --- a/ground/src/plugins/modelview/modelviewgadgetfactory.h +++ b/ground/src/plugins/modelview/modelviewgadgetfactory.h @@ -3,11 +3,11 @@ * * @file modelviewgadgetfactory.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp b/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp index 411101ca9..f2f4f97b3 100644 --- a/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp +++ b/ground/src/plugins/modelview/modelviewgadgetoptionspage.cpp @@ -3,13 +3,13 @@ * * @file modelviewgadgetoptionspage.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ -/* +/* * 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 diff --git a/ground/src/plugins/modelview/modelviewgadgetoptionspage.h b/ground/src/plugins/modelview/modelviewgadgetoptionspage.h index fbf2dfc38..b7eedda8a 100644 --- a/ground/src/plugins/modelview/modelviewgadgetoptionspage.h +++ b/ground/src/plugins/modelview/modelviewgadgetoptionspage.h @@ -3,13 +3,13 @@ * * @file modelviewgadgetoptionspage.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ -/* +/* * 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 diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.cpp b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp index 0a16fc76b..67e577362 100644 --- a/ground/src/plugins/modelview/modelviewgadgetwidget.cpp +++ b/ground/src/plugins/modelview/modelviewgadgetwidget.cpp @@ -3,11 +3,11 @@ * * @file modelviewgadgetwidget.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewgadgetwidget.h b/ground/src/plugins/modelview/modelviewgadgetwidget.h index fdba94e88..05295ddbf 100644 --- a/ground/src/plugins/modelview/modelviewgadgetwidget.h +++ b/ground/src/plugins/modelview/modelviewgadgetwidget.h @@ -3,11 +3,11 @@ * * @file modelviewgadgetwidget.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewplugin.cpp b/ground/src/plugins/modelview/modelviewplugin.cpp index d343abdf1..3d1756c61 100644 --- a/ground/src/plugins/modelview/modelviewplugin.cpp +++ b/ground/src/plugins/modelview/modelviewplugin.cpp @@ -3,11 +3,11 @@ * * @file modelviewplugin.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/modelview/modelviewplugin.h b/ground/src/plugins/modelview/modelviewplugin.h index 7b6930986..5f01c62ab 100644 --- a/ground/src/plugins/modelview/modelviewplugin.h +++ b/ground/src/plugins/modelview/modelviewplugin.h @@ -3,11 +3,11 @@ * * @file modelviewplugin.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup modelviewplugin + * @addtogroup GCSPlugins GCS Plugins * @{ - * + * @addtogroup ModelViewPlugin ModelView Plugin + * @{ + * @brief A gadget that displays a 3D representation of the UAV *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp b/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp index 1a2e86ae1..c7cbb53b0 100644 --- a/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp +++ b/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.cpp @@ -3,11 +3,11 @@ * * @file opmap_edit_waypoint_dialog.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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 diff --git a/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.h b/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.h index 264ce594c..062590fdd 100644 --- a/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.h +++ b/ground/src/plugins/opmap/opmap_edit_waypoint_dialog.h @@ -3,11 +3,11 @@ * * @file opmap_edit_waypoint_dialog.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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 diff --git a/ground/src/plugins/opmap/opmap_overlay_widget.cpp b/ground/src/plugins/opmap/opmap_overlay_widget.cpp index fb4b9d6d6..4c7f7aeab 100644 --- a/ground/src/plugins/opmap/opmap_overlay_widget.cpp +++ b/ground/src/plugins/opmap/opmap_overlay_widget.cpp @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @file opmap_overlay_widget.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 "opmap_overlay_widget.h" #include "ui_opmap_overlay_widget.h" diff --git a/ground/src/plugins/opmap/opmap_overlay_widget.h b/ground/src/plugins/opmap/opmap_overlay_widget.h index c50f29515..e10525d3d 100644 --- a/ground/src/plugins/opmap/opmap_overlay_widget.h +++ b/ground/src/plugins/opmap/opmap_overlay_widget.h @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @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 diff --git a/ground/src/plugins/opmap/opmap_statusbar_widget.cpp b/ground/src/plugins/opmap/opmap_statusbar_widget.cpp index 62353fdcd..4a8740794 100644 --- a/ground/src/plugins/opmap/opmap_statusbar_widget.cpp +++ b/ground/src/plugins/opmap/opmap_statusbar_widget.cpp @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @file opmap_statusbar_widget.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 "opmap_statusbar_widget.h" #include "ui_opmap_statusbar_widget.h" diff --git a/ground/src/plugins/opmap/opmap_statusbar_widget.h b/ground/src/plugins/opmap/opmap_statusbar_widget.h index d8a5f0451..ecb2d6206 100644 --- a/ground/src/plugins/opmap/opmap_statusbar_widget.h +++ b/ground/src/plugins/opmap/opmap_statusbar_widget.h @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @file opmap_statusbar_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_STATUSBAR_WIDGET_H #define OPMAP_STATUSBAR_WIDGET_H diff --git a/ground/src/plugins/opmap/opmap_waypointeditor_dialog.cpp b/ground/src/plugins/opmap/opmap_waypointeditor_dialog.cpp index 2832ae9d3..64ce36c23 100644 --- a/ground/src/plugins/opmap/opmap_waypointeditor_dialog.cpp +++ b/ground/src/plugins/opmap/opmap_waypointeditor_dialog.cpp @@ -3,11 +3,11 @@ * * @file opmap_waypointeditor_dialog.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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 diff --git a/ground/src/plugins/opmap/opmap_waypointeditor_dialog.h b/ground/src/plugins/opmap/opmap_waypointeditor_dialog.h index f8d1151dc..b12f9d5ee 100644 --- a/ground/src/plugins/opmap/opmap_waypointeditor_dialog.h +++ b/ground/src/plugins/opmap/opmap_waypointeditor_dialog.h @@ -3,11 +3,11 @@ * * @file opmap_waypointeditor_dialog.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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 diff --git a/ground/src/plugins/opmap/opmap_zoom_slider_widget.cpp b/ground/src/plugins/opmap/opmap_zoom_slider_widget.cpp index 6bd4208a7..e73b054ed 100644 --- a/ground/src/plugins/opmap/opmap_zoom_slider_widget.cpp +++ b/ground/src/plugins/opmap/opmap_zoom_slider_widget.cpp @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @file opmap_zoom_slider_widget.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 "opmap_zoom_slider_widget.h" #include "ui_opmap_zoom_slider_widget.h" diff --git a/ground/src/plugins/opmap/opmap_zoom_slider_widget.h b/ground/src/plugins/opmap/opmap_zoom_slider_widget.h index 5728c46c1..83087413e 100644 --- a/ground/src/plugins/opmap/opmap_zoom_slider_widget.h +++ b/ground/src/plugins/opmap/opmap_zoom_slider_widget.h @@ -1,3 +1,30 @@ +/** + ****************************************************************************** + * + * @file opmap_zoom_slider_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_ZOOM_SLIDER_WIDGET_H #define OPMAP_ZOOM_SLIDER_WIDGET_H diff --git a/ground/src/plugins/opmap/opmapgadget.cpp b/ground/src/plugins/opmap/opmapgadget.cpp index 4825ccf11..4f2028aa2 100644 --- a/ground/src/plugins/opmap/opmapgadget.cpp +++ b/ground/src/plugins/opmap/opmapgadget.cpp @@ -1,54 +1,54 @@ -/** - ****************************************************************************** - * - * @file opmapgadget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 "opmapgadget.h" -#include "opmapgadgetwidget.h" -#include "opmapgadgetconfiguration.h" - -OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) : - IUAVGadget(classId, parent), - m_widget(widget) -{ -} - -OPMapGadget::~OPMapGadget() -{ -} - -void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config) -{ - 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()); -} - +/** + ****************************************************************************** + * + * @file opmapgadget.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 "opmapgadget.h" +#include "opmapgadgetwidget.h" +#include "opmapgadgetconfiguration.h" + +OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) : + IUAVGadget(classId, parent), + m_widget(widget) +{ +} + +OPMapGadget::~OPMapGadget() +{ +} + +void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config) +{ + 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()); +} + diff --git a/ground/src/plugins/opmap/opmapgadget.h b/ground/src/plugins/opmap/opmapgadget.h index 813862f97..030caf986 100644 --- a/ground/src/plugins/opmap/opmapgadget.h +++ b/ground/src/plugins/opmap/opmapgadget.h @@ -1,57 +1,57 @@ -/** - ****************************************************************************** - * - * @file opmapgadget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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_GADGET_H_ -#define OPMAP_GADGET_H_ - -#include -#include "opmapgadgetwidget.h" - -class IUAVGadget; -//class QList; -class QWidget; -class QString; -class OPMapGadgetWidget; - -using namespace Core; - -class OPMapGadget : public Core::IUAVGadget -{ - Q_OBJECT -public: - OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent = 0); - ~OPMapGadget(); - - QWidget *widget() { return m_widget; } - void loadConfiguration(IUAVGadgetConfiguration* config); - -private: - OPMapGadgetWidget *m_widget; -}; - - -#endif // OPMAP_GADGET_H_ +/** + ****************************************************************************** + * + * @file opmapgadget.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_GADGET_H_ +#define OPMAP_GADGET_H_ + +#include +#include "opmapgadgetwidget.h" + +class IUAVGadget; +//class QList; +class QWidget; +class QString; +class OPMapGadgetWidget; + +using namespace Core; + +class OPMapGadget : public Core::IUAVGadget +{ + Q_OBJECT +public: + OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent = 0); + ~OPMapGadget(); + + QWidget *widget() { return m_widget; } + void loadConfiguration(IUAVGadgetConfiguration* config); + +private: + OPMapGadgetWidget *m_widget; +}; + + +#endif // OPMAP_GADGET_H_ diff --git a/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp index fd9f12a92..460c45a1a 100644 --- a/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp +++ b/ground/src/plugins/opmap/opmapgadgetconfiguration.cpp @@ -1,114 +1,114 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetconfiguration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 "opmapgadgetconfiguration.h" -#include -#include - -OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) : - IUAVGadgetConfiguration(classId, parent), - m_mapProvider("GoogleHybrid"), - m_defaultZoom(2), - m_defaultLatitude(0), - m_defaultLongitude(0), - m_useOpenGL(false), - m_showTileGridLines(false), - m_accessMode("ServerAndCache"), - m_useMemoryCache(true), - m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator()) -{ - if (state.count() > 0) - { - QDataStream stream(state); - - QString mapProvider; - int zoom; - double latitude; - double longitude; - bool useOpenGL; - bool showTileGridLines; - QString accessMode; - bool useMemoryCache; - QString cacheLocation; - - stream >> mapProvider; - stream >> zoom; - stream >> latitude; - stream >> longitude; - stream >> useOpenGL; - stream >> showTileGridLines; - stream >> accessMode; - stream >> useMemoryCache; - stream >> cacheLocation; - - if (!mapProvider.isEmpty()) m_mapProvider = mapProvider; - m_defaultZoom = zoom; - m_defaultLatitude = latitude; - m_defaultLongitude = longitude; - m_useOpenGL = useOpenGL; - m_showTileGridLines = showTileGridLines; - - if (!accessMode.isEmpty()) m_accessMode = accessMode; - m_useMemoryCache = useMemoryCache; - if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation; - } -} - -IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone() -{ - OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId()); - - m->m_mapProvider = m_mapProvider; - m->m_defaultZoom = m_defaultZoom; - m->m_defaultLatitude = m_defaultLatitude; - m->m_defaultLongitude = m_defaultLongitude; - m->m_useOpenGL = m_useOpenGL; - m->m_showTileGridLines = m_showTileGridLines; - m->m_accessMode = m_accessMode; - m->m_useMemoryCache = m_useMemoryCache; - m->m_cacheLocation = m_cacheLocation; - - return m; -} - -QByteArray OPMapGadgetConfiguration::saveState() const -{ - QByteArray bytes; - QDataStream stream(&bytes, QIODevice::WriteOnly); - - stream << m_mapProvider; - stream << m_defaultZoom; - stream << m_defaultLatitude; - stream << m_defaultLongitude; - stream << m_useOpenGL; - stream << m_showTileGridLines; - stream << m_accessMode; - stream << m_useMemoryCache; - stream << m_cacheLocation; - - return bytes; -} +/** + ****************************************************************************** + * + * @file opmapgadgetconfiguration.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 "opmapgadgetconfiguration.h" +#include +#include + +OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) : + IUAVGadgetConfiguration(classId, parent), + m_mapProvider("GoogleHybrid"), + m_defaultZoom(2), + m_defaultLatitude(0), + m_defaultLongitude(0), + m_useOpenGL(false), + m_showTileGridLines(false), + m_accessMode("ServerAndCache"), + m_useMemoryCache(true), + m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator()) +{ + if (state.count() > 0) + { + QDataStream stream(state); + + QString mapProvider; + int zoom; + double latitude; + double longitude; + bool useOpenGL; + bool showTileGridLines; + QString accessMode; + bool useMemoryCache; + QString cacheLocation; + + stream >> mapProvider; + stream >> zoom; + stream >> latitude; + stream >> longitude; + stream >> useOpenGL; + stream >> showTileGridLines; + stream >> accessMode; + stream >> useMemoryCache; + stream >> cacheLocation; + + if (!mapProvider.isEmpty()) m_mapProvider = mapProvider; + m_defaultZoom = zoom; + m_defaultLatitude = latitude; + m_defaultLongitude = longitude; + m_useOpenGL = useOpenGL; + m_showTileGridLines = showTileGridLines; + + if (!accessMode.isEmpty()) m_accessMode = accessMode; + m_useMemoryCache = useMemoryCache; + if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation; + } +} + +IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone() +{ + OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId()); + + m->m_mapProvider = m_mapProvider; + m->m_defaultZoom = m_defaultZoom; + m->m_defaultLatitude = m_defaultLatitude; + m->m_defaultLongitude = m_defaultLongitude; + m->m_useOpenGL = m_useOpenGL; + m->m_showTileGridLines = m_showTileGridLines; + m->m_accessMode = m_accessMode; + m->m_useMemoryCache = m_useMemoryCache; + m->m_cacheLocation = m_cacheLocation; + + return m; +} + +QByteArray OPMapGadgetConfiguration::saveState() const +{ + QByteArray bytes; + QDataStream stream(&bytes, QIODevice::WriteOnly); + + stream << m_mapProvider; + stream << m_defaultZoom; + stream << m_defaultLatitude; + stream << m_defaultLongitude; + stream << m_useOpenGL; + stream << m_showTileGridLines; + stream << m_accessMode; + stream << m_useMemoryCache; + stream << m_cacheLocation; + + return bytes; +} diff --git a/ground/src/plugins/opmap/opmapgadgetconfiguration.h b/ground/src/plugins/opmap/opmapgadgetconfiguration.h index 14d1245c6..7a3bba734 100644 --- a/ground/src/plugins/opmap/opmapgadgetconfiguration.h +++ b/ground/src/plugins/opmap/opmapgadgetconfiguration.h @@ -1,89 +1,89 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetconfiguration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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_GADGETCONFIGURATION_H -#define OPMAP_GADGETCONFIGURATION_H - -#include -#include - -using namespace Core; - -class OPMapGadgetConfiguration : public IUAVGadgetConfiguration -{ -Q_OBJECT - -Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider) -Q_PROPERTY(int zoommo READ zoom WRITE setZoom) -Q_PROPERTY(double latitude READ latitude WRITE setLatitude) -Q_PROPERTY(double longitude READ longitude WRITE setLongitude) -Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL) -Q_PROPERTY(bool showTileGridLines READ showTileGridLines WRITE setShowTileGridLines) -Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode) -Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache) -Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation) - -public: - explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); - QByteArray saveState() const; - IUAVGadgetConfiguration *clone(); - - QString mapProvider() const { return m_mapProvider; } - int zoom() const { return m_defaultZoom; } - double latitude() const { return m_defaultLatitude; } - double longitude() const { return m_defaultLongitude; } - bool useOpenGL() const { return m_useOpenGL; } - bool showTileGridLines() const { return m_showTileGridLines; } - QString accessMode() const { return m_accessMode; } - bool useMemoryCache() const { return m_useMemoryCache; } - QString cacheLocation() const { return m_cacheLocation; } - -public slots: - void setMapProvider(QString provider) { m_mapProvider = provider; } - void setZoom(int zoom) { m_defaultZoom = zoom; } - void setLatitude(double latitude) { m_defaultLatitude = latitude; } - void setLongitude(double longitude) { m_defaultLongitude = longitude; } - void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; } - void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; } - void setAccessMode(QString accessMode) { m_accessMode = accessMode; } - void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; } - void setCacheLocation(QString cacheLocation) { m_cacheLocation = cacheLocation; } - -private: - QString m_mapProvider; - int m_defaultZoom; - double m_defaultLatitude; - double m_defaultLongitude; - bool m_useOpenGL; - bool m_showTileGridLines; - QString m_accessMode; - bool m_useMemoryCache; - QString m_cacheLocation; - -}; - -#endif // OPMAP_GADGETCONFIGURATION_H +/** + ****************************************************************************** + * + * @file opmapgadgetconfiguration.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_GADGETCONFIGURATION_H +#define OPMAP_GADGETCONFIGURATION_H + +#include +#include + +using namespace Core; + +class OPMapGadgetConfiguration : public IUAVGadgetConfiguration +{ +Q_OBJECT + +Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider) +Q_PROPERTY(int zoommo READ zoom WRITE setZoom) +Q_PROPERTY(double latitude READ latitude WRITE setLatitude) +Q_PROPERTY(double longitude READ longitude WRITE setLongitude) +Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL) +Q_PROPERTY(bool showTileGridLines READ showTileGridLines WRITE setShowTileGridLines) +Q_PROPERTY(QString accessMode READ accessMode WRITE setAccessMode) +Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache) +Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation) + +public: + explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); + QByteArray saveState() const; + IUAVGadgetConfiguration *clone(); + + QString mapProvider() const { return m_mapProvider; } + int zoom() const { return m_defaultZoom; } + double latitude() const { return m_defaultLatitude; } + double longitude() const { return m_defaultLongitude; } + bool useOpenGL() const { return m_useOpenGL; } + bool showTileGridLines() const { return m_showTileGridLines; } + QString accessMode() const { return m_accessMode; } + bool useMemoryCache() const { return m_useMemoryCache; } + QString cacheLocation() const { return m_cacheLocation; } + +public slots: + void setMapProvider(QString provider) { m_mapProvider = provider; } + void setZoom(int zoom) { m_defaultZoom = zoom; } + void setLatitude(double latitude) { m_defaultLatitude = latitude; } + void setLongitude(double longitude) { m_defaultLongitude = longitude; } + void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; } + void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; } + void setAccessMode(QString accessMode) { m_accessMode = accessMode; } + void setUseMemoryCache(bool useMemoryCache) { m_useMemoryCache = useMemoryCache; } + void setCacheLocation(QString cacheLocation) { m_cacheLocation = cacheLocation; } + +private: + QString m_mapProvider; + int m_defaultZoom; + double m_defaultLatitude; + double m_defaultLongitude; + bool m_useOpenGL; + bool m_showTileGridLines; + QString m_accessMode; + bool m_useMemoryCache; + QString m_cacheLocation; + +}; + +#endif // OPMAP_GADGETCONFIGURATION_H diff --git a/ground/src/plugins/opmap/opmapgadgetfactory.cpp b/ground/src/plugins/opmap/opmapgadgetfactory.cpp index 2c665fc3b..c8c3e3ba2 100644 --- a/ground/src/plugins/opmap/opmapgadgetfactory.cpp +++ b/ground/src/plugins/opmap/opmapgadgetfactory.cpp @@ -1,58 +1,58 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetfactory.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 "opmapgadgetfactory.h" -#include "opmapgadgetwidget.h" -#include "opmapgadget.h" -#include "opmapgadgetconfiguration.h" -#include "opmapgadgetoptionspage.h" -#include - -OPMapGadgetFactory::OPMapGadgetFactory(QObject *parent) : - IUAVGadgetFactory(QString("OPMapGadget"), tr("OPMap Gadget"), parent) -{ -} - -OPMapGadgetFactory::~OPMapGadgetFactory() -{ -} - -Core::IUAVGadget * OPMapGadgetFactory::createGadget(QWidget *parent) -{ - OPMapGadgetWidget *gadgetWidget = new OPMapGadgetWidget(parent); - return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent); -} - -IUAVGadgetConfiguration * OPMapGadgetFactory::createConfiguration(const QByteArray &state) -{ - return new OPMapGadgetConfiguration(QString("OPMapGadget"), state); -} - -IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) -{ - return new OPMapGadgetOptionsPage(qobject_cast(config)); -} - +/** + ****************************************************************************** + * + * @file opmapgadgetfactory.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 "opmapgadgetfactory.h" +#include "opmapgadgetwidget.h" +#include "opmapgadget.h" +#include "opmapgadgetconfiguration.h" +#include "opmapgadgetoptionspage.h" +#include + +OPMapGadgetFactory::OPMapGadgetFactory(QObject *parent) : + IUAVGadgetFactory(QString("OPMapGadget"), tr("OPMap Gadget"), parent) +{ +} + +OPMapGadgetFactory::~OPMapGadgetFactory() +{ +} + +Core::IUAVGadget * OPMapGadgetFactory::createGadget(QWidget *parent) +{ + OPMapGadgetWidget *gadgetWidget = new OPMapGadgetWidget(parent); + return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent); +} + +IUAVGadgetConfiguration * OPMapGadgetFactory::createConfiguration(const QByteArray &state) +{ + return new OPMapGadgetConfiguration(QString("OPMapGadget"), state); +} + +IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) +{ + return new OPMapGadgetOptionsPage(qobject_cast(config)); +} + diff --git a/ground/src/plugins/opmap/opmapgadgetfactory.h b/ground/src/plugins/opmap/opmapgadgetfactory.h index 75a538929..a5391477d 100644 --- a/ground/src/plugins/opmap/opmapgadgetfactory.h +++ b/ground/src/plugins/opmap/opmapgadgetfactory.h @@ -1,52 +1,52 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetfactory.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 OPAMP_GADGETFACTORY_H_ -#define OPMAP_GADGETFACTORY_H_ - -#include - -namespace Core { -class IUAVGadget; -class IUAVGadgetFactory; -} - -using namespace Core; - -class OPMapGadgetFactory : public Core::IUAVGadgetFactory -{ - Q_OBJECT -public: - OPMapGadgetFactory(QObject *parent = 0); - ~OPMapGadgetFactory(); - - Core::IUAVGadget *createGadget(QWidget *parent); - IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); - IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); -}; - -#endif // OPMAP_GADGETFACTORY_H_ +/** + ****************************************************************************** + * + * @file opmapgadgetfactory.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 OPAMP_GADGETFACTORY_H_ +#define OPMAP_GADGETFACTORY_H_ + +#include + +namespace Core { +class IUAVGadget; +class IUAVGadgetFactory; +} + +using namespace Core; + +class OPMapGadgetFactory : public Core::IUAVGadgetFactory +{ + Q_OBJECT +public: + OPMapGadgetFactory(QObject *parent = 0); + ~OPMapGadgetFactory(); + + Core::IUAVGadget *createGadget(QWidget *parent); + IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); + IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); +}; + +#endif // OPMAP_GADGETFACTORY_H_ diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp index 9c9873339..504a2117d 100644 --- a/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp +++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.cpp @@ -1,128 +1,128 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetoptionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 "opmapgadgetoptionspage.h" -#include "opmapgadgetconfiguration.h" -#include -#include -#include -#include -#include -#include -#include - -#include "opmapcontrol/opmapcontrol.h" - -#include "ui_opmapgadgetoptionspage.h" - -// ********************************************* - -OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) : - IOptionsPage(parent), - m_config(config) -{ -} - -QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent) -{ - m_page = new Ui::OPMapGadgetOptionsPage(); - QWidget *w = new QWidget(parent); - m_page->setupUi(w); - - // populate the map provider combobox - m_page->providerComboBox->clear(); - m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes()); - - // populate the access mode combobox - m_page->accessModeComboBox->clear(); - m_page->accessModeComboBox->addItems(mapcontrol::Helper::AccessModeTypes()); - - int index = m_page->providerComboBox->findText(m_config->mapProvider()); - index = (index >= 0) ? index : 0; - m_page->providerComboBox->setCurrentIndex(index); - - m_page->zoomSpinBox->setValue(m_config->zoom()); - m_page->latitudeSpinBox->setValue(m_config->latitude()); - m_page->longitudeSpinBox->setValue(m_config->longitude()); - - m_page->checkBoxUseOpenGL->setChecked(m_config->useOpenGL()); - m_page->checkBoxShowTileGridLines->setChecked(m_config->showTileGridLines()); - - index = m_page->accessModeComboBox->findText(m_config->accessMode()); - index = (index >= 0) ? index : 0; - m_page->accessModeComboBox->setCurrentIndex(index); - - m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache()); - m_page->lineEditCacheLocation->setText(m_config->cacheLocation()); - - connect(m_page->pushButtonCacheLocation, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheLocation_clicked())); - connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked())); - - return w; -} - -void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked() -{ - QString dir = m_page->lineEditCacheLocation->text(); - -// QDir dirPath(dir); -// dir = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); -// if (!dir.isEmpty()) m_page->lineEditCacheLocation->setText(dir); - - QFileDialog::Options options(QFileDialog::ShowDirsOnly); - QString path = QFileDialog::getExistingDirectory(qobject_cast(this), tr("Choose a cache directory"), dir, options); - if (!path.isEmpty()) m_page->lineEditCacheLocation->setText(path); -} - -void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked() -{ - int index = m_page->accessModeComboBox->findText("ServerAndCache"); - index = (index >= 0) ? index : 0; - m_page->accessModeComboBox->setCurrentIndex(index); - - m_page->checkBoxUseMemoryCache->setChecked(true); - - m_page->lineEditCacheLocation->setText(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator()); -} - -void OPMapGadgetOptionsPage::apply() -{ - m_config->setMapProvider(m_page->providerComboBox->currentText()); - m_config->setZoom(m_page->zoomSpinBox->value()); - m_config->setLatitude(m_page->latitudeSpinBox->value()); - m_config->setLongitude(m_page->longitudeSpinBox->value()); - m_config->setUseOpenGL(m_page->checkBoxUseOpenGL->isChecked()); - m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked()); - m_config->setAccessMode(m_page->accessModeComboBox->currentText()); - m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked()); - m_config->setCacheLocation(m_page->lineEditCacheLocation->text()); -} - -void OPMapGadgetOptionsPage::finish() -{ - delete m_page; -} +/** + ****************************************************************************** + * + * @file opmapgadgetoptionspage.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 "opmapgadgetoptionspage.h" +#include "opmapgadgetconfiguration.h" +#include +#include +#include +#include +#include +#include +#include + +#include "opmapcontrol/opmapcontrol.h" + +#include "ui_opmapgadgetoptionspage.h" + +// ********************************************* + +OPMapGadgetOptionsPage::OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent) : + IOptionsPage(parent), + m_config(config) +{ +} + +QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent) +{ + m_page = new Ui::OPMapGadgetOptionsPage(); + QWidget *w = new QWidget(parent); + m_page->setupUi(w); + + // populate the map provider combobox + m_page->providerComboBox->clear(); + m_page->providerComboBox->addItems(mapcontrol::Helper::MapTypes()); + + // populate the access mode combobox + m_page->accessModeComboBox->clear(); + m_page->accessModeComboBox->addItems(mapcontrol::Helper::AccessModeTypes()); + + int index = m_page->providerComboBox->findText(m_config->mapProvider()); + index = (index >= 0) ? index : 0; + m_page->providerComboBox->setCurrentIndex(index); + + m_page->zoomSpinBox->setValue(m_config->zoom()); + m_page->latitudeSpinBox->setValue(m_config->latitude()); + m_page->longitudeSpinBox->setValue(m_config->longitude()); + + m_page->checkBoxUseOpenGL->setChecked(m_config->useOpenGL()); + m_page->checkBoxShowTileGridLines->setChecked(m_config->showTileGridLines()); + + index = m_page->accessModeComboBox->findText(m_config->accessMode()); + index = (index >= 0) ? index : 0; + m_page->accessModeComboBox->setCurrentIndex(index); + + m_page->checkBoxUseMemoryCache->setChecked(m_config->useMemoryCache()); + m_page->lineEditCacheLocation->setText(m_config->cacheLocation()); + + connect(m_page->pushButtonCacheLocation, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheLocation_clicked())); + connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked())); + + return w; +} + +void OPMapGadgetOptionsPage::on_pushButtonCacheLocation_clicked() +{ + QString dir = m_page->lineEditCacheLocation->text(); + +// QDir dirPath(dir); +// dir = dirPath.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); +// if (!dir.isEmpty()) m_page->lineEditCacheLocation->setText(dir); + + QFileDialog::Options options(QFileDialog::ShowDirsOnly); + QString path = QFileDialog::getExistingDirectory(qobject_cast(this), tr("Choose a cache directory"), dir, options); + if (!path.isEmpty()) m_page->lineEditCacheLocation->setText(path); +} + +void OPMapGadgetOptionsPage::on_pushButtonCacheDefaults_clicked() +{ + int index = m_page->accessModeComboBox->findText("ServerAndCache"); + index = (index >= 0) ? index : 0; + m_page->accessModeComboBox->setCurrentIndex(index); + + m_page->checkBoxUseMemoryCache->setChecked(true); + + m_page->lineEditCacheLocation->setText(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator()); +} + +void OPMapGadgetOptionsPage::apply() +{ + m_config->setMapProvider(m_page->providerComboBox->currentText()); + m_config->setZoom(m_page->zoomSpinBox->value()); + m_config->setLatitude(m_page->latitudeSpinBox->value()); + m_config->setLongitude(m_page->longitudeSpinBox->value()); + m_config->setUseOpenGL(m_page->checkBoxUseOpenGL->isChecked()); + m_config->setShowTileGridLines(m_page->checkBoxShowTileGridLines->isChecked()); + m_config->setAccessMode(m_page->accessModeComboBox->currentText()); + m_config->setUseMemoryCache(m_page->checkBoxUseMemoryCache->isChecked()); + m_config->setCacheLocation(m_page->lineEditCacheLocation->text()); +} + +void OPMapGadgetOptionsPage::finish() +{ + delete m_page; +} diff --git a/ground/src/plugins/opmap/opmapgadgetoptionspage.h b/ground/src/plugins/opmap/opmapgadgetoptionspage.h index b796c9306..b7a3cbf81 100644 --- a/ground/src/plugins/opmap/opmapgadgetoptionspage.h +++ b/ground/src/plugins/opmap/opmapgadgetoptionspage.h @@ -1,68 +1,68 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetoptionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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_GADGETOPTIONSPAGE_H -#define OPMAP_GADGETOPTIONSPAGE_H - -#include "coreplugin/dialogs/ioptionspage.h" - -class OPMapGadgetConfiguration; - -namespace Core { - class IUAVGadgetConfiguration; -} - -namespace Ui { - class OPMapGadgetOptionsPage; -} - -using namespace Core; - -class OPMapGadgetOptionsPage : public IOptionsPage -{ -Q_OBJECT -public: - explicit OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent = 0); - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -signals: - -public slots: - -private slots: - void on_pushButtonCacheLocation_clicked(); - void on_pushButtonCacheDefaults_clicked(); - -private: - OPMapGadgetConfiguration *m_config; - Ui::OPMapGadgetOptionsPage *m_page; -}; - -#endif // OPMAP_GADGETOPTIONSPAGE_H +/** + ****************************************************************************** + * + * @file opmapgadgetoptionspage.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_GADGETOPTIONSPAGE_H +#define OPMAP_GADGETOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" + +class OPMapGadgetConfiguration; + +namespace Core { + class IUAVGadgetConfiguration; +} + +namespace Ui { + class OPMapGadgetOptionsPage; +} + +using namespace Core; + +class OPMapGadgetOptionsPage : public IOptionsPage +{ +Q_OBJECT +public: + explicit OPMapGadgetOptionsPage(OPMapGadgetConfiguration *config, QObject *parent = 0); + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +signals: + +public slots: + +private slots: + void on_pushButtonCacheLocation_clicked(); + void on_pushButtonCacheDefaults_clicked(); + +private: + OPMapGadgetConfiguration *m_config; + Ui::OPMapGadgetOptionsPage *m_page; +}; + +#endif // OPMAP_GADGETOPTIONSPAGE_H diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/src/plugins/opmap/opmapgadgetwidget.cpp index 9db961940..fda30ea53 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/src/plugins/opmap/opmapgadgetwidget.cpp @@ -1,1315 +1,1315 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetwidget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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 "opmapgadgetwidget.h" -#include "ui_opmap_widget.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -// ************************************************************************************* - -// constructor -OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) -{ - // ************** - - m_widget = NULL; - m_map = NULL; - findPlaceCompleter = NULL; - m_overlay_widget = NULL; - - m_map_graphics_scene = NULL; - m_map_scene_proxy = NULL; - m_zoom_slider_widget = NULL; - m_statusbar_widget = NULL; - - - m_plugin_manager = NULL; - m_objManager = NULL; - m_positionActual = NULL; - - m_mouse_waypoint = NULL; - - prev_tile_number = 0; - - // ************** - // fetch required UAVObjects - - m_plugin_manager = ExtensionSystem::PluginManager::instance(); - m_objManager = m_plugin_manager->getObject(); - m_positionActual = PositionActual::GetInstance(m_objManager); - - // get current UAV data - PositionActual::DataFields data = m_positionActual->getData(); - - // ************** - // create the widget that holds the user controls and the map - - m_widget = new Ui::OPMap_Widget(); - m_widget->setupUi(this); - - // ************** - // create the central map widget - - m_map = new mapcontrol::OPMapWidget(); - - m_map->setFrameStyle(QFrame::NoFrame); // no border frame - m_map->setBackgroundBrush(Qt::black); // black background - - m_map->configuration->DragButton = Qt::LeftButton; // use the left mouse button for map dragging - m_map->SetMinZoom(2); - m_map->SetMaxZoom(19); - m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions - m_map->SetFollowMouse(true); // we want a contiuous mouse position reading - m_map->SetShowUAV(true); // display the UAV position on the map - -// m_map->UAV->SetTrailTime(1); // seconds -// m_map->UAV->SetTrailDistance(0.1); // kilometers - - m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed); -// m_map->UAV->SetTrailType(UAVTrailType::ByDistance); - - // ************** - - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(m_map); - m_widget->mapWidget->setLayout(layout); - - // ************** - // create the user controls overlayed onto the map - - // doing this makes the map VERY slow :( - -/* - m_zoom_slider_widget = new opmap_zoom_slider_widget(); - m_statusbar_widget = new opmap_statusbar_widget(); - - m_map_graphics_scene = m_map->scene(); - - m_map_scene_proxy = m_map_graphics_scene->addWidget(m_zoom_slider_widget); - m_map_scene_proxy = m_map_graphics_scene->addWidget(m_statusbar_widget); - - m_zoom_slider_widget->move(m_map->width() - 20 - m_zoom_slider_widget->width(), 20); - m_statusbar_widget->move(0, m_map->height() - m_statusbar_widget->height()); -*/ -/* - m_overlay_widget = new opmap_overlay_widget(m_map); - QVBoxLayout *layout2 = new QVBoxLayout; - layout2->setSpacing(0); - layout2->setContentsMargins(0, 0, 0, 0); - layout2->addWidget(m_overlay_widget); - m_map->setLayout(layout2); -*/ - // ************** - // set the user control options - - m_widget->labelUAVPos->setText("---"); - m_widget->labelMapPos->setText("---"); - m_widget->labelMousePos->setText("---"); - - m_widget->splitter->setCollapsible(1, false); - - // set the size of the collapsable widgets - QList m_SizeList; -// m_SizeList << m_widget->splitter->sizes(); - m_SizeList << 0 << 0 << 0; - m_widget->splitter->setSizes(m_SizeList); - - m_widget->progressBarMap->setMaximum(1); - - m_widget->toolButtonShowUAVtrail->setChecked(true); - -/* - #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 -*/ - // ************** - // add an auto-completer to the find-place line edit box -/* - findPlaceWordList << "england" << "london" << "birmingham" << "shropshire"; - QCompleter *findPlaceCompleter = new QCompleter(findPlaceWordList, this); - findPlaceCompleter->setCaseSensitivity(Qt::CaseInsensitive); - findPlaceCompleter->setCompletionMode(QCompleter::PopupCompletion); - findPlaceCompleter->setModelSorting(QCompleter::CaseInsensitivelySortedModel); - m_widget->comboBoxFindPlace->setCompleter(findPlaceCompleter); -*/ - m_widget->comboBoxFindPlace->setAutoCompletion(true); - - connect( m_widget->comboBoxFindPlace->lineEdit(), SIGNAL(returnPressed()), this, SLOT(comboBoxFindPlace_returnPressed())); - - // ************** - // init the waypoint tree (shown on the left on the map plugin GUI) - - m_widget->treeViewWaypoints->setModel(&wayPoint_treeView_model); - -/* - // test -// wayPoint_treeView_model = new QStandardItemModel(5, 2); - for (int r = 0; r < 5; r++) - { - for (int c = 0; c < 2; c++) - { - QStandardItem *item = new QStandardItem(QString("Row:%0, Column:%1").arg(r).arg(c)); - - if (c == 0) - { - for (int i = 0; i < 3; i++) - { - QStandardItem *child = new QStandardItem(QString("Item %0").arg(i)); - child->setEditable(false); - item->appendRow(child); - } - } - - wayPoint_treeView_model->setItem(r, c, item); - } - } - wayPoint_treeView_model->setHorizontalHeaderItem(0, new QStandardItem("Foo")); - wayPoint_treeView_model->setHorizontalHeaderItem(1, new QStandardItem("Bar-Baz")); - -// m_widget->treeViewWaypoints->setModel(wayPoint_treeView_model); -*/ - - - - - - // test only -/* - // create a waypoint group - QStandardItem *item = new QStandardItem(tr("Camera shoot at the town hall")); - // add some waypoints - { - QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "North side window view"); - child->setEditable(true); - item->appendRow(child); - } - { - QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "East side window view"); - child->setEditable(true); - item->appendRow(child); - } - { - QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "South side window view"); - child->setEditable(true); - item->appendRow(child); - } - { - QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "West side window view"); - child->setEditable(true); - item->appendRow(child); - } - wayPoint_treeView_model.appendRow(item); -*/ - // create another waypoint group - QStandardItem *item = new QStandardItem(tr("Flight path 62")); - for (int i = 1; i < 8; i++) - { // add some waypoints - QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), QString("Waypoint %0").arg(i)); - child->setEditable(true); - item->appendRow(child); - } - wayPoint_treeView_model.appendRow(item); - - - - - - - - - - - // ************** - // map stuff - - connect(m_map, SIGNAL(zoomChanged(double)), this, SLOT(zoomChanged(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&))); - - m_map->SetCurrentPosition(internals::PointLatLng(data.Latitude, data.Longitude)); // set the default map position - - // ************** - // create various context menu (mouse right click menu) actions - - createActions(); - - // ************** - // create the desired timers - - // Pip .. I don't like polling, I prefer an efficient event driven system (signal/slot) but this will do for now - - m_updateTimer = new QTimer(); - m_updateTimer->setInterval(200); - connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition())); - m_updateTimer->start(); - - m_statusUpdateTimer = new QTimer(); - m_statusUpdateTimer->setInterval(200); - connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos())); - m_statusUpdateTimer->start(); - - // ************** -} - -// destructor -OPMapGadgetWidget::~OPMapGadgetWidget() -{ - - - // 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 - - onClearWayPointsAct_triggered(); - - if (m_zoom_slider_widget) delete m_zoom_slider_widget; - if (m_statusbar_widget) delete m_statusbar_widget; - if (m_map) delete m_map; - if (m_widget) delete m_widget; -} - -// ************************************************************************************* -// widget signals - -void OPMapGadgetWidget::resizeEvent(QResizeEvent *event) -{ -// update(); - QWidget::resizeEvent(event); -} - -void OPMapGadgetWidget::mouseMoveEvent(QMouseEvent *event) -{ - if (m_map) - { -// mouse_lat_lon = m_map->currentMousePosition(); // fetch the current mouse lat/longitude position -// if (mouse_lat_lon != lat_lon) -// { // the mouse has moved -// mouse_lat_lon = lat_lon; -// -// QString coord_str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 7) + " "; -// -// statusLabel.setText(coord_str); -// widget->labelStatus->setText(coord_str); -// } - } - - if (event->buttons() & Qt::LeftButton) - { - QPoint pos = event->pos(); - } - - QWidget::mouseMoveEvent(event); -} - -void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) -{ - if (event->reason() != QContextMenuEvent::Mouse) - return; // not a mouse click event - - if (!m_map) - return; // we don't appear to have a map to work with! - - // current mouse position - QPoint p = m_map->mapFromGlobal(QCursor::pos()); - - // save the current lat/lon mouse position - mouse_lat_lon = m_map->currentMousePosition(); - - if (!m_map->contentsRect().contains(p)) - return; // the mouse click was not on the map - - // find out if we have a waypoint under the mouse cursor - QGraphicsItem *item = m_map->itemAt(p); - m_mouse_waypoint = qgraphicsitem_cast(item); - - // find out if the waypoint is locked (or not) - bool waypoint_locked = false; - if (m_mouse_waypoint) - waypoint_locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; - - // **************** - // Dynamically create the popup menu - - QMenu menu(this); - - menu.addAction(closeAct); - - menu.addSeparator(); - - menu.addAction(reloadAct); - - menu.addSeparator(); - - QMenu copySubMenu(tr("Copy"), this); - copySubMenu.addAction(copyMouseLatLonToClipAct); - copySubMenu.addAction(copyMouseLatToClipAct); - copySubMenu.addAction(copyMouseLonToClipAct); - menu.addMenu(©SubMenu); - - menu.addSeparator(); - - menu.addAction(findPlaceAct); - - menu.addSeparator(); - - menu.addAction(showCompassAct); - - menu.addSeparator()->setText(tr("Zoom")); - - menu.addAction(zoomInAct); - menu.addAction(zoomOutAct); - - QMenu zoomSubMenu(tr("&Zoom ") + "(" + QString::number(m_map->Zoom()) + ")", this); - for (int i = 0; i < zoomAct.count(); i++) - zoomSubMenu.addAction(zoomAct.at(i)); - menu.addMenu(&zoomSubMenu); - - menu.addSeparator()->setText(tr("Position")); - - menu.addAction(goMouseClickAct); - menu.addAction(goHomeAct); - menu.addAction(goUAVAct); - - menu.addSeparator()->setText(tr("UAV")); - - menu.addAction(showUAVAct); - menu.addAction(showUAVtrailAct); - menu.addAction(followUAVpositionAct); - menu.addAction(followUAVheadingAct); - - menu.addSeparator()->setText(tr("Waypoints")); - - menu.addAction(wayPointEditorAct); - menu.addAction(addWayPointAct); - - if (m_mouse_waypoint) - { // we have a waypoint under the mouse - menu.addAction(editWayPointAct); - - lockWayPointAct->setChecked(waypoint_locked); - menu.addAction(lockWayPointAct); - - if (!waypoint_locked) - menu.addAction(deleteWayPointAct); - } - - m_waypoint_list_mutex.lock(); - if (m_waypoint_list.count() > 0) - menu.addAction(clearWayPointsAct); // we have waypoints - m_waypoint_list_mutex.unlock(); - -// menu.addSeparator(); - - menu.exec(event->globalPos()); // popup the menu - - // **************** -} - -void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) -{ - if (event->key() == Qt::Key_Escape) // ESC - { - } - else - if (event->key() == Qt::Key_F1) // F1 - { - } - else - if (event->key() == Qt::Key_F2) // F2 - { - } - else - if (event->key() == Qt::Key_Up) - { - } - else - if (event->key() == Qt::Key_Down) - { - } - else - if (event->key() == Qt::Key_Left) - { - } - else - if (event->key() == Qt::Key_Right) - { - } - else - if (event->key() == Qt::Key_PageUp) - { - } - else - if (event->key() == Qt::Key_PageDown) - { - } - else - { - qDebug() << event->key() << endl; - } -} - -// ************************************************************************************* -// timer signals - -void OPMapGadgetWidget::updatePosition() -{ - PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data - - internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position - float uav_heading = data.Heading; // current UAV heading - float uav_altitude_meters = data.Altitude; // current UAV height - float uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed - - // display the UAV lat/lon position - QString str = " lat: " + QString::number(uav_pos.Lat(), 'f', 7) + - " lon: " + QString::number(uav_pos.Lng(), 'f', 7) + - " " + QString::number(uav_heading, 'f', 1) + "deg" + - " " + QString::number(uav_altitude_meters, 'f', 1) + "m" + - " " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s"; - if (m_widget) m_widget->labelUAVPos->setText(str); - - if (m_map) - { -// if (m_map->ShowUAV()) - { - m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position - m_map->UAV->SetUAVHeading(uav_heading); // set the maps UAV heading - } - } -} - -void OPMapGadgetWidget::updateMousePos() -{ - internals::PointLatLng lat_lon = m_map->currentMousePosition(); // fetch the current lat/lon mouse position - - if (mouse_lat_lon != lat_lon) - { // the mouse has moved - mouse_lat_lon = lat_lon; - - QString str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 7); - if (m_widget) m_widget->labelMousePos->setText(str); - } -} - -// ************************************************************************************* -// map signals - -void OPMapGadgetWidget::zoomChanged(double zoom) -{ - int i_zoom = (int)(zoom + 0.5); - if (i_zoom < 2 || i_zoom > 19) return; - - if (m_widget) - { -// m_widget->labelZoom->setText(" " + QString::number(zoom)); - if (m_widget->horizontalSliderZoom->value() != i_zoom) - m_widget->horizontalSliderZoom->setValue(i_zoom); - } - - if (i_zoom - 2 < zoomAct.count()) - zoomAct.at(i_zoom - 2)->setChecked(true); -} - -void OPMapGadgetWidget::OnMapDrag() -{ -} - -void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point) -{ - if (m_widget) - { - QString coord_str = " " + QString::number(point.Lat(), 'f', 7) + " " + QString::number(point.Lng(), 'f', 7) + " "; - m_widget->labelMapPos->setText(coord_str); - } -} - -void OPMapGadgetWidget::OnTilesStillToLoad(int number) -{ - if (m_widget) - { -// 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)); - - prev_tile_number = number; - } -} - -void OPMapGadgetWidget::OnTileLoadStart() -{ - if (m_widget) - m_widget->progressBarMap->setVisible(true); -} - -void OPMapGadgetWidget::OnTileLoadComplete() -{ - if (m_widget) - m_widget->progressBarMap->setVisible(false); -} - -void OPMapGadgetWidget::OnMapZoomChanged() -{ - // to do -} - -void OPMapGadgetWidget::OnMapTypeChanged(MapType::Types type) -{ - // to do -} - -void OPMapGadgetWidget::OnEmptyTileError(int zoom, core::Point pos) -{ - // to do -} - -void OPMapGadgetWidget::WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint) -{ - // to do -} - -void OPMapGadgetWidget::WPValuesChanged(WayPointItem *waypoint) -{ - // to do -} - -void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint) -{ - // to do -} - -void OPMapGadgetWidget::WPDeleted(int const &number) -{ - // to do -} - -// ************************************************************************************* -// user control signals - -void OPMapGadgetWidget::comboBoxFindPlace_returnPressed() -{ - QString place = m_widget->comboBoxFindPlace->currentText().simplified(); - if (place.isNull() || place.isEmpty()) return; - - if (!findPlaceWordList.contains(place, Qt::CaseInsensitive)) - { - findPlaceWordList << place; // add the new word into the history list -/* - m_widget->comboBoxFindPlace->setCompleter(NULL); - delete findPlaceCompleter; - findPlaceCompleter = new QCompleter(findPlaceWordList, this); - findPlaceCompleter->setCaseSensitivity(Qt::CaseInsensitive); - findPlaceCompleter->setCompletionMode(QCompleter::PopupCompletion); - findPlaceCompleter->setModelSorting(QCompleter::CaseInsensitivelySortedModel); - m_widget->comboBoxFindPlace->setCompleter(findPlaceCompleter); -*/ -/* - #if defined(Q_OS_MAC) - #elif defined(Q_OS_WIN) - saveComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt"); - #else - #endif -*/ - } - - if (!m_map) return; - - core::GeoCoderStatusCode::Types x = m_map->SetCurrentPositionByKeywords(place); - QString returned_text = mapcontrol::Helper::StrFromGeoCoderStatusCode(x); - - QMessageBox::information(this, tr("OpenPilot GCS"), returned_text, QMessageBox::Ok); -} - -void OPMapGadgetWidget::on_toolButtonFindPlace_clicked() -{ - m_widget->comboBoxFindPlace->setFocus(); - comboBoxFindPlace_returnPressed(); -} - -void OPMapGadgetWidget::on_toolButtonZoomP_clicked() -{ - zoomIn(); -} - -void OPMapGadgetWidget::on_toolButtonZoomM_clicked() -{ - zoomOut(); -} - -void OPMapGadgetWidget::on_toolButtonMapHome_clicked() -{ - followUAVpositionAct->setChecked(false); -} - -void OPMapGadgetWidget::on_toolButtonMapUAV_clicked() -{ - followUAVpositionAct->toggle(); -} - -void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked() -{ - followUAVheadingAct->toggle(); -} - -void OPMapGadgetWidget::on_toolButtonShowUAVtrail_clicked() -{ - showUAVtrailAct->toggle(); -} - -void OPMapGadgetWidget::on_toolButtonClearUAVtrail_clicked() -{ - clearUAVtrailAct->trigger(); -} - -void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position) -{ - setZoom(position); -} - -void OPMapGadgetWidget::on_toolButtonHome_clicked() -{ - // to do -} - - -void OPMapGadgetWidget::on_toolButtonPrevWaypoint_clicked() -{ - // to do -} - -void OPMapGadgetWidget::on_toolButtonNextWaypoint_clicked() -{ - // to do -} - -void OPMapGadgetWidget::on_toolButtonHoldPosition_clicked() -{ - // to do -} - -void OPMapGadgetWidget::on_toolButtonGo_clicked() -{ - // to do -} - -void OPMapGadgetWidget::on_toolButtonAddWaypoint_clicked() -{ - if (!m_map) return; - - m_waypoint_list_mutex.lock(); - - // create a waypoint at the center of the map - t_waypoint waypoint; - waypoint.item = m_map->WPCreate(m_map->CurrentPosition(), 0); - waypoint.time_seconds = 0; - waypoint.hold_time_seconds = 0; - - // and remember it in our own local waypoint list - m_waypoint_list.append(waypoint); - - m_waypoint_list_mutex.unlock(); -} - -void OPMapGadgetWidget::on_treeViewWaypoints_clicked(QModelIndex index) -{ - QStandardItem *item = wayPoint_treeView_model.itemFromIndex(index); - if (!item) return; - - // to do -} - -// ************************************************************************************* -// public functions - -void OPMapGadgetWidget::zoomIn() -{ - if (m_map) - m_map->SetZoom(m_map->Zoom() + 1); -} - -void OPMapGadgetWidget::zoomOut() -{ - if (m_map) - m_map->SetZoom(m_map->Zoom() - 1); -} - -void OPMapGadgetWidget::setZoom(int value) -{ - if (m_map) - { - internals::MouseWheelZoomType::Types zoom_type = m_map->GetMouseWheelZoomType(); - m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::ViewCenter); - - m_map->SetZoom(value); - - m_map->SetMouseWheelZoomType(zoom_type); - } -} - -void OPMapGadgetWidget::setPosition(QPointF pos) -{ - if (m_map) - m_map->SetCurrentPosition(internals::PointLatLng(pos.y(), pos.x())); -} - -void OPMapGadgetWidget::setMapProvider(QString provider) -{ - if (m_map) - m_map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider)); -} - -void OPMapGadgetWidget::setAccessMode(QString accessMode) -{ - if (m_map) - m_map->configuration->SetAccessMode(mapcontrol::Helper::AccessModeFromString(accessMode)); -} - -void OPMapGadgetWidget::setUseOpenGL(bool useOpenGL) -{ - if (m_map) - m_map->SetUseOpenGL(useOpenGL); -} - -void OPMapGadgetWidget::setShowTileGridLines(bool showTileGridLines) -{ - if (m_map) - m_map->SetShowTileGridLines(showTileGridLines); -} - -void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache) -{ - if (m_map) - m_map->configuration->SetUseMemoryCache(useMemoryCache); -} - -void OPMapGadgetWidget::setCacheLocation(QString cacheLocation) -{ - cacheLocation = cacheLocation.simplified(); // remove any surrounding spaces - - 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 - - QDir dir; - if (!dir.exists(cacheLocation)) - if (!dir.mkpath(cacheLocation)) - return; - -// qDebug() << "map cache dir: " << cacheLocation; - - if (m_map) - m_map->configuration->SetCacheLocation(cacheLocation); -} - -// ************************************************************************************* -// Context menu stuff - -void OPMapGadgetWidget::createActions() -{ - // *********************** - // create menu actions - - closeAct = new QAction(tr("&Close menu"), this); -// closeAct->setShortcuts(QKeySequence::New); - closeAct->setStatusTip(tr("Close the context menu")); - - reloadAct = new QAction(tr("&Reload map"), this); - reloadAct->setShortcut(tr("F5")); - reloadAct->setStatusTip(tr("Reload the map tiles")); - connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered())); - - copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this); - copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard")); - connect(copyMouseLatLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatLonToClipAct_triggered())); - - copyMouseLatToClipAct = new QAction(tr("Mouse latitude"), this); - copyMouseLatToClipAct->setStatusTip(tr("Copy the mouse latitude to the clipboard")); - connect(copyMouseLatToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatToClipAct_triggered())); - - copyMouseLonToClipAct = new QAction(tr("Mouse longitude"), this); - 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); - showCompassAct->setChecked(true); - connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool))); - - showUAVAct = new QAction(tr("Show UAV"), this); - showUAVAct->setStatusTip(tr("Show/Hide the UAV")); - showUAVAct->setCheckable(true); - showUAVAct->setChecked(m_map->ShowUAV()); - showUAVAct->setEnabled(false); // temporary - connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool))); - - 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())); - - 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())); - - 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")); - connect(goMouseClickAct, SIGNAL(triggered()), this, SLOT(onGoMouseClickAct_triggered())); - - goHomeAct = new QAction(tr("Go to &Home location"), this); - goHomeAct->setShortcut(tr("Ctrl+H")); - goHomeAct->setStatusTip(tr("Center the map onto the home location")); - connect(goHomeAct, SIGNAL(triggered()), this, SLOT(onGoHomeAct_triggered())); - - goUAVAct = new QAction(tr("Go to &UAV location"), this); - goUAVAct->setShortcut(tr("Ctrl+U")); - goUAVAct->setStatusTip(tr("Center the map onto the UAV location")); - connect(goUAVAct, SIGNAL(triggered()), this, SLOT(onGoUAVAct_triggered())); - - followUAVpositionAct = new QAction(tr("Follow UAV position"), this); - followUAVpositionAct->setShortcut(tr("Ctrl+F")); - followUAVpositionAct->setStatusTip(tr("Keep the map centered onto the UAV")); - followUAVpositionAct->setCheckable(true); - followUAVpositionAct->setChecked(false); - connect(followUAVpositionAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVpositionAct_toggled(bool))); - - followUAVheadingAct = new QAction(tr("Follow UAV heading"), this); - followUAVheadingAct->setShortcut(tr("Ctrl+F")); - followUAVheadingAct->setStatusTip(tr("Keep the map rotation to the UAV heading")); - followUAVheadingAct->setCheckable(true); - followUAVheadingAct->setChecked(false); - connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool))); - - showUAVtrailAct = new QAction(tr("Show UAV trail"), this); - showUAVtrailAct->setStatusTip(tr("Show/Hide the UAV trail")); - showUAVtrailAct->setCheckable(true); - showUAVtrailAct->setChecked(true); - connect(showUAVtrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVtrailAct_toggled(bool))); - - clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this); - clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail")); - connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered())); - - 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())); - - editWayPointAct = new QAction(tr("&Edit waypoint"), this); - editWayPointAct->setShortcut(tr("Ctrl+E")); - editWayPointAct->setStatusTip(tr("Edit waypoint")); - connect(editWayPointAct, SIGNAL(triggered()), this, SLOT(onEditWayPointAct_triggered())); - - lockWayPointAct = new QAction(tr("&Lock waypoint"), this); - lockWayPointAct->setStatusTip(tr("Lock/Unlock a waypoint")); - lockWayPointAct->setCheckable(true); - lockWayPointAct->setChecked(false); - connect(lockWayPointAct, SIGNAL(triggered()), this, SLOT(onLockWayPointAct_triggered())); - - deleteWayPointAct = new QAction(tr("&Delete waypoint"), this); - deleteWayPointAct->setShortcut(tr("Ctrl+D")); - deleteWayPointAct->setStatusTip(tr("Delete waypoint")); - connect(deleteWayPointAct, SIGNAL(triggered()), this, SLOT(onDeleteWayPointAct_triggered())); - - clearWayPointsAct = new QAction(tr("&Clear waypoints"), this); - clearWayPointsAct->setShortcut(tr("Ctrl+C")); - clearWayPointsAct->setStatusTip(tr("Clear waypoints")); - connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered())); - - zoomActGroup = new QActionGroup(this); - connect(zoomActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onZoomActGroup_triggered(QAction *))); - zoomAct.clear(); - for (int i = 2; i <= 19; i++) - { - QAction *zoom_act = new QAction(QString::number(i), zoomActGroup); - zoom_act->setCheckable(true); - zoom_act->setData(i); - zoomAct.append(zoom_act); - } - - // *********************** -} - -void OPMapGadgetWidget::onReloadAct_triggered() -{ - if (m_map) - m_map->ReloadMap(); -} - -void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered() -{ -// QClipboard *clipboard = qApp->clipboard(); - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(QString::number(mouse_lat_lon.Lat(), 'f', 7) + ", " + QString::number(mouse_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard); -} - -void OPMapGadgetWidget::onCopyMouseLatToClipAct_triggered() -{ -// QClipboard *clipboard = qApp->clipboard(); - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(QString::number(mouse_lat_lon.Lat(), 'f', 7), QClipboard::Clipboard); -} - -void OPMapGadgetWidget::onCopyMouseLonToClipAct_triggered() -{ -// QClipboard *clipboard = qApp->clipboard(); - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(QString::number(mouse_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard); -} - -void OPMapGadgetWidget::onFindPlaceAct_triggered() -{ - m_widget->comboBoxFindPlace->setFocus(); // move focus to the 'find place' text box - -/* - bool ok; - QString place = QInputDialog::getText(this, tr("OpenPilot GCS"), tr("Find place"), QLineEdit::Normal, QString::null, &ok); - place = place.simplified(); - if (!ok || place.isNull() || place.isEmpty()) return; - - if (!findPlaceWordList.contains(place, Qt::CaseInsensitive)) - { - findPlaceWordList += place; // add the new word into the history list - } - - if (!m_map) return; - - core::GeoCoderStatusCode::Types x = m_map->SetCurrentPositionByKeywords(place); - QString returned_text = mapcontrol::Helper::StrFromGeoCoderStatusCode(x); - - QMessageBox::information(this, tr("OpenPilot GCS"), returned_text, QMessageBox::Ok); -*/ -} - -void OPMapGadgetWidget::onShowCompassAct_toggled(bool show) -{ - if (m_map) - m_map->SetShowCompass(show); -} - -void OPMapGadgetWidget::onShowUAVAct_toggled(bool show) -{ - if (m_map) - m_map->SetShowUAV(show); // this can cause a rather big crash -} - -void OPMapGadgetWidget::onGoZoomInAct_triggered() -{ - if (m_map) - setZoom(m_map->Zoom() + 1); -} - -void OPMapGadgetWidget::onGoZoomOutAct_triggered() -{ - if (m_map) - setZoom(m_map->Zoom() - 1); -} - -void OPMapGadgetWidget::onZoomActGroup_triggered(QAction *action) -{ - if (!action) return; - - int zoom = action->data().toInt(); - if (zoom < 2 || zoom > 19) return; - - setZoom(zoom); -} - -void OPMapGadgetWidget::onGoMouseClickAct_triggered() -{ - if (m_map) - m_map->SetCurrentPosition(m_map->currentMousePosition()); // center the map onto the mouse position -} - -void OPMapGadgetWidget::onGoHomeAct_triggered() -{ - followUAVpositionAct->setChecked(false); -} - -void OPMapGadgetWidget::onGoUAVAct_triggered() -{ - PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data - - if (m_map) - { - internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position - internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position - if (map_pos != uav_pos) m_map->SetCurrentPosition(uav_pos); // center the map onto the UAV - } -} - -void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked) -{ - if (m_widget) - { - if (m_widget->toolButtonMapUAV->isChecked() != checked) - m_widget->toolButtonMapUAV->setChecked(checked); - - setMapFollowingmode(); - } -} - -void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked) -{ - if (m_widget) - { - if (m_widget->toolButtonMapUAVheading->isChecked() != checked) - m_widget->toolButtonMapUAVheading->setChecked(checked); - - setMapFollowingmode(); - } -} - -void OPMapGadgetWidget::onShowUAVtrailAct_toggled(bool checked) -{ - if (m_widget) - { - if (m_widget->toolButtonShowUAVtrail->isChecked() != checked) - m_widget->toolButtonShowUAVtrail->setChecked(checked); - - if (m_map) - m_map->UAV->SetShowTrail(checked); - } -} - -void OPMapGadgetWidget::onClearUAVtrailAct_triggered() -{ - if (m_map) - m_map->UAV->DeleteTrail(); -} - -void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered() -{ - waypoint_editor_dialog.show(); -} - -void OPMapGadgetWidget::onAddWayPointAct_triggered() -{ - if (!m_map) return; - - m_waypoint_list_mutex.lock(); - - // create a waypoint on the map at the last known mouse position - t_waypoint waypoint; - waypoint.item = m_map->WPCreate(mouse_lat_lon, 0); - waypoint.time_seconds = 0; - waypoint.hold_time_seconds = 0; - - // and remember it in our own local waypoint list - m_waypoint_list.append(waypoint); - - m_waypoint_list_mutex.unlock(); -} - -void OPMapGadgetWidget::onEditWayPointAct_triggered() -{ - if (!m_mouse_waypoint) return; - - waypoint_edit_dialog.editWaypoint(m_mouse_waypoint); - - m_mouse_waypoint = NULL; -} - -void OPMapGadgetWidget::onLockWayPointAct_triggered() -{ - if (!m_mouse_waypoint) return; - - bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; - m_mouse_waypoint->setFlag(QGraphicsItem::ItemIsMovable, locked); - - m_mouse_waypoint = NULL; -} - -void OPMapGadgetWidget::onDeleteWayPointAct_triggered() -{ - if (!m_mouse_waypoint) return; - - bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; - - if (locked) return; // waypoint is locked - - m_waypoint_list_mutex.lock(); - - for (int i = 0; i < m_waypoint_list.count(); i++) - { - t_waypoint waypoint = m_waypoint_list.at(i); - if (waypoint.item != m_mouse_waypoint) continue; - - // delete the waypoint from the map - if (m_map) m_map->WPDelete(waypoint.item); - - // delete the waypoint from our local waypoint list - m_waypoint_list.removeAt(i); - - break; - } - - m_waypoint_list_mutex.unlock(); - - m_mouse_waypoint = NULL; -} - -void OPMapGadgetWidget::onClearWayPointsAct_triggered() -{ - m_waypoint_list_mutex.lock(); - if (m_map) m_map->WPDeleteAll(); - m_waypoint_list.clear(); - m_waypoint_list_mutex.unlock(); -} - -// ************************************************************************************* -// 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(); -} - -// ************************************************************************************* - -void OPMapGadgetWidget::setMapFollowingmode() -{ - if (!m_map) return; - - if (!followUAVpositionAct->isChecked()) - { - m_map->UAV->SetMapFollowType(UAVMapFollowType::None); - m_map->SetRotate(0); // reset map rotation to 0deg - } - else - if (!followUAVheadingAct->isChecked()) - { - m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); - m_map->SetRotate(0); // reset map rotation to 0deg - } - else - { - m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode - -// if (m_map->ShowUAV()) - m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg - m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap); - } -} - -// ************************************************************************************* +/** + ****************************************************************************** + * + * @file opmapgadgetwidget.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 "opmapgadgetwidget.h" +#include "ui_opmap_widget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +// ************************************************************************************* + +// constructor +OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent) +{ + // ************** + + m_widget = NULL; + m_map = NULL; + findPlaceCompleter = NULL; + m_overlay_widget = NULL; + + m_map_graphics_scene = NULL; + m_map_scene_proxy = NULL; + m_zoom_slider_widget = NULL; + m_statusbar_widget = NULL; + + + m_plugin_manager = NULL; + m_objManager = NULL; + m_positionActual = NULL; + + m_mouse_waypoint = NULL; + + prev_tile_number = 0; + + // ************** + // fetch required UAVObjects + + m_plugin_manager = ExtensionSystem::PluginManager::instance(); + m_objManager = m_plugin_manager->getObject(); + m_positionActual = PositionActual::GetInstance(m_objManager); + + // get current UAV data + PositionActual::DataFields data = m_positionActual->getData(); + + // ************** + // create the widget that holds the user controls and the map + + m_widget = new Ui::OPMap_Widget(); + m_widget->setupUi(this); + + // ************** + // create the central map widget + + m_map = new mapcontrol::OPMapWidget(); + + m_map->setFrameStyle(QFrame::NoFrame); // no border frame + m_map->setBackgroundBrush(Qt::black); // black background + + m_map->configuration->DragButton = Qt::LeftButton; // use the left mouse button for map dragging + m_map->SetMinZoom(2); + m_map->SetMaxZoom(19); + m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionWithoutCenter); // set how the mouse wheel zoom functions + m_map->SetFollowMouse(true); // we want a contiuous mouse position reading + m_map->SetShowUAV(true); // display the UAV position on the map + +// m_map->UAV->SetTrailTime(1); // seconds +// m_map->UAV->SetTrailDistance(0.1); // kilometers + + m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed); +// m_map->UAV->SetTrailType(UAVTrailType::ByDistance); + + // ************** + + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setSpacing(0); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_map); + m_widget->mapWidget->setLayout(layout); + + // ************** + // create the user controls overlayed onto the map + + // doing this makes the map VERY slow :( + +/* + m_zoom_slider_widget = new opmap_zoom_slider_widget(); + m_statusbar_widget = new opmap_statusbar_widget(); + + m_map_graphics_scene = m_map->scene(); + + m_map_scene_proxy = m_map_graphics_scene->addWidget(m_zoom_slider_widget); + m_map_scene_proxy = m_map_graphics_scene->addWidget(m_statusbar_widget); + + m_zoom_slider_widget->move(m_map->width() - 20 - m_zoom_slider_widget->width(), 20); + m_statusbar_widget->move(0, m_map->height() - m_statusbar_widget->height()); +*/ +/* + m_overlay_widget = new opmap_overlay_widget(m_map); + QVBoxLayout *layout2 = new QVBoxLayout; + layout2->setSpacing(0); + layout2->setContentsMargins(0, 0, 0, 0); + layout2->addWidget(m_overlay_widget); + m_map->setLayout(layout2); +*/ + // ************** + // set the user control options + + m_widget->labelUAVPos->setText("---"); + m_widget->labelMapPos->setText("---"); + m_widget->labelMousePos->setText("---"); + + m_widget->splitter->setCollapsible(1, false); + + // set the size of the collapsable widgets + QList m_SizeList; +// m_SizeList << m_widget->splitter->sizes(); + m_SizeList << 0 << 0 << 0; + m_widget->splitter->setSizes(m_SizeList); + + m_widget->progressBarMap->setMaximum(1); + + m_widget->toolButtonShowUAVtrail->setChecked(true); + +/* + #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 +*/ + // ************** + // add an auto-completer to the find-place line edit box +/* + findPlaceWordList << "england" << "london" << "birmingham" << "shropshire"; + QCompleter *findPlaceCompleter = new QCompleter(findPlaceWordList, this); + findPlaceCompleter->setCaseSensitivity(Qt::CaseInsensitive); + findPlaceCompleter->setCompletionMode(QCompleter::PopupCompletion); + findPlaceCompleter->setModelSorting(QCompleter::CaseInsensitivelySortedModel); + m_widget->comboBoxFindPlace->setCompleter(findPlaceCompleter); +*/ + m_widget->comboBoxFindPlace->setAutoCompletion(true); + + connect( m_widget->comboBoxFindPlace->lineEdit(), SIGNAL(returnPressed()), this, SLOT(comboBoxFindPlace_returnPressed())); + + // ************** + // init the waypoint tree (shown on the left on the map plugin GUI) + + m_widget->treeViewWaypoints->setModel(&wayPoint_treeView_model); + +/* + // test +// wayPoint_treeView_model = new QStandardItemModel(5, 2); + for (int r = 0; r < 5; r++) + { + for (int c = 0; c < 2; c++) + { + QStandardItem *item = new QStandardItem(QString("Row:%0, Column:%1").arg(r).arg(c)); + + if (c == 0) + { + for (int i = 0; i < 3; i++) + { + QStandardItem *child = new QStandardItem(QString("Item %0").arg(i)); + child->setEditable(false); + item->appendRow(child); + } + } + + wayPoint_treeView_model->setItem(r, c, item); + } + } + wayPoint_treeView_model->setHorizontalHeaderItem(0, new QStandardItem("Foo")); + wayPoint_treeView_model->setHorizontalHeaderItem(1, new QStandardItem("Bar-Baz")); + +// m_widget->treeViewWaypoints->setModel(wayPoint_treeView_model); +*/ + + + + + + // test only +/* + // create a waypoint group + QStandardItem *item = new QStandardItem(tr("Camera shoot at the town hall")); + // add some waypoints + { + QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "North side window view"); + child->setEditable(true); + item->appendRow(child); + } + { + QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "East side window view"); + child->setEditable(true); + item->appendRow(child); + } + { + QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "South side window view"); + child->setEditable(true); + item->appendRow(child); + } + { + QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), "West side window view"); + child->setEditable(true); + item->appendRow(child); + } + wayPoint_treeView_model.appendRow(item); +*/ + // create another waypoint group + QStandardItem *item = new QStandardItem(tr("Flight path 62")); + for (int i = 1; i < 8; i++) + { // add some waypoints + QStandardItem *child = new QStandardItem(QIcon(QString::fromUtf8(":/opmap/images/waypoint.png")), QString("Waypoint %0").arg(i)); + child->setEditable(true); + item->appendRow(child); + } + wayPoint_treeView_model.appendRow(item); + + + + + + + + + + + // ************** + // map stuff + + connect(m_map, SIGNAL(zoomChanged(double)), this, SLOT(zoomChanged(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&))); + + m_map->SetCurrentPosition(internals::PointLatLng(data.Latitude, data.Longitude)); // set the default map position + + // ************** + // create various context menu (mouse right click menu) actions + + createActions(); + + // ************** + // create the desired timers + + // Pip .. I don't like polling, I prefer an efficient event driven system (signal/slot) but this will do for now + + m_updateTimer = new QTimer(); + m_updateTimer->setInterval(200); + connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition())); + m_updateTimer->start(); + + m_statusUpdateTimer = new QTimer(); + m_statusUpdateTimer->setInterval(200); + connect(m_statusUpdateTimer, SIGNAL(timeout()), this, SLOT(updateMousePos())); + m_statusUpdateTimer->start(); + + // ************** +} + +// destructor +OPMapGadgetWidget::~OPMapGadgetWidget() +{ + + + // 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 + + onClearWayPointsAct_triggered(); + + if (m_zoom_slider_widget) delete m_zoom_slider_widget; + if (m_statusbar_widget) delete m_statusbar_widget; + if (m_map) delete m_map; + if (m_widget) delete m_widget; +} + +// ************************************************************************************* +// widget signals + +void OPMapGadgetWidget::resizeEvent(QResizeEvent *event) +{ +// update(); + QWidget::resizeEvent(event); +} + +void OPMapGadgetWidget::mouseMoveEvent(QMouseEvent *event) +{ + if (m_map) + { +// mouse_lat_lon = m_map->currentMousePosition(); // fetch the current mouse lat/longitude position +// if (mouse_lat_lon != lat_lon) +// { // the mouse has moved +// mouse_lat_lon = lat_lon; +// +// QString coord_str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 7) + " "; +// +// statusLabel.setText(coord_str); +// widget->labelStatus->setText(coord_str); +// } + } + + if (event->buttons() & Qt::LeftButton) + { + QPoint pos = event->pos(); + } + + QWidget::mouseMoveEvent(event); +} + +void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) +{ + if (event->reason() != QContextMenuEvent::Mouse) + return; // not a mouse click event + + if (!m_map) + return; // we don't appear to have a map to work with! + + // current mouse position + QPoint p = m_map->mapFromGlobal(QCursor::pos()); + + // save the current lat/lon mouse position + mouse_lat_lon = m_map->currentMousePosition(); + + if (!m_map->contentsRect().contains(p)) + return; // the mouse click was not on the map + + // find out if we have a waypoint under the mouse cursor + QGraphicsItem *item = m_map->itemAt(p); + m_mouse_waypoint = qgraphicsitem_cast(item); + + // find out if the waypoint is locked (or not) + bool waypoint_locked = false; + if (m_mouse_waypoint) + waypoint_locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; + + // **************** + // Dynamically create the popup menu + + QMenu menu(this); + + menu.addAction(closeAct); + + menu.addSeparator(); + + menu.addAction(reloadAct); + + menu.addSeparator(); + + QMenu copySubMenu(tr("Copy"), this); + copySubMenu.addAction(copyMouseLatLonToClipAct); + copySubMenu.addAction(copyMouseLatToClipAct); + copySubMenu.addAction(copyMouseLonToClipAct); + menu.addMenu(©SubMenu); + + menu.addSeparator(); + + menu.addAction(findPlaceAct); + + menu.addSeparator(); + + menu.addAction(showCompassAct); + + menu.addSeparator()->setText(tr("Zoom")); + + menu.addAction(zoomInAct); + menu.addAction(zoomOutAct); + + QMenu zoomSubMenu(tr("&Zoom ") + "(" + QString::number(m_map->Zoom()) + ")", this); + for (int i = 0; i < zoomAct.count(); i++) + zoomSubMenu.addAction(zoomAct.at(i)); + menu.addMenu(&zoomSubMenu); + + menu.addSeparator()->setText(tr("Position")); + + menu.addAction(goMouseClickAct); + menu.addAction(goHomeAct); + menu.addAction(goUAVAct); + + menu.addSeparator()->setText(tr("UAV")); + + menu.addAction(showUAVAct); + menu.addAction(showUAVtrailAct); + menu.addAction(followUAVpositionAct); + menu.addAction(followUAVheadingAct); + + menu.addSeparator()->setText(tr("Waypoints")); + + menu.addAction(wayPointEditorAct); + menu.addAction(addWayPointAct); + + if (m_mouse_waypoint) + { // we have a waypoint under the mouse + menu.addAction(editWayPointAct); + + lockWayPointAct->setChecked(waypoint_locked); + menu.addAction(lockWayPointAct); + + if (!waypoint_locked) + menu.addAction(deleteWayPointAct); + } + + m_waypoint_list_mutex.lock(); + if (m_waypoint_list.count() > 0) + menu.addAction(clearWayPointsAct); // we have waypoints + m_waypoint_list_mutex.unlock(); + +// menu.addSeparator(); + + menu.exec(event->globalPos()); // popup the menu + + // **************** +} + +void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Escape) // ESC + { + } + else + if (event->key() == Qt::Key_F1) // F1 + { + } + else + if (event->key() == Qt::Key_F2) // F2 + { + } + else + if (event->key() == Qt::Key_Up) + { + } + else + if (event->key() == Qt::Key_Down) + { + } + else + if (event->key() == Qt::Key_Left) + { + } + else + if (event->key() == Qt::Key_Right) + { + } + else + if (event->key() == Qt::Key_PageUp) + { + } + else + if (event->key() == Qt::Key_PageDown) + { + } + else + { + qDebug() << event->key() << endl; + } +} + +// ************************************************************************************* +// timer signals + +void OPMapGadgetWidget::updatePosition() +{ + PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data + + internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position + float uav_heading = data.Heading; // current UAV heading + float uav_altitude_meters = data.Altitude; // current UAV height + float uav_ground_speed_meters_per_second = data.Groundspeed; // current UAV ground speed + + // display the UAV lat/lon position + QString str = " lat: " + QString::number(uav_pos.Lat(), 'f', 7) + + " lon: " + QString::number(uav_pos.Lng(), 'f', 7) + + " " + QString::number(uav_heading, 'f', 1) + "deg" + + " " + QString::number(uav_altitude_meters, 'f', 1) + "m" + + " " + QString::number(uav_ground_speed_meters_per_second, 'f', 1) + "m/s"; + if (m_widget) m_widget->labelUAVPos->setText(str); + + if (m_map) + { +// if (m_map->ShowUAV()) + { + m_map->UAV->SetUAVPos(uav_pos, uav_altitude_meters); // set the maps UAV position + m_map->UAV->SetUAVHeading(uav_heading); // set the maps UAV heading + } + } +} + +void OPMapGadgetWidget::updateMousePos() +{ + internals::PointLatLng lat_lon = m_map->currentMousePosition(); // fetch the current lat/lon mouse position + + if (mouse_lat_lon != lat_lon) + { // the mouse has moved + mouse_lat_lon = lat_lon; + + QString str = " " + QString::number(mouse_lat_lon.Lat(), 'f', 7) + " " + QString::number(mouse_lat_lon.Lng(), 'f', 7); + if (m_widget) m_widget->labelMousePos->setText(str); + } +} + +// ************************************************************************************* +// map signals + +void OPMapGadgetWidget::zoomChanged(double zoom) +{ + int i_zoom = (int)(zoom + 0.5); + if (i_zoom < 2 || i_zoom > 19) return; + + if (m_widget) + { +// m_widget->labelZoom->setText(" " + QString::number(zoom)); + if (m_widget->horizontalSliderZoom->value() != i_zoom) + m_widget->horizontalSliderZoom->setValue(i_zoom); + } + + if (i_zoom - 2 < zoomAct.count()) + zoomAct.at(i_zoom - 2)->setChecked(true); +} + +void OPMapGadgetWidget::OnMapDrag() +{ +} + +void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point) +{ + if (m_widget) + { + QString coord_str = " " + QString::number(point.Lat(), 'f', 7) + " " + QString::number(point.Lng(), 'f', 7) + " "; + m_widget->labelMapPos->setText(coord_str); + } +} + +void OPMapGadgetWidget::OnTilesStillToLoad(int number) +{ + if (m_widget) + { +// 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)); + + prev_tile_number = number; + } +} + +void OPMapGadgetWidget::OnTileLoadStart() +{ + if (m_widget) + m_widget->progressBarMap->setVisible(true); +} + +void OPMapGadgetWidget::OnTileLoadComplete() +{ + if (m_widget) + m_widget->progressBarMap->setVisible(false); +} + +void OPMapGadgetWidget::OnMapZoomChanged() +{ + // to do +} + +void OPMapGadgetWidget::OnMapTypeChanged(MapType::Types type) +{ + // to do +} + +void OPMapGadgetWidget::OnEmptyTileError(int zoom, core::Point pos) +{ + // to do +} + +void OPMapGadgetWidget::WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint) +{ + // to do +} + +void OPMapGadgetWidget::WPValuesChanged(WayPointItem *waypoint) +{ + // to do +} + +void OPMapGadgetWidget::WPInserted(int const &number, WayPointItem *waypoint) +{ + // to do +} + +void OPMapGadgetWidget::WPDeleted(int const &number) +{ + // to do +} + +// ************************************************************************************* +// user control signals + +void OPMapGadgetWidget::comboBoxFindPlace_returnPressed() +{ + QString place = m_widget->comboBoxFindPlace->currentText().simplified(); + if (place.isNull() || place.isEmpty()) return; + + if (!findPlaceWordList.contains(place, Qt::CaseInsensitive)) + { + findPlaceWordList << place; // add the new word into the history list +/* + m_widget->comboBoxFindPlace->setCompleter(NULL); + delete findPlaceCompleter; + findPlaceCompleter = new QCompleter(findPlaceWordList, this); + findPlaceCompleter->setCaseSensitivity(Qt::CaseInsensitive); + findPlaceCompleter->setCompletionMode(QCompleter::PopupCompletion); + findPlaceCompleter->setModelSorting(QCompleter::CaseInsensitivelySortedModel); + m_widget->comboBoxFindPlace->setCompleter(findPlaceCompleter); +*/ +/* + #if defined(Q_OS_MAC) + #elif defined(Q_OS_WIN) + saveComboBoxLines(m_widget->comboBoxFindPlace, QCoreApplication::applicationDirPath() + "/opmap_find_place_history.txt"); + #else + #endif +*/ + } + + if (!m_map) return; + + core::GeoCoderStatusCode::Types x = m_map->SetCurrentPositionByKeywords(place); + QString returned_text = mapcontrol::Helper::StrFromGeoCoderStatusCode(x); + + QMessageBox::information(this, tr("OpenPilot GCS"), returned_text, QMessageBox::Ok); +} + +void OPMapGadgetWidget::on_toolButtonFindPlace_clicked() +{ + m_widget->comboBoxFindPlace->setFocus(); + comboBoxFindPlace_returnPressed(); +} + +void OPMapGadgetWidget::on_toolButtonZoomP_clicked() +{ + zoomIn(); +} + +void OPMapGadgetWidget::on_toolButtonZoomM_clicked() +{ + zoomOut(); +} + +void OPMapGadgetWidget::on_toolButtonMapHome_clicked() +{ + followUAVpositionAct->setChecked(false); +} + +void OPMapGadgetWidget::on_toolButtonMapUAV_clicked() +{ + followUAVpositionAct->toggle(); +} + +void OPMapGadgetWidget::on_toolButtonMapUAVheading_clicked() +{ + followUAVheadingAct->toggle(); +} + +void OPMapGadgetWidget::on_toolButtonShowUAVtrail_clicked() +{ + showUAVtrailAct->toggle(); +} + +void OPMapGadgetWidget::on_toolButtonClearUAVtrail_clicked() +{ + clearUAVtrailAct->trigger(); +} + +void OPMapGadgetWidget::on_horizontalSliderZoom_sliderMoved(int position) +{ + setZoom(position); +} + +void OPMapGadgetWidget::on_toolButtonHome_clicked() +{ + // to do +} + + +void OPMapGadgetWidget::on_toolButtonPrevWaypoint_clicked() +{ + // to do +} + +void OPMapGadgetWidget::on_toolButtonNextWaypoint_clicked() +{ + // to do +} + +void OPMapGadgetWidget::on_toolButtonHoldPosition_clicked() +{ + // to do +} + +void OPMapGadgetWidget::on_toolButtonGo_clicked() +{ + // to do +} + +void OPMapGadgetWidget::on_toolButtonAddWaypoint_clicked() +{ + if (!m_map) return; + + m_waypoint_list_mutex.lock(); + + // create a waypoint at the center of the map + t_waypoint waypoint; + waypoint.item = m_map->WPCreate(m_map->CurrentPosition(), 0); + waypoint.time_seconds = 0; + waypoint.hold_time_seconds = 0; + + // and remember it in our own local waypoint list + m_waypoint_list.append(waypoint); + + m_waypoint_list_mutex.unlock(); +} + +void OPMapGadgetWidget::on_treeViewWaypoints_clicked(QModelIndex index) +{ + QStandardItem *item = wayPoint_treeView_model.itemFromIndex(index); + if (!item) return; + + // to do +} + +// ************************************************************************************* +// public functions + +void OPMapGadgetWidget::zoomIn() +{ + if (m_map) + m_map->SetZoom(m_map->Zoom() + 1); +} + +void OPMapGadgetWidget::zoomOut() +{ + if (m_map) + m_map->SetZoom(m_map->Zoom() - 1); +} + +void OPMapGadgetWidget::setZoom(int value) +{ + if (m_map) + { + internals::MouseWheelZoomType::Types zoom_type = m_map->GetMouseWheelZoomType(); + m_map->SetMouseWheelZoomType(internals::MouseWheelZoomType::ViewCenter); + + m_map->SetZoom(value); + + m_map->SetMouseWheelZoomType(zoom_type); + } +} + +void OPMapGadgetWidget::setPosition(QPointF pos) +{ + if (m_map) + m_map->SetCurrentPosition(internals::PointLatLng(pos.y(), pos.x())); +} + +void OPMapGadgetWidget::setMapProvider(QString provider) +{ + if (m_map) + m_map->SetMapType(mapcontrol::Helper::MapTypeFromString(provider)); +} + +void OPMapGadgetWidget::setAccessMode(QString accessMode) +{ + if (m_map) + m_map->configuration->SetAccessMode(mapcontrol::Helper::AccessModeFromString(accessMode)); +} + +void OPMapGadgetWidget::setUseOpenGL(bool useOpenGL) +{ + if (m_map) + m_map->SetUseOpenGL(useOpenGL); +} + +void OPMapGadgetWidget::setShowTileGridLines(bool showTileGridLines) +{ + if (m_map) + m_map->SetShowTileGridLines(showTileGridLines); +} + +void OPMapGadgetWidget::setUseMemoryCache(bool useMemoryCache) +{ + if (m_map) + m_map->configuration->SetUseMemoryCache(useMemoryCache); +} + +void OPMapGadgetWidget::setCacheLocation(QString cacheLocation) +{ + cacheLocation = cacheLocation.simplified(); // remove any surrounding spaces + + 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 + + QDir dir; + if (!dir.exists(cacheLocation)) + if (!dir.mkpath(cacheLocation)) + return; + +// qDebug() << "map cache dir: " << cacheLocation; + + if (m_map) + m_map->configuration->SetCacheLocation(cacheLocation); +} + +// ************************************************************************************* +// Context menu stuff + +void OPMapGadgetWidget::createActions() +{ + // *********************** + // create menu actions + + closeAct = new QAction(tr("&Close menu"), this); +// closeAct->setShortcuts(QKeySequence::New); + closeAct->setStatusTip(tr("Close the context menu")); + + reloadAct = new QAction(tr("&Reload map"), this); + reloadAct->setShortcut(tr("F5")); + reloadAct->setStatusTip(tr("Reload the map tiles")); + connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered())); + + copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this); + copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard")); + connect(copyMouseLatLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatLonToClipAct_triggered())); + + copyMouseLatToClipAct = new QAction(tr("Mouse latitude"), this); + copyMouseLatToClipAct->setStatusTip(tr("Copy the mouse latitude to the clipboard")); + connect(copyMouseLatToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatToClipAct_triggered())); + + copyMouseLonToClipAct = new QAction(tr("Mouse longitude"), this); + 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); + showCompassAct->setChecked(true); + connect(showCompassAct, SIGNAL(toggled(bool)), this, SLOT(onShowCompassAct_toggled(bool))); + + showUAVAct = new QAction(tr("Show UAV"), this); + showUAVAct->setStatusTip(tr("Show/Hide the UAV")); + showUAVAct->setCheckable(true); + showUAVAct->setChecked(m_map->ShowUAV()); + showUAVAct->setEnabled(false); // temporary + connect(showUAVAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVAct_toggled(bool))); + + 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())); + + 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())); + + 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")); + connect(goMouseClickAct, SIGNAL(triggered()), this, SLOT(onGoMouseClickAct_triggered())); + + goHomeAct = new QAction(tr("Go to &Home location"), this); + goHomeAct->setShortcut(tr("Ctrl+H")); + goHomeAct->setStatusTip(tr("Center the map onto the home location")); + connect(goHomeAct, SIGNAL(triggered()), this, SLOT(onGoHomeAct_triggered())); + + goUAVAct = new QAction(tr("Go to &UAV location"), this); + goUAVAct->setShortcut(tr("Ctrl+U")); + goUAVAct->setStatusTip(tr("Center the map onto the UAV location")); + connect(goUAVAct, SIGNAL(triggered()), this, SLOT(onGoUAVAct_triggered())); + + followUAVpositionAct = new QAction(tr("Follow UAV position"), this); + followUAVpositionAct->setShortcut(tr("Ctrl+F")); + followUAVpositionAct->setStatusTip(tr("Keep the map centered onto the UAV")); + followUAVpositionAct->setCheckable(true); + followUAVpositionAct->setChecked(false); + connect(followUAVpositionAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVpositionAct_toggled(bool))); + + followUAVheadingAct = new QAction(tr("Follow UAV heading"), this); + followUAVheadingAct->setShortcut(tr("Ctrl+F")); + followUAVheadingAct->setStatusTip(tr("Keep the map rotation to the UAV heading")); + followUAVheadingAct->setCheckable(true); + followUAVheadingAct->setChecked(false); + connect(followUAVheadingAct, SIGNAL(toggled(bool)), this, SLOT(onFollowUAVheadingAct_toggled(bool))); + + showUAVtrailAct = new QAction(tr("Show UAV trail"), this); + showUAVtrailAct->setStatusTip(tr("Show/Hide the UAV trail")); + showUAVtrailAct->setCheckable(true); + showUAVtrailAct->setChecked(true); + connect(showUAVtrailAct, SIGNAL(toggled(bool)), this, SLOT(onShowUAVtrailAct_toggled(bool))); + + clearUAVtrailAct = new QAction(tr("Clear UAV trail"), this); + clearUAVtrailAct->setStatusTip(tr("Clear the UAV trail")); + connect(clearUAVtrailAct, SIGNAL(triggered()), this, SLOT(onClearUAVtrailAct_triggered())); + + 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())); + + editWayPointAct = new QAction(tr("&Edit waypoint"), this); + editWayPointAct->setShortcut(tr("Ctrl+E")); + editWayPointAct->setStatusTip(tr("Edit waypoint")); + connect(editWayPointAct, SIGNAL(triggered()), this, SLOT(onEditWayPointAct_triggered())); + + lockWayPointAct = new QAction(tr("&Lock waypoint"), this); + lockWayPointAct->setStatusTip(tr("Lock/Unlock a waypoint")); + lockWayPointAct->setCheckable(true); + lockWayPointAct->setChecked(false); + connect(lockWayPointAct, SIGNAL(triggered()), this, SLOT(onLockWayPointAct_triggered())); + + deleteWayPointAct = new QAction(tr("&Delete waypoint"), this); + deleteWayPointAct->setShortcut(tr("Ctrl+D")); + deleteWayPointAct->setStatusTip(tr("Delete waypoint")); + connect(deleteWayPointAct, SIGNAL(triggered()), this, SLOT(onDeleteWayPointAct_triggered())); + + clearWayPointsAct = new QAction(tr("&Clear waypoints"), this); + clearWayPointsAct->setShortcut(tr("Ctrl+C")); + clearWayPointsAct->setStatusTip(tr("Clear waypoints")); + connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered())); + + zoomActGroup = new QActionGroup(this); + connect(zoomActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onZoomActGroup_triggered(QAction *))); + zoomAct.clear(); + for (int i = 2; i <= 19; i++) + { + QAction *zoom_act = new QAction(QString::number(i), zoomActGroup); + zoom_act->setCheckable(true); + zoom_act->setData(i); + zoomAct.append(zoom_act); + } + + // *********************** +} + +void OPMapGadgetWidget::onReloadAct_triggered() +{ + if (m_map) + m_map->ReloadMap(); +} + +void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered() +{ +// QClipboard *clipboard = qApp->clipboard(); + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(QString::number(mouse_lat_lon.Lat(), 'f', 7) + ", " + QString::number(mouse_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard); +} + +void OPMapGadgetWidget::onCopyMouseLatToClipAct_triggered() +{ +// QClipboard *clipboard = qApp->clipboard(); + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(QString::number(mouse_lat_lon.Lat(), 'f', 7), QClipboard::Clipboard); +} + +void OPMapGadgetWidget::onCopyMouseLonToClipAct_triggered() +{ +// QClipboard *clipboard = qApp->clipboard(); + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(QString::number(mouse_lat_lon.Lng(), 'f', 7), QClipboard::Clipboard); +} + +void OPMapGadgetWidget::onFindPlaceAct_triggered() +{ + m_widget->comboBoxFindPlace->setFocus(); // move focus to the 'find place' text box + +/* + bool ok; + QString place = QInputDialog::getText(this, tr("OpenPilot GCS"), tr("Find place"), QLineEdit::Normal, QString::null, &ok); + place = place.simplified(); + if (!ok || place.isNull() || place.isEmpty()) return; + + if (!findPlaceWordList.contains(place, Qt::CaseInsensitive)) + { + findPlaceWordList += place; // add the new word into the history list + } + + if (!m_map) return; + + core::GeoCoderStatusCode::Types x = m_map->SetCurrentPositionByKeywords(place); + QString returned_text = mapcontrol::Helper::StrFromGeoCoderStatusCode(x); + + QMessageBox::information(this, tr("OpenPilot GCS"), returned_text, QMessageBox::Ok); +*/ +} + +void OPMapGadgetWidget::onShowCompassAct_toggled(bool show) +{ + if (m_map) + m_map->SetShowCompass(show); +} + +void OPMapGadgetWidget::onShowUAVAct_toggled(bool show) +{ + if (m_map) + m_map->SetShowUAV(show); // this can cause a rather big crash +} + +void OPMapGadgetWidget::onGoZoomInAct_triggered() +{ + if (m_map) + setZoom(m_map->Zoom() + 1); +} + +void OPMapGadgetWidget::onGoZoomOutAct_triggered() +{ + if (m_map) + setZoom(m_map->Zoom() - 1); +} + +void OPMapGadgetWidget::onZoomActGroup_triggered(QAction *action) +{ + if (!action) return; + + int zoom = action->data().toInt(); + if (zoom < 2 || zoom > 19) return; + + setZoom(zoom); +} + +void OPMapGadgetWidget::onGoMouseClickAct_triggered() +{ + if (m_map) + m_map->SetCurrentPosition(m_map->currentMousePosition()); // center the map onto the mouse position +} + +void OPMapGadgetWidget::onGoHomeAct_triggered() +{ + followUAVpositionAct->setChecked(false); +} + +void OPMapGadgetWidget::onGoUAVAct_triggered() +{ + PositionActual::DataFields data = m_positionActual->getData(); // get current UAV data + + if (m_map) + { + internals::PointLatLng uav_pos = internals::PointLatLng(data.Latitude, data.Longitude); // current UAV position + internals::PointLatLng map_pos = m_map->CurrentPosition(); // current MAP position + if (map_pos != uav_pos) m_map->SetCurrentPosition(uav_pos); // center the map onto the UAV + } +} + +void OPMapGadgetWidget::onFollowUAVpositionAct_toggled(bool checked) +{ + if (m_widget) + { + if (m_widget->toolButtonMapUAV->isChecked() != checked) + m_widget->toolButtonMapUAV->setChecked(checked); + + setMapFollowingmode(); + } +} + +void OPMapGadgetWidget::onFollowUAVheadingAct_toggled(bool checked) +{ + if (m_widget) + { + if (m_widget->toolButtonMapUAVheading->isChecked() != checked) + m_widget->toolButtonMapUAVheading->setChecked(checked); + + setMapFollowingmode(); + } +} + +void OPMapGadgetWidget::onShowUAVtrailAct_toggled(bool checked) +{ + if (m_widget) + { + if (m_widget->toolButtonShowUAVtrail->isChecked() != checked) + m_widget->toolButtonShowUAVtrail->setChecked(checked); + + if (m_map) + m_map->UAV->SetShowTrail(checked); + } +} + +void OPMapGadgetWidget::onClearUAVtrailAct_triggered() +{ + if (m_map) + m_map->UAV->DeleteTrail(); +} + +void OPMapGadgetWidget::onOpenWayPointEditorAct_triggered() +{ + waypoint_editor_dialog.show(); +} + +void OPMapGadgetWidget::onAddWayPointAct_triggered() +{ + if (!m_map) return; + + m_waypoint_list_mutex.lock(); + + // create a waypoint on the map at the last known mouse position + t_waypoint waypoint; + waypoint.item = m_map->WPCreate(mouse_lat_lon, 0); + waypoint.time_seconds = 0; + waypoint.hold_time_seconds = 0; + + // and remember it in our own local waypoint list + m_waypoint_list.append(waypoint); + + m_waypoint_list_mutex.unlock(); +} + +void OPMapGadgetWidget::onEditWayPointAct_triggered() +{ + if (!m_mouse_waypoint) return; + + waypoint_edit_dialog.editWaypoint(m_mouse_waypoint); + + m_mouse_waypoint = NULL; +} + +void OPMapGadgetWidget::onLockWayPointAct_triggered() +{ + if (!m_mouse_waypoint) return; + + bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; + m_mouse_waypoint->setFlag(QGraphicsItem::ItemIsMovable, locked); + + m_mouse_waypoint = NULL; +} + +void OPMapGadgetWidget::onDeleteWayPointAct_triggered() +{ + if (!m_mouse_waypoint) return; + + bool locked = (m_mouse_waypoint->flags() & QGraphicsItem::ItemIsMovable) == 0; + + if (locked) return; // waypoint is locked + + m_waypoint_list_mutex.lock(); + + for (int i = 0; i < m_waypoint_list.count(); i++) + { + t_waypoint waypoint = m_waypoint_list.at(i); + if (waypoint.item != m_mouse_waypoint) continue; + + // delete the waypoint from the map + if (m_map) m_map->WPDelete(waypoint.item); + + // delete the waypoint from our local waypoint list + m_waypoint_list.removeAt(i); + + break; + } + + m_waypoint_list_mutex.unlock(); + + m_mouse_waypoint = NULL; +} + +void OPMapGadgetWidget::onClearWayPointsAct_triggered() +{ + m_waypoint_list_mutex.lock(); + if (m_map) m_map->WPDeleteAll(); + m_waypoint_list.clear(); + m_waypoint_list_mutex.unlock(); +} + +// ************************************************************************************* +// 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(); +} + +// ************************************************************************************* + +void OPMapGadgetWidget::setMapFollowingmode() +{ + if (!m_map) return; + + if (!followUAVpositionAct->isChecked()) + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::None); + m_map->SetRotate(0); // reset map rotation to 0deg + } + else + if (!followUAVheadingAct->isChecked()) + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); + m_map->SetRotate(0); // reset map rotation to 0deg + } + else + { + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterMap); // the map library won't let you reset the uav rotation if it's already in rotate mode + +// if (m_map->ShowUAV()) + m_map->UAV->SetUAVHeading(0); // reset the UAV heading to 0deg + m_map->UAV->SetMapFollowType(UAVMapFollowType::CenterAndRotateMap); + } +} + +// ************************************************************************************* diff --git a/ground/src/plugins/opmap/opmapgadgetwidget.h b/ground/src/plugins/opmap/opmapgadgetwidget.h index 83ec91fb7..ee890b6f3 100644 --- a/ground/src/plugins/opmap/opmapgadgetwidget.h +++ b/ground/src/plugins/opmap/opmapgadgetwidget.h @@ -1,252 +1,252 @@ -/** - ****************************************************************************** - * - * @file opmapgadgetwidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap - * @{ - * - *****************************************************************************/ -/* - * 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_GADGETWIDGET_H_ -#define OPMAP_GADGETWIDGET_H_ - -#include -#include -#include -#include -#include -#include - -#include "opmapcontrol/opmapcontrol.h" - -#include "uavobjects/uavobjectmanager.h" -#include "uavobjects/positionactual.h" -#include "extensionsystem/pluginmanager.h" - -#include "opmap_overlay_widget.h" -#include "opmap_zoom_slider_widget.h" -#include "opmap_statusbar_widget.h" -#include "opmap_waypointeditor_dialog.h" -#include "opmap_edit_waypoint_dialog.h" - -namespace Ui -{ - class OPMap_Widget; -} - -using namespace mapcontrol; - -// ****************************************************** - -// local waypoint list item structure -typedef struct t_waypoint -{ - mapcontrol::WayPointItem *item; - int time_seconds; - int hold_time_seconds; -} t_waypoint; - -// ****************************************************** - -class OPMapGadgetWidget : public QWidget -{ - Q_OBJECT - -public: - OPMapGadgetWidget(QWidget *parent = 0); - ~OPMapGadgetWidget(); - - /** - * @brief public functions - * - * @param - */ - void setZoom(int value); - void setPosition(QPointF pos); - void setMapProvider(QString provider); - void setUseOpenGL(bool useOpenGL); - void setShowTileGridLines(bool showTileGridLines); - void setAccessMode(QString accessMode); - void setUseMemoryCache(bool useMemoryCache); - void setCacheLocation(QString cacheLocation); - -public slots: - -protected: - void resizeEvent(QResizeEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void contextMenuEvent(QContextMenuEvent *event); - void keyPressEvent(QKeyEvent* event); - -private slots: - void updatePosition(); - - void updateMousePos(); - - void zoomIn(); - void zoomOut(); - - /** - * @brief signals received from the various map plug-in widget user controls - * - * @param - */ - 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_toolButtonShowUAVtrail_clicked(); - void on_toolButtonClearUAVtrail_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(); - - /** - * @brief signals received from the map object - * - * @param - */ - void zoomChanged(double zoom); - 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); - 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 - * - * @param - */ - void onReloadAct_triggered(); - void onCopyMouseLatLonToClipAct_triggered(); - void onCopyMouseLatToClipAct_triggered(); - void onCopyMouseLonToClipAct_triggered(); - void onFindPlaceAct_triggered(); - void onShowCompassAct_toggled(bool show); - void onShowUAVAct_toggled(bool show); - void onGoZoomInAct_triggered(); - void onGoZoomOutAct_triggered(); - void onGoMouseClickAct_triggered(); - void onGoHomeAct_triggered(); - void onGoUAVAct_triggered(); - void onFollowUAVpositionAct_toggled(bool checked); - void onFollowUAVheadingAct_toggled(bool checked); - void onShowUAVtrailAct_toggled(bool checked); - void onClearUAVtrailAct_triggered(); - void onOpenWayPointEditorAct_triggered(); - void onAddWayPointAct_triggered(); - void onEditWayPointAct_triggered(); - void onLockWayPointAct_triggered(); - void onDeleteWayPointAct_triggered(); - void onClearWayPointsAct_triggered(); - void onZoomActGroup_triggered(QAction *action); - -private: - double m_heading; // uav heading - - internals::PointLatLng mouse_lat_lon; - - int prev_tile_number; - - QStringList findPlaceWordList; - QCompleter *findPlaceCompleter; - - QTimer *m_updateTimer; - QTimer *m_statusUpdateTimer; - - ExtensionSystem::PluginManager *m_plugin_manager; - UAVObjectManager *m_objManager; - PositionActual *m_positionActual; - - Ui::OPMap_Widget *m_widget; - - mapcontrol::OPMapWidget *m_map; - - opmap_waypointeditor_dialog waypoint_editor_dialog; - - opmap_edit_waypoint_dialog waypoint_edit_dialog; - - opmap_overlay_widget *m_overlay_widget; - - QGraphicsScene *m_map_graphics_scene; - QGraphicsProxyWidget *m_map_scene_proxy; - opmap_zoom_slider_widget *m_zoom_slider_widget; - opmap_statusbar_widget *m_statusbar_widget; - - QStandardItemModel wayPoint_treeView_model; - - mapcontrol::WayPointItem *m_mouse_waypoint; - - QList m_waypoint_list; - QMutex m_waypoint_list_mutex; - - void createActions(); - - QAction *closeAct; - QAction *reloadAct; - QAction *copyMouseLatLonToClipAct; - QAction *copyMouseLatToClipAct; - QAction *copyMouseLonToClipAct; - QAction *findPlaceAct; - QAction *showCompassAct; - QAction *showUAVAct; - QAction *zoomInAct; - QAction *zoomOutAct; - QAction *goMouseClickAct; - QAction *goHomeAct; - QAction *goUAVAct; - QAction *followUAVpositionAct; - QAction *followUAVheadingAct; - QAction *showUAVtrailAct; - QAction *clearUAVtrailAct; - QAction *wayPointEditorAct; - QAction *addWayPointAct; - QAction *editWayPointAct; - QAction *lockWayPointAct; - QAction *deleteWayPointAct; - QAction *clearWayPointsAct; - - QActionGroup *zoomActGroup; - QList zoomAct; - - void loadComboBoxLines(QComboBox *comboBox, QString filename); - void saveComboBoxLines(QComboBox *comboBox, QString filename); - - void setMapFollowingmode(); -}; - -#endif /* OPMAP_GADGETWIDGET_H_ */ +/** + ****************************************************************************** + * + * @file opmapgadgetwidget.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_GADGETWIDGET_H_ +#define OPMAP_GADGETWIDGET_H_ + +#include +#include +#include +#include +#include +#include + +#include "opmapcontrol/opmapcontrol.h" + +#include "uavobjects/uavobjectmanager.h" +#include "uavobjects/positionactual.h" +#include "extensionsystem/pluginmanager.h" + +#include "opmap_overlay_widget.h" +#include "opmap_zoom_slider_widget.h" +#include "opmap_statusbar_widget.h" +#include "opmap_waypointeditor_dialog.h" +#include "opmap_edit_waypoint_dialog.h" + +namespace Ui +{ + class OPMap_Widget; +} + +using namespace mapcontrol; + +// ****************************************************** + +// local waypoint list item structure +typedef struct t_waypoint +{ + mapcontrol::WayPointItem *item; + int time_seconds; + int hold_time_seconds; +} t_waypoint; + +// ****************************************************** + +class OPMapGadgetWidget : public QWidget +{ + Q_OBJECT + +public: + OPMapGadgetWidget(QWidget *parent = 0); + ~OPMapGadgetWidget(); + + /** + * @brief public functions + * + * @param + */ + void setZoom(int value); + void setPosition(QPointF pos); + void setMapProvider(QString provider); + void setUseOpenGL(bool useOpenGL); + void setShowTileGridLines(bool showTileGridLines); + void setAccessMode(QString accessMode); + void setUseMemoryCache(bool useMemoryCache); + void setCacheLocation(QString cacheLocation); + +public slots: + +protected: + void resizeEvent(QResizeEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + void keyPressEvent(QKeyEvent* event); + +private slots: + void updatePosition(); + + void updateMousePos(); + + void zoomIn(); + void zoomOut(); + + /** + * @brief signals received from the various map plug-in widget user controls + * + * @param + */ + 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_toolButtonShowUAVtrail_clicked(); + void on_toolButtonClearUAVtrail_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(); + + /** + * @brief signals received from the map object + * + * @param + */ + void zoomChanged(double zoom); + 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); + 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 + * + * @param + */ + void onReloadAct_triggered(); + void onCopyMouseLatLonToClipAct_triggered(); + void onCopyMouseLatToClipAct_triggered(); + void onCopyMouseLonToClipAct_triggered(); + void onFindPlaceAct_triggered(); + void onShowCompassAct_toggled(bool show); + void onShowUAVAct_toggled(bool show); + void onGoZoomInAct_triggered(); + void onGoZoomOutAct_triggered(); + void onGoMouseClickAct_triggered(); + void onGoHomeAct_triggered(); + void onGoUAVAct_triggered(); + void onFollowUAVpositionAct_toggled(bool checked); + void onFollowUAVheadingAct_toggled(bool checked); + void onShowUAVtrailAct_toggled(bool checked); + void onClearUAVtrailAct_triggered(); + void onOpenWayPointEditorAct_triggered(); + void onAddWayPointAct_triggered(); + void onEditWayPointAct_triggered(); + void onLockWayPointAct_triggered(); + void onDeleteWayPointAct_triggered(); + void onClearWayPointsAct_triggered(); + void onZoomActGroup_triggered(QAction *action); + +private: + double m_heading; // uav heading + + internals::PointLatLng mouse_lat_lon; + + int prev_tile_number; + + QStringList findPlaceWordList; + QCompleter *findPlaceCompleter; + + QTimer *m_updateTimer; + QTimer *m_statusUpdateTimer; + + ExtensionSystem::PluginManager *m_plugin_manager; + UAVObjectManager *m_objManager; + PositionActual *m_positionActual; + + Ui::OPMap_Widget *m_widget; + + mapcontrol::OPMapWidget *m_map; + + opmap_waypointeditor_dialog waypoint_editor_dialog; + + opmap_edit_waypoint_dialog waypoint_edit_dialog; + + opmap_overlay_widget *m_overlay_widget; + + QGraphicsScene *m_map_graphics_scene; + QGraphicsProxyWidget *m_map_scene_proxy; + opmap_zoom_slider_widget *m_zoom_slider_widget; + opmap_statusbar_widget *m_statusbar_widget; + + QStandardItemModel wayPoint_treeView_model; + + mapcontrol::WayPointItem *m_mouse_waypoint; + + QList m_waypoint_list; + QMutex m_waypoint_list_mutex; + + void createActions(); + + QAction *closeAct; + QAction *reloadAct; + QAction *copyMouseLatLonToClipAct; + QAction *copyMouseLatToClipAct; + QAction *copyMouseLonToClipAct; + QAction *findPlaceAct; + QAction *showCompassAct; + QAction *showUAVAct; + QAction *zoomInAct; + QAction *zoomOutAct; + QAction *goMouseClickAct; + QAction *goHomeAct; + QAction *goUAVAct; + QAction *followUAVpositionAct; + QAction *followUAVheadingAct; + QAction *showUAVtrailAct; + QAction *clearUAVtrailAct; + QAction *wayPointEditorAct; + QAction *addWayPointAct; + QAction *editWayPointAct; + QAction *lockWayPointAct; + QAction *deleteWayPointAct; + QAction *clearWayPointsAct; + + QActionGroup *zoomActGroup; + QList zoomAct; + + void loadComboBoxLines(QComboBox *comboBox, QString filename); + void saveComboBoxLines(QComboBox *comboBox, QString filename); + + void setMapFollowingmode(); +}; + +#endif /* OPMAP_GADGETWIDGET_H_ */ diff --git a/ground/src/plugins/opmap/opmapplugin.cpp b/ground/src/plugins/opmap/opmapplugin.cpp index c12eb6781..5f78b8bf8 100644 --- a/ground/src/plugins/opmap/opmapplugin.cpp +++ b/ground/src/plugins/opmap/opmapplugin.cpp @@ -3,11 +3,11 @@ * * @file opmapplugin.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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 diff --git a/ground/src/plugins/opmap/opmapplugin.h b/ground/src/plugins/opmap/opmapplugin.h index 78c844da7..93b9351ac 100644 --- a/ground/src/plugins/opmap/opmapplugin.h +++ b/ground/src/plugins/opmap/opmapplugin.h @@ -3,11 +3,11 @@ * * @file opmapplugin.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup opmap + * @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