mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-42 GCS/Scope: Added QColorDialog color selection instead of fixed list of colors.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1023 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
9751e49d62
commit
15ed310cbd
@ -70,11 +70,6 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
||||
if(options_page->cmbUAVObjects->currentIndex() >= 0)
|
||||
on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText());
|
||||
|
||||
options_page->cmbColor->addItem("Black", QVariant(qRgb(0,0,0)));
|
||||
options_page->cmbColor->addItem("Red", QVariant(qRgb(255,0,0)));
|
||||
options_page->cmbColor->addItem("Green", QVariant(qRgb(0,255,0)));
|
||||
options_page->cmbColor->addItem("Blue", QVariant(qRgb(0,0,255)));
|
||||
|
||||
options_page->cmbScale->addItem("E-9", -9);
|
||||
options_page->cmbScale->addItem("E-6", -6);
|
||||
options_page->cmbScale->addItem("E-5",-5);
|
||||
@ -109,22 +104,34 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
||||
addPlotCurveConfig(uavObject,uavField,scale,varColor);
|
||||
}
|
||||
|
||||
if(m_config->plotCurveConfigs().count() > 0)
|
||||
options_page->lstCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||
|
||||
connect(options_page->btnAddCurve, SIGNAL(clicked()), this, SLOT(on_btnAddCurve_clicked()));
|
||||
connect(options_page->btnRemoveCurve, SIGNAL(clicked()), this, SLOT(on_btnRemoveCurve_clicked()));
|
||||
connect(options_page->lstCurves, SIGNAL(currentRowChanged(int)), this, SLOT(on_lstCurves_currentRowChanged(int)));
|
||||
connect(options_page->btnColor, SIGNAL(clicked()), this, SLOT(on_btnColor_clicked()));
|
||||
|
||||
setYAxisWidgetFromPlotCurve();
|
||||
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
void ScopeGadgetOptionsPage::on_btnColor_clicked()
|
||||
{
|
||||
QColor color = QColorDialog::getColor( QColor(options_page->btnColor->text()), options_page->widget);
|
||||
if (color.isValid()) {
|
||||
setButtonColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Populate the widgets that containts the configs for the Y-Axis from
|
||||
the selected plot curve
|
||||
*/
|
||||
void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
||||
{
|
||||
bool parseOK = false;
|
||||
QListWidgetItem* listItem = options_page->lstCurves->currentItem();
|
||||
|
||||
if(listItem == 0)
|
||||
@ -139,8 +146,17 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
||||
currentIndex = options_page->cmbScale->findData( listItem->data(Qt::UserRole + 2), Qt::UserRole, Qt::MatchExactly);
|
||||
options_page->cmbScale->setCurrentIndex(currentIndex);
|
||||
|
||||
currentIndex = options_page->cmbColor->findData( listItem->data(Qt::UserRole + 3), Qt::UserRole, Qt::MatchExactly);
|
||||
options_page->cmbColor->setCurrentIndex(currentIndex);
|
||||
QVariant varColor = listItem->data(Qt::UserRole + 3);
|
||||
int rgb = varColor.toInt(&parseOK);
|
||||
|
||||
setButtonColor(QColor((QRgb)rgb));
|
||||
}
|
||||
|
||||
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
||||
{
|
||||
options_page->btnColor->setText(color.name());
|
||||
options_page->btnColor->setPalette(QPalette(color));
|
||||
options_page->btnColor->setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -168,7 +184,6 @@ void ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged(QString val)
|
||||
*/
|
||||
void ScopeGadgetOptionsPage::apply()
|
||||
{
|
||||
|
||||
bool parseOK = false;
|
||||
|
||||
//Apply configuration changes
|
||||
@ -216,7 +231,7 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
||||
//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 = options_page->cmbColor->itemData(options_page->cmbColor->currentIndex());
|
||||
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
|
||||
|
||||
addPlotCurveConfig(uavObject,uavField,scale,varColor);
|
||||
|
||||
@ -233,7 +248,8 @@ void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavFi
|
||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
||||
|
||||
//Set the properties of the newly added list item
|
||||
QColor color = QColor( (QRgb)varColor.toInt(&parseOK) );
|
||||
QRgb rgbColor = (QRgb)varColor.toInt(&parseOK);
|
||||
QColor color = QColor( rgbColor );
|
||||
listWidgetItem->setText(listItemDisplayText);
|
||||
listWidgetItem->setTextColor( color );
|
||||
|
||||
|
@ -29,9 +29,11 @@
|
||||
#define SCOPEGADGETOPTIONSPAGE_H
|
||||
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
#include <QtGui/QColorDialog>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
@ -63,14 +65,15 @@ private:
|
||||
|
||||
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor);
|
||||
void setYAxisWidgetFromPlotCurve();
|
||||
|
||||
void setButtonColor(const QColor &color);
|
||||
|
||||
|
||||
private slots:
|
||||
void on_lstCurves_currentRowChanged(int currentRow);
|
||||
void on_btnRemoveCurve_clicked();
|
||||
void on_btnAddCurve_clicked();
|
||||
void on_cmbUAVObjects_currentIndexChanged(QString val);
|
||||
void on_cmbUAVObjects_currentIndexChanged(QString val);
|
||||
void on_btnColor_clicked();
|
||||
};
|
||||
|
||||
#endif // SCOPEGADGETOPTIONSPAGE_H
|
||||
#endif // SCOPEGADGETOPTIONSPAGE_H
|
||||
|
@ -18,88 +18,17 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>531</width>
|
||||
<height>361</height>
|
||||
<width>591</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="formLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>20</y>
|
||||
<width>251</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cmbPlotType"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Plot Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spnDataSize">
|
||||
<property name="suffix">
|
||||
<string> seconds</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>300</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Data Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spnRefreshInterval">
|
||||
<property name="suffix">
|
||||
<string> seconds</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Data Timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>160</y>
|
||||
<width>481</width>
|
||||
<height>102</height>
|
||||
<y>0</y>
|
||||
<width>551</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
@ -108,44 +37,135 @@
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X-Axis</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Plot Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cmbPlotType"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Data Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spnDataSize">
|
||||
<property name="suffix">
|
||||
<string> seconds</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>300</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Data Timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spnRefreshInterval">
|
||||
<property name="suffix">
|
||||
<string> seconds</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Plot curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>UAVObject:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="cmbUAVObjects"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cmbColor"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>UAVField:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="cmbUAVField"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="btnColor">
|
||||
<property name="text">
|
||||
<string>Choose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QComboBox" name="cmbScale">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
@ -159,6 +179,19 @@
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAddCurve">
|
||||
<property name="text">
|
||||
@ -173,10 +206,39 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="lstCurves">
|
||||
<property name="selectionBehavior">
|
||||
@ -191,46 +253,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>140</y>
|
||||
<width>81</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Plot curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>62</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Bitstream Charter</family>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X-Axis</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -297,4 +297,4 @@ TestDataGen::~TestDataGen()
|
||||
timer->stop();
|
||||
|
||||
delete timer;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user