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
9 * @addtogroup DialPlugin Dial Plugin
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
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"
33 * Loads a saved configuration or defaults if non exist.
36 DialGadgetConfiguration::DialGadgetConfiguration(QString classId
, QSettings
*qSettings
, QObject
*parent
) :
37 IUAVGadgetConfiguration(classId
, parent
),
38 m_defaultDial("Unknown"),
39 dialBackgroundID("background"),
40 dialForegroundID("foreground"),
41 dialNeedleID1("needle"),
42 dialNeedleID2("needle2"),
43 dialNeedleID3("needle3"),
53 needle1Move("Rotate"),
54 needle2Move("Rotate"),
55 needle3Move("Rotate"),
59 // if a saved configuration exists load it
61 QString dialFile
= qSettings
->value("dialFile").toString();
63 m_defaultDial
= Utils::PathUtils().InsertDataPath(dialFile
);
64 dialBackgroundID
= qSettings
->value("dialBackgroundID").toString();
65 dialForegroundID
= qSettings
->value("dialForegroundID").toString();
66 dialNeedleID1
= qSettings
->value("dialNeedleID1").toString();
67 dialNeedleID2
= qSettings
->value("dialNeedleID2").toString();
68 dialNeedleID3
= qSettings
->value("dialNeedleID3").toString();
69 needle1MinValue
= qSettings
->value("needle1MinValue").toDouble();
70 needle1MaxValue
= qSettings
->value("needle1MaxValue").toDouble();
71 needle2MinValue
= qSettings
->value("needle2MinValue").toDouble();
72 needle2MaxValue
= qSettings
->value("needle2MaxValue").toDouble();
73 needle3MinValue
= qSettings
->value("needle3MinValue").toDouble();
74 needle3MaxValue
= qSettings
->value("needle3MaxValue").toDouble();
75 needle1DataObject
= qSettings
->value("needle1DataObject").toString();
76 needle1ObjectField
= qSettings
->value("needle1ObjectField").toString();
77 needle2DataObject
= qSettings
->value("needle2DataObject").toString();
78 needle2ObjectField
= qSettings
->value("needle2ObjectField").toString();
79 needle3DataObject
= qSettings
->value("needle3DataObject").toString();
80 needle3ObjectField
= qSettings
->value("needle3ObjectField").toString();
81 needle1Factor
= qSettings
->value("needle1Factor").toDouble();
82 needle2Factor
= qSettings
->value("needle2Factor").toDouble();
83 needle3Factor
= qSettings
->value("needle3Factor").toDouble();
84 needle1Move
= qSettings
->value("needle1Move").toString();
85 needle2Move
= qSettings
->value("needle2Move").toString();
86 needle3Move
= qSettings
->value("needle3Move").toString();
87 font
= qSettings
->value("font").toString();
88 useOpenGLFlag
= qSettings
->value("useOpenGLFlag").toBool();
89 beSmooth
= qSettings
->value("beSmooth").toBool();
94 * Clones a configuration.
97 IUAVGadgetConfiguration
*DialGadgetConfiguration::clone()
99 DialGadgetConfiguration
*m
= new DialGadgetConfiguration(this->classId());
101 m
->m_defaultDial
= m_defaultDial
;
102 m
->setDialBackgroundID(dialBackgroundID
);
103 m
->setDialForegroundID(dialForegroundID
);
104 m
->setDialNeedleID1(dialNeedleID1
);
105 m
->setDialNeedleID2(dialNeedleID2
);
106 m
->setDialNeedleID3(dialNeedleID3
);
107 m
->setN1Min(needle1MinValue
);
108 m
->setN1Max(needle1MaxValue
);
109 m
->setN2Min(needle2MinValue
);
110 m
->setN2Max(needle2MaxValue
);
111 m
->setN3Min(needle3MinValue
);
112 m
->setN3Max(needle3MaxValue
);
113 m
->setN1DataObject(needle1DataObject
);
114 m
->setN1ObjField(needle1ObjectField
);
115 m
->setN2DataObject(needle2DataObject
);
116 m
->setN2ObjField(needle2ObjectField
);
117 m
->setN3DataObject(needle3DataObject
);
118 m
->setN3ObjField(needle3ObjectField
);
119 m
->setN1Factor(needle1Factor
);
120 m
->setN2Factor(needle2Factor
);
121 m
->setN3Factor(needle3Factor
);
122 m
->setN1Move(needle1Move
);
123 m
->setN2Move(needle2Move
);
124 m
->setN3Move(needle3Move
);
126 m
->useOpenGLFlag
= useOpenGLFlag
;
127 m
->beSmooth
= beSmooth
;
133 * Saves a configuration.
136 void DialGadgetConfiguration::saveConfig(QSettings
*settings
) const
138 QString dialFile
= Utils::PathUtils().RemoveDataPath(m_defaultDial
);
140 settings
->setValue("dialFile", dialFile
);
142 settings
->setValue("dialBackgroundID", dialBackgroundID
);
143 settings
->setValue("dialForegroundID", dialForegroundID
);
145 settings
->setValue("dialNeedleID1", dialNeedleID1
);
146 settings
->setValue("dialNeedleID2", dialNeedleID2
);
147 settings
->setValue("dialNeedleID3", dialNeedleID3
);
149 settings
->setValue("needle1MinValue", needle1MinValue
);
150 settings
->setValue("needle1MaxValue", needle1MaxValue
);
151 settings
->setValue("needle2MinValue", needle2MinValue
);
152 settings
->setValue("needle2MaxValue", needle2MaxValue
);
153 settings
->setValue("needle3MinValue", needle3MinValue
);
154 settings
->setValue("needle3MaxValue", needle3MaxValue
);
156 settings
->setValue("needle1DataObject", needle1DataObject
);
157 settings
->setValue("needle1ObjectField", needle1ObjectField
);
158 settings
->setValue("needle2DataObject", needle2DataObject
);
159 settings
->setValue("needle2ObjectField", needle2ObjectField
);
160 settings
->setValue("needle3DataObject", needle3DataObject
);
161 settings
->setValue("needle3ObjectField", needle3ObjectField
);
163 settings
->setValue("needle1Factor", needle1Factor
);
164 settings
->setValue("needle2Factor", needle2Factor
);
165 settings
->setValue("needle3Factor", needle3Factor
);
167 settings
->setValue("needle1Move", needle1Move
);
168 settings
->setValue("needle2Move", needle2Move
);
169 settings
->setValue("needle3Move", needle3Move
);
171 settings
->setValue("font", font
);
173 settings
->setValue("useOpenGLFlag", useOpenGLFlag
);
174 settings
->setValue("beSmooth", beSmooth
);