1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-42 GCS/Scope: Changed options panel behaviour. An existing curve can now be updated, and does not need to be duplicated and removed anymore

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1461 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
banigreyling 2010-08-29 22:45:12 +00:00 committed by banigreyling
parent 7a1353506e
commit 617de242c4
4 changed files with 52 additions and 20 deletions

View File

@ -26,14 +26,14 @@
*/
#include "scopegadgetoptionspage.h"
#include "scopegadgetconfiguration.h"
#include "ui_scopegadgetoptionspage.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavdataobject.h"
#include <QtGui/qpalette.h>
ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
@ -154,9 +154,9 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
{
options_page->btnColor->setAutoFillBackground(true);
options_page->btnColor->setText(color.name());
options_page->btnColor->setPalette(QPalette(color));
options_page->btnColor->setAutoFillBackground(true);
}
/*!
@ -228,14 +228,21 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
if(!parseOK)
scale = 0;
//TODO: Find an existing plot curve config based on the uavobject and uav field. If it
//exists, update it, else add a new one.
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
addPlotCurveConfig(uavObject,uavField,scale,varColor);
//TODO: Find an existing plot curve config based on the uavobject and uav field. If it
//exists, update it, else add a new one.
if(options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField)
{
QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem();
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,varColor);
}else
{
addPlotCurveConfig(uavObject,uavField,scale,varColor);
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
}
}
void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor)
@ -247,10 +254,19 @@ void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavFi
options_page->lstCurves->addItem(listItemDisplayText);
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,varColor);
}
void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, QVariant varColor)
{
bool parseOK = false;
//Set the properties of the newly added list item
QString listItemDisplayText = uavObject + "." + uavField;
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
QColor color = QColor( rgbColor );
listWidgetItem->setText(listItemDisplayText);
//listWidgetItem->setText(listItemDisplayText);
listWidgetItem->setTextColor( color );
//Store some additional data for the plot curve on the list item

View File

@ -30,6 +30,9 @@
#include "coreplugin/dialogs/ioptionspage.h"
#include "scopegadgetconfiguration.h"
#include "ui_scopegadgetoptionspage.h"
#include <QString>
#include <QStringList>
#include <QDebug>
@ -64,6 +67,7 @@ private:
ScopeGadgetConfiguration *m_config;
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor);
void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, QVariant varColor);
void setYAxisWidgetFromPlotCurve();
void setButtonColor(const QColor &color);

View File

@ -18,8 +18,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>341</height>
<width>611</width>
<height>241</height>
</rect>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
@ -27,7 +27,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>461</width>
<width>601</width>
<height>231</height>
</rect>
</property>
@ -190,22 +190,30 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>80</height>
<height>100</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnAddCurve">
<property name="toolTip">
<string>Add a new curve to the scope, or update it if the UAVObject and UAVField is the same.</string>
</property>
<property name="text">
<string>&gt;&gt;</string>
<string>Add
Update</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemoveCurve">
<property name="toolTip">
<string>Remove the curve from the scope.</string>
</property>
<property name="text">
<string>&lt;&lt;</string>
<string>Remove
</string>
</property>
</widget>
</item>
@ -220,7 +228,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
<height>15</height>
</size>
</property>
</spacer>

View File

@ -50,8 +50,8 @@ TestDataGen* ScopeGadgetWidget::testDataGen;
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
{
// if(testDataGen == 0)
// testDataGen = new TestDataGen();
if(testDataGen == 0)
testDataGen = new TestDataGen();
//Setup the timer that replots data
replotTimer = new QTimer(this);
@ -161,14 +161,18 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc
setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum);
//Create the curve
QString curveName = (plotData->uavObject) + "." + (plotData->uavField);
QString curveName;
if(scaleOrderFactor == 0)
curveName = (plotData->uavObject) + "." + (plotData->uavField);
else
curveName = (plotData->uavObject) + "." + (plotData->uavField) + "(E" + QString::number(scaleOrderFactor) + ")";
QwtPlotCurve* plotCurve = new QwtPlotCurve(curveName);
plotCurve->setPen(pen);
plotCurve->setData(*plotData->xData, *plotData->yData);
plotCurve->attach(this);
plotData->curve = plotCurve;
//Keep the curve details for later
m_curvesData.insert(curveName, plotData);
@ -331,7 +335,7 @@ void TestDataGen::genTestData()
BaroAltitude::DataFields baroAltitudeData;
baroAltitudeData.Altitude = 500 * sin(1 * testTime) + 200 * cos(4 * testTime) + 800;
baroAltitudeData.Temperature = 30 * sin(0.5 * testTime);
baroAltitudeData.Pressure = 100;
baroAltitudeData.Pressure = baroAltitudeData.Altitude * 0.01 + baroAltitudeData.Temperature;
baroAltitude->setData(baroAltitudeData);