2 ******************************************************************************
4 * @file opmapgadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * @addtogroup GCSPlugins GCS Plugins
8 * @addtogroup OPMapPlugin OpenPilot Map Plugin
10 * @brief The OpenPilot Map plugin
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "opmapgadgetconfiguration.h"
29 #include "utils/pathutils.h"
32 OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId
, QSettings
&settings
, QObject
*parent
) :
33 IUAVGadgetConfiguration(classId
, parent
)
35 m_defaultWaypointAltitude
= settings
.value("defaultWaypointAltitude", 15).toReal();
36 m_defaultWaypointVelocity
= settings
.value("defaultWaypointVelocity", 2).toReal();
37 m_opacity
= settings
.value("overlayOpacity", 1).toReal();
39 m_mapProvider
= settings
.value("mapProvider", "GoogleHybrid").toString();
40 m_defaultZoom
= settings
.value("defaultZoom", 2).toInt();
41 m_defaultLatitude
= settings
.value("defaultLatitude").toDouble();
42 m_defaultLongitude
= settings
.value("defaultLongitude").toDouble();
43 m_useOpenGL
= settings
.value("useOpenGL").toBool();
44 m_showTileGridLines
= settings
.value("showTileGridLines").toBool();
45 m_uavSymbol
= settings
.value("uavSymbol", QString::fromUtf8(":/uavs/images/mapquad.png")).toString();
46 m_safeAreaRadius
= settings
.value("safeAreaRadius", 5).toInt();
47 m_showSafeArea
= settings
.value("showSafeArea").toBool();
49 m_maxUpdateRate
= settings
.value("maxUpdateRate", 2000).toInt();
50 if (m_maxUpdateRate
< 100 || m_maxUpdateRate
> 5000) {
51 m_maxUpdateRate
= 2000;
54 m_accessMode
= settings
.value("accessMode", "ServerAndCache").toString();
55 m_useMemoryCache
= settings
.value("useMemoryCache").toBool();
56 m_cacheLocation
= settings
.value("cacheLocation", Utils::GetStoragePath() + "mapscache" + QDir::separator()).toString();
57 m_cacheLocation
= Utils::InsertStoragePath(m_cacheLocation
);
60 OPMapGadgetConfiguration::OPMapGadgetConfiguration(const OPMapGadgetConfiguration
&obj
) :
61 IUAVGadgetConfiguration(obj
.classId(), obj
.parent())
63 m_mapProvider
= obj
.m_mapProvider
;
64 m_defaultZoom
= obj
.m_defaultZoom
;
65 m_defaultLatitude
= obj
.m_defaultLatitude
;
66 m_defaultLongitude
= obj
.m_defaultLongitude
;
67 m_useOpenGL
= obj
.m_useOpenGL
;
68 m_showTileGridLines
= obj
.m_showTileGridLines
;
69 m_accessMode
= obj
.m_accessMode
;
70 m_useMemoryCache
= obj
.m_useMemoryCache
;
71 m_cacheLocation
= obj
.m_cacheLocation
;
72 m_uavSymbol
= obj
.m_uavSymbol
;
73 m_maxUpdateRate
= obj
.m_maxUpdateRate
;
74 m_safeAreaRadius
= obj
.m_safeAreaRadius
;
75 m_showSafeArea
= obj
.m_showSafeArea
;
76 m_opacity
= obj
.m_opacity
;
77 m_defaultWaypointAltitude
= obj
.m_defaultWaypointAltitude
;
78 m_defaultWaypointVelocity
= obj
.m_defaultWaypointVelocity
;
81 IUAVGadgetConfiguration
*OPMapGadgetConfiguration::clone() const
83 return new OPMapGadgetConfiguration(*this);
86 void OPMapGadgetConfiguration::save() const
93 void OPMapGadgetConfiguration::saveConfig(QSettings
&settings
) const
95 settings
.setValue("mapProvider", m_mapProvider
);
96 settings
.setValue("defaultZoom", m_defaultZoom
);
97 settings
.setValue("defaultLatitude", m_defaultLatitude
);
98 settings
.setValue("defaultLongitude", m_defaultLongitude
);
99 settings
.setValue("useOpenGL", m_useOpenGL
);
100 settings
.setValue("showTileGridLines", m_showTileGridLines
);
101 settings
.setValue("accessMode", m_accessMode
);
102 settings
.setValue("useMemoryCache", m_useMemoryCache
);
103 settings
.setValue("uavSymbol", m_uavSymbol
);
104 settings
.setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation
));
105 settings
.setValue("maxUpdateRate", m_maxUpdateRate
);
106 settings
.setValue("safeAreaRadius", m_safeAreaRadius
);
107 settings
.setValue("showSafeArea", m_showSafeArea
);
108 settings
.setValue("overlayOpacity", m_opacity
);
110 settings
.setValue("defaultWaypointAltitude", m_defaultWaypointAltitude
);
111 settings
.setValue("defaultWaypointVelocity", m_defaultWaypointVelocity
);
113 void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation
)
115 m_cacheLocation
= cacheLocation
;