summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--qfunctionconfigurator/functionconfig.cpp38
-rw-r--r--qfunctionconfigurator/functionconfig.h14
-rw-r--r--qfunctionconfigurator/qfunctionconfigurator.cpp13
3 files changed, 33 insertions, 32 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp
index 264097ab..2b9d3a07 100644
--- a/qfunctionconfigurator/functionconfig.cpp
+++ b/qfunctionconfigurator/functionconfig.cpp
@@ -54,17 +54,17 @@ float Map::getValueInternal(int x) {
return ret * sign;
}
-static __inline QPointF ensureInBounds(QList<QPointF> points, int i) {
- int siz = points.size();
- if (siz == 0 || i < 0)
- return QPointF(0, 0);
- if (siz > i)
- return points[i];
- return points[siz - 1];
+static QPointF ensureInBounds(QList<QPointF> points, int i) {
+ int siz = points.size();
+ if (siz == 0 || i < 0)
+ return QPointF(0, 0);
+ if (siz > i)
+ return points[i];
+ return points[siz - 1];
}
static bool sortFn(const QPointF& one, const QPointF& two) {
- return one.x() < two.x();
+ return one.x() < two.x();
}
void Map::reload() {
@@ -149,8 +149,8 @@ void Map::removePoint(int i) {
void Map::addPoint(QPointF pt) {
QMutexLocker foo(&_mutex);
- cur.input.append(pt);
- reload();
+ cur.input.append(pt);
+ reload();
}
void Map::movePoint(int idx, QPointF pt) {
@@ -182,15 +182,15 @@ void Map::loadSettings(QSettings& settings, const QString& title) {
int max = settings.value("point-count", 0).toInt();
for (int i = 0; i < max; i++) {
- newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(),
- settings.value(QString("point-%1-y").arg(i), 0).toFloat());
- if (newPoint.x() > max_x) {
- newPoint.setX(max_x);
- }
- if (newPoint.y() > max_y) {
- newPoint.setY(max_y);
- }
- points.append(newPoint);
+ newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(),
+ settings.value(QString("point-%1-y").arg(i), 0).toFloat());
+ if (newPoint.x() > max_x) {
+ newPoint.setX(max_x);
+ }
+ if (newPoint.y() > max_y) {
+ newPoint.setY(max_y);
+ }
+ points.append(newPoint);
}
settings.endGroup();
diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h
index f7930cb2..7ead2c5d 100644
--- a/qfunctionconfigurator/functionconfig.h
+++ b/qfunctionconfigurator/functionconfig.h
@@ -32,15 +32,15 @@ private:
MyMutex _mutex;
QPointF last_input_value;
volatile bool activep;
- int max_x;
- int max_y;
+ double max_x;
+ double max_y;
State cur, saved;
public:
- int maxInput() const { return max_x; }
- int maxOutput() const { return max_y; }
+ double maxInput() const { return max_x; }
+ double maxOutput() const { return max_y; }
Map();
- Map(int maxx, int maxy)
+ Map(double maxx, double maxy)
{
setMaxInput(maxx);
setMaxOutput(maxy);
@@ -58,10 +58,10 @@ public:
void addPoint(QPointF pt);
void movePoint(int idx, QPointF pt);
const QList<QPointF> getPoints();
- void setMaxInput(int MaxInput) {
+ void setMaxInput(double MaxInput) {
max_x = MaxInput;
}
- void setMaxOutput(int MaxOutput) {
+ void setMaxOutput(double MaxOutput) {
max_y = MaxOutput;
}
diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp
index 3d86216e..d3525c1d 100644
--- a/qfunctionconfigurator/qfunctionconfigurator.cpp
+++ b/qfunctionconfigurator/qfunctionconfigurator.cpp
@@ -22,7 +22,8 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) :
void QFunctionConfigurator::setConfig(Map* config, const QString& name) {
mem<QSettings> iniFile = group::ini_file();
- config->loadSettings(*iniFile, name);
+ if (name != "")
+ config->loadSettings(*iniFile, name);
_config = config;
_draw_function = true;
update_range();
@@ -49,8 +50,8 @@ void QFunctionConfigurator::drawBackground()
QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine);
const int xstep = 10, ystep = 10;
- const int maxx = _config->maxInput();
- const int maxy = _config->maxOutput();
+ const double maxx = _config->maxInput();
+ const double maxy = _config->maxOutput();
// horizontal grid
for (int i = 0; i < maxy; i += xstep)
@@ -68,7 +69,7 @@ void QFunctionConfigurator::drawBackground()
}
{
- const int i = maxy;
+ const double i = maxy;
double y = pixel_bounds.height() - i * c.y() + pixel_bounds.y();
drawLine(&painter,
QPointF(pixel_bounds.x(), y),
@@ -97,7 +98,7 @@ void QFunctionConfigurator::drawBackground()
text);
}
{
- const int i = maxx;
+ const double i = maxx;
double x = pixel_bounds.x() + i * c.x();
drawLine(&painter,
QPointF(x, pixel_bounds.y()),
@@ -132,7 +133,7 @@ void QFunctionConfigurator::drawFunction()
QPen pen(spline_color, 1.2, Qt::SolidLine);
const double max = _config->maxInput();
- const double step = std::max(1e-2, max / 500.);
+ const double step = std::max(1e-3, max / 1000.);
QPointF prev = point_to_pixel(QPointF(0, 0));
for (double i = 0; i < max; i += step) {