diff layer/PaintAssistant.cpp @ 198:c2ed5014d4ff

* Scale fixes and feature descriptions in slice layer
author Chris Cannam
date Thu, 01 Feb 2007 16:54:42 +0000
parents 4a3bdde1ef13
children 8dc50f57d480
line wrap: on
line diff
--- a/layer/PaintAssistant.cpp	Thu Feb 01 14:31:28 2007 +0000
+++ b/layer/PaintAssistant.cpp	Thu Feb 01 16:54:42 2007 +0000
@@ -20,6 +20,8 @@
 #include <QPaintDevice>
 #include <QPainter>
 
+#include <iostream>
+
 void
 PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect,
 					float minVal, float maxVal,
@@ -79,13 +81,16 @@
 
         if (val < minVal || val > maxVal) continue;
 
-        int y = getYForValue(scale, val, minVal, maxVal, rect.y(), rect.height());
+        int y = getYForValue(scale, val, minVal, maxVal, rect.y(), h);
             
         int ny = y;
         if (nval != 0.0) {
-            ny = getYForValue(scale, nval, minVal, maxVal, rect.y(), rect.height());
+            ny = getYForValue(scale, nval, minVal, maxVal, rect.y(), h);
         }
 
+//        std::cerr << "PaintAssistant::paintVerticalLevelScale: val = "
+//                  << val << ", y = " << y << ", h = " << h << std::endl;
+
         bool spaceForLabel = (i == 0 ||
                               abs(y - lastLabelledY) >= textHeight - 1);
         
@@ -97,13 +102,15 @@
             }
             
             int ty = y;
+
             if (ty < paint.fontMetrics().ascent()) {
                 ty = paint.fontMetrics().ascent();
-            } else if (ty > h - paint.fontMetrics().descent()) {
-                ty = h - paint.fontMetrics().descent();
+//            } else if (ty > rect.y() + h - paint.fontMetrics().descent()) {
+//                ty = rect.y() + h - paint.fontMetrics().descent();
             } else {
                 ty += toff;
             }
+
             paint.drawText(tx, ty, text);
             
             lastLabelledY = ty - toff;