mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
OP37/GCS Enhancements to smooth zooming. Continue preliminary work on the UAV overlay.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@994 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
0dedcd888c
commit
6714d62e42
@ -80,20 +80,22 @@ namespace mapcontrol
|
|||||||
w->RefreshPos();
|
w->RefreshPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MapGraphicItem::ConstructLastImage()
|
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||||
{
|
{
|
||||||
|
QImage temp;
|
||||||
QSize size=boundingRect().size().toSize();
|
QSize size=boundingRect().size().toSize();
|
||||||
size.setWidth(size.width()*2);
|
size.setWidth(size.width()*2*zoomdiff);
|
||||||
size.setHeight(size.height()*2);
|
size.setHeight(size.height()*2*zoomdiff);
|
||||||
lastimage=QImage(size,
|
temp=QImage(size,
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
lastimage.fill(0);
|
temp.fill(0);
|
||||||
QPainter* imagePainter=new QPainter(&lastimage);
|
QPainter imagePainter(&temp);
|
||||||
imagePainter->translate(-boundingRect().topLeft());
|
imagePainter.translate(-boundingRect().topLeft());
|
||||||
imagePainter->scale(2,2);
|
imagePainter.scale(2*zoomdiff,2*zoomdiff);
|
||||||
paintImage(imagePainter);
|
paintImage(&imagePainter);
|
||||||
imagePainter->end();
|
imagePainter.end();
|
||||||
lastimagepoint=Point(core->GetrenderOffset().X()*2,core->GetrenderOffset().Y()*2);
|
lastimagepoint=Point(core->GetrenderOffset().X()*2*zoomdiff,core->GetrenderOffset().Y()*2*zoomdiff);
|
||||||
|
lastimage=temp;
|
||||||
}
|
}
|
||||||
void MapGraphicItem::paintImage(QPainter *painter)
|
void MapGraphicItem::paintImage(QPainter *painter)
|
||||||
{
|
{
|
||||||
@ -104,13 +106,13 @@ namespace mapcontrol
|
|||||||
transform.scale(MapRenderTransform,MapRenderTransform);
|
transform.scale(MapRenderTransform,MapRenderTransform);
|
||||||
painter->setWorldTransform(transform);
|
painter->setWorldTransform(transform);
|
||||||
{
|
{
|
||||||
DrawMap2D(painter,true);
|
DrawMap2D(painter);
|
||||||
}
|
}
|
||||||
painter->resetTransform();
|
painter->resetTransform();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawMap2D(painter,true);
|
DrawMap2D(painter);
|
||||||
}
|
}
|
||||||
//painter->drawRect(maprect);
|
//painter->drawRect(maprect);
|
||||||
}
|
}
|
||||||
@ -123,15 +125,14 @@ namespace mapcontrol
|
|||||||
transform.scale(MapRenderTransform,MapRenderTransform);
|
transform.scale(MapRenderTransform,MapRenderTransform);
|
||||||
painter->setWorldTransform(transform);
|
painter->setWorldTransform(transform);
|
||||||
{
|
{
|
||||||
DrawMap2D(painter,false);
|
DrawMap2D(painter);
|
||||||
}
|
}
|
||||||
painter->resetTransform();
|
painter->resetTransform();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawMap2D(painter,false);
|
DrawMap2D(painter);
|
||||||
}
|
}
|
||||||
// painter->drawRect(maprect);
|
|
||||||
}
|
}
|
||||||
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
@ -251,12 +252,10 @@ namespace mapcontrol
|
|||||||
core->MouseWheelZooming = false;
|
core->MouseWheelZooming = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MapGraphicItem::DrawMap2D(QPainter *painter,bool ToImage)
|
void MapGraphicItem::DrawMap2D(QPainter *painter)
|
||||||
{
|
{
|
||||||
// qDebug()<<core->Matrix.count();
|
|
||||||
// painter.drawText(10,10,"TESTE");
|
if(!lastimage.isNull())
|
||||||
//painter->drawImage(0,0,lastimage);
|
|
||||||
if(!ToImage && !lastimage.isNull())
|
|
||||||
painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage);
|
painter->drawImage(core->GetrenderOffset().X()-lastimagepoint.X(),core->GetrenderOffset().Y()-lastimagepoint.Y(),lastimage);
|
||||||
|
|
||||||
for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
|
for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
|
||||||
@ -337,6 +336,8 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
|
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
||||||
{
|
{
|
||||||
core::Point ret = core->FromLatLngToLocal(point);
|
core::Point ret = core->FromLatLngToLocal(point);
|
||||||
@ -409,8 +410,8 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
void MapGraphicItem::SetZoomStep(int const& value)
|
void MapGraphicItem::SetZoomStep(int const& value)
|
||||||
{
|
{
|
||||||
if(value-core->Zoom()==1 && value<= MaxZoom())
|
if(value-core->Zoom()>0 && value<= MaxZoom())
|
||||||
ConstructLastImage();
|
ConstructLastImage(value-core->Zoom());
|
||||||
else
|
else
|
||||||
lastimage=QImage();
|
lastimage=QImage();
|
||||||
if(value > MaxZoom())
|
if(value > MaxZoom())
|
||||||
|
@ -92,9 +92,10 @@ namespace mapcontrol
|
|||||||
bool IsDragging()const{return core->IsDragging();}
|
bool IsDragging()const{return core->IsDragging();}
|
||||||
|
|
||||||
QImage lastimage;
|
QImage lastimage;
|
||||||
|
// QPainter* imagePainter;
|
||||||
core::Point lastimagepoint;
|
core::Point lastimagepoint;
|
||||||
void paintImage(QPainter* painter);
|
void paintImage(QPainter* painter);
|
||||||
void ConstructLastImage();
|
void ConstructLastImage(int const& zoomdiff);
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
@ -123,8 +124,7 @@ namespace mapcontrol
|
|||||||
Configuration *config;
|
Configuration *config;
|
||||||
bool showTileGridLines;
|
bool showTileGridLines;
|
||||||
qreal MapRenderTransform;
|
qreal MapRenderTransform;
|
||||||
void DrawMap2D(QPainter *painter,bool ToImage);
|
void DrawMap2D(QPainter *painter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Maximum possible zoom
|
* @brief Maximum possible zoom
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,9 @@ HEADERS += mapgraphicitem.h \
|
|||||||
opmapwidget.h \
|
opmapwidget.h \
|
||||||
configuration.h \
|
configuration.h \
|
||||||
waypointitem.h \
|
waypointitem.h \
|
||||||
uavitem.h
|
uavitem.h \
|
||||||
|
uavmapfollowtype.h \
|
||||||
|
uavtrailtype.h
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += network
|
QT += network
|
||||||
QT += sql
|
QT += sql
|
||||||
|
@ -304,7 +304,7 @@ namespace mapcontrol
|
|||||||
|
|
||||||
void SetShowCompass(bool const& value);
|
void SetShowCompass(bool const& value);
|
||||||
|
|
||||||
QImage X(){map->ConstructLastImage(); return map->lastimage;}
|
QImage X(){return map->lastimage;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
internals::Core *core;
|
internals::Core *core;
|
||||||
|
@ -33,13 +33,16 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "../internals/pointlatlng.h"
|
#include "../internals/pointlatlng.h"
|
||||||
#include "mapgraphicitem.h"
|
#include "mapgraphicitem.h"
|
||||||
|
#include "waypointitem.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "uavmapfollowtype.h"
|
||||||
|
#include "uavtrailtype.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @brief A QGraphicsItem representing a WayPoint
|
* @brief A QGraphicsItem representing the UAV
|
||||||
*
|
*
|
||||||
* @class WayPointItem waypointitem.h "waypointitem.h"
|
* @class UAVItem uavitem.h "mapwidget/uavitem.h"
|
||||||
*/
|
*/
|
||||||
class UAVItem:public QObject,public QGraphicsItem
|
class UAVItem:public QObject,public QGraphicsItem
|
||||||
{
|
{
|
||||||
@ -48,9 +51,14 @@ class UAVItem:public QObject,public QGraphicsItem
|
|||||||
public:
|
public:
|
||||||
enum { Type = UserType + 2 };
|
enum { Type = UserType + 2 };
|
||||||
|
|
||||||
|
private:
|
||||||
|
int trailtime;
|
||||||
|
int traildistance;
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
|
||||||
|
void UAVLeftSafetyBouble(internals::PointLatLng const& position);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // UAVITEM_H
|
#endif // UAVITEM_H
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file uavmapfollowtype.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief An enum representing the various map follow modes
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UAVMAPFOLLOWTYPE_H
|
||||||
|
#define UAVMAPFOLLOWTYPE_H
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMetaObject>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QStringList>
|
||||||
|
namespace mapcontrol {
|
||||||
|
class UAVMapFollowType:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(Types)
|
||||||
|
public:
|
||||||
|
enum Types
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// only centers the map on the UAV
|
||||||
|
/// </summary>
|
||||||
|
CenterMap,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// centers and rotates map on the UAV
|
||||||
|
/// </summary>
|
||||||
|
CenterAndRotateMap,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// map is not connected to UAV position or heading
|
||||||
|
/// </summary>
|
||||||
|
None
|
||||||
|
};
|
||||||
|
static QString StrByType(Types const& value)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = UAVMapFollowType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
QString s=metaEnum.valueToKey(value);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
static Types TypeByStr(QString const& value)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = UAVMapFollowType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
static QStringList TypesList()
|
||||||
|
{
|
||||||
|
QStringList ret;
|
||||||
|
QMetaObject metaObject = UAVMapFollowType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
for(int x=0;x<metaEnum.keyCount();++x)
|
||||||
|
{
|
||||||
|
ret.append(metaEnum.key(x));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UAVMAPFOLLOWTYPE_H
|
91
ground/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h
Normal file
91
ground/src/libs/opmapcontrol/src/mapwidget/uavtrailtype.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file uavtrailtype.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief An enum representing the uav trailing modes
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UAVTRAILTYPE_H
|
||||||
|
#define UAVTRAILTYPE_H
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMetaObject>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include <QStringList>
|
||||||
|
namespace mapcontrol {
|
||||||
|
class UAVTrailType:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(Types)
|
||||||
|
public:
|
||||||
|
enum Types
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief UAV does not plot a trail
|
||||||
|
*
|
||||||
|
* @var NoTrail
|
||||||
|
*/
|
||||||
|
NoTrail,
|
||||||
|
/**
|
||||||
|
* @brief UAV plots a trail point every 'x' seconds
|
||||||
|
*
|
||||||
|
* @var ByTimeElapsed
|
||||||
|
*/
|
||||||
|
ByTimeElapsed,
|
||||||
|
/**
|
||||||
|
* @brief UAV plots a trail point every 'x' meters (ground distance)
|
||||||
|
*
|
||||||
|
* @var ByDistance
|
||||||
|
*/
|
||||||
|
ByDistance
|
||||||
|
};
|
||||||
|
static QString StrByType(Types const& value)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = UAVTrailType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
QString s=metaEnum.valueToKey(value);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
static Types TypeByStr(QString const& value)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = UAVTrailType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
static QStringList TypesList()
|
||||||
|
{
|
||||||
|
QStringList ret;
|
||||||
|
QMetaObject metaObject = UAVTrailType().staticMetaObject;
|
||||||
|
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||||
|
for(int x=0;x<metaEnum.keyCount();++x)
|
||||||
|
{
|
||||||
|
ret.append(metaEnum.key(x));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UAVTRAILTYPE_H
|
Loading…
x
Reference in New Issue
Block a user