diff options
Diffstat (limited to 'spline')
-rw-r--r-- | spline/spline-widget.cpp | 30 | ||||
-rw-r--r-- | spline/spline.cpp | 13 | ||||
-rw-r--r-- | spline/spline.hpp | 2 |
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; |