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

Last change on this file since 1084 was 1084, checked in by weber, 16 years ago

* empty log message *

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