From cf5ab7886e8228d1622566cc59277bcf089199a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Sep 2014 07:24:52 +0200 Subject: cleanup qfc Issue: #44 Remove confusing logic and retarded comments by the usual offender. Change prototypes a bit for clarity's sake again. --- qfunctionconfigurator/qfunctionconfigurator.h | 72 +++++++++++++-------------- 1 file changed, 34 insertions(+), 38 deletions(-) (limited to 'qfunctionconfigurator/qfunctionconfigurator.h') 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 +/* Copyright (c) 2011-2014 Stanislaw Halik * 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; }; -- cgit v1.2.3