source: ntrip/trunk/BNC/src/bncudpport.cpp@ 9517

Last change on this file since 9517 was 8252, checked in by stoecker, 7 years ago

see #105 - reenable Qt4 build options, drop generic version dependend includes, replace by direct requirements, remaining QtCore lines should also be replaced

File size: 6.3 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2009
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: bncUdpPort
30 *
31 * Purpose: Select host for stream retrieval without NTRIP
32 *
33 * Author: G. Weber
34 *
35 * Created: 18-Feb-2009
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include <QLabel>
44#include <QLineEdit>
45#include <QGridLayout>
46#include <QMessageBox>
47#include <QPushButton>
48#include <QVBoxLayout>
49
50#include "bncudpport.h"
51
52using namespace std;
53
54// Constructor
55////////////////////////////////////////////////////////////////////////////
56bncUdpPort::bncUdpPort(QWidget* parent) : QDialog(parent) {
57
58 setMinimumSize(400,150);
59 QVBoxLayout* mainLayout = new QVBoxLayout(this);
60 QGridLayout* editLayout = new QGridLayout;
61
62 setWindowTitle(tr("Add Stream from UDP Port"));
63
64 _ipPortLineEdit = new QLineEdit();
65 _ipMountLineEdit = new QLineEdit();
66 _ipFormatLineEdit = new QLineEdit();
67 _ipLatLineEdit = new QLineEdit();
68 _ipLonLineEdit = new QLineEdit();
69 _ipCountryLineEdit = new QLineEdit();
70
71 int ww = QFontMetrics(font()).width('w');
72 _ipPortLineEdit->setMaximumWidth(9*ww);
73 _ipMountLineEdit->setMaximumWidth(9*ww);
74 _ipFormatLineEdit->setMaximumWidth(9*ww);
75 _ipLatLineEdit->setMaximumWidth(9*ww);
76 _ipLonLineEdit->setMaximumWidth(9*ww);
77 _ipCountryLineEdit->setMaximumWidth(9*ww);
78
79 // WhatsThis, Add Stream from UDP Port
80 // -----------------------------------
81 _ipPortLineEdit->setWhatsThis(tr("<p>BNC allows to pick up streams arriving directly at one of the local host's UDP ports without using the Ntrip transport protocol.</p><p>Enter the local port number where the UDP stream arrives.</p>"));
82 _ipMountLineEdit->setWhatsThis(tr("<p>Specify a mountpoint.</p><p>Recommended is a 4-character station ID.<br>Example: FFMJ</p>"));
83 _ipFormatLineEdit->setWhatsThis(tr("<p>Specify the stream format.</p><p>Available options are 'RTCM_2', 'RTCM_3', 'RTNET', and 'ZERO'.</p>"));
84 _ipLatLineEdit->setWhatsThis(tr("<p>Enter the approximate latitude of the stream providing receiver in degrees.<p></p>Example: 45.32</p>"));
85 _ipLonLineEdit->setWhatsThis(tr("<p>Enter the approximate longitude of the stream providing receiver in degrees.<p></p>Example: -15.20</p>"));
86 _ipCountryLineEdit->setWhatsThis(tr("<p>Specify the country code.</p><p>Follow the ISO 3166-1 alpha-3a code.<br>Example, Germany: DEU</p>"));
87
88 editLayout->addWidget(new QLabel(tr("UDP Port")), 0, 0, Qt::AlignRight);
89 editLayout->addWidget(_ipPortLineEdit, 0, 1);
90 editLayout->addWidget(new QLabel(tr("Mountpoint")),1, 0, Qt::AlignRight);
91 editLayout->addWidget(_ipMountLineEdit, 1, 1);
92 editLayout->addWidget(new QLabel(tr("Format")), 1, 2, Qt::AlignRight);
93 editLayout->addWidget(_ipFormatLineEdit, 1, 3);
94 editLayout->addWidget(new QLabel(tr("Latitude")), 2, 0, Qt::AlignRight);
95 editLayout->addWidget(_ipLatLineEdit, 2, 1);
96 editLayout->addWidget(new QLabel(tr("Longitude")), 2, 2, Qt::AlignRight);
97 editLayout->addWidget(_ipLonLineEdit, 2, 3);
98 editLayout->addWidget(new QLabel(tr("Country")), 3, 0, Qt::AlignRight);
99 editLayout->addWidget(_ipCountryLineEdit, 3, 1);
100
101 mainLayout->addLayout(editLayout);
102
103 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
104 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
105
106 _buttonCancel = new QPushButton(tr("Cancel"), this);
107 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
108
109 _buttonOK = new QPushButton(tr("OK"), this);
110 connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
111
112 _buttonOK->setDefault(true);
113
114 QHBoxLayout* buttonLayout = new QHBoxLayout;
115
116 buttonLayout->addWidget(_buttonWhatsThis);
117 buttonLayout->addStretch(1);
118 buttonLayout->addWidget(_buttonCancel);
119 buttonLayout->addWidget(_buttonOK);
120
121 mainLayout->addLayout(buttonLayout);
122}
123
124// Destructor
125////////////////////////////////////////////////////////////////////////////
126bncUdpPort::~bncUdpPort() {
127 delete _buttonCancel;
128 delete _buttonOK;
129 delete _buttonWhatsThis;
130}
131
132// Accept slot
133////////////////////////////////////////////////////////////////////////////
134void bncUdpPort::accept() {
135
136 QStringList* mountPoints = new QStringList;
137
138 if ( !_ipPortLineEdit->text().isEmpty() &&
139 !_ipMountLineEdit->text().isEmpty() &&
140 !_ipFormatLineEdit->text().isEmpty() &&
141 !_ipCountryLineEdit->text().isEmpty() &&
142 !_ipLatLineEdit->text().isEmpty() &&
143 !_ipLonLineEdit->text().isEmpty() ) {
144
145 mountPoints->push_back("//127.0.0.1:"
146 + _ipPortLineEdit->text() + "/"
147 + _ipMountLineEdit->text() + " "
148 + _ipFormatLineEdit->text() + " "
149 + _ipCountryLineEdit->text() + " "
150 + _ipLatLineEdit->text() + " "
151 + _ipLonLineEdit->text() + " "
152 + "no UN");
153 } else {
154 QMessageBox::warning(this, tr("Warning"),
155 tr("Incomplete settings"),
156 QMessageBox::Ok);
157 }
158
159 emit newMountPoints(mountPoints);
160
161 QDialog::accept();
162}
163
164// Whats This Help
165void bncUdpPort::slotWhatsThis() {
166QWhatsThis::enterWhatsThisMode();
167}
168
Note: See TracBrowser for help on using the repository browser.