Removed my temporary and unfinished plugin from repository.

git-svn-id: http://svn.osgeo.org/qgis/trunk@6666 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2007-02-22 16:08:09 +00:00
parent ff4a1e28ca
commit 1bca64cd82
20 changed files with 1 additions and 1874 deletions

View File

@ -1,5 +1,5 @@
SUBDIRS (copyright_label delimited_text grid_maker navigation north_arrow scale_bar) SUBDIRS (copyright_label delimited_text grid_maker north_arrow scale_bar)
IF (POSTGRES_FOUND) IF (POSTGRES_FOUND)
SUBDIRS (geoprocessing spit) SUBDIRS (geoprocessing spit)

View File

@ -1,60 +0,0 @@
# TODO: needs 'gpsd' detection
########################################################
# Files
SET (NAVIGATION_SRCS
navigation.cpp
navigationgui.cpp
gpspage.cpp
gpscore.cpp
positionmarker.cpp
routingcore.cpp
)
SET (NAVIGATION_UIS
navigationgui.ui
gpspage.ui
)
SET (NAVIGATION_MOC_HDRS
navigation.h
navigationgui.h
gpscore.h
routingcore.h
)
SET (NAVIGATION_RCCS navigation.qrc)
########################################################
# Build
QT4_WRAP_UI (NAVIGATION_UIS_H ${NAVIGATION_UIS})
QT4_WRAP_CPP (NAVIGATION_MOC_SRCS ${NAVIGATION_MOC_HDRS})
QT4_ADD_RESOURCES(NAVIGATION_RCC_SRCS ${NAVIGATION_RCCS})
ADD_LIBRARY (navigationplugin MODULE ${NAVIGATION_SRCS} ${NAVIGATION_UIS_H} ${NAVIGATION_MOC_SRCS} ${NAVIGATION_RCC_SRCS})
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../gui
..
)
TARGET_LINK_LIBRARIES(navigationplugin
${QT_LIBRARIES}
qgis_core
qgis_gui
)
########################################################
# Install
INSTALL(TARGETS navigationplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

View File

@ -1,86 +0,0 @@
# Copyright (C) 2003 Gary Sherman <sherman at mrcc.com>
# and 2006 Tim Sutton <tim@linfiniti.com>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# $Id: Makefile.am 5381 2006-04-26 15:02:28Z wonder $
#navigation below to be replaced with the name of the plugin
##
## Legacy support for pkgdatapath - you are encouraged to use
## Qt4.x resource files where possible rather!
##
if !HAVE_QTMAC
PKGDATAPATH=-DPKGDATAPATH=\"$(pkgdatadir)\"
endif
plugindir = ${pkglibdir}
#for plugin so
plugin_LTLIBRARIES = libqgis_plugin_navigation.la
## For Qt4 intermerdiary meta object compiler files
%.moc.cpp: %.h
$(MOC) -o $@ $<
## For Qt4 User Interface Files
ui_%.h: %.ui
$(UIC) -o $@ $<
## For Qt4 Resource Files
%.qrc.cpp: %.qrc
$(RCC) -o $@ $<
##
## For plugin lib
##
libqgis_plugin_navigation_la_SOURCES = navigation.cpp \
navigationgui.cpp \
gpspage.cpp \
gpscore.cpp \
positionmarker.cpp \
routingcore.cpp \
$(plugin_UI)\
$(plugin_MOC)\
$(plugin_RES)
plugin_MOC = navigation.moc.cpp \
navigationgui.moc.cpp \
gpscore.moc.cpp \
routingcore.moc.cpp
plugin_UI = ui_navigationgui.h \
ui_gpspage.h
plugin_RES = navigation.qrc.cpp
BUILT_SOURCES = $(plugin_MOC) $(plugin_UI) $(plugin_RES)
libqgis_plugin_navigation_la_LIBADD = $(QT_LDADD) \
$(GDAL_LDADD) \
$(GPSD_LDADD) \
../../core/libqgis_core.la \
../../gui/libqgis_gui.la
libqgis_plugin_navigation_la_CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) $(DEBUG_QGIS)
libqgis_plugin_navigation_la_CXXFLAGS = $(CXXFLAGS) \
$(EXTRA_CXXFLAGS) \
$(QT_CXXFLAGS) \
$(DEBUG_QGIS) \
$(GDAL_CFLAGS) \
$(GEOS_CFLAGS) \
-I../../core/include \
-I../../ui \
-I../../gui
libqgis_plugin_navigation_la_LDFLAGS = -avoid-version -module

