/* Copyright (c) 2012-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this * software for any purpose with or without fee is hereby granted, * provided that the above copyright notice and this permission * notice appear in all copies. */ #pragma once #include #include #include #include #include #include #include #include #include "opentrack-compat/qcopyable-mutex.hpp" #ifdef BUILD_spline_widget # define SPLINE_WIDGET_EXPORT Q_DECL_EXPORT #else # define SPLINE_WIDGET_EXPORT Q_DECL_IMPORT #endif class SPLINE_WIDGET_EXPORT Map { private: static constexpr int value_count = 10000; struct State { QList input; std::vector data; }; int precision() const; void reload(); float getValueInternal(int x); MyMutex _mutex; QPointF last_input_value; double max_x; double max_y; volatile bool activep; State cur, saved; public: double maxInput() const; double maxOutput() const; Map(); Map(double maxx, double maxy); float getValue(float x); bool getLastPoint(QPointF& point); void removePoint(int i); void removeAllPoints(); void addPoint(QPointF pt); void movePoint(int idx, QPointF pt); const QList getPoints(); void setMaxInput(double MaxInput); void setMaxOutput(double MaxOutput); void saveSettings(QSettings& settings, const QString& title); void loadSettings(QSettings& settings, const QString& title); void invalidate_unsaved_settings(); void setTrackingActive(bool blnActive); };