Newer
Older
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
if (mc)
{
switch (event->key()) {
case Qt::Key_Plus:
mc->zoomIn();
break;
case Qt::Key_Minus:
mc->zoomOut();
break;
case Qt::Key_Left:
mc->scrollLeft(this->width()/scrollStep);
break;
case Qt::Key_Right:
mc->scrollRight(this->width()/scrollStep);
break;
case Qt::Key_Down:
mc->scrollDown(this->width()/scrollStep);
break;
case Qt::Key_Up:
mc->scrollUp(this->width()/scrollStep);
break;
default:
QWidget::keyPressEvent(event);
}
void MapWidget::resizeEvent(QResizeEvent* event )
Q_UNUSED(event);
void MapWidget::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
// if (isVisible())
// {
// if (!initialized)
// {
// init();
// }
// }
}
void MapWidget::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
if (mc)
{
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
QPointF currentPos = mc->currentCoordinate();
settings.setValue("LAST_LATITUDE", currentPos.y());
settings.setValue("LAST_LONGITUDE", currentPos.x());
settings.setValue("LAST_ZOOM", mc->currentZoom());
settings.endGroup();
settings.sync();
}
void MapWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
pixhawk
committed
void MapWidget::clearWaypoints(int uas)
pixhawk
committed
{
Q_UNUSED(uas);
// Clear the previous WP track
pixhawk
committed
//mc->layer("Waypoints")->clearGeometries();
wps.clear();
foreach (Point* p, wpIcons)
{
mc->layer("Waypoints")->removeGeometry(p);
}
wpIcons.clear();
pixhawk
committed
// Get bounding box of this object BEFORE deleting the content
QRect box = waypointPath->boundingBox().toRect();
pixhawk
committed
// Delete the content
waypointPath->points().clear();
//delete waypointPath;
//waypointPath = new
//mc->layer("Waypoints")->addGeometry(waypointPath);
//wpIndex.clear();
if (isVisible()) mc->updateRequest(box);//(waypointPath->boundingBox().toRect());
pixhawk
committed
if(createPath->isChecked())
{
createPath->click();
}
}
pixhawk
committed
void MapWidget::clearPath(int uas)
mc->layer("Tracking")->clearGeometries();
foreach (qmapcontrol::LineString* ls, uasTrails)
{
QPen* linepen = ls->pen();
delete ls;
qmapcontrol::LineString* lsNew = new qmapcontrol::LineString(QList<qmapcontrol::Point*>(), "", linepen);
mc->layer("Tracking")->addGeometry(lsNew);
}
// FIXME update this with update request only for bounding box of trails
if (isVisible()) mc->updateRequestNew();//(QRect(0, 0, width(), height()));
tecnosapiens
committed
void MapWidget::updateCameraPosition(double radio, double bearing, QString dir)
{
if (mc)
{
// FIXME Mariano
//camPoints.clear();
QPointF currentPos = mc->currentCoordinate();
// QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance);
// 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);
// camPoints.append(tempPoint1);
// camPoints.append(tempPoint2);
QPen* camBorderPen = new QPen(QColor(255,0,0));
camBorderPen->setWidth(2);
if(drawCamBorder)
{
//clear camera borders
mc->layer("Camera")->clearGeometries();
//create a camera borders
qmapcontrol::CirclePoint* camBorder = new qmapcontrol::CirclePoint(currentPos.x(), currentPos.y(), radio, "camBorder", qmapcontrol::Point::Middle, camBorderPen);
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::drawBorderCamAtMap(bool status)
{
drawCamBorder = status;
updateCameraPosition(20,0,"no");
}
QPointF MapWidget::getPointxBearing_Range(double lat1, double lon1, double bearing, double distance)
{
QPointF temp;
bearing = bearing*rad;
temp.setX((lon1 + ((distance/60) * (sin(bearing)))));
temp.setY((lat1 + ((distance/60) * (cos(bearing)))));