source: ntrip/trunk/BNS/bnswindow.cpp@ 1251

Last change on this file since 1251 was 1251, checked in by weber, 15 years ago

* empty log message *

File size: 29.8 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bnsWindow
7 *
8 * Purpose: This class implements the main application window.
9 *
10 * Author: L. Mervart
11 *
12 * Created: 29-Mar-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19
20#include "bnswindow.h"
21#include "bnshlpdlg.h"
22
23using namespace std;
24
25// About Dialog - Constructor
26////////////////////////////////////////////////////////////////////////////
27bnsAboutDlg::bnsAboutDlg(QWidget* parent) :
28 QDialog(parent) {
29
30 QTextBrowser* tb = new QTextBrowser;
31 QUrl url; url.setPath(":bnsabout.html");
32 tb->setSource(url);
33 tb->setReadOnly(true);
34
35 int ww = QFontMetrics(font()).width('w');
36 QPushButton* _closeButton = new QPushButton("Close");
37 _closeButton->setMaximumWidth(10*ww);
38 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
39
40 QGridLayout* dlgLayout = new QGridLayout();
41 QLabel* img = new QLabel();
42 img->setPixmap(QPixmap(":ntrip-logo.png"));
43 dlgLayout->addWidget(img, 0,0);
44 dlgLayout->addWidget(new QLabel("BKG Ntrip State Space Server (BNS) Version 1.0"), 0,1);
45 dlgLayout->addWidget(tb,1,0,1,2);
46 dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
47
48 setLayout(dlgLayout);
49 resize(60*ww, 60*ww);
50 show();
51}
52
53// About Dialog - Destructor
54////////////////////////////////////////////////////////////////////////////
55bnsAboutDlg::~bnsAboutDlg() {
56};
57
58// Flowchart Dialog - Constructor
59////////////////////////////////////////////////////////////////////////////
60bnsFlowchartDlg::bnsFlowchartDlg(QWidget* parent) :
61 QDialog(parent) {
62
63 int ww = QFontMetrics(font()).width('w');
64 QPushButton* _closeButton = new QPushButton("Close");
65 _closeButton->setMaximumWidth(10*ww);
66 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
67
68 QGridLayout* dlgLayout = new QGridLayout();
69 QLabel* img = new QLabel();
70 img->setPixmap(QPixmap(":bnsflowchart.png"));
71 dlgLayout->addWidget(img, 0,0);
72 dlgLayout->addWidget(_closeButton,1,0,Qt::AlignLeft);
73
74 setLayout(dlgLayout);
75 show();
76}
77
78// Flowchart Dialog - Destructor
79////////////////////////////////////////////////////////////////////////////
80bnsFlowchartDlg::~bnsFlowchartDlg() {
81};
82
83// Constructor
84////////////////////////////////////////////////////////////////////////////
85bnsWindow::bnsWindow() {
86
87 _bns = 0;
88
89 QSettings settings;
90
91 QString fontString = settings.value("font").toString();
92 if ( !fontString.isEmpty() ) {
93 QFont newFont;
94 if (newFont.fromString(fontString)) {
95 QApplication::setFont(newFont);
96 }
97 }
98
99 int ww = QFontMetrics(this->font()).width('w');
100 setMinimumSize(77*ww, 65*ww);
101 setWindowTitle(tr("BKG Ntrip State Space Server (BNS) Version 1.0"));
102 setWindowIcon(QPixmap(":ntrip-logo.png"));
103
104 // Create Actions
105 // --------------
106 _actHelp = new QAction(tr("&Help Contents"),this);
107 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
108
109 _actAbout = new QAction(tr("&About BNS"),this);
110 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
111
112 _actFlowchart = new QAction(tr("&Flow Chart"),this);
113 connect(_actFlowchart, SIGNAL(triggered()), SLOT(slotFlowchart()));
114
115 _actFontSel = new QAction(tr("Select &Font"),this);
116 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
117
118 _actSaveOpt = new QAction(tr("&Save Options"),this);
119 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
120
121 _actQuit = new QAction(tr("&Quit"),this);
122 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
123
124 _actWhatsThis= new QAction(tr("Help=Shift+F1"),this);
125 connect(_actWhatsThis, SIGNAL(triggered()), SLOT(slotWhatsThis()));
126
127 _actStart = new QAction(tr("Sta&rt"),this);
128 connect(_actStart, SIGNAL(triggered()), SLOT(slotStart()));
129
130 _actStop = new QAction(tr("Sto&p"),this);
131 connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
132 _actStop->setEnabled(false);
133
134 CreateMenu();
135 AddToolbar();
136
137 // Canvas with Editable Fields
138 // ---------------------------
139 _canvas = new QWidget;
140 setCentralWidget(_canvas);
141
142 _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
143 _proxyHostLineEdit->setWhatsThis(tr("<p>If you are running BNS within a protected Local Area Network (LAN), you might need to use a proxy server to access the Internet. Enter your proxy server IP and port number in case one is operated in front of BNS. If you do not know the IP and port of your proxy server, check the proxy server settings in your Internet browser or ask your network administrator.</p><p>Note that IP streaming is sometimes not allowed in a LAN. In this case you need to ask your network administrator for an appropriate modification of the local security policy or for the installation of a TCP relay to the NTRIP broadcasters. If these are not possible, you might need to run BNS outside your LAN on a network that has unobstructed connection to the Internet.</p>"));
144 _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
145 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case one is operated in front of BNS.</p>"));
146 _proxyPortLineEdit->setMaximumWidth(9*ww);
147
148 _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
149 _logFileLineEdit->setWhatsThis(tr("<p>Records of BNS activities are shown in the Log section on the bottom of this window. They can be saved into a file when a valid path is specified in the 'Logfile (full path)' field.</p>"));
150 _fileAppendCheckBox = new QCheckBox();
151 _fileAppendCheckBox->setCheckState(Qt::CheckState(settings.value("fileAppend").toInt()));
152 _fileAppendCheckBox->setWhatsThis(tr("<p>When BNS is started, new files are created by default and any existing files with the same name will be overwritten. However, users might want to append already existing files following a restart of BNS, a system crash or when BNS crashed. Tick 'Append files' to continue with existing files and keep what has been recorded so far.</p>"));
153
154 _inpEchoLineEdit = new QLineEdit(settings.value("inpEcho").toString());
155 _inpEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming clocks and orbits are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming clocks and orbits are not saved."));
156
157 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
158 _ephHostLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the host IP e.g. of a BNC installation providing this information."));
159 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
160 _ephPortLineEdit->setWhatsThis(tr("BNS reads Broadcast Ephemeris in RINEX Version 3 Navigation file format from an IP address. Specify the IP port e.g. of a BNC installation providing this information."));
161 _ephPortLineEdit->setMaximumWidth(9*ww);
162 _ephEchoLineEdit = new QLineEdit(settings.value("ephEcho").toString());
163 _ephEchoLineEdit->setWhatsThis(tr("Specify the full path to a file where incoming Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that incoming Broadcast Ephemeris are not saved."));
164
165 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
166 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in SP3 format from an IP port. Specify a local IP port e.g. of an RTNet installation to provide this information."));
167 _clkPortLineEdit->setMaximumWidth(9*ww);
168
169 _outHost_1_LineEdit = new QLineEdit(settings.value("outHost1").toString());
170 _outHost_1_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
171//_outHost_1_LineEdit->setMaximumWidth(9*ww); // weber
172 _outPort_1_LineEdit = new QLineEdit(settings.value("outPort1").toString());
173 _outPort_1_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
174 _outPort_1_LineEdit->setMaximumWidth(9*ww);
175 _password_1_LineEdit = new QLineEdit(settings.value("password1").toString());
176 _password_1_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
177 _password_1_LineEdit->setMaximumWidth(9*ww);
178 _password_1_LineEdit->setEchoMode(QLineEdit::Password);
179
180 _outHost_2_LineEdit = new QLineEdit(settings.value("outHost2").toString());
181 _outHost_2_LineEdit->setWhatsThis(tr("BNS can stream clock and orbit corrections to Broadcast Ephemeris in RTCM Version 3 format. Specify the host IP of an NTRIP Broadcaster to upload the stream. An empty option field means that you don't want to upload corrections."));
182//_outHost_2_LineEdit->setMaximumWidth(9*ww); // weber
183 _outPort_2_LineEdit = new QLineEdit(settings.value("outPort2").toString());
184 _outPort_2_LineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
185 _outPort_2_LineEdit->setMaximumWidth(9*ww);
186 _password_2_LineEdit = new QLineEdit(settings.value("password2").toString());
187 _password_2_LineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
188 _password_2_LineEdit->setMaximumWidth(9*ww);
189 _password_2_LineEdit->setEchoMode(QLineEdit::Password);
190
191 _mountpoint_1_LineEdit = new QLineEdit(settings.value("mountpoint_1").toString());
192 _mountpoint_1_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
193 _mountpoint_1_LineEdit->setMaximumWidth(12*ww);
194 _mountpoint_2_LineEdit = new QLineEdit(settings.value("mountpoint_2").toString());
195 _mountpoint_2_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
196 _mountpoint_2_LineEdit->setMaximumWidth(12*ww);
197 _refSys_1_ComboBox = new QComboBox;
198 _refSys_1_ComboBox->setMaximumWidth(12*ww);
199 _refSys_1_ComboBox->setEditable(false);
200 _refSys_1_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
201 int ii = _refSys_1_ComboBox->findText(settings.value("refSys_1").toString());
202 if (ii != -1) {
203 _refSys_1_ComboBox->setCurrentIndex(ii);
204 }
205 _refSys_1_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
206 _refSys_2_ComboBox = new QComboBox;
207 _refSys_2_ComboBox->setMaximumWidth(12*ww);
208 _refSys_2_ComboBox->setEditable(false);
209 _refSys_2_ComboBox->addItems(QString("IGS05,ETRF2000").split(","));
210 ii = _refSys_2_ComboBox->findText(settings.value("refSys_2").toString());
211 if (ii != -1) {
212 _refSys_2_ComboBox->setCurrentIndex(ii);
213 }
214 _refSys_2_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
215 _outFile_1_LineEdit = new QLineEdit(settings.value("outFile_1").toString());
216 _outFile_1_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
217 _outFile_2_LineEdit = new QLineEdit(settings.value("outFile_2").toString());
218 _outFile_2_LineEdit->setWhatsThis(tr("Specify the full path to a file where outgoing clock and orbit corrections to Broadcast Ephemeris are saved. Beware that the size of this file can rapidly increase. Default is an empty option field meaning that outgoing corrections are not saved."));
219
220 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
221 _rnxPathLineEdit->setWhatsThis(tr("Specify the path for saving the generated clock corrections as Clock RINEX files. If the specified directory does not exist, BNS will not create Clock RINEX files."));
222 _rnxIntrComboBox = new QComboBox;
223 _rnxIntrComboBox->setMaximumWidth(9*ww);
224 _rnxIntrComboBox->setEditable(false);
225 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
226 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
227 if (ii != -1) {
228 _rnxIntrComboBox->setCurrentIndex(ii);
229 }
230 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
231 _rnxSamplSpinBox = new QSpinBox;
232 _rnxSamplSpinBox->setMinimum(0);
233 _rnxSamplSpinBox->setMaximum(60);
234 _rnxSamplSpinBox->setSingleStep(5);
235 _rnxSamplSpinBox->setMaximumWidth(9*ww);
236 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
237 _rnxSamplSpinBox->setSuffix(" sec");
238 _rnxSamplSpinBox->setWhatsThis(tr("Select the Clock RINEX file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into Clock RINEX files."));
239
240 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
241 _sp3PathLineEdit->setWhatsThis(tr("Specify the path for saving the generated orbit corrections as SP3 orbit files. If the specified directory does not exist, BNS will not create SP3 orbit files."));
242 _sp3IntrComboBox = new QComboBox;
243 _sp3IntrComboBox->setMaximumWidth(9*ww);
244 _sp3IntrComboBox->setEditable(false);
245 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
246 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
247 if (ii != -1) {
248 _sp3IntrComboBox->setCurrentIndex(ii);
249 }
250 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
251 _sp3SamplSpinBox = new QSpinBox;
252 _sp3SamplSpinBox->setMinimum(0);
253 _sp3SamplSpinBox->setMaximum(900);
254 _sp3SamplSpinBox->setSingleStep(60);
255 _sp3SamplSpinBox->setMaximumWidth(9*ww);
256 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
257 _sp3SamplSpinBox->setSuffix(" sec");
258 _sp3SamplSpinBox->setWhatsThis(tr("Select the SP3 orbit file sampling interval in seconds. A value of zero '0' tells BNS to store all available samples into SP3 orbit files."));
259
260 // TabWidget
261 // ---------
262 QTabWidget* tabs = new QTabWidget();
263
264 // Proxy Tab
265 // ---------
266 QWidget* tab_prx = new QWidget();
267 tabs->setMaximumHeight(20*ww);
268 tabs->addTab(tab_prx, "Proxy");
269
270 QGridLayout* layout_prx = new QGridLayout;
271 layout_prx->setColumnMinimumWidth(0,9*ww);
272
273 layout_prx->addWidget(new QLabel("Host"), 0, 0, Qt::AlignLeft);
274 layout_prx->addWidget(_proxyHostLineEdit, 0, 1);
275 layout_prx->addWidget(new QLabel("Port"), 1, 0, Qt::AlignLeft);
276 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
277 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 2, Qt::AlignLeft);
278 layout_prx->addWidget(new QLabel(" "), 3, 0);
279
280 tab_prx->setLayout(layout_prx);
281
282 // General Tab
283 // -----------
284 QWidget* tab_gen = new QWidget();
285 tabs->addTab(tab_gen, "General");
286
287 QGridLayout* layout_gen = new QGridLayout;
288 layout_gen->setColumnMinimumWidth(0,9*ww);
289
290 layout_gen->addWidget(new QLabel("Logfile (full path)"), 0, 0);
291 layout_gen->addWidget(_logFileLineEdit, 0, 1);
292 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
293 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
294 layout_gen->addWidget(new QLabel("General settings for logfile and file handling."), 2, 0, 1, 2, Qt::AlignLeft);
295 layout_gen->addWidget(new QLabel(" "), 3, 0);
296
297 tab_gen->setLayout(layout_gen);
298
299 // Ephemeris Tab
300 // -------------
301 QWidget* tab_eph = new QWidget();
302 tabs->addTab(tab_eph, "RINEX Ephemeris");
303
304 QGridLayout* layout_eph = new QGridLayout;
305 layout_eph->setColumnMinimumWidth(0, 9*ww);
306
307 layout_eph->addWidget(new QLabel("Host"), 0, 0);
308 layout_eph->addWidget(_ephHostLineEdit, 0, 1);
309 layout_eph->addWidget(new QLabel("Port"), 1, 0);
310 layout_eph->addWidget(_ephPortLineEdit, 1, 1);
311 layout_eph->addWidget(new QLabel("Save (full path)"), 2, 0);
312 layout_eph->addWidget(_ephEchoLineEdit, 2, 1);
313 layout_eph->addWidget(new QLabel("Read broadcast ephemeris in RINEX Version 3 Navigation format."), 3, 0, 1, 2, Qt::AlignLeft);
314//layout_eph->addWidget(new QLabel(""), 4, 0);
315
316 tab_eph->setLayout(layout_eph);
317
318 // Clock & Orbit Tab
319 // -----------------
320 QWidget* tab_co = new QWidget();
321 tabs->addTab(tab_co,"Clocks && Orbits");
322
323
324 QGridLayout* layout_co = new QGridLayout;
325 layout_co->setColumnMinimumWidth(0, 9*ww);
326
327 layout_co->addWidget(new QLabel("Listening port"), 0, 0);
328 layout_co->addWidget(_clkPortLineEdit, 0, 1);
329 layout_co->addWidget(new QLabel("Save (full path)"), 1, 0);
330 layout_co->addWidget(_inpEchoLineEdit, 1, 1);
331 layout_co->addWidget(new QLabel("Read clocks and orbits in SP3 format."), 2, 0, 1, 2, Qt::AlignLeft);
332 layout_co->addWidget(new QLabel(""), 3, 0);
333
334 tab_co->setLayout(layout_co);
335
336 // Caster Tab I
337 // ------------
338 QWidget* tab_cas1 = new QWidget();
339 tabs->addTab(tab_cas1, "Ephemeris Corrections I");
340
341 QGridLayout* layout_cas1 = new QGridLayout;
342 layout_cas1->setColumnMinimumWidth(0, 9*ww);
343 layout_cas1->addWidget(new QLabel("Host"), 0, 0);
344 layout_cas1->addWidget(_outHost_1_LineEdit, 0, 1, 1, 3);
345 layout_cas1->addWidget(new QLabel("Port"), 0, 4, Qt::AlignRight);
346 layout_cas1->addWidget(_outPort_1_LineEdit, 0, 5);
347 layout_cas1->addWidget(new QLabel("Mountpoint"), 1, 0);
348 layout_cas1->addWidget(_mountpoint_1_LineEdit, 1, 1);
349 layout_cas1->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
350 layout_cas1->addWidget(_password_1_LineEdit, 1, 3);
351 layout_cas1->addWidget(new QLabel(" "), 1, 4);
352 layout_cas1->addWidget(new QLabel(" "), 1, 5);
353 layout_cas1->addWidget(new QLabel("System"), 2, 0);
354 layout_cas1->addWidget(_refSys_1_ComboBox, 2, 1);
355 layout_cas1->addWidget(new QLabel("Save (full path)"), 2, 2, Qt::AlignRight);
356 layout_cas1->addWidget(_outFile_1_LineEdit, 2, 3, 1, 10);
357 layout_cas1->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 3, 0, 1, 10);
358
359 tab_cas1->setLayout(layout_cas1);
360
361 // Caster Tab II
362 // -------------
363 QWidget* tab_cas2 = new QWidget();
364 tabs->addTab(tab_cas2, "Ephemeris Corrections II");
365
366 QGridLayout* layout_cas2 = new QGridLayout;
367 layout_cas2->setColumnMinimumWidth(0, 9*ww);
368 layout_cas2->addWidget(new QLabel("Host"), 0, 0);
369 layout_cas2->addWidget(_outHost_2_LineEdit, 0, 1, 1, 3);
370 layout_cas2->addWidget(new QLabel("Port"), 0, 4, Qt::AlignRight);
371 layout_cas2->addWidget(_outPort_2_LineEdit, 0, 5);
372 layout_cas2->addWidget(new QLabel("Mountpoint"), 1, 0);
373 layout_cas2->addWidget(_mountpoint_2_LineEdit, 1, 1);
374 layout_cas2->addWidget(new QLabel("Password"), 1, 2, Qt::AlignRight);
375 layout_cas2->addWidget(_password_2_LineEdit, 1, 3);
376 layout_cas2->addWidget(new QLabel(" "), 1, 4);
377 layout_cas2->addWidget(new QLabel(" "), 1, 5);
378 layout_cas2->addWidget(new QLabel("System"), 2, 0);
379 layout_cas2->addWidget(_refSys_2_ComboBox, 2, 1);
380 layout_cas2->addWidget(new QLabel("Save (full path)"), 2, 2, Qt::AlignRight);
381 layout_cas2->addWidget(_outFile_2_LineEdit, 2, 3, 1, 10);
382 layout_cas2->addWidget(new QLabel("Produce broadcast ephemeris corrections, upload to caster, reference system, local storage."), 3, 0, 1, 10);
383
384 tab_cas2->setLayout(layout_cas2);
385
386 // RINEX Tab
387 // ---------
388 QWidget* tab_rin = new QWidget();
389 tabs->addTab(tab_rin, "RINEX Clocks ");
390
391 QGridLayout* layout_rin = new QGridLayout;
392 layout_rin->setColumnMinimumWidth(0, 9*ww);
393
394 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
395 layout_rin->addWidget(_rnxPathLineEdit, 0, 1);
396 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
397 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
398 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
399 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
400 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 2, Qt::AlignLeft);
401
402 tab_rin->setLayout(layout_rin);
403
404 // SP3 Tab
405 // -------
406 QWidget* tab_sp3 = new QWidget();
407 tabs->addTab(tab_sp3, "SP3 Orbits");
408
409 QGridLayout* layout_sp3 = new QGridLayout;
410 layout_sp3->setColumnMinimumWidth(0, 9*ww);
411
412 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
413 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1);
414 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
415 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
416 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
417 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
418 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 2, Qt::AlignLeft);
419
420 tab_sp3->setLayout(layout_sp3);
421
422 // Log
423 // ---
424 _log = new QTextBrowser();
425 _log->setReadOnly(true);
426 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
427
428 // Status
429 // ------
430//_status = new QWidget();
431 _status = new QGroupBox(tr("Status"));
432 QGridLayout* layout_status = new QGridLayout;
433
434 _statusLbl[0] = new QLabel("0 byte(s)"); _statusCnt[0] = 0;
435 _statusLbl[1] = new QLabel("0 byte(s)"); _statusCnt[1] = 0;
436 _statusLbl[2] = new QLabel("0 byte(s)"); _statusCnt[2] = 0;
437 _statusLbl[3] = new QLabel("RINEX Ephemeris:");
438 _statusLbl[4] = new QLabel("Clocks & Orbits:");
439 _statusLbl[5] = new QLabel("Ephemeris Corrections:");
440
441 _statusLbl[0]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
442 _statusLbl[1]->setWhatsThis(tr("Status of incoming stream of clocks and orbits."));
443 _statusLbl[2]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster."));
444 _statusLbl[3]->setWhatsThis(tr("Status of incoming broadcast ephemeris."));
445 _statusLbl[4]->setWhatsThis(tr("Status of incoming stream of clocks and orbits."));
446 _statusLbl[5]->setWhatsThis(tr("Status of outgoing stream to NTRIP broadcaster."));
447
448 layout_status->addWidget(_statusLbl[3], 0, 0);
449 layout_status->addWidget(_statusLbl[0], 0, 1);
450 layout_status->addWidget(_statusLbl[4], 1, 0);
451 layout_status->addWidget(_statusLbl[1], 1, 1);
452 layout_status->addWidget(_statusLbl[5], 0, 2);
453 layout_status->addWidget(_statusLbl[2], 0, 3);
454 _status->setLayout(layout_status);
455
456 // Main Layout
457 // -----------
458 QVBoxLayout* mainLayout = new QVBoxLayout;
459 mainLayout->addWidget(tabs);
460 mainLayout->addWidget(_log);
461 mainLayout->addWidget(_status);
462
463 _canvas->setLayout(mainLayout);
464}
465
466// Destructor
467////////////////////////////////////////////////////////////////////////////
468bnsWindow::~bnsWindow() {
469}
470
471// Close Application gracefully
472////////////////////////////////////////////////////////////////////////////
473void bnsWindow::closeEvent(QCloseEvent* event) {
474
475int iRet = QMessageBox::question(this, "Close", "Save Options?",
476 QMessageBox::Yes, QMessageBox::No,
477 QMessageBox::Cancel);
478
479 if (iRet == QMessageBox::Cancel) {
480 event->ignore();
481 return;
482 }
483 else if (iRet == QMessageBox::Yes) {
484 slotSaveOptions();
485 }
486
487 QMainWindow::closeEvent(event);
488}
489
490// About Message
491////////////////////////////////////////////////////////////////////////////
492void bnsWindow::slotAbout() {
493 new bnsAboutDlg(0);
494}
495
496//Flowchart
497////////////////////////////////////////////////////////////////////////////
498void bnsWindow::slotFlowchart() {
499 new bnsFlowchartDlg(0);
500}
501
502// Help Window
503////////////////////////////////////////////////////////////////////////////
504void bnsWindow::slotHelp() {
505 QUrl url;
506 url.setPath(":bnshelp.html");
507 new bnsHlpDlg(0, url);
508}
509
510// Select Fonts
511////////////////////////////////////////////////////////////////////////////
512void bnsWindow::slotFontSel() {
513 bool ok;
514 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
515 if (ok) {
516 QSettings settings;
517 settings.setValue("font", newFont.toString());
518 QApplication::setFont(newFont);
519 int ww = QFontMetrics(newFont).width('w');
520 setMinimumSize(77*ww, 65*ww);
521 }
522}
523
524// Whats This Help
525////////////////////////////////////////////////////////////////////////////
526void bnsWindow::slotWhatsThis() {
527QWhatsThis::enterWhatsThisMode();
528}
529
530// Create Menus
531////////////////////////////////////////////////////////////////////////////
532void bnsWindow::CreateMenu() {
533 _menuFile = menuBar()->addMenu(tr("&File"));
534 _menuFile->addAction(_actFontSel);
535 _menuFile->addSeparator();
536 _menuFile->addAction(_actSaveOpt);
537 _menuFile->addSeparator();
538 _menuFile->addAction(_actQuit);
539
540 _menuHlp = menuBar()->addMenu(tr("&Help"));
541 _menuHlp->addAction(_actHelp);
542 _menuHlp->addAction(_actFlowchart);
543 _menuHlp->addAction(_actAbout);
544}
545
546// Tool (Command) Bar
547////////////////////////////////////////////////////////////////////////////
548void bnsWindow::AddToolbar() {
549 QToolBar* toolBar = new QToolBar;
550 addToolBar(Qt::BottomToolBarArea, toolBar);
551 toolBar->setMovable(false);
552 toolBar->addAction(_actStart);
553 toolBar->addAction(_actStop);
554 toolBar->addWidget(new QLabel(" "));
555 toolBar->addAction(_actWhatsThis);
556}
557
558// Save Options
559////////////////////////////////////////////////////////////////////////////
560void bnsWindow::slotSaveOptions() {
561 QSettings settings;
562 settings.setValue("proxyHost", _proxyHostLineEdit->text());
563 settings.setValue("proxyPort", _proxyPortLineEdit->text());
564 settings.setValue("logFile", _logFileLineEdit->text());
565 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
566 settings.setValue("refSys_1", _refSys_1_ComboBox->currentText());
567 settings.setValue("refSys_2", _refSys_2_ComboBox->currentText());
568 settings.setValue("inpEcho", _inpEchoLineEdit->text());
569 settings.setValue("ephHost", _ephHostLineEdit->text());
570 settings.setValue("ephPort", _ephPortLineEdit->text());
571 settings.setValue("ephEcho", _ephEchoLineEdit->text());
572 settings.setValue("clkPort", _clkPortLineEdit->text());
573 settings.setValue("outHost1", _outHost_1_LineEdit->text());
574 settings.setValue("outPort1", _outPort_1_LineEdit->text());
575 settings.setValue("outHost2", _outHost_2_LineEdit->text());
576 settings.setValue("outPort2", _outPort_2_LineEdit->text());
577 settings.setValue("mountpoint_1",_mountpoint_1_LineEdit->text());
578 settings.setValue("mountpoint_2",_mountpoint_2_LineEdit->text());
579 settings.setValue("outFile_1", _outFile_1_LineEdit->text());
580 settings.setValue("outFile_2", _outFile_2_LineEdit->text());
581 settings.setValue("password1", _password_1_LineEdit->text());
582 settings.setValue("password2", _password_2_LineEdit->text());
583 settings.setValue("rnxPath", _rnxPathLineEdit->text());
584 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
585 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
586 settings.setValue("sp3Path", _sp3PathLineEdit->text());
587 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
588 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
589}
590
591// Display Program Messages
592////////////////////////////////////////////////////////////////////////////
593void bnsWindow::slotMessage(const QByteArray msg) {
594
595 const int maxBufferSize = 10000;
596
597 QString txt = _log->toPlainText() + "\n" +
598 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
599 _log->clear();
600 _log->append(txt.right(maxBufferSize));
601}
602
603// Delete bns
604////////////////////////////////////////////////////////////////////////////
605void bnsWindow::deleteBns() {
606 _actStart->setEnabled(true);
607 _actStop->setEnabled(false);
608 _bns->terminate();
609 _bns->wait(100);
610 delete _bns;
611 _bns = 0;
612}
613
614// Error in bns
615////////////////////////////////////////////////////////////////////////////
616void bnsWindow::slotError(const QByteArray msg) {
617 slotMessage(msg);
618 deleteBns();
619}
620
621// Stop
622////////////////////////////////////////////////////////////////////////////
623void bnsWindow::slotStop() {
624 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
625 QMessageBox::Yes, QMessageBox::No,
626 QMessageBox::NoButton);
627 if (iRet == QMessageBox::Yes) {
628 deleteBns();
629 }
630}
631
632// Start
633////////////////////////////////////////////////////////////////////////////
634void bnsWindow::slotStart() {
635 slotSaveOptions();
636
637 _actStart->setEnabled(false);
638 _actStop->setEnabled(true);
639
640 _bns = new t_bns(0);
641
642 connect(_bns, SIGNAL(newMessage(QByteArray)),
643 this, SLOT(slotMessage(const QByteArray)));
644
645 connect(_bns, SIGNAL(error(QByteArray)),
646 this, SLOT(slotError(const QByteArray)));
647
648 connect(_bns, SIGNAL(newEphBytes(int)), this, SLOT(slotEphBytes(int)));
649 connect(_bns, SIGNAL(newClkBytes(int)), this, SLOT(slotClkBytes(int)));
650 connect(_bns, SIGNAL(newOutBytes(int)), this, SLOT(slotOutBytes(int)));
651
652 _bns->start();
653}
654
655// Input and output bytes statistics
656////////////////////////////////////////////////////////////////////////////
657void bnsWindow::slotEphBytes(int nBytes) {
658 updateStatus(0, nBytes);
659}
660void bnsWindow::slotClkBytes(int nBytes) {
661 updateStatus(1, nBytes);
662}
663void bnsWindow::slotOutBytes(int nBytes) {
664 updateStatus(2, nBytes);
665}
666
667void bnsWindow::updateStatus(int ii, int nBytes) {
668 QMutexLocker locker(&_mutex);
669
670 _statusCnt[ii] += nBytes;
671
672 if (_statusCnt[ii] < 1e3) {
673 _statusLbl[ii]->setText(QString("%1 byte(s)").arg((int)_statusCnt[ii]));
674 }
675 else if (_statusCnt[ii] < 1e6) {
676 _statusLbl[ii]->setText(QString("%1 kb").arg(_statusCnt[ii]/1.e3, 5));
677 }
678 else {
679 _statusLbl[ii]->setText(QString("%1 Mb").arg(_statusCnt[ii]/1.e6, 5));
680 }
681}
Note: See TracBrowser for help on using the repository browser.