<description>Color curves adjustment</description>
<author>Till Theato, Maksim Golovkin</author>
- <parameter type="list" name="Channel" default="0.5" paramlist="0.5,0,0.1,0.2,0.3,0.4" paramlistdisplay="RGB,Red,Green,Blue,Alpha,Luma">
+ <parameter type="list" name="Channel" default="0.5" paramlist="0.5,0,0.1,0.2,0.3,0.4,0.6,0.71" paramlistdisplay="RGB,Red,Green,Blue,Alpha,Luma,Hue,Saturation">
<name>Channel</name>
</parameter>
</parameter>
<parameter type="bezier_spline" name="Bézier spline" depends="Channel" default="-1;-1#0;0#0.1;0.1|0.9;0.9#1;1#2;2">
- <name>Bézier Curve(Spline) Widget</name>
+ <name>Bézier Spline Widget</name>
</parameter>
</effect>
modes m_mode;
int m_zoomLevel;
int m_gridLines;
- /** Whether to show only handles for the selected point for all points. */
+ /** Whether to show handles for all points or only for the selected one. */
bool m_showAllHandles;
+ /** Background */
QPixmap m_pixmap;
+ /** A copy of m_pixmap but scaled to fit the size of the edit region */
QPixmap *m_pixmapCache;
+ /** Whether we have to regenerate the pixmap cache because the pixmap or the size of the edit region changed. */
bool m_pixmapIsDirty;
int m_currentPointIndex;
point_types m_currentPointType;
double m_grabOffsetX;
double m_grabOffsetY;
+ /** selected point before it was modified by dragging (at the time of the mouse press) */
BPoint m_grabPOriginal;
+ /** point with the index currentPointIndex + 1 at the time of the mouse press */
BPoint m_grabPNext;
+ /** point with the index currentPointIndex - 1 at the time of the mouse press */
BPoint m_grabPPrevious;
/** @brief Finds the point nearest to @param p and returns it's index.
QPointF CubicBezierSpline::point(double t, const QList< QPointF >& points)
{
- // coefficients from Bernstein basis polynomial of degree 3
+ /*
+ * Calculating a point on the bezier curve using the coefficients from Bernstein basis polynomial of degree 3.
+ * Using the De Casteljau algorithm would be slightly faster for when calculating a lot of values
+ * but the difference is far from noticable in this needcase
+ */
double c1 = (1-t) * (1-t) * (1-t);
double c2 = 3 * t * (1-t) * (1-t);
double c3 = 3 * t * t * (1-t);
<< m_points.at(i+1).h1
<< m_points.at(i+1).p;
- int numberOfValues = (int)((points[3].x() - points[0].x()) * m_precision * 5);
+ int numberOfValues = (int)((points[3].x() - points[0].x()) * m_precision * 10);
if (numberOfValues == 0)
numberOfValues = 1;
double step = 1 / (double)numberOfValues;
CubicBezierSpline(const CubicBezierSpline &spline, QObject* parent = 0);
CubicBezierSpline& operator=(const CubicBezierSpline &spline);
+ /** @brief Loads the points from the string @param spline.
+ *
+ * x, y values have to be separated with a ';'
+ * handles and points with a '#'
+ * and the nodes with a '|'
+ * So that you get: h1x;h1y#px;py#h2x;h2y|h1x;h1y#... */
void fromString(const QString &spline);
+ /** @brief Returns the points stoed in a string.
+ *
+ * x, y values have are separated with a ';'
+ * handles and points with a '#'
+ * and the nodes with a '|'
+ * So that you get: h1x;h1y#px;py#h2x;h2y|h1x;h1y#... */
QString toString() const;
+ /** @brief Returns a list of the points defining the spline. */
QList <BPoint> points();
+ /** @brief Finds the closest point in the pre-calculated spline to @param x.
+ * @param x x value
+ * @param cont (default = false) Whether to start searching at the previously requested x and skip all values before it.
+ This makes requesting a lot of increasing x's faster. */
qreal value(qreal x, bool cont = false);
+ /** @brief Sets the point at index @param ix to @param point and returns its index (it might have changed during validation). */
int setPoint(int ix, const BPoint &point);
+ /** @brief Adds @param point and returns its index. */
int addPoint(const BPoint &point);
+ /** @brief Removes the point at @param ix. */
void removePoint(int ix);
+
+ /** @brief Sets the precision to @param pre.
+ *
+ * The precision influences the number of points that are calculated for the spline:
+ * number of values = precision * 10 */
void setPrecision(int pre);
int getPrecision();
int indexOf(const BPoint &p);
QList <BPoint> m_points;
+ /** x, y pairs */
QMap <double, double> m_spline;
+ /** iterator used when searching for a value in in continue mode (see @function value). */
QMap <double, double>::const_iterator m_i;
+ /** Whether the spline represents the points and the precision. */
bool m_validSpline;
int m_precision;
-
};
#endif
<rect>
<x>0</x>
<y>0</y>
- <width>351</width>
- <height>78</height>
+ <width>345</width>
+ <height>67</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0" colspan="8">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item row="1" column="0" colspan="9">
<widget class="QWidget" name="widgetPoint" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
</layout>
</widget>
</item>
- <item row="2" column="1">
+ <item row="2" column="2">
<widget class="QToolButton" name="buttonShowPixmap">
<property name="toolTip">
<string>Show background indicating changes caused by modifying the curve.</string>
</property>
</widget>
</item>
- <item row="2" column="4">
+ <item row="2" column="5">
<widget class="QToolButton" name="buttonZoomIn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
- <item row="2" column="5">
+ <item row="2" column="6">
<widget class="QToolButton" name="buttonZoomOut">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
- <item row="2" column="2">
+ <item row="2" column="3">
<widget class="QToolButton" name="buttonGridChange">
<property name="toolTip">
<string>Increases the number of lines in the grid.<br />After 8 lines it will begin from 0 again.</string>
</property>
</widget>
</item>
- <item row="2" column="7">
+ <item row="2" column="8">
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="2" column="0">
+ <item row="2" column="1">
<widget class="QToolButton" name="buttonResetSpline">
<property name="toolTip">
<string>Reset the selected spline</string>
</property>
</widget>
</item>
- <item row="2" column="6">
+ <item row="2" column="7">
<widget class="QToolButton" name="buttonShowAllHandles">
<property name="toolTip">
<string>Show handles for all points or only for the selected one</string>
</property>
</widget>
</item>
+ <item row="2" column="0">
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<resources/>