source: ntrip/trunk/BNC/bncwindow.cpp@ 375

Last change on this file since 375 was 375, checked in by weber, 17 years ago

* empty log message *

File size: 28.8 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters,
3// written by Leos Mervart.
4//
5// Copyright (C) 2006
6// German Federal Agency for Cartography and Geodesy (BKG)
7// http://www.bkg.bund.de
8// Czech Technical University Prague, Department of Advanced Geodesy
9// http://www.fsv.cvut.cz
10//
11// Email: euref-ip@bkg.bund.de
12//
13// This program is free software; you can redistribute it and/or
14// modify it under the terms of the GNU General Public License
15// as published by the Free Software Foundation, version 2.
16//
17// This program is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU General Public License for more details.
21//
22// You should have received a copy of the GNU General Public License
23// along with this program; if not, write to the Free Software
24// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26/* -------------------------------------------------------------------------
27 * BKG NTRIP Client
28 * -------------------------------------------------------------------------
29 *
30 * Class: bncWindow
31 *
32 * Purpose: This class implements the main application window.
33 *
34 * Author: L. Mervart
35 *
36 * Created: 24-Dec-2005
37 *
38 * Changes:
39 *
40 * -----------------------------------------------------------------------*/
41
42#include <unistd.h>
43#include "bncwindow.h"
44#include "bncapp.h"
45#include "bncgetthread.h"
46#include "bnctabledlg.h"
47#include "bnchlpdlg.h"
48#include "bnchtml.h"
49#include "bnctableitem.h"
50
51using namespace std;
52
53// Constructor
54////////////////////////////////////////////////////////////////////////////
55bncWindow::bncWindow() {
56
57 int ww = QFontMetrics(this->font()).width('w');
58
59 static const QStringList labels = QString("account,mountpoint,decoder,lat,long,type,bytes").split(",");
60
61 setMinimumSize(77*ww, 65*ww);
62
63 setWindowTitle(tr("BKG Ntrip Client (BNC), Version 1.1b"));
64
65 // Create Actions
66 // --------------
67 _actHelp = new QAction(tr("&Help Contents"),this);
68 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
69
70 _actAbout = new QAction(tr("&About BNC"),this);
71 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
72
73 _actFontSel = new QAction(tr("Select &Font"),this);
74 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
75
76 _actSaveOpt = new QAction(tr("&Save Options"),this);
77 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
78
79 _actQuit = new QAction(tr("&Quit"),this);
80 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
81
82 _actAddMountPoints = new QAction(tr("Add &Mountpoints"),this);
83 connect(_actAddMountPoints, SIGNAL(triggered()), SLOT(slotAddMountPoints()));
84
85 _actDeleteMountPoints = new QAction(tr("&Delete Mountpoints"),this);
86 connect(_actDeleteMountPoints, SIGNAL(triggered()), SLOT(slotDeleteMountPoints()));
87 _actDeleteMountPoints->setEnabled(false);
88
89 _actGetData = new QAction(tr("Sta&rt"),this);
90 connect(_actGetData, SIGNAL(triggered()), SLOT(slotGetData()));
91
92 _actStop = new QAction(tr("Sto&p"),this);
93 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
94 _actStop->setEnabled(false);
95
96 // Create Menus
97 // ------------
98 _menuFile = menuBar()->addMenu(tr("&File"));
99 _menuFile->addAction(_actFontSel);
100 _menuFile->addSeparator();
101 _menuFile->addAction(_actSaveOpt);
102 _menuFile->addSeparator();
103 _menuFile->addAction(_actQuit);
104
105 _menuHlp = menuBar()->addMenu(tr("&Help"));
106 _menuHlp->addAction(_actHelp);
107 _menuHlp->addAction(_actAbout);
108
109 // Tool (Command) Bar
110 // ------------------
111 QToolBar* toolBar = new QToolBar;
112 addToolBar(Qt::BottomToolBarArea, toolBar);
113 toolBar->setMovable(false);
114 toolBar->addAction(_actAddMountPoints);
115 toolBar->addAction(_actDeleteMountPoints);
116 toolBar->addAction(_actGetData);
117 toolBar->addAction(_actStop);
118
119 // Canvas with Editable Fields
120 // ---------------------------
121 _canvas = new QWidget;
122 setCentralWidget(_canvas);
123
124 QGridLayout* layout = new QGridLayout;
125 _canvas->setLayout(layout);
126
127 QSettings settings;
128 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
129 _proxyHostLineEdit->setMaximumWidth(12*ww);
130 _proxyHostLineEdit->setWhatsThis(tr("<p>You may like to run BNC in a Local Area Network (LAN). LANs are often protected by a proxy server. Enter your proxy server host IP name or number and port number in case one is operated in front of BNC. If you don't know the IP and port of your proxy server, check out the proxy server settings of your Internet browser or ask your network administrator.</p><p>Note that IP streaming may generally be denied in a LAN. In such a case you need to ask your network administrator for an appropriate modification of his security policy or for the installation of a TCP relay to involved NTRIP broadcasters. If that doesn't work out, run BNC outside your LAN on a host that is connected to the Internet through an Internet Service Provider (ISP).</p>"));
131 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
132 _proxyPortLineEdit->setMaximumWidth(9*ww);
133 _proxyPortLineEdit->setWhatsThis(tr("<p>You may like to run BNC in a Local Area Network (LAN). LANs are often protected by a proxy server. Enter your proxy server host IP name or number and port number in case one is operated in front of BNC. If you don't know the IP and port of your proxy server, check out the proxy server settings of your Internet browser or ask your network administrator.</p><p>Note that IP streaming may generally be denied in a LAN. In such a case you need to ask your network administrator for an appropriate modification of his security policy or for the installation of a TCP relay to involved NTRIP broadcasters. If that doesn't work out, run BNC outside your LAN on a host that is connected to the Internet through an Internet Service Provider (ISP).</p>"));
134 _waitTimeSpinBox = new QSpinBox();
135 _waitTimeSpinBox->setMinimum(1);
136 _waitTimeSpinBox->setMaximum(30);
137 _waitTimeSpinBox->setSingleStep(1);
138 _waitTimeSpinBox->setSuffix(" sec");
139 _waitTimeSpinBox->setMaximumWidth(9*ww);
140 _waitTimeSpinBox->setValue(settings.value("waitTime").toInt());
141 _waitTimeSpinBox->setWhatsThis(tr("<p>BNC lets you output synchronized observations epoch by epoch. When feeding a real-time GNSS engine waiting for input, BNC ignores whatever is received later than 'Wait for full epoch' seconds. A value of 3 to 5 seconds could be an appropriate choice for that, depending on the latency of the incoming streams and the delay you can accept for your real-time GNSS product.</p><p>Default value for 'Wait for full epoch' is 1 second. Note that 'Wait for full epoch' does not influence the RINEX file contents. Observations received later than 'Wait for full epoch' seconds will still be included in the RINEX files.</p>"));
142 _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
143 _outFileLineEdit->setWhatsThis(tr("<p>Enter the full path for a file to save synchronized observations in a plain ASCII format.</p><p>Default value is an empty option field, meaning that no ASCII output file is created.</p>"));
144 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
145 _outPortLineEdit->setMaximumWidth(9*ww);
146 _outPortLineEdit->setWhatsThis(tr("<p>BNC makes synchronized observations available in a binary format on your local host (IP 127.0.0.1) through an IP port. Enter an IP port number to activate this function.</p><p>Default is an empty option field, meaning that no binary outputis generated.</p>"));
147 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
148_rnxPathLineEdit->setWhatsThis(tr("<p>Observations can be converted to RINEX Version 2.11. Enter a path for saving the RINEX files in a directory. If this directory does not exist, BNC will not create RINEX files.</p><p>Default value for 'RINEX directory' is an empty option field, meaning that streams are not converted to RINEX.</p>"));
149 _rnxScrpLineEdit = new QLineEdit(settings.value("rnxScript").toString());
150_rnxScrpLineEdit->setWhatsThis(tr("<p>Whenever a RINEX file is saved, you may like to compress, copy or upload it immediately via FTP. For that you enter the full path of a script or batch file which is then called to carry out these operations. The RINEX file path will be passed to the script as a command line parameter (%1 on Windows systems, $1 on Unix/Linux systems).</p><p>The triggering event for calling the script or batch file is the end of a RINEX file interval. If that is superposedby a stream outage, the triggering event is the stream reconnect.</p>"));
151 _rnxSkelLineEdit = new QLineEdit(settings.value("rnxSkel").toString());
152 _rnxSkelLineEdit->setMaximumWidth(5*ww);
153 _rnxSkelLineEdit->setWhatsThis(tr("<p>Whenever BNC generates a new RINEX file, it first tries to retrieve information needed for RINEX headers from so-called public RINEX header skeleton files which are derived from sitelogs. However, it may happen that public RINEX header skeleton files are not available, its contents is not up to date, or you need to have additional/optional records in the RINEX header.</p><p>For that BNC allows to introduce personal skeleton files that contain the header records you would like to see. You may derive a personal RINEX header skeleton file from the information given in an up to date sitelog. A file in the 'RINEX directory' with the extension 'RINEX skeleton extension' is interpreted by BNC as a personal RINEX header skeleton file for the affected stream.</p>"));
154 _rnxAppendCheckBox = new QCheckBox();
155 _rnxAppendCheckBox->setCheckState(Qt::CheckState(
156 settings.value("rnxAppend").toInt()));
157 _rnxAppendCheckBox->setWhatsThis(tr("When starting BNC, new RINEX files are created by default. Probably existing files will be overwritten. However, it may be desirable to append observations to already existing RINEX files following a restart of BNC after an intentional 'Stop', a system crash or a crash of BNC. Hit 'Append files' to continue with already existing files and thus save what has been recorded so far. Note that option 'Append files' also concerns the 'ASCII output file' and the 'Log' file."));
158 _rnxIntrComboBox = new QComboBox();
159 _rnxIntrComboBox->setMaximumWidth(9*ww);
160 _rnxIntrComboBox->setEditable(false);
161 _rnxIntrComboBox->addItems(QString("5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
162 int ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
163 if (ii != -1) {
164 _rnxIntrComboBox->setCurrentIndex(ii);
165 }
166 _rnxSamplSpinBox = new QSpinBox();
167 _rnxSamplSpinBox->setWhatsThis(tr("<p>Select the RINEX sample interval in seconds. Zero '0' stands for converting all incoming epochs to RINEX.</p><p>Default for RINEX 'Sampling' is '0'.</p>"));
168 _rnxSamplSpinBox->setMinimum(0);
169 _rnxSamplSpinBox->setMaximum(60);
170 _rnxSamplSpinBox->setSingleStep(5);
171 _rnxSamplSpinBox->setMaximumWidth(9*ww);
172 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
173 _rnxSamplSpinBox->setSuffix(" sec");
174 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
175 _logFileLineEdit->setWhatsThis(tr("<p>BNC's run-time comments as shown in the 'Log' section can be saved in a file through entering the full path for a 'Log' file.</p><p>Default value for 'Log' is an empty option field, meaning that BNC's run-time comments are not saved in a file.</p>"));
176 _mountPointsTable = new QTableWidget(0,7);
177 _mountPointsTable->setWhatsThis(tr("<p>Streams selected for retrieval are listed in the 'Mountpoints' section. Button 'Add Mountpoints' opens a window that allows you to select data streams from an NTRIP broadcaster by their mountpoints. To delete a stream, select it by mouse click and hit 'Delete Mountpoints'. For adding or deleting several streams simultaneously, highlight them using +Shift and +Ctrl.</p><p>BNC automatically selects one out of several internal decoders for a stream based on its 'format' and 'format-details' as given in the source-table. It may happen that you need to overrule the automated decoder selection. Therefore BNC allows to edit the decoder string (first double-click, then edit field 'decoder', then hit Enter). Decoder strings allowed to be introduced are 'RTCM_2.x', 'RTCM_3', and 'RTIGS'.</p><p>BNC allows to retrieve streams from Virtual Reference Stations. Whether a stream comes from a physical Reference Station (RS) or a Virtual Reference Station (VRS) is indicated in column 'type'. For retrieving a VRS stream, an approximate rover position is required to be send in NMEA format to the NTRIP broadcaster. In return, an individual user-specific data stream is generated, usually by a network RTK software. This stream is tailored exactly to the latitude and longitude shown in the 'lat' and 'long' columns. You may change these values (first double-click, then edit fields 'lat' and/or 'long', then hit Enter) according to your needs. The position has to be introduced in northern latitude degrees (example for northern hemisphere: 52.436, example for eastern hemisphere: -24.567) and eastern longitude degrees (example: 358.872 or -1.128). Editing the 'lat' and 'long' values is only possible for VRS streams. The position must point to a location within the service area of the affected RTK network.<p>"));
178
179 _mountPointsTable->horizontalHeader()->resizeSection(1,25*ww);
180 _mountPointsTable->horizontalHeader()->resizeSection(2,9*ww);
181 _mountPointsTable->horizontalHeader()->resizeSection(3,7*ww);
182 _mountPointsTable->horizontalHeader()->resizeSection(4,7*ww);
183 _mountPointsTable->horizontalHeader()->resizeSection(5,5*ww);
184 _mountPointsTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
185 _mountPointsTable->horizontalHeader()->setStretchLastSection(true);
186 _mountPointsTable->setHorizontalHeaderLabels(labels);
187// _mountPointsTable->horizontalHeader()->hide();
188// _mountPointsTable->verticalHeader()->hide();
189 _mountPointsTable->setGridStyle(Qt::NoPen);
190 _mountPointsTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
191 _mountPointsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
192 _mountPointsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
193 QListIterator<QString> it(settings.value("mountPoints").toStringList());
194 if (!it.hasNext()) {
195 _actGetData->setEnabled(false);
196 }
197 int iRow = 0;
198 while (it.hasNext()) {
199 QStringList hlp = it.next().split(" ");
200 if (hlp.size() < 5) continue; // Check number of parameters saved per mountpoint
201 _mountPointsTable->insertRow(iRow);
202
203 QUrl url(hlp[0]);
204
205 QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
206 QString format(hlp[1]); QString latitude(hlp[2]); QString longitude(hlp[3]);
207 QString nmea(hlp[4]);
208
209 QTableWidgetItem* it;
210 it = new QTableWidgetItem(url.userInfo());
211 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
212 _mountPointsTable->setItem(iRow, 0, it);
213
214 it = new QTableWidgetItem(fullPath);
215 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
216 _mountPointsTable->setItem(iRow, 1, it);
217
218 it = new QTableWidgetItem(format);
219 _mountPointsTable->setItem(iRow, 2, it);
220
221 if (nmea == "VRS") {
222 it = new QTableWidgetItem(latitude);
223 _mountPointsTable->setItem(iRow, 3, it);
224 it = new QTableWidgetItem(longitude);
225 _mountPointsTable->setItem(iRow, 4, it);
226 } else {
227 it = new QTableWidgetItem(latitude);
228 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
229 _mountPointsTable->setItem(iRow, 3, it);
230 it = new QTableWidgetItem(longitude);
231 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
232 _mountPointsTable->setItem(iRow, 4, it);
233 }
234
235 it = new QTableWidgetItem(nmea);
236 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
237 _mountPointsTable->setItem(iRow, 5, it);
238
239 bncTableItem* bncIt = new bncTableItem();
240 bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
241 _mountPointsTable->setItem(iRow, 6, bncIt);
242
243 iRow++;
244 }
245 _mountPointsTable->hideColumn(0);
246 _mountPointsTable->sortItems(1);
247
248 connect(_mountPointsTable, SIGNAL(itemSelectionChanged()),
249 SLOT(slotSelectionChanged()));
250
251 _log = new QTextEdit();
252 _log->setReadOnly(true);
253
254 _log->setWhatsThis(tr("BNC comments its activities in the 'Log' section. Information is given on the communication between BNC and the NTRIP broadcaster as well as on problems that may occur concerning communication link, stream availability, stream delay, stream conversion etc."));
255
256 layout->addWidget(new QLabel("Proxy host"), 0, 0, 1, 2);
257 layout->addWidget(_proxyHostLineEdit, 0, 2);
258 layout->addWidget(new QLabel("Proxy port"), 0, 3);
259 layout->addWidget(_proxyPortLineEdit, 0, 4);
260
261 layout->addWidget(new QLabel("Wait for full epoch"), 1, 0, 1, 2);
262 layout->addWidget(_waitTimeSpinBox, 1, 2);
263
264 layout->addWidget(new QLabel("ASCII output file (full path)"), 2, 0, 1, 2);
265 layout->addWidget(_outFileLineEdit, 2, 2, 1, 3);
266
267 layout->addWidget(new QLabel("Port for binary output"), 3, 0, 1, 2);
268 layout->addWidget(_outPortLineEdit, 3, 2);
269
270 layout->addWidget(new QLabel("RINEX directory"), 4, 0, 1, 2);
271 layout->addWidget(_rnxPathLineEdit, 4, 2, 1, 3);
272
273 layout->addWidget(new QLabel("RINEX script (full path)"), 5, 0, 1, 2);
274 layout->addWidget(_rnxScrpLineEdit, 5, 2, 1, 3);
275
276 layout->addWidget(new QLabel("RINEX file interval"), 6, 0, 1, 2);
277 layout->addWidget(_rnxIntrComboBox, 6, 2);
278 layout->addWidget(new QLabel("Sampling"), 6, 3);
279 layout->addWidget(_rnxSamplSpinBox, 6, 4);
280
281 layout->addWidget(new QLabel("RINEX skeleton extension"), 7, 0, 1, 2);
282 layout->addWidget(_rnxSkelLineEdit, 7, 2);
283
284 layout->addWidget(new QLabel("Append files"), 7, 3);
285 layout->addWidget(_rnxAppendCheckBox, 7, 4);
286
287 layout->addWidget(new QLabel("Mountpoints"), 8, 0, 1, 2);
288
289 layout->addWidget(_mountPointsTable, 9, 0, 1, 5);
290
291 layout->addWidget(new QLabel("Log (full path)"), 10, 0, 1, 2);
292 layout->addWidget(_logFileLineEdit, 10, 2, 1, 3);
293 layout->addWidget(_log, 11, 0, 1, 5);
294}
295
296// Destructor
297////////////////////////////////////////////////////////////////////////////
298bncWindow::~bncWindow() {
299}
300
301// Retrieve Table
302////////////////////////////////////////////////////////////////////////////
303void bncWindow::slotAddMountPoints() {
304
305 QSettings settings;
306 QString proxyHost = settings.value("proxyHost").toString();
307 int proxyPort = settings.value("proxyPort").toInt();
308 if (proxyHost != _proxyHostLineEdit->text() ||
309 proxyPort != _proxyPortLineEdit->text().toInt()) {
310 int iRet = QMessageBox::question(this, "Question", "Proxy options "
311 "changed. Use the new ones?",
312 QMessageBox::Yes, QMessageBox::No,
313 QMessageBox::NoButton);
314 if (iRet == QMessageBox::Yes) {
315 settings.setValue("proxyHost", _proxyHostLineEdit->text());
316 settings.setValue("proxyPort", _proxyPortLineEdit->text());
317 }
318 }
319
320 bncTableDlg* dlg = new bncTableDlg(this);
321 dlg->move(this->pos().x()+50, this->pos().y()+50);
322 connect(dlg, SIGNAL(newMountPoints(QStringList*)),
323 this, SLOT(slotNewMountPoints(QStringList*)));
324 dlg->exec();
325 delete dlg;
326
327}
328
329// Delete Selected Mount Points
330////////////////////////////////////////////////////////////////////////////
331void bncWindow::slotDeleteMountPoints() {
332
333 int nRows = _mountPointsTable->rowCount();
334 bool flg[nRows];
335 for (int iRow = 0; iRow < nRows; iRow++) {
336 if (_mountPointsTable->isItemSelected(_mountPointsTable->item(iRow,1))) {
337 flg[iRow] = true;
338 }
339 else {
340 flg[iRow] = false;
341 }
342 }
343 for (int iRow = nRows-1; iRow >= 0; iRow--) {
344 if (flg[iRow]) {
345 _mountPointsTable->removeRow(iRow);
346 }
347 }
348 _actDeleteMountPoints->setEnabled(false);
349
350 if (_mountPointsTable->rowCount() == 0) {
351 _actGetData->setEnabled(false);
352 }
353}
354
355// New Mount Points Selected
356////////////////////////////////////////////////////////////////////////////
357void bncWindow::slotNewMountPoints(QStringList* mountPoints) {
358 int iRow = 0;
359 QListIterator<QString> it(*mountPoints);
360 while (it.hasNext()) {
361 QStringList hlp = it.next().split(" ");
362 QUrl url(hlp[0]);
363 QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
364 QString format(hlp[1]); QString latitude(hlp[2]); QString longitude(hlp[3]);
365 QString nmea(hlp[4]);
366
367 _mountPointsTable->insertRow(iRow);
368
369 QTableWidgetItem* it;
370 it = new QTableWidgetItem(url.userInfo());
371 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
372 _mountPointsTable->setItem(iRow, 0, it);
373
374 it = new QTableWidgetItem(fullPath);
375 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
376 _mountPointsTable->setItem(iRow, 1, it);
377
378 it = new QTableWidgetItem(format);
379 _mountPointsTable->setItem(iRow, 2, it);
380
381 if (nmea == "VRS") {
382 it = new QTableWidgetItem(latitude);
383 _mountPointsTable->setItem(iRow, 3, it);
384 it = new QTableWidgetItem(longitude);
385 _mountPointsTable->setItem(iRow, 4, it);
386 } else {
387 it = new QTableWidgetItem(latitude);
388 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
389 _mountPointsTable->setItem(iRow, 3, it);
390 it = new QTableWidgetItem(longitude);
391 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
392 _mountPointsTable->setItem(iRow, 4, it);
393 }
394
395 it = new QTableWidgetItem(nmea);
396 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
397 _mountPointsTable->setItem(iRow, 5, it);
398
399 bncTableItem* bncIt = new bncTableItem();
400 _mountPointsTable->setItem(iRow, 6, bncIt);
401
402 iRow++;
403 }
404 _mountPointsTable->hideColumn(0);
405 _mountPointsTable->sortItems(1);
406 if (mountPoints->count() > 0) {
407 _actGetData->setEnabled(true);
408 }
409 delete mountPoints;
410}
411
412// Save Options
413////////////////////////////////////////////////////////////////////////////
414void bncWindow::slotSaveOptions() {
415 QSettings settings;
416 settings.setValue("proxyHost", _proxyHostLineEdit->text());
417 settings.setValue("proxyPort", _proxyPortLineEdit->text());
418 settings.setValue("waitTime", _waitTimeSpinBox->value());
419 settings.setValue("outFile", _outFileLineEdit->text());
420 settings.setValue("outPort", _outPortLineEdit->text());
421 settings.setValue("rnxPath", _rnxPathLineEdit->text());
422 settings.setValue("rnxScript", _rnxScrpLineEdit->text());
423 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
424 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
425 settings.setValue("rnxSkel", _rnxSkelLineEdit->text());
426 settings.setValue("rnxAppend", _rnxAppendCheckBox->checkState());
427 settings.setValue("logFile", _logFileLineEdit->text());
428
429QStringList mountPoints;
430
431 for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
432 QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
433 "@" + _mountPointsTable->item(iRow, 1)->text() );
434
435 mountPoints.append(url.toString() + " " +
436 _mountPointsTable->item(iRow, 2)->text()
437 + " " + _mountPointsTable->item(iRow, 3)->text()
438 + " " + _mountPointsTable->item(iRow, 4)->text()
439 + " " + _mountPointsTable->item(iRow, 5)->text());
440 }
441 settings.setValue("mountPoints", mountPoints);
442}
443
444// All get slots terminated
445////////////////////////////////////////////////////////////////////////////
446void bncWindow::slotGetThreadErrors() {
447 slotMessage("All Get Threads Terminated");
448 ((bncApp*)qApp)->slotMessage("All Get Threads Terminated");
449 _actAddMountPoints->setEnabled(true);
450 _actGetData->setEnabled(true);
451}
452
453// Retrieve Data
454////////////////////////////////////////////////////////////////////////////
455void bncWindow::slotGetData() {
456 slotSaveOptions();
457
458 _actAddMountPoints->setEnabled(false);
459 _actDeleteMountPoints->setEnabled(false);
460 _actGetData->setEnabled(false);
461 _actStop->setEnabled(true);
462
463 _global_caster = new bncCaster(_outFileLineEdit->text(),
464 _outPortLineEdit->text().toInt());
465
466 connect(_global_caster, SIGNAL(getThreadErrors()),
467 this, SLOT(slotGetThreadErrors()));
468
469 connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
470 this, SLOT(slotMessage(const QByteArray&)));
471 connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
472 (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
473
474 slotMessage("============ Start BNC ============");
475 ((bncApp*)qApp)->slotMessage("============ Start BNC ============");
476
477 for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
478 QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
479 "@" + _mountPointsTable->item(iRow, 1)->text() );
480
481 QByteArray format = _mountPointsTable->item(iRow, 2)->text().toAscii();
482
483 QByteArray latitude = _mountPointsTable->item(iRow, 3)->text().toAscii();
484 QByteArray longitude = _mountPointsTable->item(iRow, 4)->text().toAscii();
485 QByteArray nmea = _mountPointsTable->item(iRow, 5)->text().toAscii();
486
487 bncGetThread* getThread = new bncGetThread(url, format, latitude, longitude, nmea, iRow);
488
489 connect(getThread, SIGNAL(newMessage(const QByteArray&)),
490 this, SLOT(slotMessage(const QByteArray&)));
491 connect(getThread, SIGNAL(newMessage(const QByteArray&)),
492 (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
493
494 connect(getThread, SIGNAL(newObs(const QByteArray&, Observation*)),
495 (bncTableItem*) _mountPointsTable->item(iRow, 6),
496 SLOT(slotNewObs(const QByteArray&, Observation*)));
497
498 _global_caster->addGetThread(getThread);
499
500 getThread->start();
501 }
502}
503
504// Retrieve Data
505////////////////////////////////////////////////////////////////////////////
506void bncWindow::slotStop() {
507 int iRet = QMessageBox::question(this, "Stop", "Stop retrieving data?",
508 QMessageBox::Yes, QMessageBox::No,
509 QMessageBox::NoButton);
510 if (iRet == QMessageBox::Yes) {
511 delete _global_caster; _global_caster = 0;
512 _actGetData->setEnabled(true);
513 _actStop->setEnabled(false);
514 _actAddMountPoints->setEnabled(true);
515 }
516}
517
518// Close Application gracefully
519////////////////////////////////////////////////////////////////////////////
520void bncWindow::closeEvent(QCloseEvent* event) {
521
522 int iRet = QMessageBox::question(this, "Close", "Save Options?",
523 QMessageBox::Yes, QMessageBox::No,
524 QMessageBox::Cancel);
525
526 if (iRet == QMessageBox::Cancel) {
527 event->ignore();
528 return;
529 }
530 else if (iRet == QMessageBox::Yes) {
531 slotSaveOptions();
532 }
533
534 return QMainWindow::closeEvent(event);
535}
536
537// User changed the selection of mountPoints
538////////////////////////////////////////////////////////////////////////////
539void bncWindow::slotSelectionChanged() {
540 if (_mountPointsTable->selectedItems().isEmpty()) {
541 _actDeleteMountPoints->setEnabled(false);
542 }
543 else {
544 _actDeleteMountPoints->setEnabled(true);
545 }
546}
547
548// Display Program Messages
549////////////////////////////////////////////////////////////////////////////
550void bncWindow::slotMessage(const QByteArray& msg) {
551
552 const int maxBufferSize = 10000;
553
554 QString txt = _log->toPlainText() + "\n" +
555 QDate::currentDate().toString("yy-MM-dd ") +
556 QTime::currentTime().toString("hh:mm:ss ") + msg;
557 _log->clear();
558 _log->append(txt.right(maxBufferSize));
559}
560
561// About Message
562////////////////////////////////////////////////////////////////////////////
563void bncWindow::slotAbout() {
564
565 QTextBrowser* tb = new QTextBrowser;
566 QUrl url; url.setPath(":bncabout.html");
567 tb->setSource(url);
568 tb->setReadOnly(true);
569
570 QDialog dlg(this);
571
572 QGridLayout* dlgLayout = new QGridLayout();
573 QLabel* img = new QLabel();
574 img->setPixmap(QPixmap(":ntrip-logo.png"));
575 dlgLayout->addWidget(img, 0,0);
576 dlgLayout->addWidget(new QLabel("BKG NTRIP Client (BNC), Version 1.1b"), 0,1);
577 dlgLayout->addWidget(tb,1,0,1,2);
578
579 dlg.setLayout(dlgLayout);
580 int ww = QFontMetrics(font()).width('w');
581 dlg.resize(60*ww, 60*ww);
582 dlg.exec();
583}
584
585// Help Window
586////////////////////////////////////////////////////////////////////////////
587void bncWindow::slotHelp() {
588 QUrl url;
589 url.setPath(":bnchelp.html");
590 new bncHlpDlg(this, url);
591}
592
593// Select Fonts
594////////////////////////////////////////////////////////////////////////////
595void bncWindow::slotFontSel() {
596 bool ok;
597 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
598 if (ok) {
599 QSettings settings;
600 settings.setValue("font", newFont.toString());
601 QApplication::setFont(newFont);
602 int ww = QFontMetrics(newFont).width('w');
603 setMinimumSize(60*ww, 80*ww);
604 resize(60*ww, 80*ww);
605 }
606}
Note: See TracBrowser for help on using the repository browser.