diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-01-29 03:09:09 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-01-29 03:09:09 +0100 |
commit | ff0d3aefe8d14796f636b890595f12b5b08d6d2f (patch) | |
tree | f9b2483b5926c6e7627f49aaf4121463b20a31b1 | |
parent | cb5873922f4528b80d40e13b05bd7590421d79ee (diff) |
spline-widget: remove camel case
My eyes bleed a bit less
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 14 | ||||
-rw-r--r-- | gui/mapping-window.cpp | 36 | ||||
-rw-r--r-- | gui/mapping-window.hpp | 4 | ||||
-rw-r--r-- | logic/tracker.cpp | 10 | ||||
-rw-r--r-- | migration/20160906_00-mappings.cpp | 4 | ||||
-rw-r--r-- | spline-widget/spline-widget.cpp | 32 | ||||
-rw-r--r-- | spline-widget/spline.cpp | 60 | ||||
-rw-r--r-- | spline-widget/spline.hpp | 32 |
8 files changed, 104 insertions, 88 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 955e6dd6..9a3dbcff 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -90,7 +90,7 @@ void accela::filter(const double* input, double *output) else return out_; ); - const double val = double(m.getValue(out)); + const double val = double(m.get_value(out)); last_output[i] = output[i] = last_output[i] + signum(vec_) * dt * val; } } @@ -100,16 +100,16 @@ void settings_accela::make_splines(spline& rot, spline& trans) rot = spline(); trans = spline(); - rot.setMaxInput(rot_gains[0][0]); - trans.setMaxInput(trans_gains[0][0]); - rot.setMaxOutput(rot_gains[0][1]); - trans.setMaxOutput(trans_gains[0][1]); + rot.set_max_input(rot_gains[0][0]); + trans.set_max_input(trans_gains[0][0]); + rot.set_max_output(rot_gains[0][1]); + trans.set_max_output(trans_gains[0][1]); for (int i = 0; rot_gains[i][0] >= 0; i++) - rot.addPoint(QPointF(rot_gains[i][0], rot_gains[i][1])); + rot.add_point(QPointF(rot_gains[i][0], rot_gains[i][1])); for (int i = 0; trans_gains[i][0] >= 0; i++) - trans.addPoint(QPointF(trans_gains[i][0], trans_gains[i][1])); + trans.add_point(QPointF(trans_gains[i][0], trans_gains[i][1])); } OPENTRACK_DECLARE_FILTER(accela, dialog_accela, accelaDll) diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp index 879541de..d1188e66 100644 --- a/gui/mapping-window.cpp +++ b/gui/mapping-window.cpp @@ -9,12 +9,12 @@ #include "mapping-window.hpp" #include "logic/main-settings.hpp" #include "spline-widget/spline-widget.hpp" -MapWidget::MapWidget(Mappings& m) : - m(m) + +MapWidget::MapWidget(Mappings& m) : m(m) { ui.setupUi(this); - reload(); + load(); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); @@ -27,9 +27,8 @@ MapWidget::MapWidget(Mappings& m) : tie_setting(s.a_roll.altp, ui.rz_altp); } -void MapWidget::reload() +void MapWidget::load() { - struct { spline_widget* qfc; Axis axis; @@ -37,21 +36,20 @@ void MapWidget::reload() bool altp; } qfcs[] = { - { ui.rxconfig, Yaw, nullptr, false }, - { ui.ryconfig, Pitch, nullptr, false }, - { ui.rzconfig, Roll, nullptr, false }, - { ui.txconfig, TX, nullptr, false }, - { ui.tyconfig, TY, nullptr, false }, - { ui.tzconfig, TZ, nullptr, false }, - - { ui.rxconfig_alt, Yaw, ui.rx_altp, true }, - { ui.ryconfig_alt, Pitch, ui.ry_altp, true }, - { ui.rzconfig_alt, Roll, ui.rz_altp, true }, - { ui.txconfig_alt, TX, ui.tx_altp, true }, - { ui.tyconfig_alt, TY, ui.ty_altp, true }, - { ui.tzconfig_alt, TZ, ui.tz_altp, true }, + { ui.rxconfig, Yaw, nullptr, false, }, + { ui.ryconfig, Pitch, nullptr, false, }, + { ui.rzconfig, Roll, nullptr, false, }, + { ui.txconfig, TX, nullptr, false, }, + { ui.tyconfig, TY, nullptr, false, }, + { ui.tzconfig, TZ, nullptr, false, }, + { ui.rxconfig_alt, Yaw, ui.rx_altp, true, }, + { ui.ryconfig_alt, Pitch, ui.ry_altp, true, }, + { ui.rzconfig_alt, Roll, ui.rz_altp, true, }, + { ui.txconfig_alt, TX, ui.tx_altp, true, }, + { ui.tyconfig_alt, TY, ui.ty_altp, true, }, + { ui.tzconfig_alt, TZ, ui.tz_altp, true, }, { nullptr, Yaw, nullptr, false } -}; + }; for (int i = 0; qfcs[i].qfc; i++) { diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp index 06d969cc..9403bfb5 100644 --- a/gui/mapping-window.hpp +++ b/gui/mapping-window.hpp @@ -14,15 +14,15 @@ class MapWidget final : public QDialog Q_OBJECT public: MapWidget(Mappings& m); - void reload(); private: Ui::mapping_window ui; Mappings& m; main_settings s; - void closeEvent(QCloseEvent*) override; + void load(); + void save_dialog(); void invalidate_dialog(); diff --git a/logic/tracker.cpp b/logic/tracker.cpp index 95a60221..cf593cdd 100644 --- a/logic/tracker.cpp +++ b/logic/tracker.cpp @@ -62,10 +62,10 @@ Tracker::rmat Tracker::get_camera_offset_matrix(double c) double Tracker::map(double pos, Map& axis) { bool altp = (pos < 0) && axis.opts.altp; - axis.spline_main.setTrackingActive( !altp ); - axis.spline_alt.setTrackingActive( altp ); + axis.spline_main.set_tracking_active( !altp ); + axis.spline_alt.set_tracking_active( altp ); auto& fc = altp ? axis.spline_alt : axis.spline_main; - return double(fc.getValue(pos)); + return double(fc.get_value(pos)); } void Tracker::t_compensate(const rmat& rmat, const euler_t& xyz, euler_t& output, @@ -451,8 +451,8 @@ void Tracker::run() for (int i = 0; i < 6; i++) { - m(i).spline_main.setTrackingActive(false); - m(i).spline_alt.setTrackingActive(false); + m(i).spline_main.set_tracking_active(false); + m(i).spline_alt.set_tracking_active(false); } } diff --git a/migration/20160906_00-mappings.cpp b/migration/20160906_00-mappings.cpp index 65759dec..58674843 100644 --- a/migration/20160906_00-mappings.cpp +++ b/migration/20160906_00-mappings.cpp @@ -100,10 +100,10 @@ struct mappings_from_2_3_0_rc11 : migration for (int i = 0; i < 12; i++) { spline& spl = (i % 2) == 0 ? m(i / 2).spline_main : m(i / 2).spline_alt; - spl.removeAllPoints(); + spl.clear(); const QList<QPointF>& points = old_mappings[i]; for (const QPointF& pt : points) - spl.addPoint(pt); + spl.add_point(pt); spl.save(s); } } diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp index 826673e9..c8356fb4 100644 --- a/spline-widget/spline-widget.cpp +++ b/spline-widget/spline-widget.cpp @@ -122,8 +122,8 @@ void spline_widget::drawBackground() const QPen pen(color__, 1, Qt::SolidLine, Qt::FlatCap); const int xstep = 10, ystep = 10; - const qreal maxx = _config->maxInput(); - const qreal maxy = _config->maxOutput(); + const qreal maxx = _config->max_input(); + const qreal maxy = _config->max_output(); // horizontal grid for (int i = 0; i <= maxy; i += xstep) @@ -163,7 +163,7 @@ void spline_widget::drawFunction() QPainter painter(&_function); painter.setRenderHint(QPainter::Antialiasing, true); - const points_t points = _config->getPoints(); + const points_t points = _config->get_points(); if (moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) @@ -205,7 +205,7 @@ void spline_widget::drawFunction() #ifndef DEBUG_SPLINE static constexpr double step_ = 3./3; - const double maxx = _config->maxInput(); + const double maxx = _config->max_input(); const double step = step_ / c.x(); QPainterPath path; @@ -283,7 +283,7 @@ void spline_widget::paintEvent(QPaintEvent *e) // Show that point on the graph, with some lines to assist. // This new feature is very handy for tweaking the curves! QPointF last; - if (_config->getLastPoint(last) && isEnabled()) + if (_config->get_last_value(last) && isEnabled()) drawPoint(p, point_to_pixel(last), QColor(255, 0, 0, 120)); } @@ -317,7 +317,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e) const int point_pixel_closeness_limit = get_closeness_limit(); - points_t points = _config->getPoints(); + points_t points = _config->get_points(); if (e->button() == Qt::LeftButton) { bool bTouchingPoint = false; @@ -351,7 +351,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e) if (!too_close) { - _config->addPoint(pixel_coord_to_point(e->pos())); + _config->add_point(pixel_coord_to_point(e->pos())); show_tooltip(e->pos()); } } @@ -374,7 +374,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e) if (found_pt != -1) { - _config->removePoint(found_pt); + _config->remove_point(found_pt); } moving_control_point_idx = -1; } @@ -399,7 +399,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e) } const int i = moving_control_point_idx; - const points_t points = _config->getPoints(); + const points_t points = _config->get_points(); const int sz = points.size(); if (i >= 0 && i < sz) @@ -429,7 +429,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e) if (overlap) new_pt.setX(points[i].x()); - _config->movePoint(i, new_pt); + _config->move_point(i, new_pt); _draw_function = true; setCursor(Qt::ClosedHandCursor); @@ -546,7 +546,7 @@ void spline_widget::update_range() const int mwr = 15, mhr = 35; pixel_bounds = QRect(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); - c = QPointF(pixel_bounds.width() / _config->maxInput(), pixel_bounds.height() / _config->maxOutput()); + c = QPointF(pixel_bounds.width() / _config->max_input(), pixel_bounds.height() / _config->max_output()); _draw_function = true; _background = QPixmap(); @@ -597,13 +597,13 @@ QPointF spline_widget::pixel_coord_to_point(const QPoint& point) if (x < 0) x = 0; - if (x > _config->maxInput()) - x = _config->maxInput(); + if (x > _config->max_input()) + x = _config->max_input(); if (y < 0) y = 0; - if (y > _config->maxOutput()) - y = _config->maxOutput(); + if (y > _config->max_output()) + y = _config->max_output(); return QPointF(x, y); } @@ -635,7 +635,7 @@ bool spline_widget::is_on_pt(const QPoint& pos, int* pt) return false; } - const points_t points = _config->getPoints(); + const points_t points = _config->get_points(); for (int i = 0; i < points.size(); i++) { diff --git a/spline-widget/spline.cpp b/spline-widget/spline.cpp index 57817d40..59ed9939 100644 --- a/spline-widget/spline.cpp +++ b/spline-widget/spline.cpp @@ -42,16 +42,15 @@ spline::~spline() if (connection) { QObject::disconnect(connection); + connection = QMetaObject::Connection(); } } -spline::spline() : spline(0, 0, "") -{ -} +spline::spline() : spline(0, 0, "") {} -void spline::setTrackingActive(bool blnActive) +void spline::set_tracking_active(bool value) { - activep = blnActive; + activep = value; } bundle spline::get_bundle() @@ -59,40 +58,40 @@ bundle spline::get_bundle() return s->b; } -void spline::removeAllPoints() +void spline::clear() { QMutexLocker l(&_mutex); s->points = points_t(); validp = false; } -void spline::setMaxInput(qreal max_input) +void spline::set_max_input(qreal max_input) { QMutexLocker l(&_mutex); max_x = max_input; recompute(); } -void spline::setMaxOutput(qreal max_output) +void spline::set_max_output(qreal max_output) { QMutexLocker l(&_mutex); max_y = max_output; recompute(); } -qreal spline::maxInput() const +qreal spline::max_input() const { QMutexLocker l(&_mutex); return max_x; } -qreal spline::maxOutput() const +qreal spline::max_output() const { QMutexLocker l(&_mutex); return max_y; } -float spline::getValue(double x) +float spline::get_value(double x) { QMutexLocker foo(&_mutex); @@ -106,23 +105,26 @@ float spline::get_value_no_save(double x) { QMutexLocker foo(&_mutex); + if (max_x > 0) + x = std::min(max_x, x); + float q = float(x * precision(s->points)); int xi = (int)q; - float yi = getValueInternal(xi); - float yiplus1 = getValueInternal(xi+1); + float yi = get_value_internal(xi); + float yiplus1 = get_value_internal(xi+1); float f = (q-xi); float ret = yiplus1 * f + yi * (1.0f - f); // at least do a linear interpolation. return ret; } -bool spline::getLastPoint(QPointF& point) +DEFUN_WARN_UNUSED bool spline::get_last_value(QPointF& point) { QMutexLocker foo(&_mutex); point = last_input_value; return activep; } -float spline::getValueInternal(int x) +float spline::get_value_internal(int x) { if (!validp) { @@ -148,11 +150,27 @@ void spline::add_lone_point() QPointF spline::ensure_in_bounds(const QList<QPointF>& points, int i) { const int sz = points.size(); +start: if (i < 0 || sz == 0) return QPointF(0, 0); + if (i < sz) + { + if (max_x > 0 && max_x < points[i]) + { + i--; + goto start; + } return points[i]; + } + + if (max_x > 0 && max_x < points[sz - 1]) + { + i = sz - 2; + goto start; + } + return points[sz - 1]; } @@ -244,7 +262,7 @@ void spline::update_interp_data() } } -void spline::removePoint(int i) +void spline::remove_point(int i) { QMutexLocker foo(&_mutex); @@ -258,7 +276,7 @@ void spline::removePoint(int i) } } -void spline::addPoint(QPointF pt) +void spline::add_point(QPointF pt) { QMutexLocker foo(&_mutex); @@ -269,12 +287,12 @@ void spline::addPoint(QPointF pt) validp = false; } -void spline::addPoint(double x, double y) +void spline::add_point(double x, double y) { - addPoint(QPointF(x, y)); + add_point(QPointF(x, y)); } -void spline::movePoint(int idx, QPointF pt) +void spline::move_point(int idx, QPointF pt) { QMutexLocker foo(&_mutex); @@ -290,7 +308,7 @@ void spline::movePoint(int idx, QPointF pt) } } -QList<QPointF> spline::getPoints() const +QList<QPointF> spline::get_points() const { QMutexLocker foo(&_mutex); return s->points; diff --git a/spline-widget/spline.hpp b/spline-widget/spline.hpp index adabd33c..660757f2 100644 --- a/spline-widget/spline.hpp +++ b/spline-widget/spline.hpp @@ -44,7 +44,7 @@ class OPENTRACK_SPLINE_EXPORT spline final { double precision(const QList<QPointF>& points) const; void update_interp_data(); - float getValueInternal(int x); + float get_value_internal(int x); void add_lone_point(); static bool sort_fn(const QPointF& one, const QPointF& two); @@ -72,8 +72,8 @@ public: void save(); void set_bundle(bundle b); - qreal maxInput() const; - qreal maxOutput() const; + qreal max_input() const; + qreal max_output() const; spline(); spline(qreal maxx, qreal maxy, const QString& name); ~spline(); @@ -81,20 +81,20 @@ public: spline& operator=(const spline&) = default; spline(const spline&) = default; - float getValue(double x); + float get_value(double x); float get_value_no_save(double x); - bool getLastPoint(QPointF& point); - void removePoint(int i); - void removeAllPoints(); - - void addPoint(QPointF pt); - void addPoint(double x, double y); - void movePoint(int idx, QPointF pt); - QList<QPointF> getPoints() const; - void setMaxInput(qreal MaxInput); - void setMaxOutput(qreal MaxOutput); - - void setTrackingActive(bool blnActive); + DEFUN_WARN_UNUSED bool get_last_value(QPointF& point); + void remove_point(int i); + void clear(); + + void add_point(QPointF pt); + void add_point(double x, double y); + void move_point(int idx, QPointF pt); + QList<QPointF> get_points() const; + void set_max_input(qreal MaxInput); + void set_max_output(qreal MaxOutput); + + void set_tracking_active(bool value); bundle get_bundle(); void recompute(); |