- Timestamp:
- Nov 12, 2009, 9:08:13 AM (15 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigure.cpp
r1935 r1936 64 64 65 65 _counter = 0; 66 _maxRate = 0; 66 67 67 68 QMapIterator<QByteArray, sumAndMean*> it1(_bytes); … … 104 105 // ----------------------------------------------------------- 105 106 if (_counter == MAXCOUNTER) { 107 _maxRate = 0.0; 106 108 QMapIterator<QByteArray, sumAndMean*> it(_bytes); 107 109 while (it.hasNext()) { 108 110 it.next(); 109 111 it.value()->_mean = it.value()->_sum / _counter; 110 it.value()->_sum = 0.0; 111 } 112 it.value()->_sum = 0.0; 113 if (it.value()->_mean > _maxRate) { 114 _maxRate = it.value()->_mean; 115 } 116 } 112 117 _counter = 0; 113 118 } … … 121 126 //////////////////////////////////////////////////////////////////////////// 122 127 void bncFigure::paintEvent(QPaintEvent *) { 123 QRectF rectangle(0, 0, 640, 180); 124 QBrush rBrush(Qt::white,Qt::SolidPattern); 128 129 int xMin = 0; 130 int xMax = 640; 131 int yMin = 0; 132 int yMax = 180; 133 125 134 QPainter painter(this); 126 painter.fillRect(rectangle,rBrush); 127 painter.drawRect(rectangle);128 QLine line(50, 140, 630, 140);129 painter.drawLine( line);130 line.setLine(50, 140, 50, 10);131 painter.draw Line(line);132 QPoint textP(40, 140); 133 painter.drawText(textP, tr("0"));134 textP.setX(20);135 textP.setY(25);136 painter.drawText(textP, tr("3000")); 137 int anker=0;138 textP.setY(160);139 painter.drawText(textP, tr(QTime::currentTime().toString().toAscii())); 140 textP.setX(300);135 136 // y-axis 137 // ------ 138 painter.drawLine(xMin+50, yMax-40, xMin+50, yMin+10); 139 painter.drawText(xMin+40, yMax-40, tr("0")); 140 painter.drawText(xMin+20, yMin+25, tr("100 %")); 141 142 // x-axis 143 // ------ 144 painter.drawLine(xMin+50, yMax-40, xMax-10, yMax-40); 145 146 painter.drawText(xMin+10,yMax-10, 147 tr(QTime::currentTime().toString().toAscii())); 148 149 int anchor = 0; 141 150 142 151 QMapIterator<QByteArray, sumAndMean*> it(_bytes); … … 145 154 QByteArray staID = it.key(); 146 155 double vv = it.value()->_mean; 147 QRectF vrect((100+anker*40), (140-vv), (30), (vv)); 148 QBrush xBrush(Qt::green,Qt::SolidPattern); 149 textP.setX(100+anker*40); 156 157 int xx = xMin+100+anchor*40; 158 159 painter.drawText(xx, yMax-10, staID); 160 161 QRectF vrect(xx, yMax-40-vv, 30, vv); 162 QBrush xBrush(Qt::blue,Qt::SolidPattern); 150 163 painter.fillRect(vrect,xBrush); 151 164 painter.drawRect(vrect); 152 painter.drawText(textP, staID); 153 anker++; 165 anchor++; 154 166 } 155 167 } -
trunk/BNC/bncfigure.h
r1933 r1936 51 51 QMutex _mutex; 52 52 int _counter; 53 double _maxRate; 53 54 }; 54 55
Note:
See TracChangeset
for help on using the changeset viewer.