View File

@ -1,10 +0,0 @@
GPS navigation plugin
---------------------
This plugin shows your position in Quantum GIS map canvas.
It uses 'gpsd' software for access to different models of GPS devices
by using the same protocol.
Currently work in progress, not yet stable and lacks many features.

View File

@ -1,253 +0,0 @@
#include "qgisinterface.h"
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsdistancearea.h"
#include "gpscore.h"
#include "gpspage.h"
#include "positionmarker.h"
#include <QCheckBox>
#include <QDateTime>
#include <QMessageBox>
#include <QToolBox>
#include <cmath>
#include <iostream>
// MSVC compiler doesn't have defined M_PI in math.h
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
GpsCore::GpsCore(QgisInterface* qgis)
: mQgis(qgis)
{
// init gps widget
mGpsPage = new GpsPage;
connect(mGpsPage->chkShowPosition, SIGNAL(toggled(bool)), this, SLOT(toggledShowPosition(bool)));
mTcpSocket = new QTcpSocket(this);
// reading data from socket
connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readGpsData()));
// socket error handling
connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(socketError(QAbstractSocket::SocketError)));
connect(mTcpSocket, SIGNAL(connected()), this, SLOT(socketConnected()));
connect(mTcpSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
// create position marker
mMarker = new PositionMarker(mQgis->getMapCanvas());
mTrack = new QgsRubberBand(mQgis->getMapCanvas(), false);
mTrack->setWidth(2);
}
GpsCore::~GpsCore()
{
delete mGpsPage;
delete mTcpSocket;
delete mMarker;
delete mTrack;
}
QTcpSocket* GpsCore::tcpSocket()
{
return mTcpSocket;
}
void GpsCore::start()
{
mInputData.resize(0);
mTcpSocket->connectToHost("localhost", 2947);
// gps page is added to toolbox when we're connected
}
void GpsCore::stop()
{
QToolBox* tb = mQgis->getToolBox();
int index = tb->indexOf(mGpsPage);
if (index != -1) // does it exist?
{
tb->removeItem(index);
}
mTcpSocket->disconnectFromHost();
}
void GpsCore::readGpsData()
{
//std::cout << "readGpsData! " << mTcpSocket->bytesAvailable() << " bytes" << std::endl;
// read data
QByteArray data = mTcpSocket->readAll();
//std::cout << (const char*)data << std::endl;
// to protect buffer from getting insanely big when getting bad data
// erase the buffer when it's bigger than 1 kb
// (as there are no such long packets)
if (mInputData.count() > 1024)
{
mInputData.resize(0);
}
// append newly received data
mInputData += data;
// search for the end of the packet
QString pck;
int end;
while ((end = mInputData.indexOf('\n')) != -1)
{
// get the packet
QByteArray packet = mInputData.left(end);
// erase the packet from input buffer
mInputData = mInputData.mid(end+1);
// parse the packet
if (!packet.startsWith("GPSD,"))
{
std::cout << "bad data coming!" << std::endl;
continue;
}
// GPSD,?=...........\n
char packetType = packet.at(5);
packet = packet.mid(7);
pck = packet; // convert to QString
//std::cout << "packet::" << (const char*) packet << std::endl;
switch (packetType)
{
case 'O':
parsePacketO(pck);
break;
default:
std::cout << "got packet " << packetType << std::endl;
}
}
// an example of GPSD output:
//GPSD,O=GSA 1114599742.00 0.005 48.898057 18.073253 221.50 5.40 2.00 182.2000 4.373 0.000 62.3221 5.19 ?
}
void GpsCore::socketError(QAbstractSocket::SocketError err)
{
std::cout << "socketError! " << err << std::endl;
QString message;
if (err == QAbstractSocket::ConnectionRefusedError)
{
message = "Connection was refused.\nIs gpsd running?";
}
else if (err == QAbstractSocket::RemoteHostClosedError)
{
message = "Connection with gpsd has been closed!";
stop(); // clean up
}
else
message = QString("Error on socket with gpsd: %1").arg(err);
QMessageBox::critical(NULL, "GPS error", message);
}
void GpsCore::socketConnected()
{
// create gps page and set it as current
QToolBox* tb = mQgis->getToolBox();
tb->addItem(mGpsPage, "GPS info");
tb->setCurrentWidget(mGpsPage);
std::cout << "GPS STARTED =======================================" << std::endl;
mTcpSocket->write("w+\n", 2); // switch to watcher mode
}
void GpsCore::socketDisconnected()
{
std::cout << "disconnected!" << std::endl;
}
void GpsCore::parsePacketO(QString packet)
{
//std::cout << "got position data" << std::endl;
//std::cout << packet.toLocal8Bit().data() << std::endl;
if (packet[0] == '?') // no fix?
{
std::cout << "no fix!" << std::endl;
mGpsPage->lblFix->setText("No");
mMarker->setIcon(false);
// TODO: what to do with other fields?
return;
}
QStringList strings = packet.split(' ');
// XXX more information can be acquired from M or S request
mGpsPage->lblFix->setText("Yes");
mMarker->setIcon(true);
// time
QString timeStr = strings[1];
if (timeStr != "?")
{
QDateTime time;
time.setTime_t((uint) timeStr.toDouble()); // time is formatted as %f
mGpsPage->txtTime->setText(time.toString("hh:mm:ss"));
}
// strings[2]: time error - not interesting
// display lat & lon
mGpsPage->txtLat->setText(strings[3]);
mGpsPage->txtLon->setText(strings[4]);
// TODO: convert from wgs84 to project coordinates
double lat = strings[3].toDouble();
double lon = strings[4].toDouble();
// only if the position has changed
if (lat != mGpsPos.y() && lon != mGpsPos.x())
{
mGpsPosLast = mGpsPos;
mGpsPos = QgsPoint(lon,lat);
double angle = mDA.getBearing(mGpsPosLast, mGpsPos);
angle *= (180/M_PI);
// set marker
mMarker->setAngle(angle);
mMarker->setPosition(mGpsPos);
// hide it if told so (setPosition always shows it)
bool visible = mGpsPage->chkShowPosition->isChecked();
if (!visible)
mMarker->hide();
// add to history
mTrack->addPoint(QgsPoint(lon,lat));
// TODO: erase after some time?
// hide it if told so (setPosition always shows it)
visible = mGpsPage->chkShowHistory->isChecked();
if (!visible)
mTrack->hide();
}
// TODO: more stuff...?
}
void GpsCore::toggledShowPosition(bool toggled)
{
std::cout << "TOGGLED: " << toggled << std::endl;
}

