summaryrefslogtreecommitdiffhomepage
path: root/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
blob: dc008c93b0540ba977704b7cbe47e16b96eba918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ftnoir_filter_ewma2.h"

#include <cmath>

#include <QDebug>
#include <QString>

#include "api/plugin-api.hpp"
#include "ui_ftnoir_ewma_filtercontrols.h"

dialog_ewma::dialog_ewma()
{
    ui.setupUi(this);

    connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
    connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));

    tie_setting(s.kMaxSmoothing, ui.maxSmooth);
    tie_setting(s.kMinSmoothing, ui.minSmooth);
    tie_setting(s.kSmoothingScaleCurve, ui.powCurve);

    tie_setting(s.kSmoothingScaleCurve, ui.curve_label,
                [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2); });

    tie_setting(s.kMinSmoothing, ui.min_label,
                [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});

    tie_setting(s.kMaxSmoothing, ui.max_label,
                [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});

    connect(ui.minSmooth, &QSlider::valueChanged, this,
            [&](int v) { if (ui.maxSmooth->value() < v) ui.maxSmooth->setValue(v); });

    connect(ui.maxSmooth, &QSlider::valueChanged, this,
            [&](int v) { if (ui.minSmooth->value() > v) ui.minSmooth->setValue(v); });
}

void dialog_ewma::doOK()
{
    s.b->save();
    close();
}

void dialog_ewma::doCancel()
{
    close();
}