From f50ac3549d6a7f1199fa012e4b03f581bc8d305b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Jun 2018 12:54:47 +0200 Subject: core, modules: modernize syntax only Use more C++17 features where this helps any. --- tracker-pt/ftnoir_tracker_pt.cpp | 5 ++--- tracker-pt/ftnoir_tracker_pt.h | 12 ++++-------- tracker-pt/ftnoir_tracker_pt_dialog.cpp | 31 ++++++++++++++----------------- tracker-pt/pt-api.hpp | 3 +++ tracker-pt/pt-settings.hpp | 2 +- 5 files changed, 24 insertions(+), 29 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 243fbd60..e6cbb6ba 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -7,6 +7,7 @@ */ #include "ftnoir_tracker_pt.h" +#include "cv/video-widget.hpp" #include "compat/camera-names.hpp" #include "compat/math-imports.hpp" @@ -14,8 +15,6 @@ #include -#include - #include #include #include @@ -23,7 +22,7 @@ using namespace types; -Tracker_PT::Tracker_PT(pointer traits) : +Tracker_PT::Tracker_PT(pointer const& traits) : traits { traits }, s { traits->get_module_name() }, point_extractor { traits->make_point_extractor() }, diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index 489175e4..31bdc6bb 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -9,12 +9,9 @@ #pragma once #include "api/plugin-api.hpp" - -#include "cv/numeric.hpp" - #include "pt-api.hpp" #include "point_tracker.h" -#include "cv/video-widget.hpp" +#include "cv/numeric.hpp" #include #include @@ -25,9 +22,9 @@ #include #include #include -#include class TrackerDialog_PT; +class cv_video_widget; namespace pt_module { @@ -40,10 +37,9 @@ class Tracker_PT : public QThread, public ITracker friend class ::TrackerDialog_PT; public: - template - using pointer = typename pt_runtime_traits::pointer; + template using pointer = pt_pointer; - Tracker_PT(pointer pt_runtime_traits); + Tracker_PT(pointer const& pt_runtime_traits); ~Tracker_PT() override; module_status start_tracker(QFrame* parent_window) override; void data(double* data) override; diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 9073907d..ce1b9eb0 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -165,18 +165,16 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) // Don't bother counting roll samples. Roll calibration is hard enough // that it's a hidden unsupported feature anyway. - const QString sample_feedback = progn( - if (nsamples[0] < min_yaw_samples) - return tr("%1 yaw samples. Yaw more to %2 samples for stable calibration.") - .arg(nsamples[0]).arg(min_yaw_samples); - if (nsamples[1] < min_pitch_samples) - return tr("%1 pitch samples. Pitch more to %2 samples for stable calibration.") - .arg(nsamples[1]).arg(min_pitch_samples); - + QString sample_feedback; + if (nsamples[0] < min_yaw_samples) + sample_feedback = tr("%1 yaw samples. Yaw more to %2 samples for stable calibration.").arg(nsamples[0]).arg(min_yaw_samples); + else if (nsamples[1] < min_pitch_samples) + sample_feedback = tr("%1 pitch samples. Pitch more to %2 samples for stable calibration.").arg(nsamples[1]).arg(min_pitch_samples); + else + { const int nsamples_total = nsamples[0] + nsamples[1]; - - return tr("%1 samples. Over %2, good!").arg(nsamples_total).arg(min_samples); - ); + sample_feedback = tr("%1 samples. Over %2, good!").arg(nsamples_total).arg(min_samples); + } ui.sample_count_display->setText(sample_feedback); } @@ -184,12 +182,11 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) ui.tx_spin->setEnabled(!start); ui.ty_spin->setEnabled(!start); ui.tz_spin->setEnabled(!start); - ui.tcalib_button->setText(progn( - if (start) - return tr("Stop calibration"); - else - return tr("Start calibration"); - )); + + if (start) + ui.tcalib_button->setText(tr("Stop calibration")); + else + ui.tcalib_button->setText(tr("Start calibration")); } void TrackerDialog_PT::poll_tracker_info_impl() diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp index 621d9160..7ddddaf5 100644 --- a/tracker-pt/pt-api.hpp +++ b/tracker-pt/pt-api.hpp @@ -107,3 +107,6 @@ struct pt_runtime_traits virtual pointer make_preview(int w, int h) const = 0; virtual QString get_module_name() const = 0; }; + +template +using pt_pointer = typename pt_runtime_traits::pointer; diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index a1b9d4f6..a8e3497a 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -52,5 +52,5 @@ struct pt_settings final : options::opts value auto_threshold { b, "automatic-threshold", true }; value blob_color { b, "blob-color", pt_color_natural }; - value threshold_slider { b, "threshold-slider", slider_value(128, 0, 255) }; + value threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; }; -- cgit v1.2.3