[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [labplot/gsoc2015-datapicker] src/kdefrontend/widgets: datapicker histogram minor fix
From:       Ankit Wagadre <wagadre.ankit () gmail ! com>
Date:       2016-01-26 20:54:51
Message-ID: E1aOAdX-0003g0-1O () scm ! kde ! org
[Download RAW message or body]

Git commit bfc8a2a6282b35416c5fb4b768d9f88032b7a2a5 by Ankit Wagadre.
Committed on 26/01/2016 at 20:25.
Pushed by ankitw into branch 'gsoc2015-datapicker'.

datapicker histogram minor fix

M  +12   -2    src/kdefrontend/widgets/ImageWidget.cpp

http://commits.kde.org/labplot/bfc8a2a6282b35416c5fb4b768d9f88032b7a2a5

diff --git a/src/kdefrontend/widgets/ImageWidget.cpp \
b/src/kdefrontend/widgets/ImageWidget.cpp index d680ac1..6754e8b 100644
--- a/src/kdefrontend/widgets/ImageWidget.cpp
+++ b/src/kdefrontend/widgets/ImageWidget.cpp
@@ -72,6 +72,8 @@ HistogramView::HistogramView(QWidget* parent, int range) :
 }
 
 void HistogramView::setScalePixmap(const QString& file) {
+    // scene rect is 1000*100 where upper 1000*80 is for histogram graph
+    // and lower 1000*20 is for histogram scale
     QGraphicsPixmapItem* pixmap = new QGraphicsPixmapItem(QPixmap(file).scaled( \
1000, 20, Qt::IgnoreAspectRatio), 0, m_scene);  pixmap->setZValue(-1);
     pixmap->setPos(0, 90);
@@ -98,9 +100,17 @@ void HistogramView::drawBackground(QPainter* painter, const \
QRectF& rect) {  max = bins [i];
 
     // convert y-scale count to log scale so small counts are still visible
+    // scene rect is 1000*100 where upper 1000*80 is for histogram graph
+    // and lower 1000*20 is for histogram scale
     QPainterPath path(QPointF(0, (log(bins[0])*100/log(max))));
-    for (int i = 1; i <= m_range; i++)
-        path.lineTo(QPointF(i*1000/m_range, 80 - (log(bins[i])*80/log(max))));
+    for (int i = 1; i <= m_range; i++) {
+        int x = i*1000/m_range;
+        int y = 80;
+        if ( bins[i] > 1 )
+            y = 80 - (log(bins[i])*80/log(max));
+
+        path.lineTo(QPointF(x, y));
+    }
 
     painter->drawPath(path);
     invalidateScene(rect, QGraphicsScene::BackgroundLayer);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic