summaryrefslogtreecommitdiffhomepage
path: root/qfunctionconfigurator/qfunctionconfigurator.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-09-18 07:24:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-09-18 07:39:58 +0200
commitcf5ab7886e8228d1622566cc59277bcf089199a9 (patch)
tree2f35b7e417a634e8736f5a9a75113aee21ec5b57 /qfunctionconfigurator/qfunctionconfigurator.h
parentf95add4571874c58b35ff4929bcea75dc4080e16 (diff)
cleanup qfc
Issue: #44 Remove confusing logic and retarded comments by the usual offender. Change prototypes a bit for clarity's sake again.
Diffstat (limited to 'qfunctionconfigurator/qfunctionconfigurator.h')
-rw-r--r--qfunctionconfigurator/qfunctionconfigurator.h72
1 files changed, 34 insertions, 38 deletions
diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h
index e4af0062..4643f0d5 100644
--- a/qfunctionconfigurator/qfunctionconfigurator.h
+++ b/qfunctionconfigurator/qfunctionconfigurator.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2012 Stanislaw Halik <sthalik@misaki.pl>
+/* Copyright (c) 2011-2014 Stanislaw Halik <sthalik@misaki.pl>
* Adapted to FaceTrackNoIR by Wim Vriend.
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,73 +16,69 @@
class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget
{
Q_OBJECT
- Q_PROPERTY(QString Name READ get_name WRITE set_name)
+ Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier)
+public:
+ QFunctionConfigurator(QWidget *parent = 0);
+
+ FunctionConfig* config();
+ void setConfig(FunctionConfig* config, const QString &name);
+
+ void saveSettings(QString settingsFile, const QString &name);
QColor colorBezier() const
{
- return colBezier;
+ return spline_color;
}
void setColorBezier(QColor color)
{
- colBezier = color;
+ spline_color = color;
update();
}
- QString get_name() const {
- return name;
- }
- void set_name(QString name)
- {
- this->name = name;
- }
-public:
- QFunctionConfigurator(QWidget *parent = 0);
- FunctionConfig* config();
-
- void setConfig(FunctionConfig* config);
- void saveSettings(QString settingsFile);
-public slots:
protected slots:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
-protected:
+private:
void drawBackground();
void drawFunction();
void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG );
- void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen);
- bool point_within_pixel(QPointF pt, QPointF pixel) const;
+ void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen& pen);
+ bool point_within_pixel(const QPointF& pt, const QPointF& pixel);
protected:
virtual void resizeEvent(QResizeEvent *);
-
private:
- QString name;
void update_range() {
if (!_config)
return;
- double w = width(), h = height();
+
+ const double w = width(), h = height();
const double mwl = 40, mhl = 20;
const double mwr = 15, mhr = 35;
- range = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr));
- c = QPointF(range.width() / _config->maxInput(), range.height() / _config->maxOutput());
- _draw_function = _draw_background = true;
+
+ pixel_bounds = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr));
+ c = QPointF(pixel_bounds.width() / _config->maxInput(), pixel_bounds.height() / _config->maxOutput());
+ _draw_function = true;
+
+ _background = QPixmap();
+ _function = QPixmap();
}
- QRectF range;
- QPointF lastPoint;
- QPointF pixel_coord_to_point (QPointF point) const;
- QPointF point_to_pixel (QPointF point) const;
+ QPointF pixel_coord_to_point (const QPointF& point);
+ QPointF point_to_pixel (const QPointF& point);
- int movingPoint;
+ FunctionConfig* _config;
+
+ // bounds of the rectangle user can interact with
+ QRectF pixel_bounds;
+
+ int moving_control_point_idx;
QElapsedTimer timer;
QPointF c;
- QColor colBezier;
-
- bool _draw_background;
+ QColor spline_color;
+
QPixmap _background;
- bool _draw_function;
QPixmap _function;
-
- FunctionConfig* _config;
+ bool _draw_function;
};