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:
UAS(MAVLinkProtocol* protocol, int id = 0);
~UAS();
static const int lipoFull = 4.2f; ///< 100% charged voltage
static const int lipoEmpty = 3.5f; ///< Discharged voltage
static const float lipoFull = 4.2f; ///< 100% charged voltage
static const float lipoEmpty = 3.5f; ///< Discharged voltage
/* MANAGEMENT */
......
......@@ -7,8 +7,10 @@ QGCMapToolBar::QGCMapToolBar(QWidget *parent) :
ui(new Ui::QGCMapToolBar),
map(NULL),
optionsMenu(this),
mapTypesMenu(this),
trailPlotMenu(this),
updateTimesMenu(this),
mapTypesGroup(new QActionGroup(this)),
trailSettingsGroup(new QActionGroup(this)),
updateTimesGroup(new QActionGroup(this))
{
......@@ -45,21 +47,43 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
// Set exclusive items
trailSettingsGroup->setExclusive(true);
updateTimesGroup->setExclusive(true);
mapTypesGroup->setExclusive(true);
// Build up menu
trailPlotMenu.setTitle(tr("&Add trail dot every.."));
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()));
action->setData(-1);
//setup the mapTypesMenu
QAction* action;
action = mapTypesMenu.addAction(tr("Bing Hybrid"),this,SLOT(setMapType()));
action->setData(MapType::BingHybrid);
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)
{
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->setCheckable(true);
trailSettingsGroup->addAction(action);
......@@ -71,7 +95,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
}
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->setCheckable(true);
trailSettingsGroup->addAction(action);
......@@ -85,7 +109,7 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
// Set no trail checked if no action is checked yet
if (!trailSettingsGroup->checkedAction())
{
action->setChecked(true);
defaultTrailAction->setChecked(true);
}
optionsMenu.addMenu(&trailPlotMenu);
......@@ -119,7 +143,6 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
}
optionsMenu.addMenu(&updateTimesMenu);
ui->optionsButton->setMenu(&optionsMenu);
}
}
......@@ -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()
{
ui->posLabel->setText(tr("Starting to load tiles.."));
......@@ -201,10 +241,12 @@ void QGCMapToolBar::tileLoadProgress(int progress)
}
}
QGCMapToolBar::~QGCMapToolBar()
{
delete ui;
delete trailSettingsGroup;
delete updateTimesGroup;
delete mapTypesGroup;
// FIXME Delete all actions
}
......@@ -28,6 +28,7 @@ public slots:
void setUAVTrailTime();
void setUAVTrailDistance();
void setUpdateInterval();
void setMapType();
private:
Ui::QGCMapToolBar *ui;
......@@ -37,8 +38,11 @@ protected:
QMenu optionsMenu;
QMenu trailPlotMenu;
QMenu updateTimesMenu;
QMenu mapTypesMenu;
QActionGroup* trailSettingsGroup;
QActionGroup* updateTimesGroup;
QActionGroup* mapTypesGroup;
};
#endif // QGCMAPTOOLBAR_H
......@@ -30,6 +30,12 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
defaultGuidedAlt = -1;
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);
QAction *guidedaction = new QAction(this);
......@@ -519,6 +525,7 @@ void QGCMapWidget::updateHomePosition(double latitude, double longitude, double
void QGCMapWidget::goHome()
{
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