View File

@ -1,66 +0,0 @@
#ifndef GPSCORE_H
#define GPSCORE_H
#include <QObject>
#include <QTcpSocket>
#include "qgspoint.h"
#include "qgsdistancearea.h"
class QPainter;
class GpsPage;
class QgisInterface;
class PositionMarker;
class QgsRubberBand;
class GpsCore : public QObject
{
Q_OBJECT;
public:
GpsCore(QgisInterface* qgis);
~GpsCore();
void start();
void stop();
QTcpSocket* tcpSocket();
void parsePacketO(QString packet);
public slots:
void readGpsData();
void socketError(QAbstractSocket::SocketError);
void socketConnected();
void socketDisconnected();
void toggledShowPosition(bool);
private:
//! pointer to socket for communication with GPSD
QTcpSocket* mTcpSocket;
//! input buffer for receiving packets from GPSD
QByteArray mInputData;
//! pointer to QGIS interface
QgisInterface* mQgis;
//! pointer to GPS page
GpsPage* mGpsPage;
//! position marker
PositionMarker* mMarker;
//! rubber band for position history
QgsRubberBand* mTrack;
QgsPoint mGpsPos;
QgsPoint mGpsPosLast;
QgsDistanceArea mDA;
};
#endif

View File

@ -1,7 +0,0 @@
#include "gpspage.h"
GpsPage::GpsPage()
{
setupUi(this);
}

