krita/ui

kis_curve_widget.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
00003  *  Copyright (c) 2009 Dmitry Kazakov <dimula73@gmail.com>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 #ifndef KIS_CURVE_WIDGET_H
00020 #define KIS_CURVE_WIDGET_H
00021 
00022 // Qt includes.
00023 
00024 #include <QWidget>
00025 #include <QColor>
00026 #include <QPointF>
00027 #include <QPixmap>
00028 #include <QMouseEvent>
00029 #include <QKeyEvent>
00030 #include <QEvent>
00031 #include <QPaintEvent>
00032 #include <QList>
00033 
00034 #include <krita_export.h>
00035 
00036 class QSpinBox;
00037 
00050 class KRITAUI_EXPORT KisCurveWidget : public QWidget
00051 {
00052     Q_OBJECT
00053 
00054 public:
00055 
00060     KisCurveWidget(QWidget *parent = 0, Qt::WFlags f = 0);
00061 
00062     virtual ~KisCurveWidget();
00063 
00067     void reset(void);
00068 
00074     void setCurveGuide(const QColor & color);
00075 
00076 
00084     void setPixmap(const QPixmap & pix);
00085 
00086 signals:
00087 
00091     void modified(void);
00092 
00093 protected slots:
00094     void inOutChanged(int);
00095 
00096 
00097 protected:
00098 
00099     void keyPressEvent(QKeyEvent *);
00100     void paintEvent(QPaintEvent *);
00101     void mousePressEvent(QMouseEvent * e);
00102     void mouseReleaseEvent(QMouseEvent * e);
00103     void mouseMoveEvent(QMouseEvent * e);
00104     void leaveEvent(QEvent *);
00105     void resizeEvent(QResizeEvent *e);
00106 
00107 public:
00108 
00113     static double getCurveValue(const QList<QPointF> &curve, double x);
00114 
00119     double getCurveValue(double x);
00120 
00126     QList<QPointF> getCurve();
00127 
00132     void setCurve(QList<QPointF> inlist);
00133 
00138     void setupInOutControls(QSpinBox *in, QSpinBox *out, int min, int max);
00139     void dropInOutControls();
00140 
00146     void addPointInTheMiddle();
00147 
00148 private:
00149 
00150     class Private;
00151     Private * const d;
00152 
00153 };
00154 
00155 
00156 #endif /* KIS_CURVE_WIDGET_H */