diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/main-window.cpp | 4 | ||||
-rw-r--r-- | gui/mapping-window.cpp | 49 | ||||
-rw-r--r-- | gui/mapping-window.hpp | 3 |
3 files changed, 39 insertions, 17 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp index aa8e16f3..11479a1a 100644 --- a/gui/main-window.cpp +++ b/gui/main-window.cpp @@ -523,8 +523,8 @@ void MainWindow::display_pose(const double *mapped, const double *raw) ui.pose_display->rotate_async(mapped[Yaw], mapped[Pitch], -mapped[Roll], mapped[TX], mapped[TY], mapped[TZ]); - if (mapping_widget && mapping_widget->isVisible()) - mapping_widget->repaint(); + if (mapping_widget) + mapping_widget->refresh_tab(); QLCDNumber* raw_[] = { ui.raw_x, ui.raw_y, ui.raw_z, diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp index 0a5d3049..46224078 100644 --- a/gui/mapping-window.cpp +++ b/gui/mapping-window.cpp @@ -10,7 +10,7 @@ #include "logic/main-settings.hpp" #include "spline/spline-widget.hpp" -MapWidget::MapWidget(Mappings& m) : m(m) +MapWidget::MapWidget(Mappings& m) : m(m), widgets{} { ui.setupUi(this); @@ -43,19 +43,19 @@ void MapWidget::load() 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, }, - { nullptr, Yaw, nullptr, false } + { 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 } }; using a = axis_opts::max_clamp; @@ -100,9 +100,12 @@ void MapWidget::load() qfc.set_snap(x_snap, 1); } }); + // force signal to avoid duplicating the slot's logic - qfcs[i].qfc->setConfig(&conf); + qfc.setConfig(&conf); axis.opts.clamp.valueChanged(axis.opts.clamp); + + widgets[i % 6][altp ? 1 : 0] = &qfc; } } @@ -112,6 +115,22 @@ void MapWidget::closeEvent(QCloseEvent*) invalidate_dialog(); } +void MapWidget::refresh_tab() +{ + if (!isVisible()) + return; + + const int idx = ui.tabWidget->currentIndex(); + + if (likely(idx >= 0 && idx < 6)) + { + widgets[idx][0]->repaint(); + widgets[idx][1]->repaint(); + } + else + qDebug() << "map-widget: bad index" << idx; +} + void MapWidget::save_dialog() { s.b_map->save(); diff --git a/gui/mapping-window.hpp b/gui/mapping-window.hpp index 9403bfb5..ab0da2cc 100644 --- a/gui/mapping-window.hpp +++ b/gui/mapping-window.hpp @@ -14,11 +14,14 @@ class MapWidget final : public QDialog Q_OBJECT public: MapWidget(Mappings& m); + void refresh_tab(); private: Ui::mapping_window ui; Mappings& m; main_settings s; + spline_widget* widgets[6][2]; + void closeEvent(QCloseEvent*) override; void load(); |