summaryrefslogtreecommitdiffhomepage
path: root/filter-accela/ftnoir_filter_accela_dialog.cpp
blob: 519e6e0d66d17de9ca0c2bbce8c1321802e8a6c8 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Copyright (c) 2012-2015 Stanislaw Halik
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */
#include "ftnoir_filter_accela.h"
#include <cmath>
#include <QDebug>
#include <algorithm>
#include <QDoubleSpinBox>
#include "api/plugin-api.hpp"
#include "spline/spline-widget.hpp"
#include <QDialog>

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

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

    tie_setting(s.rot_sensitivity, ui.rotation_slider);
    tie_setting(s.pos_sensitivity, ui.translation_slider);
    tie_setting(s.ewma, ui.ewma_slider);
    tie_setting(s.rot_deadzone, ui.rot_dz_slider);
    tie_setting(s.pos_deadzone, ui.trans_dz_slider);
    tie_setting(s.rot_nonlinearity, ui.rot_nl_slider);

    tie_setting(s.rot_sensitivity, ui.rot_gain, tr("%1°"), 0, 'g', 4);
    tie_setting(s.pos_sensitivity, ui.trans_gain, tr("%1mm"));
    tie_setting(s.ewma, ui.ewma_label, tr("%1ms"));
    tie_setting(s.rot_deadzone, ui.rot_dz, tr("%1°"), 0, 'g', 4);
    tie_setting(s.pos_deadzone, ui.trans_dz, tr("%1mm"));
    tie_setting(s.rot_nonlinearity, ui.rot_nl,
        tr("<html><head/><body>"
           "<p>x<span style='vertical-align:super;'>"
           "%1"
           "</span></p>"
           "</body></html>")
    );

//#define SPLINE_ROT_DEBUG
//#define SPLINE_TRANS_DEBUG

#if defined SPLINE_ROT_DEBUG || defined SPLINE_TRANS_DEBUG
    {
        spline rot, pos;
        s.make_splines(rot, pos);

#ifdef SPLINE_ROT_DEBUG
        QDialog dr;
        spline_widget r(&dr);
        dr.setWindowTitle("Accela rotation gain"); r.set_preview_only(true); r.setEnabled(true);
        r.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); r.setConfig(&rot);
        r.setFixedSize(1024, 600);
        dr.show();
        dr.exec();
#endif

#ifdef SPLINE_TRANS_DEBUG
        QDialog dt;
        spline_widget t(&dt);
        dt.setWindowTitle("Accela translation gain"); t.set_preview_only(true); t.setEnabled(true);
        dt.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); t.setConfig(&pos);
        t.setFixedSize(1024, 600);
        dt.show();
        dt.exec();
#endif
    }
#endif
}

void dialog_accela::doOK()
{
    save();
    close();
}

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

void dialog_accela::save()
{
    s.b->save();
}