]> git.sesse.net Git - kdenlive/commitdiff
Bezier Spline:
authorTill Theato <root@ttill.de>
Thu, 6 Jan 2011 20:54:09 +0000 (20:54 +0000)
committerTill Theato <root@ttill.de>
Thu, 6 Jan 2011 20:54:09 +0000 (20:54 +0000)
- add modes Saturation and Hue (were missing from XML GUI)
- document
- some small cleanups

svn path=/trunk/kdenlive/; revision=5279

effects/frei0r_bezier_curves.xml
src/beziercurve/beziersplineeditor.h
src/beziercurve/cubicbezierspline.cpp
src/beziercurve/cubicbezierspline.h
src/widgets/bezierspline_ui.ui

index 5df3f464a80cba6289beedb33276176dbcfb4703..5bdc3c9a0bb1a2d36cb932379a9c384e9feca82b 100644 (file)
@@ -4,7 +4,7 @@
         <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>
 
@@ -13,6 +13,6 @@
         </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>
index 819ac4f50c66f3943cb314217919bfc5151295e5..eee65c8cb819a3346e8cd0318f924c080ecd263d 100644 (file)
@@ -74,18 +74,24 @@ private:
     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.
index 881d20af7e0e6bd8f53ce45daf38a3609114ecde..9a2be6060c26c4ab3eb4b5639f4cc5f95238df5e 100644 (file)
@@ -168,7 +168,11 @@ void CubicBezierSpline::keepSorted()
 
 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);
@@ -195,7 +199,7 @@ void CubicBezierSpline::update()
                 << 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;
index ebf15e3d9f94506cc702a74c2abb9be387384c2a..d28b0ae8b878be7480ad74446a2cd237c56c96dc 100644 (file)
@@ -33,15 +33,40 @@ public:
     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();
 
@@ -53,11 +78,13 @@ private:
     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
index f7c5f0b2ba50a12a8259fbff176b149bc80dcf2d..efac92ae9237d240262bc6b08f0f2f3634d636d8 100644 (file)
@@ -6,15 +6,21 @@
    <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.&lt;br /&gt;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/>