diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 05:36:40 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 05:36:40 +0200 |
commit | 18b559ff13898e8e96275b7e329bfa23b7394f6f (patch) | |
tree | 5d22b7453992a96142c2e6a5e91289e50a377858 /migration/20171020_00-max-pitch-output.cpp | |
parent | d1e7df336ce101a0fd9b05e4d3b2b8d49f6caa61 (diff) |
spline: allow switch pitch mapping max Y 90/180
Diffstat (limited to 'migration/20171020_00-max-pitch-output.cpp')
-rw-r--r-- | migration/20171020_00-max-pitch-output.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/migration/20171020_00-max-pitch-output.cpp b/migration/20171020_00-max-pitch-output.cpp new file mode 100644 index 00000000..e7ed474a --- /dev/null +++ b/migration/20171020_00-max-pitch-output.cpp @@ -0,0 +1,70 @@ +/* Copyright (c) 2017, Stanislaw Halik <sthalik@misaki.pl> + + * 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 "migration.hpp" +#include "options/options.hpp" +#include "logic/mappings.hpp" +#include "logic/main-settings.hpp" + +#include <QString> + +using namespace options; +using namespace migrations; + +struct max_pitch_output : migration +{ + max_pitch_output() = default; + + QString unique_date() const override + { + return "20171020_00"; + } + + QString name() const override + { + return "max pitch output in mapping window"; + } + + bool should_run() const override + { + { + static constexpr char const* name = "pitch-max-output-value"; + + bundle b = make_bundle("opentrack-mappings"); + + if (b->contains(name) && b->get<QVariant>(name) != QVariant::Invalid) + return false; + } + + main_settings s; + Mappings m { s.all_axis_opts }; + + Map& pitch_map = m(Pitch); + spline& pitch_spline_1 = pitch_map.spline_main; + spline& pitch_spline_2 = pitch_map.spline_alt; + + for (const spline& spl : { pitch_spline_1, pitch_spline_2 }) + for (QPointF& point : spl.get_points()) + if (point.y() - 1e-2 > 90) + return false; + + return true; + } + + void run() override + { + main_settings s; + axis_opts& pitch_opts = s.a_pitch; + + pitch_opts.clamp_y = axis_opts::o_r90; + + s.b_map->save(); + } +}; + +OPENTRACK_MIGRATION(max_pitch_output); |