comparison 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
comparison
equal deleted inserted replaced
197:6b023411087b 198:c2ed5014d4ff
17 17
18 #include "base/AudioLevel.h" 18 #include "base/AudioLevel.h"
19 19
20 #include <QPaintDevice> 20 #include <QPaintDevice>
21 #include <QPainter> 21 #include <QPainter>
22
23 #include <iostream>
22 24
23 void 25 void
24 PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect, 26 PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect,
25 float minVal, float maxVal, 27 float minVal, float maxVal,
26 Scale scale, std::vector<int> *vy) 28 Scale scale, std::vector<int> *vy)
77 break; 79 break;
78 } 80 }
79 81
80 if (val < minVal || val > maxVal) continue; 82 if (val < minVal || val > maxVal) continue;
81 83
82 int y = getYForValue(scale, val, minVal, maxVal, rect.y(), rect.height()); 84 int y = getYForValue(scale, val, minVal, maxVal, rect.y(), h);
83 85
84 int ny = y; 86 int ny = y;
85 if (nval != 0.0) { 87 if (nval != 0.0) {
86 ny = getYForValue(scale, nval, minVal, maxVal, rect.y(), rect.height()); 88 ny = getYForValue(scale, nval, minVal, maxVal, rect.y(), h);
87 } 89 }
90
91 // std::cerr << "PaintAssistant::paintVerticalLevelScale: val = "
92 // << val << ", y = " << y << ", h = " << h << std::endl;
88 93
89 bool spaceForLabel = (i == 0 || 94 bool spaceForLabel = (i == 0 ||
90 abs(y - lastLabelledY) >= textHeight - 1); 95 abs(y - lastLabelledY) >= textHeight - 1);
91 96
92 if (spaceForLabel) { 97 if (spaceForLabel) {
95 if (scale != LinearScale) { 100 if (scale != LinearScale) {
96 tx = w - 10 - paint.fontMetrics().width(text); 101 tx = w - 10 - paint.fontMetrics().width(text);
97 } 102 }
98 103
99 int ty = y; 104 int ty = y;
105
100 if (ty < paint.fontMetrics().ascent()) { 106 if (ty < paint.fontMetrics().ascent()) {
101 ty = paint.fontMetrics().ascent(); 107 ty = paint.fontMetrics().ascent();
102 } else if (ty > h - paint.fontMetrics().descent()) { 108 // } else if (ty > rect.y() + h - paint.fontMetrics().descent()) {
103 ty = h - paint.fontMetrics().descent(); 109 // ty = rect.y() + h - paint.fontMetrics().descent();
104 } else { 110 } else {
105 ty += toff; 111 ty += toff;
106 } 112 }
113
107 paint.drawText(tx, ty, text); 114 paint.drawText(tx, ty, text);
108 115
109 lastLabelledY = ty - toff; 116 lastLabelledY = ty - toff;
110 /* 117 /*
111 if (ny != y) { 118 if (ny != y) {