20 #include <QMutexLocker>
34 #include <aprsconfig.h>
36 #ifdef HAVE_QEXTSERIALPORT
40 using namespace Marble;
53 m_mutex( new QMutex ),
54 m_initialized( false ),
59 m_useInternet( true ),
62 m_aprsHost(
"rotate.aprs.net" ),
64 m_tncTty(
"/dev/ttyUSB0" ),
80 this, SLOT(updateVisibility(
bool)) );
82 m_action =
new QAction(
this );
83 connect( m_action, SIGNAL(toggled(
bool)),
92 delete m_configDialog;
93 delete ui_configWidget;
95 QMap<QString, AprsObject *>::Iterator obj;
96 QMap<QString, AprsObject *>::Iterator end = m_objects.end();
98 for( obj = m_objects.begin(); obj != end; ++obj ) {
107 void AprsPlugin::updateVisibility(
bool visible )
122 return QStringList(
"aprs" );
127 return QString(
"ALWAYS" );
132 return QStringList(
"HOVERS_ABOVE_SURFACE" );
137 return tr(
"Amateur Radio Aprs Plugin" );
142 return tr(
"Amateur Radio &Aprs Plugin" );
147 return QString(
"aprs-plugin" );
157 return tr(
"This plugin displays APRS data gleaned from the Internet. APRS is an Amateur Radio protocol for broadcasting location and other information." );
167 return QList<PluginAuthor>()
168 <<
PluginAuthor(
"Wes Hardaker",
"hardaker@users.sourceforge.net" );
173 return QIcon(
":/icons/aprs.png");
180 if ( m_tcpipGatherer )
183 #ifdef HAVE_QEXTSERIALPORT
188 if ( m_fileGatherer )
192 if ( m_tcpipGatherer )
193 if ( m_tcpipGatherer->wait(2000) )
194 delete m_tcpipGatherer;
196 #ifdef HAVE_QEXTSERIALPORT
198 if ( m_ttyGatherer->wait(2000) )
199 delete m_ttyGatherer;
202 if ( m_fileGatherer )
203 if ( m_fileGatherer->wait(2000) )
204 delete m_fileGatherer;
215 if ( m_useInternet ) {
218 &m_objects, m_mutex, &m_filter);
222 m_tcpipGatherer->start();
223 mDebug() <<
"started TCPIP gatherer";
226 #ifdef HAVE_QEXTSERIALPORT
230 &m_objects, m_mutex, NULL);
235 m_ttyGatherer->start();
236 mDebug() <<
"started TTY gatherer";
244 &m_objects, m_mutex, NULL);
249 m_fileGatherer->start();
250 mDebug() <<
"started File gatherer";
257 m_initialized =
true;
258 mDebug() <<
"APRS initialized";
265 if ( !m_configDialog ) {
267 m_configDialog =
new QDialog();
268 ui_configWidget =
new Ui::AprsConfigWidget;
269 ui_configWidget->setupUi( m_configDialog );
271 connect( ui_configWidget->m_buttonBox, SIGNAL(accepted()),
272 SLOT(writeSettings()) );
273 connect( ui_configWidget->m_buttonBox, SIGNAL(rejected()),
274 SLOT(readSettings()) );
280 return m_configDialog;
283 void AprsPlugin::readSettings()
285 if ( !m_configDialog ) {
289 #ifndef HAVE_QEXTSERIALPORT
290 ui_configWidget->tabWidget->setTabEnabled( ui_configWidget->tabWidget->indexOf(
291 ui_configWidget->Device ), false );
296 ui_configWidget->m_internetBox->setCheckState( Qt::Checked );
298 ui_configWidget->m_internetBox->setCheckState( Qt::Unchecked );
301 ui_configWidget->m_serverName->setText( m_aprsHost );
302 ui_configWidget->m_serverPort->setText( QString::number( m_aprsPort ) );
306 ui_configWidget->m_serialBox->setCheckState( Qt::Checked );
308 ui_configWidget->m_serialBox->setCheckState( Qt::Unchecked );
311 ui_configWidget->m_ttyName->setText( m_tncTty );
315 ui_configWidget->m_useFile->setCheckState( Qt::Checked );
317 ui_configWidget->m_useFile->setCheckState( Qt::Unchecked );
320 ui_configWidget->m_fileName->setText( m_aprsFile );
324 ui_configWidget->m_tcpipdump->setCheckState( Qt::Checked );
326 ui_configWidget->m_tcpipdump->setCheckState( Qt::Unchecked );
329 ui_configWidget->m_ttydump->setCheckState( Qt::Checked );
331 ui_configWidget->m_ttydump->setCheckState( Qt::Unchecked );
334 ui_configWidget->m_filedump->setCheckState( Qt::Checked );
336 ui_configWidget->m_filedump->setCheckState( Qt::Unchecked );
339 ui_configWidget->m_fadetime->setText( QString::number( m_fadeTime ) );
340 ui_configWidget->m_hidetime->setText( QString::number( m_hideTime ) );
344 void AprsPlugin::writeSettings()
346 m_useInternet = ui_configWidget->m_internetBox->checkState() == Qt::Checked;
347 m_useTty = ui_configWidget->m_serialBox->checkState() == Qt::Checked;
348 m_useFile = ui_configWidget->m_useFile->checkState() == Qt::Checked;
350 m_aprsHost = ui_configWidget->m_serverName->text();
351 m_aprsPort = ui_configWidget->m_serverPort->text().toInt();
352 m_tncTty = ui_configWidget->m_ttyName->text();
354 m_dumpTcpIp = ui_configWidget->m_tcpipdump->checkState() == Qt::Checked;
355 m_dumpTty = ui_configWidget->m_ttydump->checkState() == Qt::Checked;
356 m_dumpFile = ui_configWidget->m_filedump->checkState() == Qt::Checked;
358 m_fadeTime = ui_configWidget->m_fadetime->text().toInt();
359 m_hideTime = ui_configWidget->m_hidetime->text().toInt();
369 result.insert(
"useInternet",
true );
370 result.insert(
"useTTY",
false );
371 result.insert(
"useFile",
false );
372 result.insert(
"APRSHost",
"rotate.aprs.net" );
373 result.insert(
"APRSPort",
"10253" );
374 result.insert(
"TNCTTY",
"/dev/ttyUSB0" );
375 result.insert(
"FileName",
"" );
376 result.insert(
"TCPIPDump",
false );
377 result.insert(
"TTYDump",
false );
378 result.insert(
"FileDump",
false );
379 result.insert(
"fadeTime", 10 );
380 result.insert(
"hideTime", 45 );
389 m_useInternet = settings.value(
"useInternet",
true ).toBool();
390 m_useTty = settings.value(
"useTTY",
false ).toBool();
391 m_useFile = settings.value(
"useFile",
false ).toBool();
393 m_aprsHost = settings.value(
"APRSHost",
"rotate.aprs.net" ).toString();
394 m_aprsPort = settings.value(
"APRSPort", 10253 ).toInt();
395 m_tncTty = settings.value(
"TNCTTY",
"/dev/ttyUSB0" ).toString();
396 m_aprsFile = settings.value(
"FileName",
"" ).toString();
398 m_dumpTcpIp = settings.value(
"TCPIPDump",
false ).toBool();
399 m_dumpTty = settings.value(
"TTYDump",
false ).toBool();
400 m_dumpFile = settings.value(
"FileDump",
false ).toBool();
402 m_fadeTime = settings.value(
"fadeTime", 10 ).toInt();
403 m_hideTime = settings.value(
"hideTime", 45 ).toInt();
411 return m_initialized;
416 Q_UNUSED( renderPos )
419 int fadetime = m_fadeTime * 60000;
420 int hidetime = m_hideTime * 60000;
426 QString towrite =
"#filter a/" +
431 mDebug() <<
"upating filter: " << towrite.toLocal8Bit().data();
433 QMutexLocker locker( m_mutex );
438 QMutexLocker locker( m_mutex );
439 QMap<QString, AprsObject *>::ConstIterator obj;
440 for( obj = m_objects.constBegin(); obj != m_objects.constEnd(); ++obj ) {
441 ( *obj )->render( painter, viewport, fadetime, hidetime );
451 m_action->setCheckable(
true );
452 m_action->setChecked(
visible() );
453 m_action->setIcon(
icon() );
461 #include "AprsPlugin.moc"
bool visible() const
is visible
QIcon icon() const
Returns an icon for the plugin.
A painter that allows to draw geometric primitives on the map.
This file contains the headers for MarbleModel.
void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
void setSeenFrom(GeoAprsCoordinates::SeenFrom seenFrom)
QString guiString() const
String that should be displayed in GUI.
const GeoDataLatLonAltBox & viewLatLonAltBox() const
QString nameId() const
Returns the unique name of the plugin.
QString description() const
Returns a user description of the plugin.
QHash< QString, QVariant > settings() const
Settings of the plugin.
qreal north(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the northern boundary of the bounding box.
qreal east(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the eastern boundary of the bounding box.
QString copyrightYears() const
Layer of a GeoScene document.
QList< PluginAuthor > pluginAuthors() const
void settingsChanged(QString nameId)
This signal is emitted if the settings of the RenderPlugin changed.
void visibilityChanged(bool visible, const QString &nameId)
This signal is emitted if the visibility is changed with.
void setVisible(bool visible)
settting visible
A public class that controls what is visible in the viewport of a Marble map.
#define Q_EXPORT_PLUGIN2(a, b)
This file contains the headers for ViewportParams.
qreal west(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the western boundary of the bounding box.
The data model (not based on QAbstractModel) for a MarbleWidget.
This class displays a layer of aprs (which aprs TBD).
QDialog * configDialog()
Returns a pointer to the configuration dialog of the plugin.
void setEnabled(bool enabled)
settting enabled
void setDumpOutput(bool to)
qreal south(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the southern boundary of the bounding box.
QStringList backendTypes() const
Returns the name(s) of the backend that the plugin can render This method should return the name of t...
QString name() const
Returns the user-visible name of the plugin.
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos, GeoSceneLayer *layer=0)
Renders the content provided by the layer on the viewport.
QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
bool isInitialized() const
virtual QHash< QString, QVariant > settings() const
Settings of the plugin.
RenderType
A Type of plugin.
QDebug mDebug()
a function to replace qDebug() in Marble library code
The abstract class that creates a renderable item.
virtual void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
QString renderPolicy() const
Return how the plugin settings should be used.