From a45d0e113511913867802d8cb6bed143eacf7696 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Thu, 6 Jan 2011 09:05:58 +0000 Subject: [PATCH] Bezier Spline: - Add modes hue and saturation - some documentation svn path=/trunk/kdenlive/; revision=5274 --- src/beziercurve/beziersplineeditor.cpp | 2 ++ src/beziercurve/beziersplineeditor.h | 4 ---- src/beziercurve/beziersplinewidget.cpp | 8 ++++---- src/beziercurve/beziersplinewidget.h | 18 ++++++++++++++++-- src/beziercurve/bpoint.h | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/beziercurve/beziersplineeditor.cpp b/src/beziercurve/beziersplineeditor.cpp index c6183ee6..a507f4e0 100644 --- a/src/beziercurve/beziersplineeditor.cpp +++ b/src/beziercurve/beziersplineeditor.cpp @@ -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) diff --git a/src/beziercurve/beziersplineeditor.h b/src/beziercurve/beziersplineeditor.h index cccb47aa..0320e319 100644 --- a/src/beziercurve/beziersplineeditor.h +++ b/src/beziercurve/beziersplineeditor.h @@ -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: diff --git a/src/beziercurve/beziersplinewidget.cpp b/src/beziercurve/beziersplinewidget.cpp index 5fc7fd1a..d22fc02f 100644 --- a/src/beziercurve/beziersplinewidget.cpp +++ b/src/beziercurve/beziersplinewidget.cpp @@ -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()) { diff --git a/src/beziercurve/beziersplinewidget.h b/src/beziercurve/beziersplinewidget.h index 06178448..ccdff198 100644 --- a/src/beziercurve/beziersplinewidget.h +++ b/src/beziercurve/beziersplinewidget.h @@ -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: diff --git a/src/beziercurve/bpoint.h b/src/beziercurve/bpoint.h index 388cec20..2bd1fa29 100644 --- a/src/beziercurve/bpoint.h +++ b/src/beziercurve/bpoint.h @@ -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; }; -- 2.39.2