]> git.sesse.net Git - kdenlive/commitdiff
Bezier Spline:
authorTill Theato <root@ttill.de>
Thu, 6 Jan 2011 09:05:58 +0000 (09:05 +0000)
committerTill Theato <root@ttill.de>
Thu, 6 Jan 2011 09:05:58 +0000 (09:05 +0000)
- Add modes hue and saturation
- some documentation

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

src/beziercurve/beziersplineeditor.cpp
src/beziercurve/beziersplineeditor.h
src/beziercurve/beziersplinewidget.cpp
src/beziercurve/beziersplinewidget.h
src/beziercurve/bpoint.h

index c6183ee6406b39b9a301e1053285998531442839..a507f4e0509f295513cf757ba8eb61f9130de4b5 100644 (file)
@@ -216,7 +216,9 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
     for (int i = 0; i <= max; ++i) {
         point = m_spline.points().at(i);
         if (i == m_currentPointIndex) {
+            // selected point: fill p and handles
             p.setBrush(QBrush(QColor(Qt::red), Qt::SolidPattern));
+            // connect p and handles with lines
             if (i != 0)
                 p.drawLine(QLineF(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight, point.p.x() * wWidth, wHeight - point.p.y() * wHeight));
             if (i != max)
index cccb47aa91f18f3a485b3b08a5e3fc0379a947e2..0320e3197f36f1542289365235f99d038b757363 100644 (file)
@@ -48,7 +48,6 @@ public slots:
     void slotZoomOut();
 
 protected:
-    //void keyPressEvent(QKeyEvent *event);
     void paintEvent(QPaintEvent *event);
     void mousePressEvent(QMouseEvent *event);
     void mouseReleaseEvent(QMouseEvent * event);
@@ -74,10 +73,7 @@ private:
     BPoint m_grabPOriginal;
     BPoint m_grabPNext;
     BPoint m_grabPPrevious;
-    //QPointF m_draggedAwayPoint;
-    //int m_draggedAwayPointIndex;
 
-    //inline void drawGrid(QPainter &p, int width, int height);
     int nearestPointInRange(QPointF p, int wWidth, int wHeight, point_types *sel);
 
 signals:
index 5fc7fd1ad2c2ad77d56fcdd8574b2c15e97b5b3e..d22fc02f80aca3eccc0ab7006f04541f2ba7b226 100644 (file)
@@ -47,7 +47,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
     m_edit.setSpline(s);
 
     connect(&m_edit, SIGNAL(modified()), this, SIGNAL(modified()));
-    connect(&m_edit, SIGNAL(currentPoint(const BPoint&)), this, SLOT(slotUpdatePoint(const BPoint&)));
+    connect(&m_edit, SIGNAL(currentPoint(const BPoint&)), this, SLOT(slotUpdatePointEntries(const BPoint&)));
 
     connect(m_ui.spinPX, SIGNAL(editingFinished()), this, SLOT(slotUpdatePointP()));
     connect(m_ui.spinPY, SIGNAL(editingFinished()), this, SLOT(slotUpdatePointP()));
@@ -91,13 +91,13 @@ void BezierSplineWidget::slotShowPixmap(bool show)
 {
     m_showPixmap = show;
     KdenliveSettings::setBezier_showpixmap(show);
-    if (show && m_mode != ModeAlpha && m_mode != ModeRGB)
-        m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)(m_mode)))));
+    if (show && (m_mode == ModeRed || m_mode == ModeGreen || m_mode == ModeBlue || m_mode == ModeLuma ))
+        m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)(m_mode == ModeLuma ? int(m_mode) - 1 : m_mode)))));
     else
         m_edit.setPixmap(QPixmap());
 }
 
-void BezierSplineWidget::slotUpdatePoint(const BPoint &p)
+void BezierSplineWidget::slotUpdatePointEntries(const BPoint &p)
 {
     blockSignals(true);
     if (p == BPoint()) {
index 061784488505a08ce1146282ab362e8fb3ba0ee2..ccdff1983d5fd103297a6c918b75d0b1cbf2f844 100644 (file)
@@ -31,23 +31,37 @@ class BezierSplineWidget : public QWidget
     Q_OBJECT
     
 public:
+    /** @brief Sets up the UI and sets the spline to @param spline. */
     BezierSplineWidget(const QString &spline, QWidget* parent = 0);
 
+    /** @brief Returns the current spline. */
     QString spline();
 
-    enum CurveModes { ModeRed, ModeGreen, ModeBlue, ModeAlpha, ModeLuma, ModeRGB/*, ModeSaturation*/ };
+    /** The curvemodes refer to the usage of the spline.
+     * As this widget is currently only used for frei0r.curves the modes are the channels this filter accepts. */
+    enum CurveModes { ModeRed, ModeGreen, ModeBlue, ModeAlpha, ModeLuma, ModeRGB, ModeHue, ModeSaturation };
+
+    /** @brief Sets the mode to @param mode and updates the editors background pixmap if necessary. */
     void setMode(CurveModes mode);
 
 private slots:
-    void slotUpdatePoint(const BPoint &p);
+    /** @brief Sets the spinboxes for modifing the selected point to @param p. */
+    void slotUpdatePointEntries(const BPoint &p);
 
+    /** @brief Updates the editor and thus the spline if the current point's p was modified using the spinboxes. */
     void slotUpdatePointP();
+    /** @brief Updates the editor and thus the spline if the current point's h1 was modified using the spinboxes. */
     void slotUpdatePointH1();
+    /** @brief Updates the editor and thus the spline if the current point's h2 was modified using the spinboxes. */
     void slotUpdatePointH2();
 
+    /** @brief Increases the number of lines in the editor's grid. If there are already 8 lines the number is set to 0. */
     void slotGridChange();
+    /** @brief Turns showing the background pixmap in the editor on/off. */
     void slotShowPixmap(bool show = true);
+    /** @brief Resets the current spline. */
     void slotResetSpline();
+    /** @brief Linkes the handles. This will always make them stay in one line through p. */
     void slotSetHandlesLinked(bool linked);
 
 private:
index 388cec2019a984152eaac8685e2b99a29c1d297c..2bd1fa29121babdd76d1a40f2a9c12441da3810a 100644 (file)
@@ -64,7 +64,7 @@ public:
     /** handle 2 */
     QPointF h2;
 
-    /** handles are locked to achieve a natural locking spline => PH1 = -r*PH2 ; a line can be drawn through h1, p, h2 */
+    /** handles are linked to achieve a natural locking spline => PH1 = -r*PH2 ; a line can be drawn through h1, p, h2 */
     bool handlesLinked;
 };