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

Last change on this file since 1068 was 1068, checked in by mervart, 16 years ago

* empty log message *

File size: 26.0 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 _ephHostLineEdit = new QLineEdit(settings.value("ephHost").toString());
155 _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."));
156 _ephPortLineEdit = new QLineEdit(settings.value("ephPort").toString());
157 _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."));
158 _ephPortLineEdit->setMaximumWidth(9*ww);
159
160 _clkPortLineEdit = new QLineEdit(settings.value("clkPort").toString());
161 _clkPortLineEdit->setWhatsThis(tr("BNS reads Clocks & Orbits referring to the IGS system (X,Y,Z, ECEF) in plain ASCII format from an IP port. Specify a local IP port e.g. for an RTNet installation to provide this information."));
162 _clkPortLineEdit->setMaximumWidth(9*ww);
163
164 _outHostLineEdit = new QLineEdit(settings.value("outHost").toString());
165 _outHostLineEdit->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."));
166 _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
167 _outPortLineEdit->setWhatsThis(tr("Specify the IP port of an NTRIP Broadcaster to upload the stream. Default is port 80."));
168 _outPortLineEdit->setMaximumWidth(9*ww);
169 _passwordLineEdit = new QLineEdit(settings.value("password").toString());
170 _passwordLineEdit->setWhatsThis(tr("Specify the stream upload password protecting the mounpoint on an NTRIP Broadcaster."));
171 _passwordLineEdit->setMaximumWidth(9*ww);
172 _passwordLineEdit->setEchoMode(QLineEdit::Password);
173 _mountpoint_1_LineEdit = new QLineEdit(settings.value("mountpoint_1").toString());
174 _mountpoint_1_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
175 _mountpoint_1_LineEdit->setMaximumWidth(9*ww);
176 _mountpoint_2_LineEdit = new QLineEdit(settings.value("mountpoint_2").toString());
177 _mountpoint_2_LineEdit->setWhatsThis(tr("Specify the mounpoint for stream upload to an NTRIP Broadcaster."));
178 _mountpoint_2_LineEdit->setMaximumWidth(9*ww);
179 _refSys_1_ComboBox = new QComboBox;
180 _refSys_1_ComboBox->setMaximumWidth(9*ww);
181 _refSys_1_ComboBox->setEditable(false);
182 _refSys_1_ComboBox->addItems(QString("IGS05,ETRS89").split(","));
183 int ii = _refSys_1_ComboBox->findText(settings.value("refSys_1").toString());
184 if (ii != -1) {
185 _refSys_1_ComboBox->setCurrentIndex(ii);
186 }
187 _refSys_1_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
188 _refSys_2_ComboBox = new QComboBox;
189 _refSys_2_ComboBox->setMaximumWidth(9*ww);
190 _refSys_2_ComboBox->setEditable(false);
191 _refSys_2_ComboBox->addItems(QString("IGS05,ETRS89").split(","));
192 ii = _refSys_2_ComboBox->findText(settings.value("refSys_2").toString());
193 if (ii != -1) {
194 _refSys_2_ComboBox->setCurrentIndex(ii);
195 }
196 _refSys_2_ComboBox->setWhatsThis(tr("Select the target reference system for outgoing clock and orbit corrections."));
197 _outFile_1_LineEdit = new QLineEdit(settings.value("outFile_1").toString());
198 _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."));
199 _outFile_2_LineEdit = new QLineEdit(settings.value("outFile_2").toString());
200 _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."));
201
202 _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
203 _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."));
204 _rnxIntrComboBox = new QComboBox;
205 _rnxIntrComboBox->setMaximumWidth(9*ww);
206 _rnxIntrComboBox->setEditable(false);
207 _rnxIntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
208 ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
209 if (ii != -1) {
210 _rnxIntrComboBox->setCurrentIndex(ii);
211 }
212 _rnxIntrComboBox->setWhatsThis(tr("Select the length of the Clock RINEX file."));
213 _rnxSamplSpinBox = new QSpinBox;
214 _rnxSamplSpinBox->setMinimum(0);
215 _rnxSamplSpinBox->setMaximum(60);
216 _rnxSamplSpinBox->setSingleStep(5);
217 _rnxSamplSpinBox->setMaximumWidth(9*ww);
218 _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
219 _rnxSamplSpinBox->setSuffix(" sec");
220 _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."));
221
222 _sp3PathLineEdit = new QLineEdit(settings.value("sp3Path").toString());
223 _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."));
224 _sp3IntrComboBox = new QComboBox;
225 _sp3IntrComboBox->setMaximumWidth(9*ww);
226 _sp3IntrComboBox->setEditable(false);
227 _sp3IntrComboBox->addItems(QString("1 min,2 min,5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
228 ii = _sp3IntrComboBox->findText(settings.value("sp3Intr").toString());
229 if (ii != -1) {
230 _sp3IntrComboBox->setCurrentIndex(ii);
231 }
232 _sp3IntrComboBox->setWhatsThis(tr("Select the length of the SP3 orbit file."));
233 _sp3SamplSpinBox = new QSpinBox;
234 _sp3SamplSpinBox->setMinimum(0);
235 _sp3SamplSpinBox->setMaximum(900);
236 _sp3SamplSpinBox->setSingleStep(60);
237 _sp3SamplSpinBox->setMaximumWidth(9*ww);
238 _sp3SamplSpinBox->setValue(settings.value("sp3Sampl").toInt());
239 _sp3SamplSpinBox->setSuffix(" sec");
240 _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."));
241
242 // TabWidget
243 // ---------
244 QTabWidget* tabs = new QTabWidget();
245
246 // Proxy Tab
247 // ---------
248 QWidget* tab_prx = new QWidget();
249 tabs->setMaximumHeight(20*ww);
250 tabs->addTab(tab_prx, "Proxy");
251
252 QGridLayout* layout_prx = new QGridLayout;
253 layout_prx->setColumnMinimumWidth(0,9*ww);
254
255 layout_prx->addWidget(new QLabel("Proxy host"), 0, 0, Qt::AlignLeft);
256 layout_prx->addWidget(_proxyHostLineEdit, 0, 1);
257 layout_prx->addWidget(new QLabel("Proxy port"), 1, 0, Qt::AlignLeft);
258 layout_prx->addWidget(_proxyPortLineEdit, 1, 1);
259 layout_prx->addWidget(new QLabel("Settings for the proxy in protected networks, leave boxes blank if none."),2, 0, 1, 2, Qt::AlignLeft);
260 layout_prx->addWidget(new QLabel(" "), 3, 0);
261 layout_prx->addWidget(new QLabel(" "), 4, 0);
262
263 tab_prx->setLayout(layout_prx);
264
265 // General Tab
266 // -----------
267 QWidget* tab_gen = new QWidget();
268 tabs->addTab(tab_gen, "General");
269
270 QGridLayout* layout_gen = new QGridLayout;
271 layout_gen->setColumnMinimumWidth(0,9*ww);
272
273 layout_gen->addWidget(new QLabel("Logfile (full path)"), 0, 0);
274 layout_gen->addWidget(_logFileLineEdit, 0, 1);
275 layout_gen->addWidget(new QLabel("Append files"), 1, 0);
276 layout_gen->addWidget(_fileAppendCheckBox, 1, 1);
277 layout_gen->addWidget(new QLabel("General settings for logfile, file handling and target reference system."), 2, 0, 1, 2, Qt::AlignLeft);
278 layout_gen->addWidget(new QLabel(" "), 3, 0);
279
280 tab_gen->setLayout(layout_gen);
281
282 // Input Tab
283 // ---------
284 QWidget* tab_inp = new QWidget();
285 tabs->addTab(tab_inp, "Input");
286
287 QGridLayout* layout_inp = new QGridLayout;
288 layout_inp->setColumnMinimumWidth(0, 9*ww);
289
290 layout_inp->addWidget(new QLabel("Ephemeris"), 0, 0, Qt::AlignLeft);
291 layout_inp->addWidget(new QLabel("Host"), 0, 1, Qt::AlignRight);
292 layout_inp->addWidget(_ephHostLineEdit, 0, 2);
293 layout_inp->addWidget(new QLabel("Port"), 0, 3, Qt::AlignLeft);
294 layout_inp->addWidget(_ephPortLineEdit, 0, 4);
295 layout_inp->addWidget(new QLabel("Clocks & Orbits"), 1, 0, Qt::AlignLeft);
296 layout_inp->addWidget(new QLabel("BNS listening on Port"), 1, 1, 1, 3, Qt::AlignRight);
297 layout_inp->addWidget(_clkPortLineEdit, 1, 4);
298 layout_inp->addWidget(new QLabel("Read broadcast ephemeris and IGS clocks and orbits."), 2, 0, 1, 6, Qt::AlignLeft);
299 layout_inp->addWidget(new QLabel(""), 3, 0);
300 layout_inp->addWidget(new QLabel(""), 4, 0);
301
302 tab_inp->setLayout(layout_inp);
303
304 // NTRIP Caster Tab
305 // ----------------
306 QWidget* tab_cas = new QWidget();
307 tabs->addTab(tab_cas, "NTRIP Caster");
308
309 QGridLayout* layout_cas = new QGridLayout;
310 layout_cas->setColumnMinimumWidth(0, 9*ww);
311
312 layout_cas->addWidget(new QLabel("Host"), 0, 0, Qt::AlignLeft);
313 layout_cas->addWidget(_outHostLineEdit, 0, 1);
314 layout_cas->addWidget(new QLabel("Port"), 0, 2, Qt::AlignLeft);
315 layout_cas->addWidget(_outPortLineEdit, 0, 3);
316 layout_cas->addWidget(new QLabel("Password"), 0, 4, Qt::AlignLeft);
317 layout_cas->addWidget(_passwordLineEdit, 0, 5);
318
319 layout_cas->addWidget(new QLabel("Mountpoint 1"), 1, 0, Qt::AlignLeft);
320 layout_cas->addWidget(_mountpoint_1_LineEdit, 1, 1);
321 layout_cas->addWidget(new QLabel("Save stream (full path)"), 1, 2, Qt::AlignLeft);
322 layout_cas->addWidget(_outFile_1_LineEdit, 1, 3);
323 layout_cas->addWidget(new QLabel("System"), 1, 4);
324 layout_cas->addWidget(_refSys_1_ComboBox, 1, 5);
325
326 layout_cas->addWidget(new QLabel("Mountpoint 2"), 2, 0, Qt::AlignLeft);
327 layout_cas->addWidget(_mountpoint_2_LineEdit, 2, 1);
328 layout_cas->addWidget(new QLabel("Save stream (full path)"), 2, 2, Qt::AlignLeft);
329 layout_cas->addWidget(_outFile_2_LineEdit, 2, 3);
330 layout_cas->addWidget(new QLabel("System"), 2, 4);
331 layout_cas->addWidget(_refSys_2_ComboBox, 2, 5);
332
333 layout_cas->addWidget(new QLabel("Stream upload of clock and orbit corrections to NTRIP broadcaster."), 4, 0, 1, 4, Qt::AlignLeft);
334 layout_cas->addWidget(new QLabel(""), 5, 0);
335
336 tab_cas->setLayout(layout_cas);
337
338 // RINEX Tab
339 // ---------
340 QWidget* tab_rin = new QWidget();
341 tabs->addTab(tab_rin, "RINEX Clocks ");
342
343 QGridLayout* layout_rin = new QGridLayout;
344 layout_rin->setColumnMinimumWidth(0, 9*ww);
345
346 layout_rin->addWidget(new QLabel("Directory"), 0, 0);
347 layout_rin->addWidget(_rnxPathLineEdit, 0, 1);
348 layout_rin->addWidget(new QLabel("Interval"), 1, 0);
349 layout_rin->addWidget(_rnxIntrComboBox, 1, 1);
350 layout_rin->addWidget(new QLabel("Sampling"), 2, 0);
351 layout_rin->addWidget(_rnxSamplSpinBox, 2, 1);
352 layout_rin->addWidget(new QLabel("Save clock corrections in Clock RINEX file format."), 3, 0, 1, 2, Qt::AlignLeft);
353 layout_rin->addWidget(new QLabel(""), 4, 0);
354
355 tab_rin->setLayout(layout_rin);
356
357 // SP3 Tab
358 // -------
359 QWidget* tab_sp3 = new QWidget();
360 tabs->addTab(tab_sp3, "SP3 Orbits");
361
362 QGridLayout* layout_sp3 = new QGridLayout;
363 layout_sp3->setColumnMinimumWidth(0, 9*ww);
364
365 layout_sp3->addWidget(new QLabel("Directory"), 0, 0);
366 layout_sp3->addWidget(_sp3PathLineEdit, 0, 1);
367 layout_sp3->addWidget(new QLabel("Interval"), 1, 0);
368 layout_sp3->addWidget(_sp3IntrComboBox, 1, 1);
369 layout_sp3->addWidget(new QLabel("Sampling"), 2, 0);
370 layout_sp3->addWidget(_sp3SamplSpinBox, 2, 1);
371 layout_sp3->addWidget(new QLabel("Save orbit corrections in SP3 file format."), 3, 0, 1, 2, Qt::AlignLeft);
372 layout_sp3->addWidget(new QLabel(""), 4, 0);
373
374 tab_sp3->setLayout(layout_sp3);
375
376 // Log
377 // ---
378 _log = new QTextBrowser();
379 _log->setReadOnly(true);
380 _log->setWhatsThis(tr("Records of BNS's activities are shown in the Log section."));
381
382 // Status
383 // ------
384 _status = new QWidget();
385 QGridLayout* layout_status = new QGridLayout;
386
387 _statusLbl[0] = new QLabel("0 byte(s)"); _statusCnt[0] = 0;
388 _statusLbl[1] = new QLabel("0 byte(s)"); _statusCnt[1] = 0;
389 _statusLbl[2] = new QLabel("0 byte(s)"); _statusCnt[2] = 0;
390 _statusLbl[3] = new QLabel("Input Ephemeris");
391 _statusLbl[4] = new QLabel("Input Clock & Orbits");
392 _statusLbl[5] = new QLabel("Output");
393
394 layout_status->addWidget(_statusLbl[3], 0, 0);
395 layout_status->addWidget(_statusLbl[0], 0, 1);
396 layout_status->addWidget(_statusLbl[4], 0, 2);
397 layout_status->addWidget(_statusLbl[1], 0, 3);
398 layout_status->addWidget(_statusLbl[5], 1, 2);
399 layout_status->addWidget(_statusLbl[2], 1, 3);
400 _status->setLayout(layout_status);
401
402 // Main Layout
403 // -----------
404 QVBoxLayout* mainLayout = new QVBoxLayout;
405 mainLayout->addWidget(tabs);
406 mainLayout->addWidget(_log);
407 mainLayout->addWidget(_status);
408
409 _canvas->setLayout(mainLayout);
410}
411
412// Destructor
413////////////////////////////////////////////////////////////////////////////
414bnsWindow::~bnsWindow() {
415}
416
417// Close Application gracefully
418////////////////////////////////////////////////////////////////////////////
419void bnsWindow::closeEvent(QCloseEvent* event) {
420
421int iRet = QMessageBox::question(this, "Close", "Save Options?",
422 QMessageBox::Yes, QMessageBox::No,
423 QMessageBox::Cancel);
424
425 if (iRet == QMessageBox::Cancel) {
426 event->ignore();
427 return;
428 }
429 else if (iRet == QMessageBox::Yes) {
430 slotSaveOptions();
431 }
432
433 QMainWindow::closeEvent(event);
434}
435
436// About Message
437////////////////////////////////////////////////////////////////////////////
438void bnsWindow::slotAbout() {
439 new bnsAboutDlg(0);
440}
441
442//Flowchart
443////////////////////////////////////////////////////////////////////////////
444void bnsWindow::slotFlowchart() {
445 new bnsFlowchartDlg(0);
446}
447
448// Help Window
449////////////////////////////////////////////////////////////////////////////
450void bnsWindow::slotHelp() {
451 QUrl url;
452 url.setPath(":bnshelp.html");
453 new bnsHlpDlg(0, url);
454}
455
456// Select Fonts
457////////////////////////////////////////////////////////////////////////////
458void bnsWindow::slotFontSel() {
459 bool ok;
460 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
461 if (ok) {
462 QSettings settings;
463 settings.setValue("font", newFont.toString());
464 QApplication::setFont(newFont);
465 int ww = QFontMetrics(newFont).width('w');
466 setMinimumSize(77*ww, 65*ww);
467 }
468}
469
470// Whats This Help
471////////////////////////////////////////////////////////////////////////////
472void bnsWindow::slotWhatsThis() {
473QWhatsThis::enterWhatsThisMode();
474}
475
476// Create Menus
477////////////////////////////////////////////////////////////////////////////
478void bnsWindow::CreateMenu() {
479 _menuFile = menuBar()->addMenu(tr("&File"));
480 _menuFile->addAction(_actFontSel);
481 _menuFile->addSeparator();
482 _menuFile->addAction(_actSaveOpt);
483 _menuFile->addSeparator();
484 _menuFile->addAction(_actQuit);
485
486 _menuHlp = menuBar()->addMenu(tr("&Help"));
487 _menuHlp->addAction(_actHelp);
488 _menuHlp->addAction(_actFlowchart);
489 _menuHlp->addAction(_actAbout);
490}
491
492// Tool (Command) Bar
493////////////////////////////////////////////////////////////////////////////
494void bnsWindow::AddToolbar() {
495 QToolBar* toolBar = new QToolBar;
496 addToolBar(Qt::BottomToolBarArea, toolBar);
497 toolBar->setMovable(false);
498 toolBar->addAction(_actStart);
499 toolBar->addAction(_actStop);
500 toolBar->addWidget(new QLabel(" "));
501 toolBar->addAction(_actWhatsThis);
502}
503
504// Save Options
505////////////////////////////////////////////////////////////////////////////
506void bnsWindow::slotSaveOptions() {
507 QSettings settings;
508 settings.setValue("proxyHost", _proxyHostLineEdit->text());
509 settings.setValue("proxyPort", _proxyPortLineEdit->text());
510 settings.setValue("logFile", _logFileLineEdit->text());
511 settings.setValue("fileAppend", _fileAppendCheckBox->checkState());
512 settings.setValue("refSys_1", _refSys_1_ComboBox->currentText());
513 settings.setValue("refSys_2", _refSys_2_ComboBox->currentText());
514 settings.setValue("ephHost", _ephHostLineEdit->text());
515 settings.setValue("ephPort", _ephPortLineEdit->text());
516 settings.setValue("clkPort", _clkPortLineEdit->text());
517 settings.setValue("outHost", _outHostLineEdit->text());
518 settings.setValue("outPort", _outPortLineEdit->text());
519 settings.setValue("mountpoint_1", _mountpoint_1_LineEdit->text());
520 settings.setValue("mountpoint_2", _mountpoint_2_LineEdit->text());
521 settings.setValue("outFile_1", _outFile_1_LineEdit->text());
522 settings.setValue("outFile_2", _outFile_2_LineEdit->text());
523 settings.setValue("password", _passwordLineEdit->text());
524 settings.setValue("rnxPath", _rnxPathLineEdit->text());
525 settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
526 settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
527 settings.setValue("sp3Path", _sp3PathLineEdit->text());
528 settings.setValue("sp3Intr", _sp3IntrComboBox->currentText());
529 settings.setValue("sp3Sampl", _sp3SamplSpinBox->value());
530}
531
532// Display Program Messages
533////////////////////////////////////////////////////////////////////////////
534void bnsWindow::slotMessage(const QByteArray msg) {
535
536 const int maxBufferSize = 10000;
537
538 QString txt = _log->toPlainText() + "\n" +
539 QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ") + msg;
540 _log->clear();
541 _log->append(txt.right(maxBufferSize));
542}
543
544// Delete bns
545////////////////////////////////////////////////////////////////////////////
546void bnsWindow::deleteBns() {
547 _actStart->setEnabled(true);
548 _actStop->setEnabled(false);
549 _bns->terminate();
550 _bns->wait(100);
551 delete _bns;
552 _bns = 0;
553}
554
555// Error in bns
556////////////////////////////////////////////////////////////////////////////
557void bnsWindow::slotError(const QByteArray msg) {
558 slotMessage(msg);
559 deleteBns();
560}
561
562// Stop
563////////////////////////////////////////////////////////////////////////////
564void bnsWindow::slotStop() {
565 int iRet = QMessageBox::question(this, "Stop", "Do you want to stop?",
566 QMessageBox::Yes, QMessageBox::No,
567 QMessageBox::NoButton);
568 if (iRet == QMessageBox::Yes) {
569 deleteBns();
570 }
571}
572
573// Start
574////////////////////////////////////////////////////////////////////////////
575void bnsWindow::slotStart() {
576 slotSaveOptions();
577
578 _actStart->setEnabled(false);
579 _actStop->setEnabled(true);
580
581 _bns = new t_bns(0);
582
583 connect(_bns, SIGNAL(newMessage(QByteArray)),
584 this, SLOT(slotMessage(const QByteArray)));
585
586 connect(_bns, SIGNAL(error(QByteArray)),
587 this, SLOT(slotError(const QByteArray)));
588
589 connect(_bns, SIGNAL(newEphBytes(int)), this, SLOT(slotEphBytes(int)));
590 connect(_bns, SIGNAL(newClkBytes(int)), this, SLOT(slotClkBytes(int)));
591 connect(_bns, SIGNAL(newOutBytes(int)), this, SLOT(slotOutBytes(int)));
592
593 _bns->start();
594}
595
596// Input and output bytes statistics
597////////////////////////////////////////////////////////////////////////////
598void bnsWindow::slotEphBytes(int nBytes) {
599 updateStatus(0, nBytes);
600}
601void bnsWindow::slotClkBytes(int nBytes) {
602 updateStatus(1, nBytes);
603}
604void bnsWindow::slotOutBytes(int nBytes) {
605 updateStatus(2, nBytes);
606}
607
608void bnsWindow::updateStatus(int ii, int nBytes) {
609 QMutexLocker locker(&_mutex);
610
611 _statusCnt[ii] += nBytes;
612
613 if (_statusCnt[ii] < 1e3) {
614 _statusLbl[ii]->setText(QString("%1 byte(s)").arg((int)_statusCnt[ii]));
615 }
616 else if (_statusCnt[ii] < 1e6) {
617 _statusLbl[ii]->setText(QString("%1 kb").arg(_statusCnt[ii]/1.e3, 5));
618 }
619 else {
620 _statusLbl[ii]->setText(QString("%1 Mb").arg(_statusCnt[ii]/1.e6, 5));
621 }
622}
Note: See TracBrowser for help on using the repository browser.