View File

@ -1,15 +0,0 @@
#ifndef GPSPAGE_H
#define GPSPAGE_H
#include <QWidget>
#include "ui_gpspage.h"
class GpsPage : public QWidget, public Ui::gpsPage
{
public:
GpsPage();
};
#endif

View File

@ -1,149 +0,0 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>gpsPage</class>
<widget class="QWidget" name="gpsPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>185</width>
<height>398</height>
</rect>
</property>
<property name="font" >
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="windowTitle" >
<string>GPS</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" >
<widget class="QLineEdit" name="txtTime" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>GPS Fix:</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Longitude:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="txtLon" />
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="txtLat" />
</item>
<item row="0" column="1" >
<widget class="QLabel" name="lblFix" >
<property name="font" >
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>No</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>GPS Time:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Latitude:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkShowPosition" >
<property name="text" >
<string>Show position on map</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowHistory" >
<property name="text" >
<string>Show position history</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkMovingMap" >
<property name="text" >
<string>Recenter map</string>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -1,205 +0,0 @@
/***************************************************************************
navigation.cpp
A simple GPS navigation and routing system
-------------------
begin : [PluginDate]
copyright : [(C) Your Name and Date]
email : [Your Email]
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: plugin.cpp 5400 2006-04-30 20:14:08Z wonder $ */
//
// QGIS Specific includes
//
#include <qgisinterface.h>
#include "navigation.h"
#include "navigationgui.h"
#include "gpscore.h"
#include "routingcore.h"
//
// Qt4 Related Includes
//
#include <QToolBar>
#include <QMenuBar>
#include <QMessageBox>
#include <QMenu>
#include <QLineEdit>
#include <QAction>
#include <QApplication>
#include <QCursor>
//non qt includes
#include <iostream>
#ifdef WIN32
#define QGISEXTERN extern "C" __declspec( dllexport )
#else
#define QGISEXTERN extern "C"
#endif
static const char * const sIdent = "$Id: plugin.cpp 5400 2006-04-30 20:14:08Z wonder $";
static const QString sName = QObject::tr("Navigation");
static const QString sDescription = QObject::tr("A simple GPS navigation and routing system");
static const QString sPluginVersion = QObject::tr("Version 0.1");
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
//////////////////////////////////////////////////////////////////////
//
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
//
//////////////////////////////////////////////////////////////////////
/**
* Constructor for the plugin. The plugin is passed a pointer
* an interface object that provides access to exposed functions in QGIS.
* @param theQGisInterface - Pointer to the QGIS interface object
*/
Navigation::Navigation(QgisInterface * theQgisInterface):
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
mQGisIface(theQgisInterface)
{
}
Navigation::~Navigation()
{
}
/*
* Initialize the GUI interface for the plugin - this is only called once when the plugin is
* added to the plugin registry in the QGIS application.
*/
void Navigation::initGui()
{
// Create the action for tool
mQActionPointer = new QAction(QIcon(":/navigation/navigation.png"),tr("&Navigation"), this);
// Connect the action to the run
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
// Add the toolbar
mToolBarPointer = new QToolBar(mQGisIface->getMainWindow(), "Navigation");
mToolBarPointer->setLabel("Navigation");
// Add the icon to the toolbar
mQGisIface->addToolBarIcon(mQActionPointer);
// Add to the plugins menu
mQGisIface->addPluginMenu(tr("&Navigation"), mQActionPointer);
// create gps core
mGps = new GpsCore(mQGisIface);
// create routing core
mRouting = new RoutingCore(mQGisIface);
}
//method defined in interface
void Navigation::help()
{
//implement me!
}
// Slot called when the menu item is activated
// If you created more menu items / toolbar buttons in initiGui, you should
// create a separate handler for each action - this single run() method will
// not be enough
void Navigation::run()
{
NavigationGui *myPluginGui=new NavigationGui(this);
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
//listen for when the layer has been made so we can draw it
connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
myPluginGui->show();
}
// Unload the plugin by cleaning up the GUI
void Navigation::unload()
{
// remove the GUI
mQGisIface->removePluginMenu(tr("&Navigation"),mQActionPointer);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
delete mGps;
}
//////////////////////////////////////////////////////////////////////
//
// END OF MANDATORY PLUGIN METHODS
//
//////////////////////////////////////////////////////////////////////
QgisInterface* Navigation::qgis()
{
return mQGisIface;
}
GpsCore* Navigation::gps()
{
return mGps;
}
//////////////////////////////////////////////////////////////////////////
//
//
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
//
//
//////////////////////////////////////////////////////////////////////////
/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
* of the plugin class
*/
// Class factory to return a new instance of the plugin class
QGISEXTERN QgisPlugin * classFactory(QgisInterface * theQgisInterfacePointer)
{
return new Navigation(theQgisInterfacePointer);
}
// Return the name of the plugin - note that we do not user class members as
// the class may not yet be insantiated when this method is called.
QGISEXTERN QString name()
{
return sName;
}
// Return the description
QGISEXTERN QString description()
{
return sDescription;
}
// Return the type (either UI or MapLayer plugin)
QGISEXTERN int type()
{
return sPluginType;
}
// Return the version number for the plugin
QGISEXTERN QString version()
{
return sPluginVersion;
}
// Delete ourself
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
{
delete thePluginPointer;
}

