Commit fe00cbb2 authored by lm's avatar lm
Browse files

Reverted buggy changes

parent 06ecc8c2
......@@ -44,7 +44,7 @@ class Waypoint : public QObject
public:
Waypoint(quint16 id = 0, double x = 0.0, double y = 0.0, double z = 0.0, double param1 = 0.0, double param2 = 0.0, double param3 = 0.0, double param4 = 0.0,
bool autocontinue = true, bool current = false, MAV_FRAME frame=MAV_FRAME_GLOBAL_RELATIVE_ALT, MAV_CMD action=MAV_CMD_NAV_WAYPOINT);
bool autocontinue = true, bool current = false, MAV_FRAME frame=MAV_FRAME_GLOBAL, MAV_CMD action=MAV_CMD_NAV_WAYPOINT);
~Waypoint();
quint16 getId() const { return id; }
......
......@@ -93,8 +93,6 @@ void MapWidget::init()
geomLayer = new qmapcontrol::GeometryLayer("Waypoints", mapadapter);
mc->addLayer(geomLayer);
homePosition = new qmapcontrol::GeometryLayer("Station", mapadapter);
mc->addLayer(homePosition);
//
......@@ -115,16 +113,6 @@ void MapWidget::init()
lastZoom = settings.value("LAST_ZOOM", lastZoom).toInt();
settings.endGroup();
index = 0;
settings.beginGroup("QGC_MAPINDEX");
index = settings.value("MAP_INDEX", index).toInt();
settings.endGroup();
settings.beginGroup("QGC_HOMEPOSITION");
homeCoordinate.setY(settings.value("HOME_LATITUDE", homeCoordinate.y()).toDouble());
homeCoordinate.setX(settings.value("HOME_LONGITUDE", homeCoordinate.x()).toDouble());
settings.endGroup();
// SET INITIAL POSITION AND ZOOM
// Set default zoom level
mc->setZoom(lastZoom);
......@@ -150,14 +138,6 @@ void MapWidget::init()
connect(mapproviderGroup, SIGNAL(triggered(QAction*)),
this, SLOT(mapproviderSelected(QAction*)));
//mapSettings.beginGroup("Map_Widget");
//QAction *act = new QAction(mapSettings.value("QAction").toString(), this);
//mapproviderSelected(act);
//mapSettings.endGroup();
// Overlay seems currently broken
// yahooActionOverlay = new QAction(tr("Yahoo: street overlay"), this);
// yahooActionOverlay->setCheckable(true);
......@@ -203,17 +183,11 @@ void MapWidget::init()
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"));
setHome = new QPushButton(QIcon(":/images/actions/go-home.svg"), "", this);
setHome->setStyleSheet(buttonStyle);
setHome->setToolTip(tr("Set home"));
setHome->setStatusTip(tr("Set home"));
zoomin->setMaximumWidth(30);
zoomout->setMaximumWidth(30);
createPath->setMaximumWidth(30);
// clearTracking->setMaximumWidth(30);
followgps->setMaximumWidth(30);
setHome->setMaximumWidth(30);
goToButton->setMaximumWidth(30);
// Set checkable buttons
......@@ -221,7 +195,6 @@ void MapWidget::init()
// create a style and the slots to change the background so it is easier to distinguish
followgps->setCheckable(true);
createPath->setCheckable(true);
setHome->setCheckable(true);
// add buttons to control the map (zoom, GPS tracking and WP capture)
QGridLayout* innerlayout = new QGridLayout(mc);
......@@ -231,7 +204,6 @@ void MapWidget::init()
innerlayout->addWidget(zoomout, 1, 0);
innerlayout->addWidget(followgps, 2, 0);
innerlayout->addWidget(createPath, 3, 0);
innerlayout->addWidget(setHome, 4, 0);
//innerlayout->addWidget(clearTracking, 4, 0);
// Add spacers to compress buttons on the top left
innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 5, 0);
......@@ -248,6 +220,17 @@ void MapWidget::init()
waypointPath = new qmapcontrol::LineString (wps, "Waypoint path", pointPen);
mc->layer("Waypoints")->addGeometry(waypointPath);
//Camera Control
// CAMERA INDICATOR LAYER
// create a layer with the mapadapter and type GeometryLayer (for camera indicator)
camLayer = new qmapcontrol::GeometryLayer("Camera", mapadapter);
mc->addLayer(camLayer);
//camLine = new qmapcontrol::LineString(camPoints,"Camera Eje", camBorderPen);
drawCamBorder = false;
radioCamera = 10;
// Done set state
initialized = true;
......@@ -279,12 +262,6 @@ void MapWidget::init()
connect(createPath, SIGNAL(clicked(bool)),
this, SLOT(createPathButtonClicked(bool)));
connect(setHome, SIGNAL(clicked(bool)), this, SLOT(createHomePositionClick(bool)));
connect(mc, SIGNAL(mouseEventCoordinate(const QMouseEvent*,QPointF)), this,
SLOT(createHomePosition(const QMouseEvent*,QPointF)));
//connect(setHome, SIGNAL(clicked(bool)), this, SLOT(createHomePosition(bool)));
connect(geomLayer, SIGNAL(geometryClicked(Geometry*,QPoint)),
this, SLOT(captureGeometryClick(Geometry*, QPoint)));
......@@ -295,44 +272,10 @@ void MapWidget::init()
connect(geomLayer, SIGNAL(geometryEndDrag(Geometry*, QPointF)),
this, SLOT(captureGeometryEndDrag(Geometry*, QPointF)));
connect(homePosition, SIGNAL(geometryClicked(Geometry*,QPoint)),
this, SLOT(captureGeometryClick(Geometry*, QPoint)));
connect(homePosition, SIGNAL(geometryDragged(Geometry*, QPointF)),
this, SLOT(captureGeometryDragHome(Geometry*, QPointF)));
connect(homePosition, SIGNAL(geometryEndDrag(Geometry*, QPointF)),
this, SLOT(captureGeometryEndDrag(Geometry*, QPointF)));
this->loadSettingsMap(index);
this->createHomePosition(homeCoordinate);
qDebug() << "CHECK END";
}
}
void MapWidget::loadSettingsMap(int8_t index)
{
switch(index)
{
case 0:
mapproviderSelected(osmAction);
break;
case 1:
mapproviderSelected(yahooActionMap);
break;
case 2:
mapproviderSelected(yahooActionSatellite);
break;
case 3:
mapproviderSelected(googleActionMap);
break;
case 4:
mapproviderSelected(googleSatAction);
break;
}
}
void MapWidget::goTo()
{
bool ok;
......@@ -373,8 +316,6 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::OSMMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
homePosition->setMapAdapter(mapadapter);
index = 0;
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
......@@ -391,8 +332,6 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::YahooMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
homePosition->setMapAdapter(mapadapter);
index = 1;
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
......@@ -409,8 +348,6 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1");
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
homePosition->setMapAdapter(mapadapter);
index = 2;
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
......@@ -424,8 +361,6 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::GoogleMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
homePosition->setMapAdapter(mapadapter);
index = 3;
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
......@@ -440,8 +375,6 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter = new qmapcontrol::GoogleSatMapAdapter();
l->setMapAdapter(mapadapter);
geomLayer->setMapAdapter(mapadapter);
homePosition->setMapAdapter(mapadapter);
index = 4;
if (isVisible()) mc->updateRequestNew();
mc->setZoom(zoom);
......@@ -497,6 +430,7 @@ void MapWidget::createPathButtonClicked(bool checked)
* @param coordinate The coordinate in which it occured the mouse event
* @note This slot is connected to the mouseEventCoordinate of the QMapControl object
*/
void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordinate)
{
if (QEvent::MouseButtonRelease == event->type() && createPath->isChecked())
......@@ -534,6 +468,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
// Refresh the screen
if (isVisible()) mc->updateRequest(tempPoint->boundingBox().toRect());
}
// emit signal mouse was clicked
//emit captureMapCoordinateClick(coordinate);
}
......@@ -757,38 +692,6 @@ void MapWidget::captureGeometryEndDrag(Geometry* geom, QPointF coordinate)
mc->setMouseMode(qmapcontrol::MapControl::Panning);
}
if (!setHome->isChecked())
{
mc->setMouseMode(qmapcontrol::MapControl::Panning);
if(mav)
{
// Update homePosition
UASManager::instance()->setHomePosition(
static_cast<double>(homeCoordinate.y()),
static_cast<double>(homeCoordinate.x()), 0);
}
}
}
void MapWidget::captureGeometryDragHome(Geometry *geom, QPointF coordinate)
{
if (isVisible()) mc->updateRequest(geom->boundingBox().toRect());
Waypoint2DIcon* point2Find = dynamic_cast <Waypoint2DIcon*> (geom);
if (point2Find)// && wps.count() > index)
{
// Update visual
point2Find->setCoordinate(coordinate);
homeCoordinate.setX(coordinate.x());
homeCoordinate.setY(coordinate.y());
qmapcontrol::Point* tempPoint = new qmapcontrol::Point(homeCoordinate.x(), homeCoordinate.y(),"g");
if (isVisible()) mc->updateRequest(tempPoint->boundingBox().toRect());
}
}
MapWidget::~MapWidget()
......@@ -796,7 +699,6 @@ MapWidget::~MapWidget()
delete mc;
delete m_ui;
}
/**
*
* @param uas the UAS/MAV to monitor/display with the HUD
......@@ -1093,7 +995,7 @@ void MapWidget::wheelEvent(QWheelEvent *event)
detailZoom = qAbs(qMin(0, mc->currentZoom()-newZoom));
// visual field of camera
//updateCameraPosition(20*newZoom,0,"no");
updateCameraPosition(20*newZoom,0,"no");
}
}
......@@ -1160,19 +1062,7 @@ void MapWidget::hideEvent(QHideEvent* event)
settings.setValue("LAST_LONGITUDE", currentPos.x());
settings.setValue("LAST_ZOOM", mc->currentZoom());
settings.endGroup();
settings.beginGroup("QGC_MAPINDEX");
settings.setValue("MAP_INDEX", index);
settings.endGroup();
settings.beginGroup("QGC_HOMEPOSITION");
settings.setValue("HOME_LATITUDE", homeCoordinate.y());
settings.setValue("HOME_LONGITUDE", homeCoordinate.x());
settings.endGroup();
settings.sync();
}
}
......@@ -1241,55 +1131,72 @@ void MapWidget::clearPath(int uas)
}
}
void MapWidget::createHomePosition(const QMouseEvent *event, const QPointF coordinate)
void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
{
if (QEvent::MouseButtonRelease == event->type() && setHome->isChecked())
Q_UNUSED(dir);
Q_UNUSED(bearing);
if (mc)
{
this->createHomePosition(coordinate);
}
}
// FIXME Mariano
//camPoints.clear();
QPointF currentPos = mc->currentCoordinate();
// QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance);
void MapWidget::createHomePosition(const QPointF coordinate)
{
homeCoordinate= coordinate;
Waypoint2DIcon* tempCirclePoint;
// qmapcontrol::Point* tempPoint1 = new qmapcontrol::Point(currentPos.x(), currentPos.y(),"inicial",qmapcontrol::Point::Middle);
// qmapcontrol::Point* tempPoint2 = new qmapcontrol::Point(actualPos.x(), actualPos.y(),"final",qmapcontrol::Point::Middle);
double latitude = homeCoordinate.y();
double longitude = homeCoordinate.x();
// camPoints.append(tempPoint1);
// camPoints.append(tempPoint2);
tempCirclePoint = new Waypoint2DIcon(
longitude,
latitude,
20, "g", qmapcontrol::Point::Middle);
// camLine->setPoints(camPoints);
QPen* pencil = new QPen(Qt::blue);
tempCirclePoint->setPen(pencil);
QPen* camBorderPen = new QPen(QColor(255,0,0));
camBorderPen->setWidth(2);
mc->layer("Station")->clearGeometries();
mc->layer("Station")->addGeometry(tempCirclePoint);
//radio = mc->currentZoom()
qmapcontrol::Point* tempPoint = new qmapcontrol::Point(latitude, longitude,"g");
if(drawCamBorder)
{
//clear camera borders
mc->layer("Camera")->clearGeometries();
if (isVisible())
{
mc->updateRequest(tempPoint->boundingBox().toRect());
//create a camera borders
qmapcontrol::CirclePoint* camBorder = new qmapcontrol::CirclePoint(currentPos.x(), currentPos.y(), radio, "camBorder", qmapcontrol::Point::Middle, camBorderPen);
//camBorder->setCoordinate(currentPos);
mc->layer("Camera")->addGeometry(camBorder);
// mc->layer("Camera")->addGeometry(camLine);
if (isVisible()) mc->updateRequestNew();
}
else
{
//clear camera borders
mc->layer("Camera")->clearGeometries();
if (isVisible()) mc->updateRequestNew();
}
}
}
void MapWidget::createHomePositionClick(bool click)
void MapWidget::drawBorderCamAtMap(bool status)
{
Q_UNUSED(click);
drawCamBorder = status;
updateCameraPosition(20,0,"no");
if (!setHome->isChecked())
{
if(mav)
{
UASManager::instance()->setHomePosition(
static_cast<double>(homeCoordinate.y()),
static_cast<double>(homeCoordinate.x()), 0);
}
QPointF MapWidget::getPointxBearing_Range(double lat1, double lon1, double bearing, double distance)
{
QPointF temp;
double rad = M_PI/180;
//qDebug()<<"Set home position "<<homeCoordinate.y()<<" "<<homeCoordinate.x();
}
}
bearing = bearing*rad;
temp.setX((lon1 + ((distance/60) * (sin(bearing)))));
temp.setY((lat1 + ((distance/60) * (cos(bearing)))));
return temp;
}
......@@ -40,7 +40,8 @@ This file is part of the QGROUNDCONTROL project
#include "QPointF"
#include <qmath.h>
#include <QSettings>
class QMenu;
class Waypoint;
......@@ -75,8 +76,8 @@ public slots:
void updateAttitude(UASInterface* uas, double roll, double pitch, double yaw, quint64 usec);
void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
void updatePosition(float time, double lat, double lon);
//void updateCameraPosition(double distance, double bearing, QString dir);
//QPointF getPointxBearing_Range(double lat1, double lon1, double bearing, double distance);
void updateCameraPosition(double distance, double bearing, QString dir);
QPointF getPointxBearing_Range(double lat1, double lon1, double bearing, double distance);
/** @brief Clear the waypoints overlay layer */
void clearWaypoints(int uas=0);
......@@ -92,7 +93,7 @@ public slots:
void updateWaypoint(int uas, Waypoint* wp);
void updateWaypoint(int uas, Waypoint* wp, bool updateView);
//void drawBorderCamAtMap(bool status);
void drawBorderCamAtMap(bool status);
/** @brief Bring up dialog to go to a specific location */
void goTo();
......@@ -117,7 +118,6 @@ protected:
QPushButton* followgps;
QPushButton* createPath;
QPushButton* clearTracking;
QPushButton* setHome;
QLabel* gpsposition;
QMenu* mapMenu;
QPushButton* mapButton;
......@@ -128,7 +128,9 @@ protected:
qmapcontrol::Layer* overlay; ///< Street overlay (foreground)
qmapcontrol::Layer* tracks; ///< Layer for UAV tracks
qmapcontrol::GeometryLayer* geomLayer; ///< Layer for waypoints
qmapcontrol::GeometryLayer* homePosition; ///< Layer for station control
//only for experiment
qmapcontrol::GeometryLayer* camLayer; ///< Layer for camera indicator
int zoomLevel;
int detailZoom; ///< Steps zoomed in further than qMapControl allows
......@@ -140,6 +142,8 @@ protected:
QMap<int, qmapcontrol::Point*> uasIcons;
QMap<int, qmapcontrol::LineString*> uasTrails;
QMap<int, QPen*> mavPens;
//QMap<int, QList<qmapcontrol::Point*> > mavWps;
//QMap<int, qmapcontrol::LineString*> waypointPaths;
UASInterface* mav;
quint64 lastUpdate;
bool initialized;
......@@ -153,23 +157,20 @@ protected:
void captureGeometryDrag(Geometry* geom, QPointF coordinate);
void captureGeometryEndDrag(Geometry* geom, QPointF coordinate);
void captureGeometryDragHome(Geometry* geom, QPointF coordinate);
void createPathButtonClicked(bool checked);
/** @brief Create the graphic representation of the waypoint */
void createWaypointGraphAtMap(int id, const QPointF coordinate);
void mapproviderSelected(QAction* action);
void createHomePosition(const QMouseEvent* event, const QPointF coordinate);
void createHomePosition(const QPointF coordinate);
void createHomePositionClick(bool click);
void loadSettingsMap(int8_t index);
signals:
//void movePoint(QPointF newCoord);
//void captureMapCoordinateClick(const QPointF coordinate); //ROCA
//void createGlobalWP(bool value, QPointF centerCoordinate);
void waypointCreated(Waypoint* wp);
void sendGeometryEndDrag(const QPointF coordinate, const int index);
private:
Ui::MapWidget *m_ui;
QList<qmapcontrol::Point*> wps;
......@@ -179,8 +180,14 @@ private:
QPen* pointPen;
int wpExists(const QPointF coordinate);
bool waypointIsDrag;
QPointF homeCoordinate;
int8_t index;
qmapcontrol::LineString* camLine;
QList<qmapcontrol::Point*> camPoints;
QPointF lastCamBorderPos;
bool drawCamBorder;
int radioCamera;
};
#endif // MAPWIDGET_H
......@@ -190,13 +190,12 @@ void WaypointList::add()
// Create global frame waypoint per default
wp = new Waypoint(0, uas->getLatitude(), uas->getLongitude(), uas->getAltitude(), 0.0, 0.0, 0.0, 0.0, true, true, MAV_FRAME_GLOBAL, MAV_CMD_NAV_WAYPOINT);
uas->getWaypointManager()->addWaypoint(wp);
}
}
}
void WaypointList::addCurrentPositonWaypoint(){
void WaypointList::addCurrentPositonWaypoint()
{
/* TODO: implement with new waypoint structure
if (uas)
{
......@@ -463,9 +462,6 @@ void WaypointList::moveUp(Waypoint* wp)
uas->getWaypointManager()->moveWaypoint(i, i-1);
}
}
//emitir seal de cambio orden en la lista,
//la debe capturar el mapwidget para volver a dibujar la ruta
}
void WaypointList::moveDown(Waypoint* wp)
......@@ -525,6 +521,13 @@ void WaypointList::on_clearWPListButton_clicked()
widget->remove();
}
}
else
{
// if(isGlobalWP)
// {
// emit clearPathclicked();
// }
}
}
///** @brief The MapWidget informs that a waypoint global was changed on the map */
......
......@@ -108,7 +108,7 @@ public slots:
signals:
void clearPathclicked();
void createWaypointAtMap(const QPointF coordinate);
void changePointList();
protected:
virtual void changeEvent(QEvent *e);
......
Supports Markdown
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