summaryrefslogtreecommitdiffhomepage
path: root/qfunctionconfigurator/functionconfig.h
blob: 281007d6f09cbd588edc2c439cf9d12ede1893d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Copyright (c) 2011-2012, Stanislaw Halik <sthalik@misaki.pl>

 * 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.
 */

#include <QList>
#include <QPointF>
#include <QString>
#include <QSettings>
#include <QMutex>
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"

#ifndef FUNCTION_CONFIG_H
#define FUNCTION_CONFIG_H

#define MEMOIZE_PRECISION 400

class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig {
private:
    QMutex _mutex;
	QList<QPointF> _points;
	void reload();
    float* _data;
	int _size;
	QString _title;
    float getValueInternal(int x);
	QPointF lastValueTracked;								// The last input value requested by the Tracker, with it's output-value.
	bool _tracking_active;
	int _max_Input;
	int _max_Output;

public:
	//
	// Contructor(s) and destructor
	//
	FunctionConfig(QString title, QList<QPointF> points, int intMaxInput, int intMaxOutput);
	FunctionConfig(QString title, int intMaxInput, int intMaxOutput);
	virtual ~FunctionConfig();

    float getValue(float x);
	bool getLastPoint(QPointF& point);						// Get the last Point that was requested.

	//
	// Functions to manipulate the Function
	//
	void removePoint(int i);
	void addPoint(QPointF pt);
	void movePoint(int idx, QPointF pt);
	QList<QPointF> getPoints();
	void setMaxInput(int MaxInput) {
		_max_Input = MaxInput;
	}
	void setMaxOutput(int MaxOutput) {
		_max_Output = MaxOutput;
	}

	//
	// Functions to load/save the Function-Points to an INI-file
	//
	void saveSettings(QSettings& settings);
	void loadSettings(QSettings& settings);
	void loadSettings(QSettings& settings, QList<QPointF>& defPoints);

	void setTrackingActive(bool blnActive) {
		_tracking_active = blnActive;
	}
    QString getTitle() { return _title; }
};

#endif