summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-17 22:15:13 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-17 22:32:05 +0200
commit630a8a253ca6b868148e9850ab4203484762c853 (patch)
tree41597bd1f27294c4c32806d6f85e9f5b05582fec /logic
parent2a7101c6544c7ce49ff6d306734a34b41a936166 (diff)
logic/mappings: update to new api
Diffstat (limited to 'logic')
-rw-r--r--logic/mappings.hpp77
1 files changed, 32 insertions, 45 deletions
diff --git a/logic/mappings.hpp b/logic/mappings.hpp
index 038b7560..942f53d2 100644
--- a/logic/mappings.hpp
+++ b/logic/mappings.hpp
@@ -12,77 +12,64 @@ using namespace options;
#include "spline-widget/spline.hpp"
#include "main-settings.hpp"
-class Map {
-public:
+struct Map final
+{
Map(QString primary,
QString secondary,
int max_x,
int max_y,
axis_opts& opts) :
- spline_main(max_x, max_y),
- spline_alt(max_x, max_y),
opts(opts),
name1(primary),
- name2(secondary)
+ name2(secondary),
+ spline_main(max_x, max_y, primary),
+ spline_alt(max_x, max_y, secondary)
+ {
+ }
+
+ void save()
+ {
+ spline_main.save();
+ spline_alt.save();
+ }
+
+ void load()
{
- mem<QSettings> iniFile = group::ini_file();
- spline_main.loadSettings(*iniFile, primary);
- spline_alt.loadSettings(*iniFile, secondary);
+ spline_main.reload();
+ spline_alt.reload();
}
- spline spline_main;
- spline spline_alt;
+
axis_opts& opts;
QString name1, name2;
+ spline spline_main, spline_alt;
};
-class Mappings {
+class Mappings
+{
private:
Map axes[6];
public:
Mappings(std::vector<axis_opts*> opts) :
axes {
- Map("tx","tx_alt", 30, 75, *opts[TX]),
- Map("ty","ty_alt", 30, 75, *opts[TY]),
- Map("tz","tz_alt", 30, 75, *opts[TZ]),
- Map("rx", "rx_alt", 180, 180, *opts[Yaw]),
- Map("ry", "ry_alt", 180, 180, *opts[Pitch]),
- Map("rz", "rz_alt", 180, 180, *opts[Roll])
+ Map("spline-X", "alt-spline-X", 30, 75, *opts[TX]),
+ Map("spline-Y", "alt-spline-Y", 30, 75, *opts[TY]),
+ Map("spline-Z", "alt-spline-Z", 30, 75, *opts[TZ]),
+ Map("spline-yaw", "alt-spline-yaw", 180, 180, *opts[Yaw]),
+ Map("spline-pitch", "alt-spline-pitch", 180, 180, *opts[Pitch]),
+ Map("spline-roll", "alt-spline-roll", 180, 180, *opts[Roll])
}
{}
inline Map& operator()(int i) { return axes[i]; }
inline const Map& operator()(int i) const { return axes[i]; }
+ inline Map& operator()(unsigned i) { return axes[i]; }
+ inline const Map& operator()(unsigned i) const { return axes[i]; }
- void load_mappings()
- {
- mem<QSettings> iniFile = group::ini_file();
-
- for (int i = 0; i < 6; i++)
- {
- axes[i].spline_main.loadSettings(*iniFile, axes[i].name1);
- axes[i].spline_alt.loadSettings(*iniFile, axes[i].name2);
- axes[i].opts.b->reload();
- }
- }
- void save_mappings()
- {
- mem<QSettings> iniFile = group::ini_file();
-
- for (int i = 0; i < 6; i++)
- {
- axes[i].spline_main.saveSettings(*iniFile, axes[i].name1);
- axes[i].spline_alt.saveSettings(*iniFile, axes[i].name2);
- axes[i].opts.b->save();
- }
- }
-
- void invalidate_unsaved()
+ template<typename f> void forall(f&& fun)
{
- for (int i = 0; i < 6; i++)
+ for (unsigned i = 0; i < 6; i++)
{
- axes[i].spline_main.invalidate_unsaved_settings();
- axes[i].spline_alt.invalidate_unsaved_settings();
- axes[i].opts.b->reload();
+ fun(axes[i]);
}
}
};