View File

@ -1,124 +0,0 @@
/***************************************************************************
plugin.h
Functions:
-------------------
begin : Jan 21, 2004
copyright : (C) 2004 by Tim Sutton
email : tim@linfiniti.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: plugin.h 5400 2006-04-30 20:14:08Z wonder $ */
/***************************************************************************
* QGIS Programming conventions:
*
* mVariableName - a class level member variable
* sVariableName - a static class level member variable
* variableName() - accessor for a class member (no 'get' in front of name)
* setVariableName() - mutator for a class member (prefix with 'set')
*
* Additional useful conventions:
*
* theVariableName - a method parameter (prefix with 'the')
* myVariableName - a locally declared variable within a method ('my' prefix)
*
* DO: Use mixed case variable names - myVariableName
* DON'T: separate variable names using underscores: my_variable_name (NO!)
*
* **************************************************************************/
#ifndef Navigation_H
#define Navigation_H
//QT4 includes
#include <QObject>
//QGIS includes
#include "../qgisplugin.h"
//forward declarations
class QAction;
class QToolBar;
class QgisInterface;
class GpsCore;
class RoutingCore;
/**
* \class Plugin
* \brief [name] plugin for QGIS
* [description]
*/
class Navigation:public QObject, public QgisPlugin
{
Q_OBJECT;
public:
//////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN METHODS FOLLOW
//
//////////////////////////////////////////////////////////////////////
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param theInterface Pointer to the QgisInterface object.
*/
Navigation(QgisInterface * theInterface);
//! Destructor
virtual ~Navigation();
QgisInterface* qgis();
GpsCore* gps();
public slots:
//! init the gui
virtual void initGui();
//! Show the dialog box
void run();
//! unload the plugin
void unload();
//! show the help document
void help();
//////////////////////////////////////////////////////////////////////
//
// END OF MANDATORY PLUGIN METHODS
//
//////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
//
////////////////////////////////////////////////////////////////////
int mPluginType;
//! Pointer to our toolbar
QToolBar *mToolBarPointer;
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
//!pointer to the qaction for this plugin
QAction * mQActionPointer;
////////////////////////////////////////////////////////////////////
//
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
//
////////////////////////////////////////////////////////////////////
GpsCore* mGps;
RoutingCore* mRouting;
};
#endif //Navigation_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/navigation/" >
<file>navigation.png</file>
</qresource>
</RCC>

View File

