Bugfix: time gate filter size, improve dialog shutdown

This commit is contained in:
Jan Käberich 2022-01-13 19:34:57 +01:00
parent 4d959598b5
commit dc5cb73b3f
2 changed files with 5 additions and 18 deletions

View File

@ -237,15 +237,6 @@ void Math::TimeGate::updateFilter()
auto maxX = input->rData().back().x;
auto minX = input->rData().front().x;
// auto c1 = center - span / 2;
// auto c2 = center + span / 2;
// if(c1 < minX) {
// c1 = minX;
// }
// if(c2 > maxX) {
// c2 = maxX;
// }
auto wc1 = Util::Scale<double>(center - span / 2, minX, maxX, 0, 1);
auto wc2 = Util::Scale<double>(center + span / 2, minX, maxX, 0, 1);
@ -270,7 +261,7 @@ void Math::TimeGate::updateFilter()
Fft::shift(buf, true);
Fft::transform(buf, false);
filter.resize(buf.size());
filter.resize(buf.size() / 2);
for(unsigned int i=0;i<buf.size() / 2;i++) {
filter[i] = abs(buf[i]);
}
@ -389,8 +380,6 @@ void Math::TimeGateGraph::paintEvent(QPaintEvent *event)
p1.setY(Util::Scale<double>(y_last, -120, 20, plotBottom, plotTop));
p2.setX(Util::Scale<double>(now.x, minX, maxX, plotLeft, plotRight));
p2.setY(Util::Scale<double>(y_now, -120, 20, plotBottom, plotTop));
// auto p1 = plotValueToPixel(last.x, y_last);
// auto p2 = plotValueToPixel(now.x, y_now);
// draw line
p.drawLine(p1, p2);
}
@ -398,7 +387,7 @@ void Math::TimeGateGraph::paintEvent(QPaintEvent *event)
auto filter = gate->rFilter();
pen = QPen(Qt::red, 1);
p.setPen(pen);
for(unsigned int i=increment;i<filter.size();i+=increment) {
for(unsigned int i=increment;i<filter.size() && i<input.size();i+=increment) {
auto x_last = input[i-increment].x;
auto x_now = input[i].x;
@ -414,9 +403,6 @@ void Math::TimeGateGraph::paintEvent(QPaintEvent *event)
p1.setY(Util::Scale<double>(f_last, -120, 20, plotBottom, plotTop));
p2.setX(Util::Scale<double>(x_now, minX, maxX, plotLeft, plotRight));
p2.setY(Util::Scale<double>(f_now, -120, 20, plotBottom, plotTop));
// auto p1 = plotValueToPixel(x_last, f_last);
// auto p2 = plotValueToPixel(x_now, f_now);
// draw line
p.drawLine(p1, p2);
}

View File

@ -169,7 +169,7 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
auto d = new QDialog();
auto ui = new Ui::NewTraceMathDialog();
ui->setupUi(d);
connect(d, &QDialog::finished, [=](){
connect(d, &QDialog::rejected, [=](){
delete ui;
});
for(int i = 0; i < (int) TraceMath::Type::Last;i++) {
@ -184,8 +184,9 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
connect(ui->list, &QListWidget::currentRowChanged, ui->stack, &QStackedWidget::setCurrentIndex);
connect(ui->list, &QListWidget::doubleClicked, ui->buttonBox, &QDialogButtonBox::accepted);
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){
connect(d, &QDialog::accepted, [=](){
auto type = static_cast<TraceMath::Type>(ui->list->currentRow());
delete ui;
auto newMath = TraceMath::createMath(type);
model->addOperations(newMath);
if(newMath.size() == 1) {