mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14: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:
parent
7a1353506e
commit
617de242c4
@ -26,14 +26,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scopegadgetoptionspage.h"
|
#include "scopegadgetoptionspage.h"
|
||||||
#include "scopegadgetconfiguration.h"
|
|
||||||
#include "ui_scopegadgetoptionspage.h"
|
|
||||||
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjects/uavobjectmanager.h"
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
#include "uavobjects/uavdataobject.h"
|
#include "uavobjects/uavdataobject.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <QtGui/qpalette.h>
|
||||||
|
|
||||||
|
|
||||||
ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) :
|
ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
@ -154,9 +154,9 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
|||||||
|
|
||||||
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
options_page->btnColor->setAutoFillBackground(true);
|
||||||
options_page->btnColor->setText(color.name());
|
options_page->btnColor->setText(color.name());
|
||||||
options_page->btnColor->setPalette(QPalette(color));
|
options_page->btnColor->setPalette(QPalette(color));
|
||||||
options_page->btnColor->setAutoFillBackground(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -228,14 +228,21 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
|||||||
if(!parseOK)
|
if(!parseOK)
|
||||||
scale = 0;
|
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();
|
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)
|
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);
|
options_page->lstCurves->addItem(listItemDisplayText);
|
||||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
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
|
//Set the properties of the newly added list item
|
||||||
|
QString listItemDisplayText = uavObject + "." + uavField;
|
||||||
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
|
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
|
||||||
QColor color = QColor( rgbColor );
|
QColor color = QColor( rgbColor );
|
||||||
listWidgetItem->setText(listItemDisplayText);
|
//listWidgetItem->setText(listItemDisplayText);
|
||||||
listWidgetItem->setTextColor( color );
|
listWidgetItem->setTextColor( color );
|
||||||
|
|
||||||
//Store some additional data for the plot curve on the list item
|
//Store some additional data for the plot curve on the list item
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
#include "coreplugin/dialogs/ioptionspage.h"
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
|
|
||||||
|
#include "scopegadgetconfiguration.h"
|
||||||
|
#include "ui_scopegadgetoptionspage.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -64,6 +67,7 @@ private:
|
|||||||
ScopeGadgetConfiguration *m_config;
|
ScopeGadgetConfiguration *m_config;
|
||||||
|
|
||||||
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor);
|
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 setYAxisWidgetFromPlotCurve();
|
||||||
void setButtonColor(const QColor &color);
|
void setButtonColor(const QColor &color);
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>601</width>
|
<width>611</width>
|
||||||
<height>341</height>
|
<height>241</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>461</width>
|
<width>601</width>
|
||||||
<height>231</height>
|
<height>231</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -190,22 +190,30 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>80</height>
|
<height>100</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnAddCurve">
|
<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">
|
<property name="text">
|
||||||
<string>>></string>
|
<string>Add
|
||||||
|
Update</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnRemoveCurve">
|
<widget class="QPushButton" name="btnRemoveCurve">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove the curve from the scope.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><<</string>
|
<string>Remove
|
||||||
|
</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -220,7 +228,7 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>30</height>
|
<height>15</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -50,8 +50,8 @@ TestDataGen* ScopeGadgetWidget::testDataGen;
|
|||||||
|
|
||||||
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
|
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
|
||||||
{
|
{
|
||||||
// if(testDataGen == 0)
|
if(testDataGen == 0)
|
||||||
// testDataGen = new TestDataGen();
|
testDataGen = new TestDataGen();
|
||||||
|
|
||||||
//Setup the timer that replots data
|
//Setup the timer that replots data
|
||||||
replotTimer = new QTimer(this);
|
replotTimer = new QTimer(this);
|
||||||
@ -161,14 +161,18 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int sc
|
|||||||
setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum);
|
setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum);
|
||||||
|
|
||||||
//Create the curve
|
//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);
|
QwtPlotCurve* plotCurve = new QwtPlotCurve(curveName);
|
||||||
plotCurve->setPen(pen);
|
plotCurve->setPen(pen);
|
||||||
plotCurve->setData(*plotData->xData, *plotData->yData);
|
plotCurve->setData(*plotData->xData, *plotData->yData);
|
||||||
plotCurve->attach(this);
|
plotCurve->attach(this);
|
||||||
plotData->curve = plotCurve;
|
plotData->curve = plotCurve;
|
||||||
|
|
||||||
|
|
||||||
//Keep the curve details for later
|
//Keep the curve details for later
|
||||||
m_curvesData.insert(curveName, plotData);
|
m_curvesData.insert(curveName, plotData);
|
||||||
|
|
||||||
@ -331,7 +335,7 @@ void TestDataGen::genTestData()
|
|||||||
BaroAltitude::DataFields baroAltitudeData;
|
BaroAltitude::DataFields baroAltitudeData;
|
||||||
baroAltitudeData.Altitude = 500 * sin(1 * testTime) + 200 * cos(4 * testTime) + 800;
|
baroAltitudeData.Altitude = 500 * sin(1 * testTime) + 200 * cos(4 * testTime) + 800;
|
||||||
baroAltitudeData.Temperature = 30 * sin(0.5 * testTime);
|
baroAltitudeData.Temperature = 30 * sin(0.5 * testTime);
|
||||||
baroAltitudeData.Pressure = 100;
|
baroAltitudeData.Pressure = baroAltitudeData.Altitude * 0.01 + baroAltitudeData.Temperature;
|
||||||
baroAltitude->setData(baroAltitudeData);
|
baroAltitude->setData(baroAltitudeData);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user