Commit 1a1224b4 authored by Bryan Godbolt's avatar Bryan Godbolt

Merge remote branch 'upstream/experimental' into experimental

parents 89ebecea 86eba06b
......@@ -19,6 +19,7 @@ var followEnabled = false;
var lastLat = 0;
var lastLon = 0;
var lastAlt = 0;
var currLat = 47.3769;
var currLon = 8.549444;
var currAlt = 470;
......@@ -44,6 +45,8 @@ var planeOrient;
var planeLoc;
var aircraft = [];
var aircraftLocations = [];
var aircraftLastLocations = [];
var attitudes = [];
var locations = [];
var trails = [];
......@@ -68,6 +71,11 @@ function init()
google.earth.createInstance("map3d", initCallback, failureCallback);
}
function setFollowEnabled(enable)
{
followEnabled = enable;
}
function setCurrAircraft(id)
......@@ -133,7 +141,8 @@ function createAircraft(id, type, color)
// Write into global structure
aircraft[id] = planePlacemark;
attitudes[id] = planeOrient;
locations[id] = planeLoc;
aircraftLocations[id] = planeLoc;
aircraftLastLocations[id] = ge.createLocation('');
//planeColor = color;
createTrail(id, color);
......@@ -168,7 +177,7 @@ trailsVisible[id] = false;
}
function hideTrail(id)
function clearTrail(id)
{
trailsVisible[id] = false;
ge.getFeatures().removeChild(trailPlacemarks[id]);
......@@ -188,65 +197,73 @@ function setViewRange(dist)
function addTrailPosition(id, lat, lon, alt)
{
trails[id].setExtrude(false);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
trails[id].setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
trails[id].getCoordinates().pushLatLngAlt(lat, lon, alt);
// Add LineString points
trails[id].getCoordinates().pushLatLngAlt(lat, lon, alt);
// Create a style and set width and color of line
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(trailColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Create a style and set width and color of line
trailPlacemarks[id].setStyleSelector(ge.createStyle(''));
lineStyle = trailPlacemarks[id].getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(trailColors[id]);  // aabbggrr format
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
if (trailsVisible[id] == true) ge.getFeatures().replaceChild(trailPlacemarks[id], trailPlacemarks[id]);
// Add the feature to Earth
if (trailsVisible[id] == true) ge.getFeatures().replaceChild(trailPlacemarks[id], trailPlacemarks[id]);
}
function initCallback(object)
{
ge = object;
ge.getWindow().setVisibility(true);
ge.getOptions().setStatusBarVisibility(true);
ge.getOptions().setScaleLegendVisibility(true);
ge.getOptions().setFlyToSpeed(5.0);
//ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
ge = object;
ge.getWindow().setVisibility(true);
ge.getOptions().setStatusBarVisibility(true);
ge.getOptions().setScaleLegendVisibility(true);
//ge.getOptions().setFlyToSpeed(5.0);
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
initialized = true;
initialized = true;
}
function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
{
if (id == currAircraft)
{
lastLat = currLat;
lastLon = lastLon;
if (lastLat == 0)
{
lastLat = currLat;
lastLon = currLon;
}
currLat = lat;
currLon = lon;
currAlt = alt;
// Interpolate between t-1 and t and set new states
lastLat = lastLat*0.8+currLat*0.2;
lastLon = lastLon*0.8+currLon*0.2;
lastAlt = lastAlt*0.8+currAlt*0.2;
//currFollowHeading = ((yaw/M_PI)+1.0)*360.0;
}
// FIXME Currently invalid conversion from right-handed z-down to z-up frame
planeOrient.setRoll(((roll/M_PI)+1.0)*360.0);
planeOrient.setTilt(((pitch/M_PI)+1.0)*360.0);
planeOrient.setHeading(((yaw/M_PI)+1.0)*360.0);
planeLoc.setLatitude(lat);
planeLoc.setLongitude(lon);
planeLoc.setAltitude(alt);
planeOrient.setRoll(((roll/M_PI))*180.0+180.0);
planeOrient.setTilt(((pitch/M_PI))*180.0+180.0);
planeOrient.setHeading(((yaw/M_PI))*180.0-90.0);
currFollowHeading = ((yaw/M_PI))*180.0;
planeLoc.setLatitude(lastLat);
planeLoc.setLongitude(lastLon);
planeLoc.setAltitude(lastAlt);
planeModel.setLocation(planeLoc);
if (followEnabled) updateFollowAircraft();
}
}
function enableDaylight(enabled)
......@@ -280,13 +297,14 @@ function setCurrentAircraft(id)
function updateFollowAircraft()
{
currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
currView.setLatitude(currLat);
currView.setLongitude(currLon);
currView.setAltitude(currAlt);
currView.setLatitude(lastLat);
currView.setLongitude(lastLon);
currView.setAltitude(lastAlt);
currView.setRange(currViewRange);
currView.setTilt(currFollowTilt);
currFollowHeading = 0.9*currFollowHeading+0.1*((Math.atan2(lastLat-currLat, lastLon-currLon)/M_PI)+1.0)*360.0;
currView.setHeading(currFollowHeading-0.0);
currView.setHeading(currFollowHeading);
ge.getView().setAbstractView(currView);
}
......
......@@ -251,6 +251,21 @@ QSlider::groove:horizontal {
margin: -5px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
border-radius: 3px;
}
QSlider::groove:vertical {
border: 1px solid #999999;
width: 4px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #4A4A4F, stop:1 #4A4A4F);
margin: 2px 0;
}
QSlider::handle:vertical {
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #232228, stop: 1 #020208);
border: 2px solid #379AC3;
height: 18px;
margin: 0 -5px; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
border-radius: 3px;
}
QPushButton#forceLandButton {
font-weight: bold;
......
......@@ -119,7 +119,7 @@ namespace qmapcontrol
virtual bool hasClickedPoints() const;
virtual void setPen(QPen* pen);
virtual QList<Geometry*> clickedPoints();
virtual QList<Point*> points()=0;
virtual QList<Point*>& points()=0;
private:
Geometry* myparentGeometry;
......
......@@ -153,7 +153,7 @@ namespace qmapcontrol
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
tileData.save(&buffer, "PNG");
// FIXME This is weird - why first write in buffer and then in file?
file.write(bytes);
file.close();
return true;
......
......@@ -39,10 +39,10 @@ namespace qmapcontrol
delete mapAdapter;
}
void Layer::setSize(QSize size)
void Layer::setSize(QSize size, QPoint screenmiddle)
{
this->size = size;
screenmiddle = QPoint(size.width()/2, size.height()/2);
this->screenmiddle = screenmiddle;// QPoint(size.width()/2, size.height()/2);
//QMatrix mat;
//mat.translate(480/2, 640/2);
//mat.rotate(45);
......@@ -292,10 +292,12 @@ namespace qmapcontrol
// PREFETCHING
int upper = mapmiddle_tile_y-tiles_above-1;
int right = mapmiddle_tile_x+tiles_right+1;
int left = mapmiddle_tile_x-tiles_right-1;
int lower = mapmiddle_tile_y+tiles_bottom+1;
// FIXME Make prefetching a parameter
int upper = mapmiddle_tile_y-tiles_above-2;
int right = mapmiddle_tile_x+tiles_right+2;
int left = mapmiddle_tile_x-tiles_right-2;
int lower = mapmiddle_tile_y+tiles_bottom+2;
int j = upper;
for (int i=left; i<=right; i++)
......
......@@ -139,7 +139,7 @@ namespace qmapcontrol
void moveWidgets(const QPoint mapmiddle_px) const;
void drawYourImage(QPainter* painter, const QPoint mapmiddle_px) const;
void drawYourGeometries(QPainter* painter, const QPoint mapmiddle_px, QRect viewport) const;
void setSize(QSize size);
void setSize(QSize size, QPoint screenmiddle);
QRect offscreenViewport() const;
bool takesMouseEvents() const;
void mouseEvent(const QMouseEvent*, const QPoint mapmiddle_px);
......
......@@ -29,12 +29,9 @@ namespace qmapcontrol
LayerManager::LayerManager(MapControl* mapcontrol, QSize size)
:mapcontrol(mapcontrol), scroll(QPoint(0,0)), size(size), whilenewscroll(QPoint(0,0))
{
// genauer berechnen?
offSize = size *2;
composedOffscreenImage = QPixmap(offSize);
composedOffscreenImage2 = QPixmap(offSize);
setOffscreenImageFactor(2);
zoomImage = QPixmap(size);
zoomImage.fill(Qt::white);
zoomImage.fill(Qt::black);
screenmiddle = QPoint(size.width()/2, size.height()/2);
}
......@@ -44,6 +41,20 @@ namespace qmapcontrol
mylayers.clear();
}
void LayerManager::setOffscreenImageFactor(float factor)
{
offSize = size * factor;
offFactor = factor;
composedOffscreenImage = QPixmap(offSize);
composedOffscreenImage2 = QPixmap(offSize);
resize(size);
}
float LayerManager::offscreenImageFactor()
{
return offFactor;
}
QPointF LayerManager::currentCoordinate() const
{
return mapmiddle;
......@@ -209,7 +220,7 @@ namespace qmapcontrol
{
mylayers.append(layer);
layer->setSize(size);
layer->setSize(size, screenmiddle);
connect(layer, SIGNAL(updateRequest(QRectF)),
this, SLOT(updateRequest(QRectF)));
......@@ -229,7 +240,7 @@ namespace qmapcontrol
if (clearImage)
{
composedOffscreenImage2.fill(Qt::white);
composedOffscreenImage2.fill(Qt::black);
}
QPainter painter(&composedOffscreenImage2);
......@@ -264,7 +275,7 @@ namespace qmapcontrol
// layer rendern abbrechen?
zoomImageScroll = QPoint(0,0);
zoomImage.fill(Qt::white);
zoomImage.fill(Qt::black);
QPixmap tmpImg = composedOffscreenImage.copy(screenmiddle.x()+scroll.x(),screenmiddle.y()+scroll.y(), size.width(), size.height());
QPainter painter(&zoomImage);
......@@ -428,6 +439,20 @@ namespace qmapcontrol
forceRedraw();
}
void LayerManager::drawGeoms()
{
QPainter painter(&composedOffscreenImage);
QListIterator<Layer*> it(mylayers);
while (it.hasNext())
{
Layer* l = it.next();
if (l->layertype() == Layer::GeometryLayer && l->isVisible())
{
l->drawYourGeometries(&painter, mapmiddle_px, layer()->offscreenViewport());
}
}
}
void LayerManager::drawGeoms(QPainter* painter)
{
QListIterator<Layer*> it(mylayers);
......@@ -440,6 +465,8 @@ namespace qmapcontrol
}
}
}
void LayerManager::drawImage(QPainter* painter)
{
painter->drawPixmap(-scroll.x()-screenmiddle.x(),
......@@ -455,11 +482,11 @@ namespace qmapcontrol
void LayerManager::resize(QSize newSize)
{
size = newSize;
offSize = newSize *2;
offSize = newSize *offFactor;
composedOffscreenImage = QPixmap(offSize);
composedOffscreenImage2 = QPixmap(offSize);
zoomImage = QPixmap(newSize);
zoomImage.fill(Qt::white);
zoomImage.fill(Qt::black);
screenmiddle = QPoint(newSize.width()/2, newSize.height()/2);
......@@ -467,7 +494,7 @@ namespace qmapcontrol
while (it.hasNext())
{
Layer* l = it.next();
l->setSize(newSize);
l->setSize(newSize, screenmiddle);
}
newOffscreenImage();
......
......@@ -121,6 +121,11 @@ namespace qmapcontrol
*/
void setZoom(int zoomlevel);
//! Sets the factor the offscreen image should be larger than the visible area
void setOffscreenImageFactor(float factor);
//! Get the factor the offscreen image is larger than the screen
float offscreenImageFactor();
//! The Viewport of the display
/*!
* Returns the visible viewport in world coordinates
......@@ -166,13 +171,15 @@ namespace qmapcontrol
*/
int currentZoom() const;
void drawGeoms();
void drawGeoms(QPainter* painter);
void drawImage(QPainter* painter);
private:
LayerManager& operator=(const LayerManager& rhs);
LayerManager(const LayerManager& old);
//! This method have to be invoked to draw a new offscreen image
//! This method has to be invoked to draw a new offscreen image
/*!
* @param clearImage if the current offscreeen image should be cleared
* @param showZoomImage if a zoom image should be painted
......@@ -188,8 +195,9 @@ namespace qmapcontrol
QPoint scroll; // scrollvalue of the offscreen image
QPoint zoomImageScroll; // scrollvalue of the zoom image
QSize size; // widget size
QSize offSize; // size of the offscreen image
QSize size; ///< widget size
QSize offSize; ///< size of the offscreen image
float offFactor; ///< Size of the offscreen image
QPixmap composedOffscreenImage;
QPixmap composedOffscreenImage2;
......
......@@ -56,7 +56,12 @@ namespace qmapcontrol
vertices.append(point);
}
QList<Point*> LineString::points()
void LineString::clearPoints()
{
vertices.clear();
}
QList<Point*>& LineString::points()
{
return vertices;
}
......
......@@ -56,7 +56,7 @@ namespace qmapcontrol
/*!
* @return a list with the points of the LineString
*/
QList<Point*> points();
QList<Point*>& points();
//! adds a point at the end of the LineString
/*!
......@@ -64,6 +64,9 @@ namespace qmapcontrol
*/
void addPoint ( Point* point );
//! Remove all points from the LineString
void clearPoints();
//! sets the given list as points of the LineString
/*!
* @param points the points which should be set for the LineString
......
......@@ -23,6 +23,9 @@
*
*/
#include <QDialog>
#include <QDesktopServices>
#include "mapcontrol.h"
namespace qmapcontrol
{
......@@ -61,6 +64,29 @@ namespace qmapcontrol
return layermanager->layer(layername);
}
void MapControl::setOffscreenImageFactor(double factor)
{
layermanager->setOffscreenImageFactor(factor);
}
float MapControl::offscreenImageFactor()
{
return layermanager->offscreenImageFactor();
}
void MapControl::openImageSaveDialog()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Image as"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("Image file (*.jpg *.png);;"));
if (fileName != "")
{
if (!fileName.contains(".png") && !fileName.contains(".jpg"))
{
fileName.append(".png");
}
layermanager->getImage().save(fileName, fileName.split(".").last().toUpper().toAscii(), 95);
}
}
QList<QString> MapControl::layers() const
{
return layermanager->layers();
......@@ -324,6 +350,12 @@ namespace qmapcontrol
{
update(rect);
}
void MapControl::drawGeometries()
{
layermanager->drawGeoms();
}
void MapControl::updateRequestNew()
{
// qDebug() << "MapControl::updateRequestNew()";
......@@ -345,7 +377,7 @@ namespace qmapcontrol
{
layermanager->setZoom(zoomlevel);
qDebug() << "MAPCONTROL: Set zoomlevel to:" << zoomlevel << "at " << __FILE__ << __LINE__;
//qDebug() << "MAPCONTROL: Set zoomlevel to:" << zoomlevel << "at " << __FILE__ << __LINE__;
update();
}
......
......@@ -92,6 +92,9 @@ namespace qmapcontrol
*/
Layer* layer ( const QString& layername ) const;
//! The factor the offscreen image is larger than the current viewport
float offscreenImageFactor();
//! returns the names of all layers
/*!
* @return returns a QList with the names of all layers
......@@ -342,6 +345,8 @@ namespace qmapcontrol
*/
void updateRequest ( QRect rect );
void drawGeometries();
//! updates the hole map by creating a new offscreen image
/*!
*
......@@ -354,6 +359,12 @@ namespace qmapcontrol
*/
void resize(const QSize newSize);
//! Open a popup to save the current offscreen image to disk
void openImageSaveDialog();
//! Sets the factor the offscreen image should be larger than the visible area */
void setOffscreenImageFactor(double factor);
private slots:
void tick();
void loadingFinished();
......
......@@ -93,13 +93,19 @@ namespace qmapcontrol
// qDebug() << "Network loaded: " << (loaded);
parent->receivedImage(pm, url);
}
else if (pm.width() == 0 || pm.height() == 0)
{
// Silently ignore map request for a
// 0xn pixel map
}
else
{
// QGC FIXME Error is currently undetected
// TODO Error is currently undetected
//qDebug() << "NETWORK_PIXMAP_ERROR: " << ax;
qDebug() << "QMapControl external library: ERROR loading map:" << "width:" << pm.width() << "heigh:" << pm.height() << "at " << __FILE__ << __LINE__;
qDebug() << "HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
//qDebug() << "HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__;
}
}
......
......@@ -293,12 +293,11 @@ namespace qmapcontrol
emit(positionChanged(this));
}
QList<Point*> Point::points()
QList<Point*>& Point::points()
{
//TODO: assigning temp?!
QList<Point*> points;
points.append(this);
return points;
// FIXME TODO: THIS IS ABSOLUTELY WRONG IN THE ORIGINAL LIBRARY
// NEEDS AN INHERITANCE REWRITE!!!!
return m_points;
}
QWidget* Point::widget()
......
......@@ -139,7 +139,7 @@ namespace qmapcontrol
*/
QPointF coordinate() const;
virtual QList<Point*> points();
virtual QList<Point*>& points();
/*! \brief returns the widget of the point
@return the widget of the point
......@@ -191,6 +191,7 @@ namespace qmapcontrol
QSize displaysize;
QSize minsize;
QSize maxsize;
QList<Point*> m_points;
void drawWidget(const MapAdapter* mapadapter, const QPoint offset);
......
INCLUDE_DIRECTORIES(include)
SET_SOURCE_FILES(NMEALIB_SRC_FILES
context.c
time.c
generate.c
generator.c
gmath.c
info.c
parse.c
parser.c
sentence.c
tok.c
)
PIXHAWK_LIBRARY(nmea SHARED ${NMEALIB_SRC_FILES})
This diff is collapsed.
NMEA library
Disclaimer
The National Marine Electronics Association (NMEA) has developed a specification that defines the interface between various pieces of marine electronic equipment. The standard permits marine electronics to send information to computers and to other marine equipment.
Most computer programs that provide real time position information understand and expect data to be in NMEA format. This data includes the complete PVT (position, velocity, time) solution computed by the GPS receiver. The idea of NMEA is to send a line of data called a sentence that is totally self contained and independent from other sentences. All NMEA sentences is sequences of ACSII symbols begins with a '$' and ends with a carriage return/line feed sequence and can be no longer than 80 characters of visible text (plus the line terminators).
Introduction
We present library in 'C' programming language for work with NMEA protocol. Small and easy to use. The library build on different compilers under different platforms (see below). The code was tested in real projects. Just download and try...
Features
- Analysis NMEA sentences and granting GPS data in C structures
- Generate NMEA sentences
- Supported sentences: GPGGA, GPGSA, GPGSV, GPRMC, GPVTG
- Multilevel architecture of algorithms
- Additional functions of geographical mathematics and work with navigation data
Supported (tested) platforms
- Microsoft Windows (MS Visual Studio 8.0, GCC)
- Windows Mobile, Windows CE (MS Visual Studio 8.0)
- UNIX (GCC)
Licence: LGPL