[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncTableDlg
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Displays the source table, allows mountpoints selection
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Dec-2005
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[1493] | 41 | #include <iostream>
|
---|
| 42 |
|
---|
[35] | 43 | #include "bnctabledlg.h"
|
---|
| 44 | #include "bncgetthread.h"
|
---|
[1848] | 45 | #include "bncnetqueryv1.h"
|
---|
[3335] | 46 | #include "bncnetqueryv2.h"
|
---|
[1535] | 47 | #include "bncsettings.h"
|
---|
[2753] | 48 | #include "bncmap.h"
|
---|
[35] | 49 |
|
---|
[1373] | 50 | using namespace std;
|
---|
| 51 |
|
---|
[35] | 52 | // Constructor
|
---|
| 53 | ////////////////////////////////////////////////////////////////////////////
|
---|
[90] | 54 | bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
|
---|
[35] | 55 |
|
---|
| 56 | setMinimumSize(600,400);
|
---|
[1611] | 57 | setWindowTitle(tr("Add Streams from Caster"));
|
---|
[35] | 58 |
|
---|
| 59 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
| 60 |
|
---|
[1474] | 61 | int ww = QFontMetrics(font()).width('w');
|
---|
| 62 |
|
---|
| 63 | _casterPortLineEdit = new QLineEdit();
|
---|
| 64 | _casterPortLineEdit->setMaximumWidth(9*ww);
|
---|
| 65 |
|
---|
| 66 | _casterUserLineEdit = new QLineEdit();
|
---|
| 67 | _casterUserLineEdit->setMaximumWidth(9*ww);
|
---|
| 68 |
|
---|
| 69 | _casterPasswordLineEdit = new QLineEdit();
|
---|
| 70 | _casterPasswordLineEdit->setMaximumWidth(9*ww);
|
---|
[3294] | 71 | _casterPasswordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
---|
[1474] | 72 |
|
---|
| 73 | _casterHostComboBox = new QComboBox();
|
---|
[1482] | 74 | _casterHostComboBox->setMaxCount(10);
|
---|
[1474] | 75 | _casterHostComboBox->setDuplicatesEnabled(false);
|
---|
| 76 | _casterHostComboBox->setEditable(true);
|
---|
[1477] | 77 | _casterHostComboBox->setMinimumWidth(20*ww);
|
---|
[1474] | 78 | _casterHostComboBox->setMaximumWidth(20*ww);
|
---|
| 79 | connect(_casterHostComboBox, SIGNAL(currentIndexChanged(const QString&)),
|
---|
| 80 | this, SLOT(slotCasterHostChanged(const QString&)));
|
---|
[1535] | 81 | bncSettings settings;
|
---|
[1481] | 82 | settings.remove("casterHostList");
|
---|
| 83 | settings.remove("casterHost");
|
---|
| 84 | settings.remove("casterPort");
|
---|
| 85 | settings.remove("casterUser");
|
---|
| 86 | settings.remove("casterPassword");
|
---|
[1476] | 87 | QStringList casterUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 88 | for (int ii = 0; ii < casterUrlList.count(); ii++) {
|
---|
| 89 | QUrl url(casterUrlList[ii]);
|
---|
[1474] | 90 | _casterHostComboBox->addItem(url.host());
|
---|
[1274] | 91 | }
|
---|
[683] | 92 |
|
---|
[1350] | 93 | _ntripVersionComboBox = new QComboBox();
|
---|
[3335] | 94 | _ntripVersionComboBox->addItems(QString("1,2,2s,R,U").split(","));
|
---|
[1350] | 95 | int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
|
---|
| 96 | if (kk != -1) {
|
---|
| 97 | _ntripVersionComboBox->setCurrentIndex(kk);
|
---|
| 98 | }
|
---|
[1459] | 99 | _ntripVersionComboBox->setMaximumWidth(5*ww);
|
---|
[1350] | 100 |
|
---|
[1459] | 101 | _buttonCasterTable = new QPushButton(tr("Show"), this);
|
---|
| 102 | connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
|
---|
| 103 | _buttonCasterTable->setMaximumWidth(5*ww);
|
---|
| 104 |
|
---|
[683] | 105 | // WhatsThis
|
---|
| 106 | // ---------
|
---|
[1459] | 107 | _casterUserLineEdit->setWhatsThis(tr("<p>Access to some streams on NTRIP broadcasters may be restricted. You'll need to enter a valid 'User ID' and 'Password' for access to these protected streams.</p><p>Accounts are usually provided per NTRIP broadcaster through a registration process. Register through <u>http://igs.bkg.bund.de/index_ntrip_reg.htm</u> for access to protected streams on <u>www.euref-ip.net</u> and <u>www.igs-ip.net</u>.</p>"));
|
---|
[1474] | 108 | _casterHostComboBox->setWhatsThis(tr("<p>Enter the NTRIP broadcaster hostname or IP number.</p><p>Note that EUREF and IGS operate NTRIP broadcasters at <u>http://www.euref-ip.net/home</u> and <u>http://www.igs-ip.net/home</u>.</p>"));
|
---|
[1459] | 109 | _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
|
---|
| 110 | _casterPasswordLineEdit->setWhatsThis(tr("Access to some streams on NTRIP broadcasters may be restricted. You'll need to enter a valid 'Password' for access to these protected streams."));
|
---|
[35] | 111 |
|
---|
[88] | 112 | QGridLayout* editLayout = new QGridLayout;
|
---|
[1459] | 113 | editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
|
---|
[1474] | 114 | editLayout->addWidget(_casterHostComboBox, 0, 1);
|
---|
[1459] | 115 | editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
|
---|
| 116 | editLayout->addWidget(_casterPortLineEdit, 0, 3);
|
---|
[1598] | 117 | editLayout->addWidget(new QLabel(tr("Casters table")), 0, 4, Qt::AlignRight);
|
---|
[1459] | 118 | editLayout->addWidget(_buttonCasterTable, 0, 5);
|
---|
| 119 | editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
|
---|
| 120 | editLayout->addWidget(_casterUserLineEdit, 1, 1);
|
---|
| 121 | editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
|
---|
| 122 | editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
|
---|
| 123 | editLayout->addWidget(new QLabel(tr(" NTRIP Version")),1, 4, Qt::AlignRight);
|
---|
| 124 | editLayout->addWidget(_ntripVersionComboBox, 1, 5);
|
---|
[88] | 125 |
|
---|
[35] | 126 | mainLayout->addLayout(editLayout);
|
---|
| 127 |
|
---|
[1471] | 128 | _buttonCasterTable->setWhatsThis(tr("<p>Hit 'Show' for a table of known NTRIP broadcaster installations as maintained at <u>www.rtcm-ntrip.org/home.</u></p><p>A window opens which allows to select a broadcaster for stream retrieval.</p>"));
|
---|
[3780] | 129 | _ntripVersionComboBox->setWhatsThis(tr("<p>Select the NTRIP transport protocol version you want to use. Implemented options are:<br> 1: NTRIP version 1, TCP/IP<br> 2: NTRIP version 2, TCP/IP mode<br> 2s: NTRIP version 2 TCP/IP mode via SSL<br> R: NTRIP Version 2, RTSP/RTP mode<br> U: NTRIP Version 2, UDP mode<br>Select option '1' if you are not sure whether the NTRIP broadcaster supports NTRIP version 2.</p><p>Note that RTSP/RTP (option 'R') and UDP (option 'U') are not accepted by proxies and sometimes not supported by mobile Internet Service Providers.</p>"));
|
---|
[1409] | 130 |
|
---|
[35] | 131 | _table = new QTableWidget(this);
|
---|
[3345] | 132 | _table->setWhatsThis(tr("<p>Use the 'Get Table' button to download the sourcetable from the selected NTRIP broadcaster. Select the desired streams line by line, using +Shift and +Ctrl when necessary. Hit 'OK' to return to the main window.</p><p>Pay attention to data field 'format'. Keep in mind that BNC can only decode and convert streams that come in RTCM Version 2.x, or RTCM Version 3.x format. See data field 'format-details' for available message types and their repetition rates in brackets.</p><p>The content of data field 'nmea' tells you whether a stream comes from a virtual reference station (VRS).</p>"));
|
---|
[195] | 133 | connect(_table, SIGNAL(itemSelectionChanged()),
|
---|
| 134 | this, SLOT(slotSelectionChanged()));
|
---|
[35] | 135 | mainLayout->addWidget(_table);
|
---|
| 136 |
|
---|
[402] | 137 | _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
|
---|
[399] | 138 | connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
|
---|
| 139 |
|
---|
[195] | 140 | _buttonGet = new QPushButton(tr("Get table"), this);
|
---|
[399] | 141 | _buttonGet->setDefault(true);
|
---|
[35] | 142 | connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
|
---|
[366] | 143 |
|
---|
[2753] | 144 | _buttonMap = new QPushButton(tr("Map"), this);
|
---|
| 145 | _buttonMap->setEnabled(false);
|
---|
| 146 | connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap()));
|
---|
| 147 |
|
---|
[2796] | 148 | _buttonClose = new QPushButton(tr("Close"), this);
|
---|
| 149 | connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
|
---|
[35] | 150 |
|
---|
[2796] | 151 | _buttonSelect = new QPushButton(tr("Select"), this);
|
---|
| 152 | connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select()));
|
---|
[35] | 153 |
|
---|
| 154 | QHBoxLayout* buttonLayout = new QHBoxLayout;
|
---|
[399] | 155 | buttonLayout->addWidget(_buttonWhatsThis);
|
---|
[35] | 156 | buttonLayout->addStretch(1);
|
---|
[2753] | 157 | buttonLayout->addWidget(_buttonMap);
|
---|
[35] | 158 | buttonLayout->addWidget(_buttonGet);
|
---|
[2796] | 159 | buttonLayout->addWidget(_buttonSelect);
|
---|
| 160 | buttonLayout->addWidget(_buttonClose);
|
---|
[35] | 161 |
|
---|
| 162 | mainLayout->addLayout(buttonLayout);
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | // Destructor
|
---|
| 166 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 167 | bncTableDlg::~bncTableDlg() {
|
---|
[1490] | 168 | delete _casterHostComboBox;
|
---|
| 169 | delete _casterPortLineEdit;
|
---|
| 170 | delete _casterUserLineEdit;
|
---|
| 171 | delete _casterPasswordLineEdit;
|
---|
[3361] | 172 | bncSettings settings;
|
---|
| 173 | settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
|
---|
| 174 | settings.sync();
|
---|
[1490] | 175 | delete _ntripVersionComboBox;
|
---|
| 176 | delete _buttonGet;
|
---|
[2796] | 177 | delete _buttonClose;
|
---|
| 178 | delete _buttonSelect;
|
---|
[1490] | 179 | delete _buttonWhatsThis;
|
---|
| 180 | delete _buttonCasterTable;
|
---|
| 181 | delete _table;
|
---|
[35] | 182 | }
|
---|
| 183 |
|
---|
[1493] | 184 | // Read full caster table (static)
|
---|
[35] | 185 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3335] | 186 | t_irc bncTableDlg::getFullTable(const QString& ntripVersion,
|
---|
| 187 | const QString& casterHost,
|
---|
[1376] | 188 | int casterPort, QStringList& allLines,
|
---|
| 189 | bool alwaysRead) {
|
---|
[35] | 190 |
|
---|
[299] | 191 | static QMutex mutex;
|
---|
[298] | 192 | static QMap<QString, QStringList> allTables;
|
---|
| 193 |
|
---|
[299] | 194 | QMutexLocker locker(&mutex);
|
---|
| 195 |
|
---|
[298] | 196 | if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
|
---|
| 197 | allLines = allTables.find(casterHost).value();
|
---|
| 198 | return success;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
[191] | 201 | allLines.clear();
|
---|
| 202 |
|
---|
[3335] | 203 | bncNetQuery* query = 0;
|
---|
[3337] | 204 | if (ntripVersion == "2") {
|
---|
| 205 | query = new bncNetQueryV2(false);
|
---|
[3335] | 206 | }
|
---|
[3337] | 207 | else if (ntripVersion == "2s") {
|
---|
| 208 | query = new bncNetQueryV2(true);
|
---|
| 209 | }
|
---|
[3335] | 210 | else {
|
---|
| 211 | query = new bncNetQueryV1();
|
---|
| 212 | }
|
---|
| 213 |
|
---|
[88] | 214 | QUrl url;
|
---|
[191] | 215 | url.setHost(casterHost);
|
---|
| 216 | url.setPort(casterPort);
|
---|
[1375] | 217 | url.setPath("/");
|
---|
[3335] | 218 | if (ntripVersion == "2s") {
|
---|
| 219 | url.setScheme("https");
|
---|
| 220 | }
|
---|
| 221 | else {
|
---|
| 222 | url.setScheme("http");
|
---|
| 223 | }
|
---|
[35] | 224 |
|
---|
[1373] | 225 | QByteArray outData;
|
---|
[3335] | 226 | query->waitForRequestResult(url, outData);
|
---|
| 227 | if (query->status() == bncNetQuery::finished) {
|
---|
[1375] | 228 | QTextStream in(outData);
|
---|
| 229 | QString line = in.readLine();
|
---|
| 230 | while ( !line.isNull() ) {
|
---|
| 231 | allLines.append(line);
|
---|
| 232 | line = in.readLine();
|
---|
| 233 | }
|
---|
| 234 | allTables.insert(casterHost, allLines);
|
---|
[3335] | 235 | delete query;
|
---|
[1375] | 236 | return success;
|
---|
| 237 | }
|
---|
| 238 | else {
|
---|
[3335] | 239 | delete query;
|
---|
[191] | 240 | return failure;
|
---|
[35] | 241 | }
|
---|
[191] | 242 | }
|
---|
| 243 |
|
---|
| 244 | // Read Table from Caster
|
---|
| 245 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 246 | void bncTableDlg::slotGetTable() {
|
---|
| 247 |
|
---|
[555] | 248 | _buttonGet->setEnabled(false);
|
---|
[2753] | 249 | _buttonMap->setEnabled(true);
|
---|
[1459] | 250 | _buttonCasterTable->setEnabled(false);
|
---|
[555] | 251 |
|
---|
[3335] | 252 | if ( getFullTable(_ntripVersionComboBox->currentText(),
|
---|
| 253 | _casterHostComboBox->currentText(),
|
---|
[191] | 254 | _casterPortLineEdit->text().toInt(),
|
---|
[1493] | 255 | _allLines, true) != success ) {
|
---|
[191] | 256 | QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
|
---|
[645] | 257 | _buttonGet->setEnabled(true);
|
---|
[191] | 258 | return;
|
---|
| 259 | }
|
---|
[2753] | 260 |
|
---|
[1493] | 261 | static const QStringList labels = QString("mountpoint,identifier,format,"
|
---|
| 262 | "format-details,carrier,system,network,country,lat,long,"
|
---|
| 263 | "nmea,solution,generator,compress.,auth.,fee,bitrate,"
|
---|
| 264 | "misc").split(",");
|
---|
| 265 |
|
---|
[191] | 266 | QStringList lines;
|
---|
[196] | 267 | QStringListIterator it(_allLines);
|
---|
[191] | 268 | while (it.hasNext()) {
|
---|
| 269 | QString line = it.next();
|
---|
| 270 | if (line.indexOf("STR") == 0) {
|
---|
[1493] | 271 | QStringList hlp = line.split(";");
|
---|
| 272 | if (hlp.size() > labels.size()) {
|
---|
| 273 | lines.push_back(line);
|
---|
| 274 | }
|
---|
[191] | 275 | }
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | if (lines.size() > 0) {
|
---|
[35] | 279 | _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 280 | _table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
[1493] | 281 | _table->setColumnCount(labels.size());
|
---|
| 282 | _table->setRowCount(lines.size());
|
---|
| 283 | for (int nRow = 0; nRow < lines.size(); nRow++) {
|
---|
| 284 | QStringList columns = lines[nRow].split(";");
|
---|
| 285 | for (int ic = 1; ic < columns.size(); ic++) {
|
---|
| 286 | if (ic == 11) {
|
---|
| 287 | if (columns[ic] == "0") {
|
---|
| 288 | columns[ic] = "no";
|
---|
| 289 | } else {
|
---|
| 290 | columns[ic] = "yes";
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 | QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
|
---|
| 294 | item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
---|
| 295 | _table->setItem(nRow, ic-1, item);
|
---|
[35] | 296 | }
|
---|
| 297 | }
|
---|
[103] | 298 | _table->setHorizontalHeaderLabels(labels);
|
---|
[104] | 299 | _table->setSortingEnabled(true);
|
---|
[371] | 300 | int ww = QFontMetrics(this->font()).width('w');
|
---|
[1493] | 301 | _table->horizontalHeader()->resizeSection( 0,10*ww);
|
---|
| 302 | _table->horizontalHeader()->resizeSection( 1,10*ww);
|
---|
| 303 | _table->horizontalHeader()->resizeSection( 2, 8*ww);
|
---|
| 304 | _table->horizontalHeader()->resizeSection( 3,22*ww);
|
---|
| 305 | _table->horizontalHeader()->resizeSection( 4, 5*ww);
|
---|
| 306 | _table->horizontalHeader()->resizeSection( 5, 8*ww);
|
---|
| 307 | _table->horizontalHeader()->resizeSection( 6, 8*ww);
|
---|
| 308 | _table->horizontalHeader()->resizeSection( 7, 7*ww);
|
---|
| 309 | _table->horizontalHeader()->resizeSection( 8, 6*ww);
|
---|
| 310 | _table->horizontalHeader()->resizeSection( 9, 6*ww);
|
---|
| 311 | _table->horizontalHeader()->resizeSection(10, 6*ww);
|
---|
| 312 | _table->horizontalHeader()->resizeSection(11, 6*ww);
|
---|
[371] | 313 | _table->horizontalHeader()->resizeSection(12,15*ww);
|
---|
[1493] | 314 | _table->horizontalHeader()->resizeSection(13, 8*ww);
|
---|
| 315 | _table->horizontalHeader()->resizeSection(14, 5*ww);
|
---|
| 316 | _table->horizontalHeader()->resizeSection(15, 5*ww);
|
---|
| 317 | _table->horizontalHeader()->resizeSection(16, 7*ww);
|
---|
[371] | 318 | _table->horizontalHeader()->resizeSection(17,15*ww);
|
---|
[1493] | 319 | _table->sortItems(0);
|
---|
[35] | 320 | }
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[2753] | 323 | // Show world map
|
---|
| 324 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 325 | void bncTableDlg::slotShowMap() {
|
---|
| 326 |
|
---|
| 327 | bncMap* winMap = new bncMap(this);
|
---|
[2796] | 328 | winMap->setGeometry( x(), int(y()+height()*1.3), 880, 440 );
|
---|
[2753] | 329 |
|
---|
[3292] | 330 | connect(this, SIGNAL(newPoint(QPointF, QString, QPen, double)),
|
---|
| 331 | winMap, SLOT(slotNewPoint(QPointF, QString, QPen, double)));
|
---|
[2753] | 332 |
|
---|
[2796] | 333 | connect(this, SIGNAL(fitMap()),
|
---|
| 334 | winMap, SLOT(slotFitMap() ));
|
---|
[3292] | 335 |
|
---|
| 336 | connect(this, SIGNAL(fitFont()),
|
---|
| 337 | winMap, SLOT(slotFitFont() ));
|
---|
[2796] | 338 |
|
---|
[2753] | 339 | _buttonMap->setEnabled(false);
|
---|
| 340 | showSourceTable();
|
---|
| 341 | winMap->exec();
|
---|
| 342 | _buttonMap->setEnabled(true);
|
---|
| 343 |
|
---|
[3292] | 344 | disconnect(this, SIGNAL(newPoint(QPointF, QString, QPen, double)),
|
---|
| 345 | winMap, SLOT(slotNewPoint(QPointF, QString, QPen, double)));
|
---|
[2753] | 346 |
|
---|
[2796] | 347 | disconnect(this, SIGNAL(fitMap()),
|
---|
| 348 | winMap, SLOT(slotFitMap() ));
|
---|
| 349 |
|
---|
[3292] | 350 | disconnect(this, SIGNAL(fitFont()),
|
---|
| 351 | winMap, SLOT(slotFitFont() ));
|
---|
| 352 |
|
---|
[2753] | 353 | delete winMap;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | // Show world map
|
---|
| 357 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 358 | void bncTableDlg::showSourceTable() {
|
---|
| 359 |
|
---|
| 360 | for( int i = 0; i < _allLines.size(); i++ ){
|
---|
| 361 |
|
---|
| 362 | if( _allLines.at(i).startsWith("STR") == true ){
|
---|
| 363 |
|
---|
| 364 | QStringList tmp = _allLines.at(i).split(';');
|
---|
| 365 | if( tmp.size() > 0 ){
|
---|
| 366 |
|
---|
| 367 | QPointF point;
|
---|
| 368 | point.setY( tmp.at(9).toDouble() );
|
---|
| 369 | point.setX( tmp.at(10).toDouble() );
|
---|
[2796] | 370 |
|
---|
[2753] | 371 | QString site = tmp.at(1);
|
---|
| 372 | site.resize(4);
|
---|
| 373 |
|
---|
[3292] | 374 | emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,200)), 1.5), 1.5 );
|
---|
[2796] | 375 | }
|
---|
[2753] | 376 | }
|
---|
| 377 | }
|
---|
[2796] | 378 | emit fitMap();
|
---|
[2753] | 379 | }
|
---|
| 380 |
|
---|
| 381 |
|
---|
[2796] | 382 | // Select slot
|
---|
[35] | 383 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2796] | 384 | void bncTableDlg::select() {
|
---|
[35] | 385 |
|
---|
[3335] | 386 | QString ntripVersion = _ntripVersionComboBox->currentText();
|
---|
[3336] | 387 |
|
---|
[1476] | 388 | QUrl url;
|
---|
[3335] | 389 | if (ntripVersion == "2s") {
|
---|
| 390 | url.setScheme("https");
|
---|
| 391 | }
|
---|
| 392 | else {
|
---|
| 393 | url.setScheme("http");
|
---|
| 394 | }
|
---|
[1476] | 395 | url.setHost(_casterHostComboBox->currentText());
|
---|
| 396 | url.setPort(_casterPortLineEdit->text().toInt());
|
---|
[1508] | 397 | url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
|
---|
| 398 | url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
|
---|
[1477] | 399 | addUrl(url);
|
---|
[1476] | 400 |
|
---|
[35] | 401 | QStringList* mountPoints = new QStringList;
|
---|
| 402 | if (_table) {
|
---|
| 403 | for (int ir = 0; ir < _table->rowCount(); ir++) {
|
---|
[59] | 404 | QTableWidgetItem* item = _table->item(ir,0);
|
---|
[2753] | 405 | QString site = _table->item(ir,0)->text();
|
---|
[59] | 406 | QString format = _table->item(ir,2)->text();
|
---|
[366] | 407 | QString latitude = _table->item(ir,8)->text();
|
---|
| 408 | QString longitude = _table->item(ir,9)->text();
|
---|
| 409 | QString nmea = _table->item(ir,10)->text();
|
---|
[59] | 410 | format.replace(" ", "_");
|
---|
[35] | 411 | if (_table->isItemSelected(item)) {
|
---|
| 412 | url.setPath(item->text());
|
---|
[2796] | 413 | mountPoints->push_back(url.toString() + " " + format + " " + latitude
|
---|
[1351] | 414 | + " " + longitude + " " + nmea + " " + ntripVersion);
|
---|
[2753] | 415 |
|
---|
[2796] | 416 | site.resize(4);
|
---|
[2753] | 417 | emit newPoint(QPointF(longitude.toDouble(),latitude.toDouble()), site,
|
---|
[3292] | 418 | QPen(QBrush(QColor(255,0,0,200)), 3.0), 3.0 );
|
---|
[35] | 419 | }
|
---|
| 420 | }
|
---|
| 421 | }
|
---|
| 422 | emit newMountPoints(mountPoints);
|
---|
[3292] | 423 | emit fitFont();
|
---|
[35] | 424 | }
|
---|
[195] | 425 |
|
---|
| 426 | // User changed the selection of mountPoints
|
---|
| 427 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 428 | void bncTableDlg::slotSelectionChanged() {
|
---|
| 429 | if (_table->selectedItems().isEmpty()) {
|
---|
| 430 | }
|
---|
| 431 | }
|
---|
| 432 |
|
---|
[399] | 433 | // Whats This Help
|
---|
| 434 | void bncTableDlg::slotWhatsThis() {
|
---|
| 435 | QWhatsThis::enterWhatsThisMode();
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[1459] | 438 | // Slot caster table
|
---|
| 439 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 440 | void bncTableDlg::slotCasterTable() {
|
---|
| 441 |
|
---|
| 442 | _buttonCasterTable->setEnabled(false);
|
---|
[1474] | 443 | _casterHostComboBox->setEnabled(false);
|
---|
[1461] | 444 | _casterPortLineEdit->setEnabled(false);
|
---|
| 445 | _casterUserLineEdit->setEnabled(false);
|
---|
| 446 | _casterPasswordLineEdit->setEnabled(false);
|
---|
| 447 | _ntripVersionComboBox->setEnabled(false);
|
---|
| 448 | _buttonWhatsThis->setEnabled(false);
|
---|
| 449 | _buttonGet->setEnabled(false);
|
---|
[2796] | 450 | _buttonClose->setEnabled(false);
|
---|
| 451 | _buttonSelect->setEnabled(false);
|
---|
[1461] | 452 |
|
---|
[3335] | 453 | bncCasterTableDlg* dlg =
|
---|
| 454 | new bncCasterTableDlg(_ntripVersionComboBox->currentText(), this);
|
---|
[1459] | 455 | dlg->move(this->pos().x()+50, this->pos().y()+50);
|
---|
[1474] | 456 | connect(dlg, SIGNAL(newCaster(QString, QString)),
|
---|
| 457 | this, SLOT(slotNewCaster(QString, QString)));
|
---|
[1459] | 458 | dlg->exec();
|
---|
| 459 | delete dlg;
|
---|
[1461] | 460 |
|
---|
[1459] | 461 | _buttonCasterTable->setEnabled(true);
|
---|
[1474] | 462 | _casterHostComboBox->setEnabled(true);
|
---|
[1461] | 463 | _casterPortLineEdit->setEnabled(true);
|
---|
| 464 | _casterUserLineEdit->setEnabled(true);
|
---|
| 465 | _casterPasswordLineEdit->setEnabled(true);
|
---|
| 466 | _ntripVersionComboBox->setEnabled(true);
|
---|
| 467 | _buttonWhatsThis->setEnabled(true);
|
---|
| 468 | _buttonGet->setEnabled(true);
|
---|
[2796] | 469 | _buttonClose->setEnabled(true);
|
---|
| 470 | _buttonSelect->setEnabled(true);
|
---|
[399] | 471 |
|
---|
[1459] | 472 | }
|
---|
| 473 |
|
---|
[1492] | 474 | // New caster selected
|
---|
| 475 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 476 | void bncTableDlg::slotNewCaster(QString newCasterHost, QString newCasterPort) {
|
---|
| 477 |
|
---|
| 478 | _casterHostComboBox->insertItem(0, newCasterHost);
|
---|
| 479 | _casterHostComboBox->setCurrentIndex(0);
|
---|
| 480 | _casterUserLineEdit->setText("");
|
---|
[1497] | 481 | _casterPasswordLineEdit->setText("");
|
---|
[1492] | 482 | _casterPortLineEdit->setText(newCasterPort);
|
---|
| 483 |
|
---|
[3336] | 484 | QString ntripVersion = _ntripVersionComboBox->currentText();
|
---|
| 485 |
|
---|
[1492] | 486 | QUrl url;
|
---|
[3336] | 487 | if (ntripVersion == "2s") {
|
---|
| 488 | url.setScheme("https");
|
---|
| 489 | }
|
---|
| 490 | else {
|
---|
| 491 | url.setScheme("http");
|
---|
| 492 | }
|
---|
[1492] | 493 | url.setHost(newCasterHost);
|
---|
| 494 | url.setPort(newCasterPort.toInt());
|
---|
| 495 | addUrl(url);
|
---|
| 496 |
|
---|
| 497 | _casterHostComboBox->setCurrentIndex(0);
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | // New caster selected
|
---|
| 501 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 502 | void bncTableDlg::addUrl(const QUrl& url) {
|
---|
[1535] | 503 | bncSettings settings;
|
---|
[1492] | 504 | QStringList oldUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 505 | QStringList newUrlList;
|
---|
| 506 | newUrlList << url.toString();
|
---|
| 507 | for (int ii = 0; ii < oldUrlList.count(); ii++) {
|
---|
| 508 | QUrl oldUrl(oldUrlList[ii]);
|
---|
| 509 | if (url.host() != oldUrl.host()) {
|
---|
| 510 | newUrlList << oldUrl.toString();
|
---|
| 511 | }
|
---|
| 512 | }
|
---|
| 513 | settings.setValue("casterUrlList", newUrlList);
|
---|
| 514 | settings.sync();
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | // New caster selected in combobox
|
---|
| 518 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 519 | void bncTableDlg::slotCasterHostChanged(const QString& newHost) {
|
---|
[1535] | 520 | bncSettings settings;
|
---|
[1492] | 521 | QStringList casterUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 522 | for (int ii = 0; ii < casterUrlList.count(); ii++) {
|
---|
| 523 | QUrl url(casterUrlList[ii]);
|
---|
| 524 | if (url.host() == newHost) {
|
---|
[1508] | 525 | _casterUserLineEdit->setText(
|
---|
| 526 | QUrl::fromPercentEncoding(url.userName().toAscii()));
|
---|
| 527 | _casterPasswordLineEdit->setText(
|
---|
| 528 | QUrl::fromPercentEncoding(url.password().toAscii()));
|
---|
[1492] | 529 | if (url.port() > 0) {
|
---|
| 530 | _casterPortLineEdit->setText(QString("%1").arg(url.port()));
|
---|
| 531 | }
|
---|
| 532 | else {
|
---|
| 533 | _casterPortLineEdit->setText("");
|
---|
| 534 | }
|
---|
| 535 | }
|
---|
| 536 | }
|
---|
| 537 | }
|
---|
| 538 |
|
---|
[1459] | 539 | // Caster table
|
---|
| 540 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3335] | 541 | bncCasterTableDlg::bncCasterTableDlg(const QString& ntripVersion,
|
---|
| 542 | QWidget* parent) :
|
---|
[1459] | 543 | QDialog(parent) {
|
---|
| 544 |
|
---|
[1461] | 545 | static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
|
---|
[1459] | 546 |
|
---|
| 547 | _casterTable = new QTableWidget(this);
|
---|
| 548 |
|
---|
| 549 | QUrl url;
|
---|
| 550 | url.setHost("www.rtcm-ntrip.org");
|
---|
| 551 | url.setPath("/");
|
---|
[3336] | 552 | if (ntripVersion == "2s") {
|
---|
| 553 | url.setPort(443);
|
---|
| 554 | url.setScheme("https");
|
---|
| 555 | }
|
---|
| 556 | else {
|
---|
| 557 | url.setPort(2101);
|
---|
| 558 | url.setScheme("http");
|
---|
| 559 | }
|
---|
[1459] | 560 |
|
---|
[3335] | 561 | bncNetQuery* query = 0;
|
---|
[3337] | 562 | if (ntripVersion == "2") {
|
---|
| 563 | query = new bncNetQueryV2(false);
|
---|
[3335] | 564 | }
|
---|
[3337] | 565 | else if (ntripVersion == "2s") {
|
---|
| 566 | query = new bncNetQueryV2(true);
|
---|
| 567 | }
|
---|
[3335] | 568 | else {
|
---|
| 569 | query = new bncNetQueryV1();
|
---|
| 570 | }
|
---|
| 571 |
|
---|
[1459] | 572 | QByteArray outData;
|
---|
[3335] | 573 | query->waitForRequestResult(url, outData);
|
---|
[1494] | 574 |
|
---|
| 575 | QStringList lines;
|
---|
[3335] | 576 | if (query->status() == bncNetQuery::finished) {
|
---|
[1459] | 577 | QTextStream in(outData);
|
---|
| 578 | QString line = in.readLine();
|
---|
| 579 | while ( !line.isNull() ) {
|
---|
| 580 | line = in.readLine();
|
---|
| 581 | if (line.indexOf("CAS") == 0) {
|
---|
[1494] | 582 | QStringList hlp = line.split(";");
|
---|
| 583 | if (hlp.size() > labels.size()) {
|
---|
| 584 | lines.push_back(line);
|
---|
| 585 | }
|
---|
[1459] | 586 | }
|
---|
| 587 | }
|
---|
| 588 | }
|
---|
[1494] | 589 |
|
---|
[3335] | 590 | delete query;
|
---|
| 591 |
|
---|
[1459] | 592 | if (lines.size() > 0) {
|
---|
| 593 | _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 594 | _casterTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
| 595 |
|
---|
| 596 | QStringList hlp = lines[0].split(";");
|
---|
[1494] | 597 | _casterTable->setColumnCount(labels.size());
|
---|
| 598 | _casterTable->setRowCount(lines.size());
|
---|
[1459] | 599 |
|
---|
[1494] | 600 | for (int nRow = 0; nRow < lines.size(); nRow++) {
|
---|
| 601 | QStringList columns = lines[nRow].split(";");
|
---|
| 602 | for (int ic = 1; ic < columns.size(); ic++) {
|
---|
| 603 | if (ic == 5) {
|
---|
| 604 | if (columns[ic] == "0") {
|
---|
| 605 | columns[ic] = "no";
|
---|
| 606 | } else {
|
---|
| 607 | columns[ic] = "yes";
|
---|
| 608 | }
|
---|
| 609 | }
|
---|
| 610 | QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
|
---|
| 611 | item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
---|
| 612 | _casterTable->setItem(nRow, ic-1, item);
|
---|
[1459] | 613 | }
|
---|
| 614 | }
|
---|
| 615 | }
|
---|
| 616 | _casterTable->setHorizontalHeaderLabels(labels);
|
---|
| 617 | _casterTable->setSortingEnabled(true);
|
---|
[1494] | 618 | _casterTable->sortItems(0);
|
---|
[1459] | 619 | int ww = QFontMetrics(this->font()).width('w');
|
---|
| 620 | _casterTable->horizontalHeader()->resizeSection(0,15*ww);
|
---|
[1494] | 621 | _casterTable->horizontalHeader()->resizeSection(1, 5*ww);
|
---|
[1459] | 622 | _casterTable->horizontalHeader()->resizeSection(2,15*ww);
|
---|
| 623 | _casterTable->horizontalHeader()->resizeSection(3,15*ww);
|
---|
[1494] | 624 | _casterTable->horizontalHeader()->resizeSection(4, 5*ww);
|
---|
| 625 | _casterTable->horizontalHeader()->resizeSection(5, 7*ww);
|
---|
| 626 | _casterTable->horizontalHeader()->resizeSection(6, 7*ww);
|
---|
| 627 | _casterTable->horizontalHeader()->resizeSection(7, 7*ww);
|
---|
[1459] | 628 | _casterTable->horizontalHeader()->resizeSection(8,15*ww);
|
---|
| 629 |
|
---|
[1488] | 630 | _closeButton = new QPushButton("Cancel");
|
---|
[1459] | 631 | connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
---|
| 632 | _closeButton->setMinimumWidth(8*ww);
|
---|
| 633 | _closeButton->setMaximumWidth(8*ww);
|
---|
| 634 |
|
---|
[1488] | 635 | _okButton = new QPushButton(tr("OK"), this);
|
---|
[1459] | 636 | connect(_okButton, SIGNAL(clicked()), this, SLOT(slotAcceptCasterTable()));
|
---|
| 637 | _okButton->setMinimumWidth(8*ww);
|
---|
| 638 | _okButton->setMaximumWidth(8*ww);
|
---|
| 639 |
|
---|
[1488] | 640 | _whatsThisButton = new QPushButton(tr("Help=Shift+F1"), this);
|
---|
| 641 | connect(_whatsThisButton, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
|
---|
| 642 | _whatsThisButton->setMinimumWidth(12*ww);
|
---|
| 643 | _whatsThisButton->setMaximumWidth(12*ww);
|
---|
[1459] | 644 |
|
---|
[1471] | 645 | _casterTable->setWhatsThis(tr("<p>Select an NTRIP broadcaster and hit 'OK'.</p><p>See <u>http://www.rtcm-ntrip.org/home</u> for further details on known NTRIP broadcaster installations.</u>."));
|
---|
[1459] | 646 |
|
---|
| 647 | QGridLayout* dlgLayout = new QGridLayout();
|
---|
| 648 | dlgLayout->addWidget(new QLabel(" List of NTRIP Broadcasters from www.rtcm-ntrip.org"), 0,0,1,3,Qt::AlignLeft);
|
---|
[1488] | 649 | dlgLayout->addWidget(_casterTable, 1, 0, 1, 3);
|
---|
| 650 | dlgLayout->addWidget(_whatsThisButton, 2, 0);
|
---|
| 651 | dlgLayout->addWidget(_closeButton, 2, 1, Qt::AlignRight);
|
---|
| 652 | dlgLayout->addWidget(_okButton, 2, 2);
|
---|
[1459] | 653 |
|
---|
| 654 | setMinimumSize(600,400);
|
---|
| 655 | setWindowTitle(tr("Select Broadcaster"));
|
---|
| 656 | setLayout(dlgLayout);
|
---|
[1504] | 657 | resize(68*ww, 50*ww);
|
---|
[1459] | 658 | show();
|
---|
| 659 | }
|
---|
| 660 |
|
---|
[1488] | 661 | // Caster table destructor
|
---|
[1459] | 662 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1488] | 663 | bncCasterTableDlg::~bncCasterTableDlg() {
|
---|
| 664 | delete _casterTable;
|
---|
| 665 | delete _okButton;
|
---|
| 666 | delete _closeButton;
|
---|
| 667 | delete _whatsThisButton;
|
---|
[1459] | 668 | }
|
---|
| 669 |
|
---|
[1488] | 670 | // Caster table what's this
|
---|
[1459] | 671 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1488] | 672 | void bncCasterTableDlg:: slotWhatsThis() {
|
---|
| 673 | QWhatsThis::enterWhatsThisMode();
|
---|
[1459] | 674 | }
|
---|
| 675 |
|
---|
| 676 | // Accept caster table
|
---|
| 677 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 678 | void bncCasterTableDlg::slotAcceptCasterTable() {
|
---|
| 679 | if (_casterTable) {
|
---|
[1489] | 680 | for (int ir = _casterTable->rowCount() - 1; ir >= 0 ; ir--) {
|
---|
[1474] | 681 | if (_casterTable->isItemSelected(_casterTable->item(ir,0))) {
|
---|
| 682 | emit newCaster(_casterTable->item(ir,0)->text(),
|
---|
| 683 | _casterTable->item(ir,1)->text());
|
---|
[1459] | 684 | }
|
---|
| 685 | }
|
---|
| 686 | }
|
---|
[1474] | 687 | QDialog::accept();
|
---|
[1459] | 688 | }
|
---|