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

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

* empty log message *

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