Newer
Older
/*==================================================================
======================================================================*/
/**
* @file
lm
committed
#include "QGC.h"
#include "UASInterface.h"
#include "UASManager.h"
lm
committed
#include "MAV2DIcon.h"
#include "Waypoint2DIcon.h"
pixhawk
committed
#include "UASWaypointManager.h"
QWidget(parent),
mc(NULL),
zoomLevel(0),
uasIcons(),
uasTrails(),
mav(NULL),
lastUpdate(0),
initialized(false),
m_ui(new Ui::MapWidget)
}
void MapWidget::init()
{
mc = new qmapcontrol::MapControl(this->size());
// display the MapControl in the application
QGridLayout* layout = new QGridLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(mc, 0, 0);
setLayout(layout);
// VISUAL MAP STYLE
QString buttonStyle("QAbstractButton { background-color: rgba(20, 20, 20, 45%); border-color: rgba(10, 10, 10, 50%)} QAbstractButton:checked { border: 2px solid #379AC3; }");
mc->setPen(QGC::colorCyan.darker(400));
lm
committed
lm
committed
// Accept focus by clicking or keyboard
this->setFocusPolicy(Qt::StrongFocus);
// create MapControl
mc->showScale(true);
mc->showCoord(true);
mc->enablePersistentCache();
mc->setMouseTracking(true); // required to update the mouse position for diplay and capture
// create MapAdapter to get maps from
//TileMapAdapter* osmAdapter = new TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17);
qmapcontrol::MapAdapter* mapadapter_overlay = new qmapcontrol::YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=2.2&t=h&s=256&x=%2&y=%3&z=%1");
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// MAP BACKGROUND
mapadapter = new qmapcontrol::GoogleSatMapAdapter();
l = new qmapcontrol::MapLayer("Google Satellite", mapadapter);
mc->addLayer(l);
// STREET OVERLAY
overlay = new qmapcontrol::MapLayer("Overlay", mapadapter_overlay);
overlay->setVisible(false);
mc->addLayer(overlay);
// MAV FLIGHT TRACKS
tracks = new qmapcontrol::MapLayer("Tracking", mapadapter);
mc->addLayer(tracks);
// WAYPOINT LAYER
// create a layer with the mapadapter and type GeometryLayer (for waypoints)
geomLayer = new qmapcontrol::GeometryLayer("Waypoints", mapadapter);
mc->addLayer(geomLayer);
//
// Layer* gsatLayer = new Layer("Google Satellite", gsat, Layer::MapLayer);
// mc->addLayer(gsatLayer);
// Zurich, ETH
int lastZoom = 16;
double lastLat = 47.376889;
double lastLon = 8.548056;
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
lastLat = settings.value("LAST_LATITUDE", lastLat).toDouble();
lastLon = settings.value("LAST_LONGITUDE", lastLon).toDouble();
lastZoom = settings.value("LAST_ZOOM", lastZoom).toInt();
settings.endGroup();
// SET INITIAL POSITION AND ZOOM
// Set default zoom level
mc->setZoom(lastZoom);
mc->setView(QPointF(lastLon, lastLat));
// Veracruz Mexico
//mc->setView(QPointF(-96.105208,19.138955));
// Add controls to select map provider
/////////////////////////////////////////////////
QActionGroup* mapproviderGroup = new QActionGroup(this);
Jessica
committed
osmAction = new QAction(QIcon(":/files/images/mapproviders/openstreetmap.png"), tr("OpenStreetMap"), mapproviderGroup);
yahooActionMap = new QAction(QIcon(":/files/images/mapproviders/yahoo.png"), tr("Yahoo: Map"), mapproviderGroup);
yahooActionSatellite = new QAction(QIcon(":/files/images/mapproviders/yahoo.png"), tr("Yahoo: Satellite"), mapproviderGroup);
googleActionMap = new QAction(QIcon(":/files/images/mapproviders/google.png"), tr("Google: Map"), mapproviderGroup);
googleSatAction = new QAction(QIcon(":/files/images/mapproviders/google.png"), tr("Google: Sat"), mapproviderGroup);
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
osmAction->setCheckable(true);
yahooActionMap->setCheckable(true);
yahooActionSatellite->setCheckable(true);
googleActionMap->setCheckable(true);
googleSatAction->setCheckable(true);
googleSatAction->setChecked(true);
connect(mapproviderGroup, SIGNAL(triggered(QAction*)),
this, SLOT(mapproviderSelected(QAction*)));
// Overlay seems currently broken
// yahooActionOverlay = new QAction(tr("Yahoo: street overlay"), this);
// yahooActionOverlay->setCheckable(true);
// yahooActionOverlay->setChecked(overlay->isVisible());
// connect(yahooActionOverlay, SIGNAL(toggled(bool)),
// overlay, SLOT(setVisible(bool)));
// mapproviderGroup->addAction(googleSatAction);
// mapproviderGroup->addAction(osmAction);
// mapproviderGroup->addAction(yahooActionOverlay);
// mapproviderGroup->addAction(googleActionMap);
// mapproviderGroup->addAction(yahooActionMap);
// mapproviderGroup->addAction(yahooActionSatellite);
// Create map provider selection menu
mapMenu = new QMenu(this);
mapMenu->addActions(mapproviderGroup->actions());
mapMenu->addSeparator();
// mapMenu->addAction(yahooActionOverlay);
mapButton = new QPushButton(this);
mapButton->setText("Map Source");
mapButton->setMenu(mapMenu);
mapButton->setStyleSheet(buttonStyle);
// create buttons to control the map (zoom, GPS tracking and WP capture)
Jessica
committed
QPushButton* zoomin = new QPushButton(QIcon(":/files/images/actions/list-add.svg"), "", this);
Jessica
committed
QPushButton* zoomout = new QPushButton(QIcon(":/files/images/actions/list-remove.svg"), "", this);
Jessica
committed
createPath = new QPushButton(QIcon(":/files/images/actions/go-bottom.svg"), "", this);
createPath->setStyleSheet(buttonStyle);
createPath->setToolTip(tr("Start / end waypoint add mode"));
createPath->setStatusTip(tr("Start / end waypoint add mode"));
// clearTracking = new QPushButton(QIcon(""), "", this);
// clearTracking->setStyleSheet(buttonStyle);
Jessica
committed
followgps = new QPushButton(QIcon(":/files/images/actions/system-lock-screen.svg"), "", this);
followgps->setStyleSheet(buttonStyle);
followgps->setToolTip(tr("Follow the position of the current MAV with the map center"));
followgps->setStatusTip(tr("Follow the position of the current MAV with the map center"));
QPushButton* goToButton = new QPushButton(QIcon(""), "T", this);
goToButton->setStyleSheet(buttonStyle);
goToButton->setToolTip(tr("Enter a latitude/longitude position to move the map to"));
goToButton->setStatusTip(tr("Enter a latitude/longitude position to move the map to"));
zoomin->setMaximumWidth(30);
zoomout->setMaximumWidth(30);
createPath->setMaximumWidth(30);
// clearTracking->setMaximumWidth(30);
followgps->setMaximumWidth(30);
goToButton->setMaximumWidth(30);
// Set checkable buttons
// TODO: Currently checked buttons are are very difficult to distinguish when checked.
// create a style and the slots to change the background so it is easier to distinguish
followgps->setCheckable(true);
createPath->setCheckable(true);
// add buttons to control the map (zoom, GPS tracking and WP capture)
QGridLayout* innerlayout = new QGridLayout(mc);
innerlayout->setMargin(3);
Loading
Loading full blame...