Changeset 1932 in ntrip for trunk/BNC/bncwindow.cpp
- Timestamp:
- Nov 12, 2009, 7:42:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncwindow.cpp
r1931 r1932 53 53 #include "bnctableitem.h" 54 54 #include "bncsettings.h" 55 #include "bncfigure.h" 55 56 56 57 using namespace std; … … 58 59 // Constructor 59 60 //////////////////////////////////////////////////////////////////////////// 60 FWidget::FWidget(QWidget *parent) : QWidget(parent) {61 bncSettings settings;62 QListIterator<QString> it(settings.value("mountPoints").toStringList());63 while (it.hasNext()) {64 QStringList hlp = it.next().split(" ");65 QUrl url(hlp[0]);66 QByteArray staID = url.path().mid(1).toAscii();67 _bytes[staID] = new sumAndMean();68 }69 _counter = 0;70 slotNextAnimationFrame();71 }72 73 // Destructor74 ////////////////////////////////////////////////////////////////////////////75 FWidget::~FWidget() {76 }77 78 //79 ////////////////////////////////////////////////////////////////////////////80 void FWidget::slotNewData(const QByteArray staID, double nbyte) {81 QMutexLocker locker(&_mutex);82 QMap<QByteArray, sumAndMean*>::const_iterator it = _bytes.find(staID);83 if (it != _bytes.end()) {84 it.value()->_sum += nbyte;85 }86 }87 88 //89 ////////////////////////////////////////////////////////////////////////////90 void FWidget::slotNextAnimationFrame() {91 QMutexLocker locker(&_mutex);92 if (++_counter == 10) {93 QMapIterator<QByteArray, sumAndMean*> it(_bytes);94 while (it.hasNext()) {95 it.next();96 it.value()->_mean = it.value()->_sum / _counter;97 it.value()->_sum = 0.0;98 }99 _counter = 0;100 }101 update();102 QTimer::singleShot(1000, this, SLOT(slotNextAnimationFrame()));103 }104 105 //106 ////////////////////////////////////////////////////////////////////////////107 void FWidget::paintEvent(QPaintEvent *) {108 QRectF rectangle(0, 0, 640, 180);109 QBrush rBrush(Qt::white,Qt::SolidPattern);110 QPainter painter(this);111 painter.fillRect(rectangle,rBrush);112 painter.drawRect(rectangle);113 QLine line(50, 140, 630, 140);114 painter.drawLine(line);115 line.setLine(50, 140, 50, 10);116 painter.drawLine(line);117 QPoint textP(40, 140);118 painter.drawText(textP, tr("0"));119 textP.setX(20);120 textP.setY(25);121 painter.drawText(textP, tr("3000"));122 int anker=0;123 textP.setY(160);124 painter.drawText(textP, tr(QTime::currentTime().toString().toAscii()));125 textP.setX(300);126 127 QMapIterator<QByteArray, sumAndMean*> it(_bytes);128 while (it.hasNext()) {129 it.next();130 QByteArray staID = it.key();131 double vv = it.value()->_mean;132 QRectF vrect((100+anker*40), (140-vv), (30), (vv));133 QBrush xBrush(Qt::green,Qt::SolidPattern);134 textP.setX(100+anker*40);135 painter.fillRect(vrect,xBrush);136 painter.drawRect(vrect);137 painter.drawText(textP, staID);138 anker++;139 }140 }141 142 // Constructor143 ////////////////////////////////////////////////////////////////////////////144 61 bncWindow::bncWindow() { 145 62 146 63 _caster = 0; 147 64 148 _ Figure1 = new FWidget(this);65 _bncFigure = new bncFigure(this); 149 66 150 67 int ww = QFontMetrics(this->font()).width('w'); … … 491 408 // ---------- 492 409 QGridLayout* log2Layout = new QGridLayout; 493 log2Layout->addWidget(_ Figure1, 0,0);410 log2Layout->addWidget(_bncFigure, 0,0); 494 411 log2group->setLayout(log2Layout); 495 412 … … 1323 1240 ((bncTableItem*) _mountPointsTable->item(iRow, 7))->setGetThread(thread); 1324 1241 connect(thread, SIGNAL(newBytes(QByteArray, double)), 1325 _ Figure1, SLOT(slotNewData(QByteArray, double)));1242 _bncFigure, SLOT(slotNewData(QByteArray, double))); 1326 1243 1327 1244 break;
Note:
See TracChangeset
for help on using the changeset viewer.