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();
47 m_maxUpdateRate
= settings
.value("maxUpdateRate", 2000).toInt();
48 if (m_maxUpdateRate
< 100 || m_maxUpdateRate
> 5000) {
49 m_maxUpdateRate
= 2000;
52 m_accessMode
= settings
.value("accessMode", "ServerAndCache").toString();
53 m_useMemoryCache
= settings
.value("useMemoryCache").toBool();
54 m_cacheLocation
= settings
.value("cacheLocation", Utils::GetStoragePath() + "mapscache" + QDir::separator()).toString();
55 m_cacheLocation
= Utils::InsertStoragePath(m_cacheLocation
);
58 OPMapGadgetConfiguration::OPMapGadgetConfiguration(const OPMapGadgetConfiguration
&obj
) :
59 IUAVGadgetConfiguration(obj
.classId(), obj
.parent())
61 m_mapProvider
= obj
.m_mapProvider
;
62 m_defaultZoom
= obj
.m_defaultZoom
;
63 m_defaultLatitude
= obj
.m_defaultLatitude
;
64 m_defaultLongitude
= obj
.m_defaultLongitude
;
65 m_useOpenGL
= obj
.m_useOpenGL
;
66 m_showTileGridLines
= obj
.m_showTileGridLines
;
67 m_accessMode
= obj
.m_accessMode
;
68 m_useMemoryCache
= obj
.m_useMemoryCache
;
69 m_cacheLocation
= obj
.m_cacheLocation
;
70 m_uavSymbol
= obj
.m_uavSymbol
;
71 m_maxUpdateRate
= obj
.m_maxUpdateRate
;
72 m_opacity
= obj
.m_opacity
;
73 m_defaultWaypointAltitude
= obj
.m_defaultWaypointAltitude
;
74 m_defaultWaypointVelocity
= obj
.m_defaultWaypointVelocity
;
77 IUAVGadgetConfiguration
*OPMapGadgetConfiguration::clone() const
79 return new OPMapGadgetConfiguration(*this);
82 void OPMapGadgetConfiguration::save() const
89 void OPMapGadgetConfiguration::saveConfig(QSettings
&settings
) const
91 settings
.setValue("mapProvider", m_mapProvider
);
92 settings
.setValue("defaultZoom", m_defaultZoom
);
93 settings
.setValue("defaultLatitude", m_defaultLatitude
);
94 settings
.setValue("defaultLongitude", m_defaultLongitude
);
95 settings
.setValue("useOpenGL", m_useOpenGL
);
96 settings
.setValue("showTileGridLines", m_showTileGridLines
);
97 settings
.setValue("accessMode", m_accessMode
);
98 settings
.setValue("useMemoryCache", m_useMemoryCache
);
99 settings
.setValue("uavSymbol", m_uavSymbol
);
100 settings
.setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation
));
101 settings
.setValue("maxUpdateRate", m_maxUpdateRate
);
102 settings
.setValue("overlayOpacity", m_opacity
);
104 settings
.setValue("defaultWaypointAltitude", m_defaultWaypointAltitude
);
105 settings
.setValue("defaultWaypointVelocity", m_defaultWaypointVelocity
);
107 void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation
)
109 m_cacheLocation
= cacheLocation
;