2 ******************************************************************************
4 * @file scopegadget.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
8 * @addtogroup ScopePlugin Scope Gadget Plugin
10 * @brief The scope Gadget, graphically plots the states of UAVObjects
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 "scopegadget.h"
29 #include "scopegadgetconfiguration.h"
30 #include "scopegadgetwidget.h"
32 #include <QVBoxLayout>
35 ScopeGadget::ScopeGadget(QString classId
, ScopeGadgetWidget
*widget
, QWidget
*parent
) :
36 IUAVGadget(classId
, parent
), m_widget(widget
)
38 m_wrapper
= new QWidget();
39 QVBoxLayout
*layout
= new QVBoxLayout();
40 layout
->setContentsMargins(4, 4, 4, 4);
41 layout
->addWidget(m_widget
);
42 m_wrapper
->setLayout(layout
);
45 void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration
*config
)
47 ScopeGadgetConfiguration
*sgConfig
= qobject_cast
<ScopeGadgetConfiguration
*>(config
);
48 ScopeGadgetWidget
*widget
= qobject_cast
<ScopeGadgetWidget
*>(m_widget
);
50 widget
->setObjectName(config
->name());
51 widget
->setPlotDataSize(sgConfig
->dataSize());
52 widget
->setRefreshInterval(sgConfig
->refreshInterval());
54 if (sgConfig
->plotType() == SequentialPlot
) {
55 widget
->setupSequentialPlot();
56 } else if (sgConfig
->plotType() == ChronoPlot
) {
57 widget
->setupChronoPlot();
60 foreach(PlotCurveConfiguration
* plotCurveConfig
, sgConfig
->plotCurveConfigs()) {
61 QString uavObject
= plotCurveConfig
->uavObject
;
62 QString uavField
= plotCurveConfig
->uavField
;
63 int scale
= plotCurveConfig
->yScalePower
;
64 int mean
= plotCurveConfig
->yMeanSamples
;
65 QString mathFunction
= plotCurveConfig
->mathFunction
;
66 QRgb color
= plotCurveConfig
->color
;
67 bool antialiased
= plotCurveConfig
->drawAntialiased
;
75 QPen(QBrush(QColor(color
), Qt::SolidPattern
),
84 widget
->setLoggingEnabled(sgConfig
->getLoggingEnabled());
85 widget
->setLoggingNewFileOnConnect(sgConfig
->getLoggingNewFileOnConnect());
86 widget
->setLoggingPath(sgConfig
->getLoggingPath());
88 widget
->csvLoggingStop();
89 widget
->csvLoggingSetName(sgConfig
->name());
90 widget
->csvLoggingStart();
94 Scope gadget destructor: should delete the associated scope gadget widget too!
96 ScopeGadget::~ScopeGadget()
101 void ScopeGadget::saveState(QSettings
*qSettings
)
103 m_widget
->saveState(qSettings
);
106 void ScopeGadget::restoreState(QSettings
*qSettings
)
108 m_widget
->restoreState(qSettings
);