]> git.sesse.net Git - kdenlive/commitdiff
I/Q Lines: Visual enhancements.
authorSimon A. Eugster <simon.eu@gmail.com>
Fri, 26 Nov 2010 17:08:30 +0000 (17:08 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Fri, 26 Nov 2010 17:08:30 +0000 (17:08 +0000)
Vectorscope: Mouse Circle not limited to the Vectorscope's Circle's bounding rect anymore.

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

src/abstractscopewidget.cpp
src/abstractscopewidget.h
src/vectorscope.cpp
src/vectorscope.h

index 58d199526eddd891fe840730e39cafd65f8a3784..7109704c8f4ffc2f84bbfecbf4e3ca8801233453 100644 (file)
@@ -29,7 +29,9 @@ const QColor dark2(25,  25,  23, 255);
 const QPen AbstractScopeWidget::penThick(QBrush(QColor(250, 250, 250)),     2, Qt::SolidLine);
 const QPen AbstractScopeWidget::penThin(QBrush(QColor(250, 250, 250)),     1, Qt::SolidLine);
 const QPen AbstractScopeWidget::penLight(QBrush(QColor(200, 200, 250, 150)), 1, Qt::SolidLine);
+const QPen AbstractScopeWidget::penLightDots(QBrush(QColor(200, 200, 250, 150)), 1, Qt::DotLine);
 const QPen AbstractScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)),      1, Qt::SolidLine);
+const QPen AbstractScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)),      1, Qt::DotLine);
 
 AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
         QWidget(parent),
index 74623e693d0d6d3f5f7040f75cb8a230e0271748..0d5a597bdc5663966c6002bc35e7d1a6fdb81e51 100644 (file)
@@ -83,7 +83,9 @@ public:
     static const QPen penThick;
     static const QPen penThin;
     static const QPen penLight;
+    static const QPen penLightDots;
     static const QPen penDark;
+    static const QPen penDarkDots;
 
 protected:
     ///// Variables /////
index dbd90f7637ac4f66a653aabf1d7ef899831b402d..860fd61cbfe3b165678acbb1accf14c8af6f82b1 100644 (file)
@@ -179,6 +179,8 @@ QRect Vectorscope::scopeRect()
     QPoint topleft(offset, ui->verticalSpacer->geometry().y()+offset);
     QPoint bottomright(ui->horizontalSpacer->geometry().right()-offset, this->size().height()-offset);
 
+    m_visibleRect = QRect(topleft, bottomright);
+
     QRect scopeRect(topleft, bottomright);
 
     // Circle Width: min of width and height
@@ -216,7 +218,7 @@ QImage Vectorscope::renderHUD(uint)
     if (m_mouseWithinWidget) {
         // Mouse moved: Draw a circle over the scope
 
-        hud = QImage(m_scopeRect.size(), QImage::Format_ARGB32);
+        hud = QImage(m_visibleRect.size(), QImage::Format_ARGB32);
         hud.fill(qRgba(0, 0, 0, 0));
 
         QPainter davinci(&hud);
@@ -286,34 +288,34 @@ QImage Vectorscope::renderBackground(uint)
     QTime start = QTime::currentTime();
     start.start();
 
-    QImage bg;
+    QImage bg(m_visibleRect.size(), QImage::Format_ARGB32);
+    bg.fill(qRgba(0,0,0,0));
+
+    // Set up tools
+    QPainter davinci(&bg);
+    davinci.setRenderHint(QPainter::Antialiasing, true);
+
+    QPoint vinciPoint;
+    QPoint vinciPoint2;
+
+    // Draw the color plane (if selected)
+    QImage colorPlane;
     switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
     case BG_YUV:
-//        qDebug() << "YUV background.";
-        bg = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 128, 1/VectorscopeGenerator::scaling, false, true);
+        colorPlane = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 128, 1/VectorscopeGenerator::scaling, false, true);
+        davinci.drawImage(0, 0, colorPlane);
         break;
     case BG_CHROMA:
