source: ntrip/trunk/BNC/bncfigure.cpp@ 1932

Last change on this file since 1932 was 1932, checked in by mervart, 14 years ago

* empty log message *

File size: 3.9 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncFigure
30 *
31 * Purpose:
32 *
33 * Author: Perlt, Mervart
34 *
35 * Created: 11-Nov-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include "bncfigure.h"
44#include "bncsettings.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncFigure::bncFigure(QWidget *parent) : QWidget(parent) {
51 bncSettings settings;
52 QListIterator<QString> it(settings.value("mountPoints").toStringList());
53 while (it.hasNext()) {
54 QStringList hlp = it.next().split(" ");
55 QUrl url(hlp[0]);
56 QByteArray staID = url.path().mid(1).toAscii();
57 _bytes[staID] = new sumAndMean();
58 }
59 _counter = 0;
60 slotNextAnimationFrame();
61}
62
63// Destructor
64////////////////////////////////////////////////////////////////////////////
65bncFigure::~bncFigure() {
66}
67
68//
69////////////////////////////////////////////////////////////////////////////
70void bncFigure::slotNewData(const QByteArray staID, double nbyte) {
71 QMutexLocker locker(&_mutex);
72 QMap<QByteArray, sumAndMean*>::const_iterator it = _bytes.find(staID);
73 if (it != _bytes.end()) {
74 it.value()->_sum += nbyte;
75 }
76}
77
78//
79////////////////////////////////////////////////////////////////////////////
80void bncFigure::slotNextAnimationFrame() {
81 QMutexLocker locker(&_mutex);
82 if (++_counter == 10) {
83 QMapIterator<QByteArray, sumAndMean*> it(_bytes);
84 while (it.hasNext()) {
85 it.next();
86 it.value()->_mean = it.value()->_sum / _counter;
87 it.value()->_sum = 0.0;
88 }
89 _counter = 0;
90 }
91 update();
92 QTimer::singleShot(1000, this, SLOT(slotNextAnimationFrame()));
93}
94
95//
96////////////////////////////////////////////////////////////////////////////
97void bncFigure::paintEvent(QPaintEvent *) {
98 QRectF rectangle(0, 0, 640, 180);
99 QBrush rBrush(Qt::white,Qt::SolidPattern);
100 QPainter painter(this);
101 painter.fillRect(rectangle,rBrush);
102 painter.drawRect(rectangle);
103 QLine line(50, 140, 630, 140);
104 painter.drawLine(line);
105 line.setLine(50, 140, 50, 10);
106 painter.drawLine(line);
107 QPoint textP(40, 140);
108 painter.drawText(textP, tr("0"));
109 textP.setX(20);
110 textP.setY(25);
111 painter.drawText(textP, tr("3000"));
112 int anker=0;
113 textP.setY(160);
114 painter.drawText(textP, tr(QTime::currentTime().toString().toAscii()));
115 textP.setX(300);
116
117 QMapIterator<QByteArray, sumAndMean*> it(_bytes);
118 while (it.hasNext()) {
119 it.next();
120 QByteArray staID = it.key();
121 double vv = it.value()->_mean;
122 QRectF vrect((100+anker*40), (140-vv), (30), (vv));
123 QBrush xBrush(Qt::green,Qt::SolidPattern);
124 textP.setX(100+anker*40);
125 painter.fillRect(vrect,xBrush);
126 painter.drawRect(vrect);
127 painter.drawText(textP, staID);
128 anker++;
129 }
130}
131
Note: See TracBrowser for help on using the repository browser.