From 0c217eea58ec9d72a17ec6c2e0c0f75e776964cb Mon Sep 17 00:00:00 2001 From: pandx Date: Fri, 28 Mar 2025 11:29:30 +0800 Subject: [PATCH] add callback for velocity. --- velocity.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++ velocity.h | 2 ++ velocity.ui | 72 +++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 131 insertions(+), 3 deletions(-) diff --git a/velocity.cpp b/velocity.cpp index 437dd0f..92be270 100644 --- a/velocity.cpp +++ b/velocity.cpp @@ -28,12 +28,72 @@ Velocity::Velocity(int slot_no_, int channel_, bool active, QWidget *parent) Init(); connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Velocity::on_1x_ampl_toggled); connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Velocity::on_2x_ampl_toggled); + connect(ui->checkBox_rms, &QCheckBox::toggled, this, &Velocity::on_rms_toggled); + connect(ui->checkBox_integrate, &QCheckBox::toggled, this, &Velocity::on_integrate_toggled); } Velocity::~Velocity() { delete ui; } +void Velocity::on_rms_toggled(bool checked) { + // TODO: 自定义的回调 + if (checked) { + ui->checkBox_integrate->setEnabled(false); + QStringList items = {"0-10 mm/s rms", "0-20 mm/s rms", "0-50 mm/s rms", "自定义"}; + ui->comboBox_direct_value_range->clear(); + ui->comboBox_direct_value_range->addItems(items); + ui->comboBox_direct_value_range->setCurrentIndex(1); + ui->comboBox_1x_value_range->clear(); + ui->comboBox_1x_value_range->addItems(items); + ui->comboBox_1x_value_range->setCurrentIndex(1); + ui->comboBox_2x_value_range->clear(); + ui->comboBox_2x_value_range->addItems(items); + ui->comboBox_2x_value_range->setCurrentIndex(1); + return; + } + ui->checkBox_integrate->setEnabled(true); + ui->comboBox_direct_value_range->clear(); + QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"}; + ui->comboBox_direct_value_range->addItems(items); + ui->comboBox_direct_value_range->setCurrentIndex(1); + ui->comboBox_1x_value_range->clear(); + ui->comboBox_1x_value_range->addItems(items); + ui->comboBox_1x_value_range->setCurrentIndex(1); + ui->comboBox_2x_value_range->clear(); + ui->comboBox_2x_value_range->addItems(items); + ui->comboBox_2x_value_range->setCurrentIndex(1); +} + +void Velocity::on_integrate_toggled(bool checked) { + // TODO: 自定义的回调 + if (checked) { + ui->checkBox_rms->setEnabled(false); + ui->comboBox_direct_value_range->clear(); + QStringList items = {"0-100 um pp", "0-200 um pp", "0-500 um pp", "自定义"}; + ui->comboBox_direct_value_range->addItems(items); + ui->comboBox_direct_value_range->setCurrentIndex(1); + ui->comboBox_1x_value_range->clear(); + ui->comboBox_1x_value_range->addItems(items); + ui->comboBox_1x_value_range->setCurrentIndex(1); + ui->comboBox_2x_value_range->clear(); + ui->comboBox_2x_value_range->addItems(items); + ui->comboBox_2x_value_range->setCurrentIndex(1); + return; + } + ui->checkBox_rms->setEnabled(true); + ui->comboBox_direct_value_range->clear(); + QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"}; + ui->comboBox_direct_value_range->addItems(items); + ui->comboBox_direct_value_range->setCurrentIndex(1); + ui->comboBox_1x_value_range->clear(); + ui->comboBox_1x_value_range->addItems(items); + ui->comboBox_1x_value_range->setCurrentIndex(1); + ui->comboBox_2x_value_range->clear(); + ui->comboBox_2x_value_range->addItems(items); + ui->comboBox_2x_value_range->setCurrentIndex(1); +} + void Velocity::on_pushButton_cancel_clicked() { this->close(); } diff --git a/velocity.h b/velocity.h index 333c14b..1cee422 100644 --- a/velocity.h +++ b/velocity.h @@ -22,6 +22,8 @@ class Velocity : public QWidget { void on_pushButton_cancel_clicked(); void on_1x_ampl_toggled(bool checked); void on_2x_ampl_toggled(bool checked); + void on_rms_toggled(bool checked); + void on_integrate_toggled(bool checked); private: Ui::Velocity *ui; diff --git a/velocity.ui b/velocity.ui index 4252d0c..bc2d851 100644 --- a/velocity.ui +++ b/velocity.ui @@ -376,9 +376,30 @@ 22 + + 0-20 mm/s pk + + + 1 + - 0 - 20 mm/s + 0-10 mm/s pk + + + + + 0-20 mm/s pk + + + + + 0-50 mm/s pk + + + + + 自定义 @@ -391,6 +412,9 @@ 22 + + 1 + @@ -430,9 +454,27 @@ 22 + + 1 + - 0 - 20 mm/s + 0-10 mm/s pk + + + + + 0-20 mm/s pk + + + + + 0-50 mm/s pk + + + + + 自定义 @@ -448,6 +490,9 @@ 22 + + 1 + @@ -503,6 +548,9 @@ 22 + + 1 + @@ -532,9 +580,27 @@ 22 + + 1 + - 0 - 20 mm/s + 0-10 mm/s pk + + + + + 0-20 mm/s pk + + + + + 0-50 mm/s pk + + + + + 自定义