- Timestamp:
- Nov 13, 2009, 11:48:31 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigure.cpp
r1950 r1951 130 130 int xMax = 640; 131 131 int yMin = 0; 132 int yMax = 180; 132 int yMax = 120; 133 float xLine = .60; 134 133 135 134 136 QPainter painter(this); … … 136 138 // y-axis 137 139 // ------ 138 int yLength = (yMax-40) - (yMin+10); 139 painter.drawLine(xMin+50, yMax-40, xMin+50, yMin+10); 140 painter.drawText(xMin+30, yMax-40, tr("0")); 140 int yLength = int((yMax-yMin)*xLine) - (yMin+10); 141 painter.drawLine(xMin+50, int((yMax-yMin)*xLine), xMin+50, yMin+10); 141 142 142 143 QString maxRateStr; 143 144 if (8.0 * _maxRate < 1e3) { 144 maxRateStr = QString("%1 bps").arg(int(8.0 * _maxRate)); 145 maxRateStr = QString("%1 bps").arg(int(8.0 * _maxRate)); 146 painter.drawText(xMin+0, int((yMax-yMin)*xLine), tr("0 bps")); 145 147 } 146 148 else if (8.0 * _maxRate < 1e6) { 147 149 maxRateStr = QString("%1 kbps").arg(int(8.0 * _maxRate / 1.e3)); 150 painter.drawText(xMin+0, int((yMax-yMin)*xLine), tr("0 kbps")); 148 151 } 149 152 else { 150 153 maxRateStr = QString("%1 Mbps").arg(int(8.0 * _maxRate / 1.e6)); 154 painter.drawText(xMin+0, int((yMax-yMin)*xLine), tr("0 Mbps")); 151 155 } 152 156 153 painter.drawText(xMin+0, yMin+25, maxRateStr); 157 if(_maxRate > 0.0) { 158 painter.drawText(xMin+0, yMin+25, maxRateStr); 159 } 154 160 155 161 // x-axis 156 162 // ------ 157 painter.drawLine(xMin+50, yMax-40, xMax-10, yMax-40); 158 159 painter.drawText(xMin+10,yMax-10, 160 tr(QTime::currentTime().toString().toAscii())); 163 painter.drawLine(xMin+50, int((yMax-yMin)*xLine), xMax*3, int((yMax-yMin)*xLine)); 161 164 162 165 int anchor = 0; 163 164 166 QMapIterator<QByteArray, sumAndMean*> it(_bytes); 165 167 while (it.hasNext()) { … … 167 169 QByteArray staID = it.key(); 168 170 169 int xx = xMin+100+anchor*40; 171 int xx = xMin+70+anchor*15; 172 int yy = int(yLength * (it.value()->_mean / _maxRate)); 170 173 171 painter.drawText(xx, yMax-10, staID.left(5)); 174 painter.save(); 175 painter.translate(xx, yMax); 176 painter.rotate(-90); 177 painter.drawText(0, 0, staID.left(5)); 178 painter.restore(); 172 179 173 180 if(_maxRate > 0.0) { 174 int yy = int(yLength * (it.value()->_mean / _maxRate)); 175 painter.fillRect(xx, yMax-40-yy, 30, yy, 176 QBrush(Qt::blue,Qt::SolidPattern)); 181 painter.fillRect(xx-10, int((yMax-yMin)*xLine)-yy, 10, yy, 182 QBrush(Qt::gray,Qt::SolidPattern)); 177 183 } 178 184
Note:
See TracChangeset
for help on using the changeset viewer.