@ -1,109 +0,0 @@
/***************************************************************************
* Copyright (C) 2003 by Tim Sutton *
* tim@linfiniti.com *
* *
* This is a plugin generated from the QGIS plugin template *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "navigationgui.h"
#include "navigation.h"
#include "gpscore.h"
#include "qgisinterface.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include <QMessageBox>
NavigationGui::NavigationGui(Navigation* plugin)
: QDialog (plugin->qgis()->getMainWindow(), QgisGui::ModalDialogFlags), mPlugin(plugin)
{
setupUi(this);
QTcpSocket* socket = plugin->gps()->tcpSocket();
// init GUI with the current state of the socket
gpsStateChanged(socket->state());
connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
this, SLOT(gpsStateChanged(QAbstractSocket::SocketState)));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(socketError(QAbstractSocket::SocketError)));
}
NavigationGui::~NavigationGui()
{
}
void NavigationGui::on_buttonBox_accepted()
{
//close the dialog
accept();
}
void NavigationGui::on_buttonBox_rejected()
{
reject();
}
void NavigationGui::on_pbnStart_clicked()
{
mPlugin->gps()->start();
}
void NavigationGui::on_pbnStop_clicked()
{
mPlugin->gps()->stop();
}
void NavigationGui::gpsStateChanged(QAbstractSocket::SocketState state)
{
QString status;
switch (state)
{
case QAbstractSocket::UnconnectedState:
status = "Not Connected";
break;
case QAbstractSocket::HostLookupState:
status = "Looking up host...";
break;
case QAbstractSocket::ConnectingState:
status = "Connecting...";
break;
case QAbstractSocket::ConnectedState:
status = "Connected!";
break;
case QAbstractSocket::ClosingState:
status = "Closing connection...";
break;
default:
status = "???";
}
lblConnectionStatus->setText(status);
bool canStart = (state == QAbstractSocket::UnconnectedState);
pbnStart->setEnabled(canStart);
pbnStop->setEnabled(!canStart);
}
void NavigationGui::socketError(QAbstractSocket::SocketError error)
{
// GUI is not updated automatically on error => do it explicitly
gpsStateChanged(mPlugin->gps()->tcpSocket()->state());
}
void NavigationGui::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}

View File

@ -1,37 +0,0 @@
#ifndef NavigationGUI_H
#define NavigationGUI_H
#include <QDialog>
#include <ui_navigationgui.h>
#include <QAbstractSocket>
class Navigation;
class NavigationGui : public QDialog, private Ui::NavigationGui
{
Q_OBJECT
public:
NavigationGui(Navigation* plugin);
~NavigationGui();
private:
Navigation* mPlugin;
static const int context_id = 0;
public slots:
void gpsStateChanged(QAbstractSocket::SocketState);
void socketError(QAbstractSocket::SocketError);
private slots:
void on_pbnStart_clicked();
void on_pbnStop_clicked();
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
};
#endif

View File

@ -1,607 +0,0 @@
<ui version="4.0" >
<class>NavigationGui</class>
<widget class="QDialog" name="NavigationGui" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>416</height>
</rect>
</property>
<property name="windowTitle" >
<string>Navigation plugin settings</string>
</property>
<property name="windowIcon" >
<iconset/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>GPS</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>This plugin uses 'gpsd' (GPS daemon) for acquiring your current position. Please select the option which suits best your needs:</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3" >
<property name="text" >
<string>GPS daemon already runs</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Simulate GPS using 'gpsfake'</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="3" >
<widget class="QPushButton" name="pushButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>31</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2" colspan="2" >
<widget class="QSlider" name="horizontalSlider" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="label_3" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Log file to play:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="label_4" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Playback speed:</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="lineEdit" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Start 'gpsd' daemon</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>31</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_7" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Input defice for 'gpsd'</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboGpsInput" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable" >
<bool>true</bool>
</property>
<item>
<property name="text" >
<string>/dev/ttyS0</string>
</property>
</item>
<item>
<property name="text" >
<string>/dev/ttyS1</string>
</property>
</item>
<item>
<property name="text" >
<string>/dev/ttyS2</string>
</property>
</item>
<item>
<property name="text" >
<string>/dev/ttyS3</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>59</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="pbnStart" >
<property name="text" >
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnStop" >
<property name="text" >
<string>Stop</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>256</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>GPSD connection:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblConnectionStatus" >
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="routing" >
<attribute name="title" >
<string>Routing</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>To enable routing support you must specify a vector layer that will be used as the roadmap.</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Vector layer for roadmap:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboLayer" />
</item>
</layout>
</item>
<item>
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10" >
<property name="text" >
<string>Optional additional settings for better routing:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRoadClass" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Support for road classification</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Field containing the classification:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboRoadClass" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkRoadDirection" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Support for one-way roads</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_11" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Field with information about direction:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboRoadDirection" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lblStatus" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<property name="text" >
<string>Status</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnGenerateGraph" >
<property name="text" >
<string>Compute routing data</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_8" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="../gps_importer/qgsgps_plugin.qrc" >:/gps.xpm</pixmap>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>radioButton_3</tabstop>
<tabstop>radioButton</tabstop>
<tabstop>radioButton_2</tabstop>
<tabstop>cboGpsInput</tabstop>
<tabstop>pbnStart</tabstop>
<tabstop>pbnStop</tabstop>
<tabstop>cboLayer</tabstop>
<tabstop>cboRoadClass</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,69 +0,0 @@
#include <QPainter>
#include <QPainterPath>
#include "positionmarker.h"
PositionMarker::PositionMarker(QgsMapCanvas* mapCanvas)
: QgsMapCanvasItem(mapCanvas)
{
mHasPosition = false;
mAngle = 0;
setZValue(100); // be on top
}
void PositionMarker::setIcon(bool hasPosition)
{
mHasPosition = hasPosition;
}
void PositionMarker::setAngle(double angle)
{
mAngle = angle;
}
void PositionMarker::setPosition(const QgsPoint& point)
{
if (mPosition != point)
{
mPosition = point;
QPointF pt = toCanvasCoords(mPosition);
setPos(pt);
updateCanvas();
}
}
QRectF PositionMarker::boundingRect() const
{
return QRectF(-12,-12,12,12);
}
void PositionMarker::paint(QPainter* p)
{
//if (mHasPosition)
{
QPainterPath path;
path.moveTo(0,-10);
path.lineTo(10,10);
path.lineTo(0,5);
path.lineTo(-10,10);
path.lineTo(0,-10);
// render position with angle
p->save();
p->setRenderHint(QPainter::Antialiasing);
if (mHasPosition)
p->setBrush(QBrush(QColor(0,0,0)));
else
p->setBrush(QBrush(QColor(200,200,200)));
p->setPen(QColor(255,255,255));
p->rotate(mAngle);
p->drawPath(path);
p->restore();
}
/* else
{
// TODO: draw '?' to show that we don't have position
}*/
}

View File

@ -1,41 +0,0 @@
#ifndef POSITIONMARKER_H
#define POSITIONMARKER_H
#include "qgsmapcanvasitem.h"
#include "qgspoint.h"
class QPainter;
class PositionMarker : public QgsMapCanvasItem
{
public:
PositionMarker(QgsMapCanvas* mapCanvas);
void setPosition(const QgsPoint& point);
void setIcon(bool hasPosition);
void setAngle(double angle);
void paint(QPainter* p);
QRectF boundingRect() const;
protected:
bool mHasPosition;
//! angle in degrees (north = 0, south = 180)
double mAngle;
//! size
int mIconSize;
//! coordinates of the point in the center
QgsPoint mPosition;
};
#endif

View File

@ -1,9 +0,0 @@
#include "routingcore.h"
#include "qgisinterface.h"
RoutingCore::RoutingCore(QgisInterface* qgis)
: mQgis(qgis)
{
}

View File

@ -1,21 +0,0 @@
#ifndef ROUTINGCORE_H
#define ROUTINGCORE_H
#include <QObject>
class QgisInterface;
class RoutingCore : public QObject
{
Q_OBJECT
public:
RoutingCore(QgisInterface* qgis);
private:
QgisInterface* mQgis;
};
#endif