Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / dial / dialgadgetconfiguration.cpp
blob1fa2f09968d7d80d78d05765fa40ea427981ba37
1 /**
2 ******************************************************************************
4 * @file dialgadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @see The GNU Public License (GPL) Version 3
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup DialPlugin Dial Plugin
10 * @{
11 * @brief Plots flight information rotary style dials
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "dialgadgetconfiguration.h"
30 #include "utils/pathutils.h"
32 /**
33 * Loads a saved configuration.
36 DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
37 IUAVGadgetConfiguration(classId, parent)
39 QString dialFile = settings.value("dialFile", "Unknown").toString();
41 m_defaultDial = Utils::InsertDataPath(dialFile);
42 dialBackgroundID = settings.value("dialBackgroundID", "background").toString();
43 dialForegroundID = settings.value("dialForegroundID", "foreground").toString();
44 dialNeedleID1 = settings.value("dialNeedleID1", "needle").toString();
45 dialNeedleID2 = settings.value("dialNeedleID2", "needle2").toString();
46 dialNeedleID3 = settings.value("dialNeedleID3", "needle3").toString();
47 needle1MinValue = settings.value("needle1MinValue", 0).toDouble();
48 needle1MaxValue = settings.value("needle1MaxValue", 100).toDouble();
49 needle2MinValue = settings.value("needle2MinValue", 0).toDouble();
50 needle2MaxValue = settings.value("needle2MaxValue", 100).toDouble();
51 needle3MinValue = settings.value("needle3MinValue", 0).toDouble();
52 needle3MaxValue = settings.value("needle3MaxValue", 100).toDouble();
53 needle1DataObject = settings.value("needle1DataObject").toString();
54 needle1ObjectField = settings.value("needle1ObjectField").toString();
55 needle2DataObject = settings.value("needle2DataObject").toString();
56 needle2ObjectField = settings.value("needle2ObjectField").toString();
57 needle3DataObject = settings.value("needle3DataObject").toString();
58 needle3ObjectField = settings.value("needle3ObjectField").toString();
59 needle1Factor = settings.value("needle1Factor", 1).toDouble();
60 needle2Factor = settings.value("needle2Factor", 1).toDouble();
61 needle3Factor = settings.value("needle3Factor", 1).toDouble();
62 needle1Move = settings.value("needle1Move", "Rotate").toString();
63 needle2Move = settings.value("needle2Move", "Rotate").toString();
64 needle3Move = settings.value("needle3Move", "Rotate").toString();
65 font = settings.value("font").toString();
66 useOpenGLFlag = settings.value("useOpenGLFlag", false).toBool();
67 beSmooth = settings.value("beSmooth", true).toBool();
70 DialGadgetConfiguration::DialGadgetConfiguration(const DialGadgetConfiguration &obj) :
71 IUAVGadgetConfiguration(obj.classId(), obj.parent())
73 m_defaultDial = obj.m_defaultDial;
74 dialBackgroundID = obj.dialBackgroundID;
75 dialForegroundID = obj.dialForegroundID;
76 dialNeedleID1 = obj.dialNeedleID1;
77 dialNeedleID2 = obj.dialNeedleID2;
78 dialNeedleID3 = obj.dialNeedleID3;
79 needle1MinValue = obj.needle1MinValue;
80 needle1MaxValue = obj.needle1MaxValue;
81 needle2MinValue = obj.needle2MinValue;
82 needle2MaxValue = obj.needle2MaxValue;
83 needle3MinValue = obj.needle3MinValue;
84 needle3MaxValue = obj.needle3MaxValue;
85 needle1DataObject = obj.needle1DataObject;
86 needle1ObjectField = obj.needle1ObjectField;
87 needle2DataObject = obj.needle2DataObject;
88 needle2ObjectField = obj.needle2ObjectField;
89 needle3DataObject = obj.needle3DataObject;
90 needle3ObjectField = obj.needle3ObjectField;
91 needle1Factor = obj.needle1Factor;
92 needle2Factor = obj.needle2Factor;
93 needle3Factor = obj.needle3Factor;
94 needle1Move = obj.needle1Move;
95 needle2Move = obj.needle2Move;
96 needle3Move = obj.needle3Move;
97 font = obj.font;
98 useOpenGLFlag = obj.useOpenGLFlag;
99 beSmooth = obj.beSmooth;
103 * Clones a configuration.
106 IUAVGadgetConfiguration *DialGadgetConfiguration::clone() const
108 return new DialGadgetConfiguration(*this);
112 * Saves a configuration.
115 void DialGadgetConfiguration::saveConfig(QSettings &settings) const
117 QString dialFile = Utils::RemoveDataPath(m_defaultDial);
119 settings.setValue("dialFile", dialFile);
121 settings.setValue("dialBackgroundID", dialBackgroundID);
122 settings.setValue("dialForegroundID", dialForegroundID);
124 settings.setValue("dialNeedleID1", dialNeedleID1);
125 settings.setValue("dialNeedleID2", dialNeedleID2);
126 settings.setValue("dialNeedleID3", dialNeedleID3);
128 settings.setValue("needle1MinValue", QString::number(needle1MinValue));
129 settings.setValue("needle1MaxValue", QString::number(needle1MaxValue));
130 settings.setValue("needle2MinValue", QString::number(needle2MinValue));
131 settings.setValue("needle2MaxValue", QString::number(needle2MaxValue));
132 settings.setValue("needle3MinValue", QString::number(needle3MinValue));
133 settings.setValue("needle3MaxValue", QString::number(needle3MaxValue));
135 settings.setValue("needle1DataObject", needle1DataObject);
136 settings.setValue("needle1ObjectField", needle1ObjectField);
137 settings.setValue("needle2DataObject", needle2DataObject);
138 settings.setValue("needle2ObjectField", needle2ObjectField);
139 settings.setValue("needle3DataObject", needle3DataObject);
140 settings.setValue("needle3ObjectField", needle3ObjectField);
142 settings.setValue("needle1Factor", QString::number(needle1Factor));
143 settings.setValue("needle2Factor", QString::number(needle2Factor));
144 settings.setValue("needle3Factor", QString::number(needle3Factor));
146 settings.setValue("needle1Move", needle1Move);
147 settings.setValue("needle2Move", needle2Move);
148 settings.setValue("needle3Move", needle3Move);
150 settings.setValue("font", font);
152 settings.setValue("useOpenGLFlag", useOpenGLFlag);
153 settings.setValue("beSmooth", beSmooth);