summaryrefslogtreecommitdiffhomepage
path: root/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
blob: 55e9782e2874a4e9ce859787e6244dafd5b9ddb0 (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
48
49
50
#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,
                [](auto& x) { return x * 100; },
                "%1%", 0, 'f', 2);

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

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

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

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

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

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