-        bg = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 255, 1/VectorscopeGenerator::scaling, true, true);
+        colorPlane = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 255, 1/VectorscopeGenerator::scaling, true, true);
+        davinci.drawImage(0, 0, colorPlane);
         break;
     case BG_YPbPr:
-        bg = m_colorTools->yPbPrColorWheel(m_scopeRect.size(), (unsigned char) 128, 1/VectorscopeGenerator::scaling, true);
-        break;
-    default:
-//        qDebug() << "No background.";
-        bg = QImage(cw, cw, QImage::Format_ARGB32);
-        bg.fill(qRgba(0,0,0,0));
+        colorPlane = m_colorTools->yPbPrColorWheel(m_scopeRect.size(), (unsigned char) 128, 1/VectorscopeGenerator::scaling, true);
+        davinci.drawImage(0, 0, colorPlane);
         break;
     }
 
 
-    // Draw the vectorscope circle
-    QPainter davinci(&bg);
-    QPoint vinciPoint;
-    QPoint vinciPoint2;
-
-
-    davinci.setRenderHint(QPainter::Antialiasing, true);
-
 
     // Draw I/Q lines (from the YIQ color space; Skin tones lie on the I line)
     // Positions are calculated by transforming YIQ:[0 1 0] or YIQ:[0 0 1] to YUV/YPbPr.
@@ -321,10 +323,10 @@ QImage Vectorscope::renderBackground(uint)
 
         switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
         case BG_NONE:
-            davinci.setPen(penLight);
+            davinci.setPen(penLightDots);
             break;
         default:
-            davinci.setPen(penDark);
+            davinci.setPen(penDarkDots);
             break;
         }
 
@@ -333,20 +335,20 @@ QImage Vectorscope::renderBackground(uint)
             vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(.544,-.838));
         } else {
             vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(-.675,.737));
-            vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(.624,-.682));
+            vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(.675,-.737));
         }
 
         davinci.drawLine(vinciPoint, vinciPoint2);
         davinci.setPen(penThick);
-        davinci.drawText(vinciPoint - QPoint(10, 10), "I");
+        davinci.drawText(vinciPoint - QPoint(11, 5), "I");
 
 
         switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
         case BG_NONE:
-            davinci.setPen(penLight);
+            davinci.setPen(penLightDots);
             break;
         default:
-            davinci.setPen(penDark);
+            davinci.setPen(penDarkDots);
             break;
         }
 
@@ -355,18 +357,18 @@ QImage Vectorscope::renderBackground(uint)
             vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(-.838,-.544));
         } else {
             vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(.908, .443));
-            vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(-.962,-.443));
+            vinciPoint2 = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(-.908,-.443));
         }
 
         davinci.drawLine(vinciPoint, vinciPoint2);
         davinci.setPen(penThick);
-        davinci.drawText(vinciPoint - QPoint(-10, 10), "Q");
+        davinci.drawText(vinciPoint - QPoint(-7, 2), "Q");
 
 
 
     }
 
-    // Draw the main circle
+    // Draw the vectorscope circle
     davinci.setPen(penThick);
     davinci.drawEllipse(0, 0, cw, cw);
 
index 0ce55a648ba74cb7fc2ac3b2a29b0454cf749807..d2798caef10f60687b0356fa93df95a8bcc68ef2 100644 (file)
@@ -71,6 +71,9 @@ private:
 
     QPoint m_centerPoint, pR75, pG75, pB75, pCy75, pMg75, pYl75;
     QPoint qR75, qG75, qB75, qCy75, qMg75, qYl75;
+    /** Unlike the scopeRect, this rect represents the overall visible rectangle
+        and not only the square touching the Vectorscope's circle. */
+    QRect m_visibleRect;
 
     /** Updates the dimension. Only necessary when the widget has been resized. */
     void updateDimensions();