source: ntrip/trunk/BNC/src/PPP/pppWidgets.cpp@ 5893

Last change on this file since 5893 was 5893, checked in by mervart, 10 years ago
File size: 13.0 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_pppWidgets
30 *
31 * Purpose: This class stores widgets for PPP options
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Jul-2014
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include "PPP/pppWidgets.h"
44#include "qtfilechooser.h"
45#include "bncsettings.h"
46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51t_pppWidgets::t_pppWidgets() {
52
53 _dataSource = new QComboBox(); _dataSource ->setObjectName("PPP/dataSource"); _widgets << _dataSource;
54 _rinexObs = new qtFileChooser(); _rinexObs ->setObjectName("PPP/rinexObs"); _widgets << _rinexObs;
55 _rinexNav = new qtFileChooser(); _rinexNav ->setObjectName("PPP/rinexNav"); _widgets << _rinexNav;
56 _corrMount = new QLineEdit(); _corrMount ->setObjectName("PPP/corrMount"); _widgets << _corrMount;
57 _corrFile = new qtFileChooser(); _corrFile ->setObjectName("PPP/corrFile"); _widgets << _corrFile;
58 _crdFile = new qtFileChooser(); _crdFile ->setObjectName("PPP/crdFile"); _widgets << _crdFile;
59 _antexFile = new qtFileChooser(); _antexFile ->setObjectName("PPP/antexFile"); _widgets << _antexFile;
60 _logFile = new QLineEdit(); _logFile ->setObjectName("PPP/logFile"); _widgets << _logFile;
61 _nmeaFile = new QLineEdit(); _nmeaFile ->setObjectName("PPP/nmeaFile"); _widgets << _nmeaFile;
62 _nmeaPort = new QLineEdit(); _nmeaPort ->setObjectName("PPP/nmeaPort"); _widgets << _nmeaPort;
63 _staTable = new QTableWidget(); _staTable ->setObjectName("PPP/staTable"); _widgets << _staTable;
64 _lcGPS = new QComboBox(); _lcGPS ->setObjectName("PPP/lcGPS"); _widgets << _lcGPS;
65 _lcGLONASS = new QComboBox(); _lcGLONASS ->setObjectName("PPP/lcGLONASS"); _widgets << _lcGLONASS;
66 _lcGalileo = new QComboBox(); _lcGalileo ->setObjectName("PPP/lcGalileo"); _widgets << _lcGalileo;
67 _sigmaC1 = new QLineEdit(); _sigmaC1 ->setObjectName("PPP/sigmaC1"); _widgets << _sigmaC1;
68 _sigmaL1 = new QLineEdit(); _sigmaL1 ->setObjectName("PPP/sigmaL1"); _widgets << _sigmaL1;
69 _corrWaitTime = new QSpinBox(); _corrWaitTime->setObjectName("PPP/corrWaitTime"); _widgets << _corrWaitTime;
70 _addStaButton = new QPushButton("Add Station"); _widgets << _addStaButton;
71 _delStaButton = new QPushButton("Delete Station"); _widgets << _delStaButton;
72 _plotCoordinates = new QLineEdit; _plotCoordinates ->setObjectName("PPP/plotCoordinates"); _widgets << _plotCoordinates;
73 _mapWinButton = new QPushButton; _mapWinButton ->setObjectName("PPP/mapWinButton"); _widgets << _mapWinButton;
74 _gmRadioButton = new QRadioButton; _gmRadioButton ->setObjectName("PPP/gmRadioButton"); _widgets << _gmRadioButton;
75 _osmRadioButton = new QRadioButton; _osmRadioButton ->setObjectName("PPP/osmRadioButton"); _widgets << _osmRadioButton;
76 _mapWinDotSizeLineEdit = new QLineEdit; _mapWinDotSizeLineEdit ->setObjectName("PPP/mapWinDotSizeLineEdit"); _widgets << _mapWinDotSizeLineEdit;
77 _mapWinDotColorComboBox = new QComboBox; _mapWinDotColorComboBox->setObjectName("PPP/mapWinDotColorComboBox"); _widgets << _mapWinDotColorComboBox;
78 _mapSpeedSlider = new QSlider; _mapSpeedSlider ->setObjectName("PPP/mapSpeedSlider"); _widgets << _mapSpeedSlider;
79
80 _dataSource->setEditable(false);
81 _dataSource->addItems(QString("no,Real-Time Streams,RINEX Files").split(","));
82 connect(_dataSource, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(slotEnableWidgets()));
83
84 _lcGPS->setEditable(false);
85 _lcGPS->addItems(QString("no,P3,L3,P3&L3").split(","));
86
87 _lcGLONASS->setEditable(false);
88 _lcGLONASS->addItems(QString("no,P3,L3,P3&L3").split(","));
89
90 _lcGalileo->setEditable(false);
91 _lcGalileo->addItems(QString("no,P3,L3,P3&L3").split(","));
92
93 _corrWaitTime->setMinimum(0);
94 _corrWaitTime->setMaximum(20);
95 _corrWaitTime->setSingleStep(1);
96 _corrWaitTime->setSuffix(" sec");
97 _corrWaitTime->setSpecialValueText("no");
98
99 _staTable->setColumnCount(9);
100 _staTable->setRowCount(0);
101 _staTable->setHorizontalHeaderLabels(
102 QString("Station,Sigma N,Sigma E,Sigma H,Noise N,Noise E,Noise H,Tropo Sigma,Tropo Noise").split(","));
103 _staTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
104 _staTable->setSelectionBehavior(QAbstractItemView::SelectRows);
105 _staTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
106 /// _staTable->horizontalHeader()->setStretchLastSection(true);
107 _staTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
108
109 connect(_addStaButton, SIGNAL(clicked()), this, SLOT(slotAddStation()));
110 connect(_delStaButton, SIGNAL(clicked()), this, SLOT(slotDelStation()));
111
112 _mapWinButton->setText("Open Map");
113
114 _mapWinDotColorComboBox->setEditable(false);
115 _mapWinDotColorComboBox->addItems(QString("red,yellow").split(","));
116
117 _mapSpeedSlider->setOrientation(Qt::Horizontal);
118 _mapSpeedSlider->setRange(1, 100);
119 _mapSpeedSlider->setTickPosition(QSlider::TicksBelow);
120 _mapSpeedSlider->setTickInterval(10);
121
122 readOptions();
123}
124
125//
126////////////////////////////////////////////////////////////////////////////
127void t_pppWidgets::readOptions() {
128
129 bncSettings settings;
130
131 // ComboBoxes
132 // ----------
133 int ii = _dataSource->findText(settings.value(_dataSource->objectName()).toString());
134 if (ii != -1) {
135 _dataSource->setCurrentIndex(ii);
136 }
137 ii = _lcGPS->findText(settings.value(_lcGPS->objectName()).toString());
138 if (ii != -1) {
139 _lcGPS->setCurrentIndex(ii);
140 }
141 ii = _lcGLONASS->findText(settings.value(_lcGLONASS->objectName()).toString());
142 if (ii != -1) {
143 _lcGLONASS->setCurrentIndex(ii);
144 }
145 ii = _lcGalileo->findText(settings.value(_lcGalileo->objectName()).toString());
146 if (ii != -1) {
147 _lcGalileo->setCurrentIndex(ii);
148 }
149
150 // FileChoosers
151 // ------------
152 _rinexObs ->setFileName(settings.value(_rinexObs ->objectName()).toString());
153 _rinexNav ->setFileName(settings.value(_rinexNav ->objectName()).toString());
154 _corrFile ->setFileName(settings.value(_corrFile ->objectName()).toString());
155 _crdFile ->setFileName(settings.value(_crdFile ->objectName()).toString());
156 _antexFile->setFileName(settings.value(_antexFile->objectName()).toString());
157
158 // LineEdits
159 // ---------
160 _corrMount->setText(settings.value(_corrMount->objectName()).toString());
161 _logFile ->setText(settings.value(_logFile ->objectName()).toString());
162 _nmeaFile ->setText(settings.value(_nmeaFile ->objectName()).toString());
163 _nmeaPort ->setText(settings.value(_nmeaPort ->objectName()).toString());
164 _sigmaC1 ->setText(settings.value(_sigmaC1 ->objectName()).toString());
165 _sigmaL1 ->setText(settings.value(_sigmaL1 ->objectName()).toString());
166
167 // SpinBox
168 // -------
169 _corrWaitTime->setValue(settings.value(_corrWaitTime->objectName()).toInt());
170
171 // Table with stations
172 // -------------------
173 for (int iRow = _staTable->rowCount()-1; iRow >=0; iRow--) {
174 _staTable->removeRow(iRow);
175 }
176 int iRow = -1;
177 QListIterator<QString> it(settings.value(_staTable->objectName()).toStringList());
178 while (it.hasNext()) {
179 QStringList hlp = it.next().split(",");
180 ++iRow;
181 _staTable->insertRow(iRow);
182 for (int iCol = 0; iCol < hlp.size(); iCol++) {
183 _staTable->setItem(iRow, iCol, new QTableWidgetItem(hlp[iCol]));
184 }
185 }
186
187 // Plots and Maps
188 // --------------
189 _plotCoordinates ->setText(settings.value(_plotCoordinates->objectName()).toString());
190 _gmRadioButton ->setChecked(!settings.value(_gmRadioButton->objectName()).toBool());
191 _osmRadioButton ->setChecked(settings.value(_osmRadioButton->objectName()).toBool());
192 _mapWinDotSizeLineEdit->setText(settings.value(_mapWinDotSizeLineEdit->objectName()).toString());
193
194 ii = _mapWinDotColorComboBox->findText(settings.value(_mapWinDotColorComboBox->objectName()).toString());
195 if (ii != -1) {
196 _mapWinDotColorComboBox->setCurrentIndex(ii);
197 }
198
199 int speed = settings.value(_mapSpeedSlider->objectName()).toInt();
200 if (speed == 0) speed = _mapSpeedSlider->maximum();
201 _mapSpeedSlider->setSliderPosition(speed);
202}
203
204//
205////////////////////////////////////////////////////////////////////////////
206void t_pppWidgets::saveOptions() {
207
208 bncSettings settings;
209
210 settings.setValue(_dataSource ->objectName(), _dataSource ->currentText());
211 settings.setValue(_rinexObs ->objectName(), _rinexObs ->fileName());
212 settings.setValue(_rinexNav ->objectName(), _rinexNav ->fileName());
213 settings.setValue(_corrMount ->objectName(), _corrMount ->text());
214 settings.setValue(_corrFile ->objectName(), _corrFile ->fileName());
215 settings.setValue(_crdFile ->objectName(), _crdFile ->fileName());
216 settings.setValue(_antexFile ->objectName(), _antexFile ->fileName());
217 settings.setValue(_logFile ->objectName(), _logFile ->text());
218 settings.setValue(_nmeaFile ->objectName(), _nmeaFile ->text());
219 settings.setValue(_nmeaPort ->objectName(), _nmeaPort ->text());
220 settings.setValue(_lcGPS ->objectName(), _lcGPS ->currentText());
221 settings.setValue(_lcGLONASS ->objectName(), _lcGLONASS ->currentText());
222 settings.setValue(_lcGalileo ->objectName(), _lcGalileo ->currentText());
223 settings.setValue(_sigmaC1 ->objectName(), _sigmaC1 ->text());
224 settings.setValue(_sigmaL1 ->objectName(), _sigmaL1 ->text());
225 settings.setValue(_corrWaitTime->objectName(), _corrWaitTime->value());
226
227 QStringList staList;
228 for (int iRow = 0; iRow < _staTable->rowCount(); iRow++) {
229 QString hlp;
230 for (int iCol = 0; iCol < _staTable->columnCount(); iCol++) {
231 if (_staTable->item(iRow, iCol)) {
232 hlp += _staTable->item(iRow, iCol)->text() + ",";
233 }
234 }
235 if (!hlp.isEmpty()) {
236 staList << hlp;
237 }
238 }
239 settings.setValue(_staTable->objectName(), staList);
240}
241
242//
243////////////////////////////////////////////////////////////////////////////
244void t_pppWidgets::slotEnableWidgets() {
245
246 const static QPalette paletteWhite(QColor(255, 255, 255));
247 const static QPalette paletteGray(QColor(230, 230, 230));
248
249 bool allDisabled = _dataSource->currentText() == "no";
250 bool realTime = _dataSource->currentText() == "Real-Time Streams";
251 bool rinexFiles = _dataSource->currentText() == "RINEX Files";
252
253 QListIterator<QWidget*> it(_widgets);
254 while (it.hasNext()) {
255 QWidget* widget = it.next();
256 widget->setEnabled(!allDisabled);
257 }
258
259 if (realTime) {
260 _rinexObs->setEnabled(false);
261 _rinexNav->setEnabled(false);
262 _corrFile->setEnabled(false);
263 }
264 else if (rinexFiles) {
265 _corrMount->setEnabled(false);
266 }
267
268 _dataSource->setEnabled(true);
269
270 it.toFront();
271 while (it.hasNext()) {
272 QWidget* widget = it.next();
273 if (widget->isEnabled()) {
274 widget->setPalette(paletteWhite);
275 }
276 else {
277 widget->setPalette(paletteGray);
278 }
279 }
280}
281
282//
283////////////////////////////////////////////////////////////////////////////
284void t_pppWidgets::slotAddStation() {
285 int iRow = _staTable->rowCount();
286 _staTable->insertRow(iRow);
287 for (int iCol = 0; iCol < _staTable->columnCount(); iCol++) {
288 _staTable->setItem(iRow, iCol, new QTableWidgetItem(""));
289 }
290}
291
292//
293////////////////////////////////////////////////////////////////////////////
294void t_pppWidgets::slotDelStation() {
295 int nRows = _staTable->rowCount();
296 bool flg[nRows];
297 for (int iRow = 0; iRow < nRows; iRow++) {
298 if (_staTable->isItemSelected(_staTable->item(iRow,1))) {
299 flg[iRow] = true;
300 }
301 else {
302 flg[iRow] = false;
303 }
304 }
305 for (int iRow = nRows-1; iRow >= 0; iRow--) {
306 if (flg[iRow]) {
307 _staTable->removeRow(iRow);
308 }
309 }
310}
311
Note: See TracBrowser for help on using the repository browser.