Commit ee28a045 authored by tstellanova's avatar tstellanova

Merge remote-tracking branch 'origin/master' into display_flt_modes

parents 14efc602 38caf81a
...@@ -56,8 +56,8 @@ public: ...@@ -56,8 +56,8 @@ public:
UAS(MAVLinkProtocol* protocol, int id = 0); UAS(MAVLinkProtocol* protocol, int id = 0);
~UAS(); ~UAS();
static const int lipoFull = 4.2f; ///< 100% charged voltage static const float lipoFull = 4.2f; ///< 100% charged voltage
static const int lipoEmpty = 3.5f; ///< Discharged voltage static const float lipoEmpty = 3.5f; ///< Discharged voltage
/* MANAGEMENT */ /* MANAGEMENT */
......
...@@ -7,8 +7,10 @@ QGCMapToolBar::QGCMapToolBar(QWidget *parent) : ...@@ -7,8 +7,10 @@ QGCMapToolBar::QGCMapToolBar(QWidget *parent) :
ui(new Ui::QGCMapToolBar), ui(new Ui::QGCMapToolBar),
map(NULL), map(NULL),
optionsMenu(this), optionsMenu(this),
mapTypesMenu(this),
trailPlotMenu(this), trailPlotMenu(this),
updateTimesMenu(this), updateTimesMenu(this),
mapTypesGroup(new QActionGroup(this)),
trailSettingsGroup(new QActionGroup(this)), trailSettingsGroup(new QActionGroup(this)),
updateTimesGroup(new QActionGroup(this)) updateTimesGroup(new QActionGroup(this))
{ {
...@@ -45,21 +47,43 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) ...@@ -45,21 +47,43 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
// Set exclusive items // Set exclusive items
trailSettingsGroup->setExclusive(true); trailSettingsGroup->setExclusive(true);
updateTimesGroup->setExclusive(true); updateTimesGroup->setExclusive(true);
mapTypesGroup->setExclusive(true);
// Build up menu // Build up menu
trailPlotMenu.setTitle(tr("&Add trail dot every..")); trailPlotMenu.setTitle(tr("&Add trail dot every.."));
updateTimesMenu.setTitle(tr("&Limit map view update rate to..")); updateTimesMenu.setTitle(tr("&Limit map view update rate to.."));
mapTypesMenu.setTitle(tr("&Map type"));
// FIXME MARK CURRENT VALUES IN MENU
QAction* action = trailPlotMenu.addAction(tr("No trail"), this, SLOT(setUAVTrailTime())); //setup the mapTypesMenu
action->setData(-1); QAction* action;
action = mapTypesMenu.addAction(tr("Bing Hybrid"),this,SLOT(setMapType()));
action->setData(MapType::BingHybrid);
action->setCheckable(true); action->setCheckable(true);
trailSettingsGroup->addAction(action); mapTypesGroup->addAction(action);
action = mapTypesMenu.addAction(tr("Google Hybrid"),this,SLOT(setMapType()));
action->setData(MapType::GoogleHybrid);
action->setCheckable(true);
mapTypesGroup->addAction(action);
action = mapTypesMenu.addAction(tr("OpenStreetMap"),this,SLOT(setMapType()));
action->setData(MapType::OpenStreetMap);
action->setCheckable(true);
mapTypesGroup->addAction(action);
//TODO check current item
optionsMenu.addMenu(&mapTypesMenu);
// FIXME MARK CURRENT VALUES IN MENU
QAction *defaultTrailAction = trailPlotMenu.addAction(tr("No trail"), this, SLOT(setUAVTrailTime()));
defaultTrailAction->setData(-1);
defaultTrailAction->setCheckable(true);
trailSettingsGroup->addAction(defaultTrailAction);
for (int i = 0; i < uavTrailTimeCount; ++i) for (int i = 0; i < uavTrailTimeCount; ++i)
{ {
QAction* action = trailPlotMenu.addAction(tr("%1 second%2").arg(uavTrailTimeList[i]).arg((uavTrailTimeList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailTime())); action = trailPlotMenu.addAction(tr("%1 second%2").arg(uavTrailTimeList[i]).arg((uavTrailTimeList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailTime()));
action->setData(uavTrailTimeList[i]); action->setData(uavTrailTimeList[i]);
action->setCheckable(true); action->setCheckable(true);
trailSettingsGroup->addAction(action); trailSettingsGroup->addAction(action);
...@@ -71,7 +95,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) ...@@ -71,7 +95,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
} }
for (int i = 0; i < uavTrailDistanceCount; ++i) for (int i = 0; i < uavTrailDistanceCount; ++i)
{ {
QAction* action = trailPlotMenu.addAction(tr("%1 meter%2").arg(uavTrailDistanceList[i]).arg((uavTrailDistanceList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailDistance())); action = trailPlotMenu.addAction(tr("%1 meter%2").arg(uavTrailDistanceList[i]).arg((uavTrailDistanceList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailDistance()));
action->setData(uavTrailDistanceList[i]); action->setData(uavTrailDistanceList[i]);
action->setCheckable(true); action->setCheckable(true);
trailSettingsGroup->addAction(action); trailSettingsGroup->addAction(action);
...@@ -85,7 +109,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) ...@@ -85,7 +109,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
// Set no trail checked if no action is checked yet // Set no trail checked if no action is checked yet
if (!trailSettingsGroup->checkedAction()) if (!trailSettingsGroup->checkedAction())
{ {
action->setChecked(true); defaultTrailAction->setChecked(true);
} }
optionsMenu.addMenu(&trailPlotMenu); optionsMenu.addMenu(&trailPlotMenu);
...@@ -119,7 +143,6 @@ void QGCMapToolBar::setMap(QGCMapWidget* map) ...@@ -119,7 +143,6 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
} }
optionsMenu.addMenu(&updateTimesMenu); optionsMenu.addMenu(&updateTimesMenu);
ui->optionsButton->setMenu(&optionsMenu); ui->optionsButton->setMenu(&optionsMenu);
} }
} }
...@@ -175,6 +198,23 @@ void QGCMapToolBar::setUpdateInterval() ...@@ -175,6 +198,23 @@ void QGCMapToolBar::setUpdateInterval()
} }
} }
void QGCMapToolBar::setMapType()
{
QObject* sender = QObject::sender();
QAction* action = qobject_cast<QAction*>(sender);
if (action)
{
bool ok;
int mapType = action->data().toInt(&ok);
if (ok)
{
map->SetMapType((MapType::Types)mapType);
ui->posLabel->setText(tr("Map type: %1").arg(mapType));
}
}
}
void QGCMapToolBar::tileLoadStart() void QGCMapToolBar::tileLoadStart()
{ {
ui->posLabel->setText(tr("Starting to load tiles..")); ui->posLabel->setText(tr("Starting to load tiles.."));
...@@ -201,10 +241,12 @@ void QGCMapToolBar::tileLoadProgress(int progress) ...@@ -201,10 +241,12 @@ void QGCMapToolBar::tileLoadProgress(int progress)
} }
} }
QGCMapToolBar::~QGCMapToolBar() QGCMapToolBar::~QGCMapToolBar()
{ {
delete ui; delete ui;
delete trailSettingsGroup; delete trailSettingsGroup;
delete updateTimesGroup; delete updateTimesGroup;
delete mapTypesGroup;
// FIXME Delete all actions // FIXME Delete all actions
} }
...@@ -28,6 +28,7 @@ public slots: ...@@ -28,6 +28,7 @@ public slots:
void setUAVTrailTime(); void setUAVTrailTime();
void setUAVTrailDistance(); void setUAVTrailDistance();
void setUpdateInterval(); void setUpdateInterval();
void setMapType();
private: private:
Ui::QGCMapToolBar *ui; Ui::QGCMapToolBar *ui;
...@@ -37,8 +38,11 @@ protected: ...@@ -37,8 +38,11 @@ protected:
QMenu optionsMenu; QMenu optionsMenu;
QMenu trailPlotMenu; QMenu trailPlotMenu;
QMenu updateTimesMenu; QMenu updateTimesMenu;
QMenu mapTypesMenu;
QActionGroup* trailSettingsGroup; QActionGroup* trailSettingsGroup;
QActionGroup* updateTimesGroup; QActionGroup* updateTimesGroup;
QActionGroup* mapTypesGroup;
}; };
#endif // QGCMAPTOOLBAR_H #endif // QGCMAPTOOLBAR_H
...@@ -30,6 +30,12 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) : ...@@ -30,6 +30,12 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
defaultGuidedAlt = -1; defaultGuidedAlt = -1;
loadSettings(false); loadSettings(false);
//handy for debugging:
//this->SetShowTileGridLines(true);
//default appears to be Google Hybrid, and is broken currently
this->SetMapType(MapType::BingHybrid);
this->setContextMenuPolicy(Qt::ActionsContextMenu); this->setContextMenuPolicy(Qt::ActionsContextMenu);
QAction *guidedaction = new QAction(this); QAction *guidedaction = new QAction(this);
...@@ -519,6 +525,7 @@ void QGCMapWidget::updateHomePosition(double latitude, double longitude, double ...@@ -519,6 +525,7 @@ void QGCMapWidget::updateHomePosition(double latitude, double longitude, double
void QGCMapWidget::goHome() void QGCMapWidget::goHome()
{ {
SetCurrentPosition(Home->Coord()); SetCurrentPosition(Home->Coord());
SetZoom(18); //zoom to "large RC park" size
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment