summaryrefslogtreecommitdiffhomepage
path: root/spline
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-24 18:54:34 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 19:32:10 +0100
commita88e34b21b07f70123926fcb5c505d6afdf99807 (patch)
tree905059194dcc64c7c163b8912947d8173fd4cc91 /spline
parent5bf85412e4eacf92acc936b6e74bce0e2b1055d9 (diff)
style/quality only
No functional changes. - add `override' everywhere where missing - almost pass clang's `-Wweak-vtables' - avoid some float/double conversions - remove unused private members - make signedness conversions explicit - put stuff in right namespaces to aid analysis
Diffstat (limited to 'spline')
-rw-r--r--spline/spline-widget.cpp10
-rw-r--r--spline/spline.cpp22
-rw-r--r--spline/spline.hpp12
3 files changed, 22 insertions, 22 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 4a591870..36d3e2bf 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -107,7 +107,7 @@ void spline_widget::drawBackground()
const QPen pen(color__, 1, Qt::SolidLine, Qt::FlatCap);
- const int ystep = y_step_, xstep = x_step_;
+ const int ystep = std::ceil(y_step_), xstep = std::ceil(x_step_);
const double maxx = config->max_input();
const double maxy = config->max_output();
@@ -505,7 +505,7 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
double x = value.x(), y = value.y();
if (preview_only)
- y = config->get_value_no_save(x);
+ y = (double)config->get_value_no_save((float)x);
const int x_ = iround(x), y_ = iround(y);
@@ -515,7 +515,7 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
y = y_;
// the style on OSX has different offsets
- static const bool is_fusion =
+ constexpr bool is_fusion =
#if defined __APPLE__
true;
#else
@@ -535,8 +535,8 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
bool spline_widget::is_in_bounds(const QPointF& pos) const
{
- const int grace = point_size_in_pixels * 3;
- const int bottom_grace = int(point_size_in_pixels * 1.5);
+ const int grace = (int)std::ceil(point_size_in_pixels * 3);
+ const int bottom_grace = (int)std::ceil(point_size_in_pixels * 1.5);
return (pos.x() + grace > pixel_bounds.left() &&
pos.x() - grace < pixel_bounds.right() &&
pos.y() + grace > pixel_bounds.top() &&
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 0c619c50..ea5b8c95 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -25,7 +25,12 @@
#include <QDebug>
-using namespace spline_detail;
+namespace spline_detail {
+
+base_spline_::~base_spline_() = default;
+base_spline::~base_spline() = default;
+spline_modify_mixin::~spline_modify_mixin() = default;
+spline_settings_mixin::~spline_settings_mixin() = default;
spline::spline(const QString& name, const QString& axis_name, Axis axis)
{
@@ -220,7 +225,7 @@ void spline::update_interp_data() const
{
if (data[i] == magic_fill_value)
data[i] = last;
- data[i] = (float)clamp(data[i], 0, maxy);
+ data[i] = clamp(data[i], 0, (float)maxy);
last = data[i];
}
}
@@ -361,7 +366,7 @@ void spline::ensure_valid(points_t& list) const
const int sz = list.size();
QList<QPointF> all_points, tmp;
- all_points.reserve(sz), tmp.reserve(sz);
+ all_points.reserve(sz); tmp.reserve(sz);
const double maxx = max_input();
@@ -445,14 +450,12 @@ void spline::disconnect_signals()
{
if (conn_changed)
{
- QObject::disconnect(conn_changed), conn_changed = {};
- QObject::disconnect(conn_maxx), conn_maxx = {};
- QObject::disconnect(conn_maxy), conn_maxy = {};
+ QObject::disconnect(conn_changed); conn_changed = {};
+ QObject::disconnect(conn_maxx); conn_maxx = {};
+ QObject::disconnect(conn_maxy); conn_maxy = {};
}
}
-namespace spline_detail {
-
settings::settings(bundle const& b, const QString& axis_name, Axis idx):
b(b ? b : make_bundle("")),
opts(axis_name, idx)
@@ -460,5 +463,4 @@ settings::settings(bundle const& b, const QString& axis_name, Axis idx):
settings::~settings() = default;
-}
-
+} // ns spline_detail
diff --git a/spline/spline.hpp b/spline/spline.hpp
index 270c4670..87489076 100644
--- a/spline/spline.hpp
+++ b/spline/spline.hpp
@@ -48,7 +48,8 @@ public:
struct OTR_SPLINE_EXPORT base_spline_
{
- virtual inline ~base_spline_();
+ virtual ~base_spline_();
+ base_spline_& operator=(const base_spline_&) = default;
virtual float get_value(double x) = 0;
virtual float get_value_no_save(double x) const = 0;
@@ -72,7 +73,7 @@ struct OTR_SPLINE_EXPORT spline_settings_mixin
virtual std::shared_ptr<spline_detail::base_settings> get_settings() = 0;
virtual std::shared_ptr<const spline_detail::base_settings> get_settings() const = 0;
- virtual inline ~spline_settings_mixin();
+ virtual ~spline_settings_mixin();
};
struct OTR_SPLINE_EXPORT spline_modify_mixin
@@ -83,11 +84,12 @@ struct OTR_SPLINE_EXPORT spline_modify_mixin
virtual void remove_point(int i) = 0;
virtual void clear() = 0;
- virtual inline ~spline_modify_mixin();
+ virtual ~spline_modify_mixin();
};
struct OTR_SPLINE_EXPORT base_spline : base_spline_, spline_modify_mixin, spline_settings_mixin
{
+ ~base_spline() override;
};
class OTR_SPLINE_EXPORT spline : public base_spline
@@ -158,10 +160,6 @@ public:
using settings = spline_detail::settings;
};
-inline base_spline_::~base_spline_() = default;
-inline spline_modify_mixin::~spline_modify_mixin() = default;
-inline spline_settings_mixin::~spline_settings_mixin() = default;
-
} // ns spline_detail
using spline = spline_detail::spline;