2 * Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
3 * Copyright (c) 2009 Dmitry Kazakov <dimula73@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef KIS_CURVE_WIDGET_H
20 #define KIS_CURVE_WIDGET_H
28 #include <QMouseEvent>
31 #include <QPaintEvent>
38 * KisCurveWidget is a widget that shows a single curve that can be edited
39 * by the user. The user can grab the curve and move it; this creates
40 * a new control point. Control points can be deleted by selecting a point
41 * and pressing the delete key.
43 * (From: http://techbase.kde.org/Projects/Widgets_and_Classes#KisCurveWidget)
44 * KisCurveWidget allows editing of spline based y=f(x) curves. Handy for cases
45 * where you want the user to control such things as tablet pressure
46 * response, color transformations, acceleration by time, aeroplane lift
49 class KisCurveWidget : public QWidget
56 * Create a new curve widget with a default curve, that is a straight
57 * line from bottom-left to top-right.
59 KisCurveWidget(QWidget *parent = 0, Qt::WFlags f = 0);
61 virtual ~KisCurveWidget();
64 * Reset the curve to the default shape
69 * Enable the guide and set the guide color to the specified color.
71 * XXX: it seems that the guide feature isn't actually implemented yet?
73 void setCurveGuide(const QColor & color);
77 * Set a background pixmap. The background pixmap will be drawn under
78 * the grid and the curve.
80 * XXX: or is the pixmap what is drawn to the left and bottom of the curve
83 void setPixmap(const QPixmap & pix);
85 virtual QSize sizeHint() const;
90 * Emitted whenever a control point has changed position.
95 void inOutChanged(int);
100 void keyPressEvent(QKeyEvent *);
101 void paintEvent(QPaintEvent *);
102 void mousePressEvent(QMouseEvent * e);
103 void mouseReleaseEvent(QMouseEvent * e);
104 void mouseMoveEvent(QMouseEvent * e);
105 void leaveEvent(QEvent *);
106 void resizeEvent(QResizeEvent *e);
111 * @return get a list with all defined points. If you want to know what the
112 * y value for a given x is on the curve defined by these points, use getCurveValue().
115 KisCubicCurve curve();
118 * Replace the current curve with a curve specified by the curve defined by the control
119 * points in @param inlist.
121 void setCurve(KisCubicCurve inlist);
124 * Connect/disconnect external spinboxes to the curve
125 * @min/@max - is the range for their values
127 void setupInOutControls(QSpinBox *in, QSpinBox *out, int min, int max);
128 void dropInOutControls();
131 * Handy function that creates new point in the middle
132 * of the curve and sets focus on the m_intIn field,
133 * so the user can move this point anywhere in a moment
135 void addPointInTheMiddle();
137 void setMaxPoints(int max);
147 #endif /* KIS_CURVE_WIDGET_H */