|
|
|
@ -16,8 +16,22 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
@@ -16,8 +16,22 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
|
|
|
|
|
ui(new Ui::QGCParamSlider) |
|
|
|
|
{ |
|
|
|
|
ui->setupUi(this); |
|
|
|
|
endEditMode(); |
|
|
|
|
connect(ui->doneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); |
|
|
|
|
|
|
|
|
|
scaledInt = ui->valueSlider->maximum() - ui->valueSlider->minimum(); |
|
|
|
|
|
|
|
|
|
ui->editDoneButton->show(); |
|
|
|
|
ui->editMaxLabel->show(); |
|
|
|
|
ui->editMinLabel->show(); |
|
|
|
|
ui->editNameLineEdit->show(); |
|
|
|
|
ui->editInstructionsLabel->show(); |
|
|
|
|
ui->editRefreshParamsButton->show(); |
|
|
|
|
ui->editSelectParamComboBox->show(); |
|
|
|
|
ui->editSelectComponentComboBox->show(); |
|
|
|
|
ui->editStatusLabel->show(); |
|
|
|
|
ui->editMinSpinBox->show(); |
|
|
|
|
ui->editMaxSpinBox->show(); |
|
|
|
|
ui->editTypeComboBox->show(); |
|
|
|
|
connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QGCParamSlider::~QGCParamSlider() |
|
|
|
@ -27,31 +41,34 @@ QGCParamSlider::~QGCParamSlider()
@@ -27,31 +41,34 @@ QGCParamSlider::~QGCParamSlider()
|
|
|
|
|
|
|
|
|
|
void QGCParamSlider::startEditMode() |
|
|
|
|
{ |
|
|
|
|
ui->doneButton->show(); |
|
|
|
|
ui->maxLabel->show(); |
|
|
|
|
ui->minLabel->show(); |
|
|
|
|
ui->nameLineEdit->show(); |
|
|
|
|
ui->instructionsLabel->show(); |
|
|
|
|
ui->refreshParamsButton->show(); |
|
|
|
|
ui->selectParamComboBox->show(); |
|
|
|
|
ui->minSpinBox->show(); |
|
|
|
|
ui->maxSpinBox->show(); |
|
|
|
|
ui->typeComboBox->show(); |
|
|
|
|
ui->editDoneButton->show(); |
|
|
|
|
ui->editMaxLabel->show(); |
|
|
|
|
ui->editMinLabel->show(); |
|
|
|
|
ui->editNameLineEdit->show(); |
|
|
|
|
ui->editInstructionsLabel->show(); |
|
|
|
|
ui->editRefreshParamsButton->show(); |
|
|
|
|
ui->editSelectParamComboBox->show(); |
|
|
|
|
ui->editSelectComponentComboBox->show(); |
|
|
|
|
ui->editStatusLabel->show(); |
|
|
|
|
ui->editMinSpinBox->show(); |
|
|
|
|
ui->editMaxSpinBox->show(); |
|
|
|
|
isInEditMode = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::endEditMode() |
|
|
|
|
{ |
|
|
|
|
ui->doneButton->hide(); |
|
|
|
|
ui->maxLabel->hide(); |
|
|
|
|
ui->minLabel->hide(); |
|
|
|
|
ui->nameLineEdit->hide(); |
|
|
|
|
ui->instructionsLabel->hide(); |
|
|
|
|
ui->refreshParamsButton->hide(); |
|
|
|
|
ui->selectParamComboBox->hide(); |
|
|
|
|
ui->minSpinBox->hide(); |
|
|
|
|
ui->maxSpinBox->hide(); |
|
|
|
|
ui->typeComboBox->hide(); |
|
|
|
|
ui->editDoneButton->hide(); |
|
|
|
|
ui->editMaxLabel->hide(); |
|
|
|
|
ui->editMinLabel->hide(); |
|
|
|
|
ui->editNameLineEdit->hide(); |
|
|
|
|
ui->editInstructionsLabel->hide(); |
|
|
|
|
ui->editRefreshParamsButton->hide(); |
|
|
|
|
ui->editSelectParamComboBox->hide(); |
|
|
|
|
ui->editSelectComponentComboBox->hide(); |
|
|
|
|
ui->editStatusLabel->hide(); |
|
|
|
|
ui->editMinSpinBox->hide(); |
|
|
|
|
ui->editMaxSpinBox->hide(); |
|
|
|
|
ui->editTypeComboBox->hide(); |
|
|
|
|
isInEditMode = false; |
|
|
|
|
emit editingFinished(); |
|
|
|
|
} |
|
|
|
@ -68,6 +85,21 @@ void QGCParamSlider::sendParameter()
@@ -68,6 +85,21 @@ void QGCParamSlider::sendParameter()
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::setSliderValue(int sliderValue) |
|
|
|
|
{ |
|
|
|
|
parameterValue = scaledIntToFloat(sliderValue); |
|
|
|
|
QString unit(""); |
|
|
|
|
ui->valueLabel->setText(QString("%1 %2").arg(parameterValue, 0, 'f', 3).arg(unit)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::setParameterValue(int uas, int component, QString parameterName, float value) |
|
|
|
|
{ |
|
|
|
|
parameterValue = value; |
|
|
|
|
QString unit(""); |
|
|
|
|
ui->valueLabel->setText(QString("%1 %2").arg(value, 0, 'f', 3).arg(unit)); |
|
|
|
|
ui->valueSlider->setValue(floatToScaledInt(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::changeEvent(QEvent *e) |
|
|
|
|
{ |
|
|
|
|
QWidget::changeEvent(e); |
|
|
|
@ -80,12 +112,35 @@ void QGCParamSlider::changeEvent(QEvent *e)
@@ -80,12 +112,35 @@ void QGCParamSlider::changeEvent(QEvent *e)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::writeSettings(QSettings& settings) |
|
|
|
|
float QGCParamSlider::scaledIntToFloat(int sliderValue) |
|
|
|
|
{ |
|
|
|
|
return (((double)sliderValue)/scaledInt)*(parameterMax - parameterMin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int QGCParamSlider::floatToScaledInt(float value) |
|
|
|
|
{ |
|
|
|
|
return ((value - parameterMin)/(parameterMax - parameterMin))*scaledInt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::readSettings(const QSettings& settings) |
|
|
|
|
void QGCParamSlider::writeSettings(QSettings& settings) |
|
|
|
|
{ |
|
|
|
|
settings.setValue("TYPE", "SLIDER"); |
|
|
|
|
settings.setValue("QGC_PARAM_SLIDER_DESCRIPTION", ui->nameLabel->text()); |
|
|
|
|
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
|
|
|
|
|
settings.setValue("QGC_PARAM_SLIDER_PARAMID", ui->editSelectParamComboBox->currentText()); |
|
|
|
|
settings.setValue("QGC_PARAM_SLIDER_COMPONENTID", ui->editSelectComponentComboBox->currentText()); |
|
|
|
|
settings.setValue("QGC_PARAM_SLIDER_MIN", ui->editMinSpinBox->value()); |
|
|
|
|
settings.setValue("QGC_PARAM_SLIDER_MAX", ui->editMaxSpinBox->value()); |
|
|
|
|
settings.sync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCParamSlider::readSettings(const QSettings& settings) |
|
|
|
|
{ |
|
|
|
|
ui->nameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString()); |
|
|
|
|
//settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text());
|
|
|
|
|
ui->editSelectParamComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); |
|
|
|
|
ui->editSelectComponentsComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); |
|
|
|
|
ui->editMinSpinBox(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); |
|
|
|
|
ui->editMaxSpinBox(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); |
|
|
|
|
qDebug() << "DONE READING SETTINGS"; |
|
|
|
|
} |
|
|
|
|