summaryrefslogtreecommitdiffhomepage
path: root/spline
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-20 05:36:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-20 05:36:40 +0200
commit18b559ff13898e8e96275b7e329bfa23b7394f6f (patch)
tree5d22b7453992a96142c2e6a5e91289e50a377858 /spline
parentd1e7df336ce101a0fd9b05e4d3b2b8d49f6caa61 (diff)
spline: allow switch pitch mapping max Y 90/180
Diffstat (limited to 'spline')
-rw-r--r--spline/spline-widget.cpp30
-rw-r--r--spline/spline.cpp13
-rw-r--r--spline/spline.hpp2
3 files changed, 28 insertions, 17 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index a80e08b7..2aa5e6ac 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -49,25 +49,23 @@ spline_widget::~spline_widget()
void spline_widget::setConfig(spline* spl)
{
- if (spl != _config)
+ if (connection)
{
- if (connection)
- {
- QObject::disconnect(connection);
- connection = QMetaObject::Connection();
- }
+ QObject::disconnect(connection);
+ connection = QMetaObject::Connection();
+ }
- if (spl)
- {
- std::shared_ptr<spline::settings> s = spl->get_settings();
- connection = connect(s.get(), &spline::settings::recomputed,
- this, [this]() { reload_spline(); },
- Qt::QueuedConnection);
- }
+ _config = spl;
- _config = spl;
- _background = QPixmap();
+ if (spl)
+ {
update_range();
+ _config->ensure_valid(_config->get_points());
+
+ std::shared_ptr<spline::settings> s = spl->get_settings();
+ connection = connect(s.get(), &spline::settings::recomputed,
+ this, [this]() { reload_spline(); },
+ Qt::QueuedConnection);
}
}
@@ -509,6 +507,8 @@ void spline_widget::mouseReleaseEvent(QMouseEvent *e)
void spline_widget::reload_spline()
{
+ if (_config)
+ _config->ensure_valid(_config->get_points());
// don't recompute here as the value's about to be recomputed in the callee
update_range();
}
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 9d783df6..f28cc98d 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -427,7 +427,18 @@ void spline::ensure_valid(const QList<QPointF>& the_points)
}
return false;
);
- if (!overlap)
+
+ const bool over_limit = progn(
+ bool ret = false;
+ if (pt.y() - 1e-2 > max_y)
+ {
+ pt.setY(max_y);
+ ret = true;
+ }
+ return ret;
+ );
+
+ if (!overlap && !over_limit)
ret_list.push_back(pt);
}
diff --git a/spline/spline.hpp b/spline/spline.hpp
index 328d1ece..cb2dc654 100644
--- a/spline/spline.hpp
+++ b/spline/spline.hpp
@@ -62,7 +62,7 @@ class OTR_SPLINE_EXPORT spline final
MyMutex _mutex;
QPointF last_input_value;
- qreal max_x, max_y;
+ qreal max_x, max_y; // XXX TODO move to value<double> -sh 20171020
bool activep;
bool validp;