Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / lineardial / lineardialgadgetconfiguration.cpp
blobe38404c9d79eedd8e2c1c74eb5786a7f0f7f6332
1 /**
2 ******************************************************************************
4 * @file lineardialgadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup LinearDialPlugin Linear Dial Plugin
9 * @{
10 * @brief Implements a gadget that displays linear gauges
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
21 * for more details.
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 "lineardialgadgetconfiguration.h"
29 #include "utils/pathutils.h"
31 /**
32 * Loads a saved configuration or defaults if non exist.
35 LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
36 IUAVGadgetConfiguration(classId, parent)
38 QString dFile = settings.value("dFile").toString();
40 dialFile = Utils::InsertDataPath(dFile);
41 sourceDataObject = settings.value("sourceDataObject", "Unknown").toString();
42 sourceObjectField = settings.value("sourceObjectField", "Unknown").toString();
43 minValue = settings.value("minValue", 0).toDouble();
44 maxValue = settings.value("maxValue", 100).toDouble();
45 redMin = settings.value("redMin", 0).toDouble();
46 redMax = settings.value("redMax", 33).toDouble();
47 yellowMin = settings.value("yellowMin", 33).toDouble();
48 yellowMax = settings.value("yellowMax", 66).toDouble();
49 greenMin = settings.value("greenMin", 66).toDouble();
50 greenMax = settings.value("greenMax", 100).toDouble();
51 font = settings.value("font").toString();
52 decimalPlaces = settings.value("decimalPlaces", 0).toInt();
53 factor = settings.value("factor", 1.0).toDouble();
54 useOpenGLFlag = settings.value("useOpenGLFlag").toBool();
57 LineardialGadgetConfiguration::LineardialGadgetConfiguration(const LineardialGadgetConfiguration &obj) :
58 IUAVGadgetConfiguration(obj.classId(), obj.parent())
60 dialFile = obj.dialFile;
61 sourceDataObject = obj.sourceDataObject;
62 sourceObjectField = obj.sourceObjectField;
63 minValue = obj.minValue;
64 maxValue = obj.maxValue;
65 redMin = obj.redMin;
66 redMax = obj.redMax;
67 yellowMin = obj.yellowMin;
68 yellowMax = obj.yellowMax;
69 greenMin = obj.greenMin;
70 greenMax = obj.greenMax;
71 font = obj.font;
72 decimalPlaces = obj.decimalPlaces;
73 factor = obj.factor;
74 useOpenGLFlag = obj.useOpenGLFlag;
77 /**
78 * Clones a configuration.
81 IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone() const
83 return new LineardialGadgetConfiguration(*this);
86 /**
87 * Saves a configuration.
90 void LineardialGadgetConfiguration::saveConfig(QSettings &settings) const
92 QString dFile = Utils::RemoveDataPath(dialFile);
94 settings.setValue("dFile", dFile);
95 settings.setValue("sourceDataObject", sourceDataObject);
96 settings.setValue("sourceObjectField", sourceObjectField);
97 settings.setValue("minValue", minValue);
98 settings.setValue("maxValue", maxValue);
99 settings.setValue("redMin", redMin);
100 settings.setValue("redMax", redMax);
101 settings.setValue("yellowMin", yellowMin);
102 settings.setValue("yellowMax", yellowMax);
103 settings.setValue("greenMin", greenMin);
104 settings.setValue("greenMax", greenMax);
105 settings.setValue("font", font);
106 settings.setValue("decimalPlaces", decimalPlaces);
107 settings.setValue("factor", factor);
108 settings.setValue("useOpenGLFlag", useOpenGLFlag);