mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Added context menu for switching UAV text output off.
This commit is contained in:
parent
e26e996734
commit
3e4f2e21ce
@ -32,7 +32,7 @@ const qreal Pi = 3.14;
|
||||
namespace mapcontrol
|
||||
{
|
||||
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true)
|
||||
,autosetdistance(100),altitude(0)
|
||||
,autosetdistance(100),altitude(0),showUAVInfo(false)
|
||||
{
|
||||
pic.load(uavPic);
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||
@ -60,6 +60,13 @@ namespace mapcontrol
|
||||
Q_UNUSED(widget);
|
||||
|
||||
|
||||
//Draw plane
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
|
||||
//Return if context menu switch for UAV info is off
|
||||
if(!showUAVInfo)
|
||||
return;
|
||||
|
||||
QPen myPen;
|
||||
|
||||
//Turn on anti-aliasing so the fonts don't look terrible
|
||||
@ -136,30 +143,28 @@ namespace mapcontrol
|
||||
painter->drawArc(rect, 0*16, -spanAngle*16);
|
||||
}
|
||||
|
||||
//HUH? What does this do?
|
||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||
|
||||
|
||||
//*********** Create time rings
|
||||
myPen.setWidth(2);
|
||||
double ringTime=0;
|
||||
if(groundspeed_mps > 0){ //Don't clutter the display with rings that are only one pixel wide
|
||||
myPen.setWidth(2);
|
||||
|
||||
double alpha= .1;
|
||||
groundspeed_mps_filt= (1-alpha)*groundspeed_mps_filt + alpha*groundspeed_mps;
|
||||
double alpha= .1;
|
||||
groundspeed_mps_filt= (1-alpha)*groundspeed_mps_filt + alpha*groundspeed_mps;
|
||||
|
||||
double ringTime=10*pow(2,17-map->ZoomTotal());
|
||||
ringTime=10*pow(2,17-map->ZoomTotal());
|
||||
|
||||
myPen.setColor(QColor(0, 0, 0, 100));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*1*meters2pixels,groundspeed_mps_filt*ringTime*1*meters2pixels);
|
||||
myPen.setColor(QColor(0, 0, 0, 100));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*1*meters2pixels,groundspeed_mps_filt*ringTime*1*meters2pixels);
|
||||
|
||||
myPen.setColor(QColor(0, 0, 0, 110));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*2*meters2pixels,groundspeed_mps_filt*ringTime*2*meters2pixels);
|
||||
|
||||
myPen.setColor(QColor(0, 0, 0, 120));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*4*meters2pixels,groundspeed_mps_filt*ringTime*4*meters2pixels);
|
||||
myPen.setColor(QColor(0, 0, 0, 110));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*2*meters2pixels,groundspeed_mps_filt*ringTime*2*meters2pixels);
|
||||
|
||||
myPen.setColor(QColor(0, 0, 0, 120));
|
||||
painter->setPen(myPen);
|
||||
painter->drawEllipse(QPointF(0,0),groundspeed_mps_filt*ringTime*4*meters2pixels,groundspeed_mps_filt*ringTime*4*meters2pixels);
|
||||
}
|
||||
|
||||
//***** Text info overlay. The font is a "glow" font, so that it's easier to use on the map
|
||||
|
||||
@ -196,19 +201,22 @@ namespace mapcontrol
|
||||
path.addText(textAnchorX, textAnchorY+16*3, borderfont, uavoInfoStrLine4);
|
||||
path.addText(textAnchorX, textAnchorY+16*4, borderfont, uavoInfoStrLine5);
|
||||
|
||||
//Add text for time rings. Always add the left side...
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*1*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*2*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*4*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||
//... and add the right side, only if it doesn't interfere with the uav info text
|
||||
if(groundspeed_mps_filt*ringTime*4*meters2pixels > 200){
|
||||
if(groundspeed_mps_filt*ringTime*2*meters2pixels > 200){
|
||||
if(groundspeed_mps_filt*ringTime*1*meters2pixels > 200){
|
||||
path.addText(groundspeed_mps_filt*ringTime*1*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||
//Add text for time rings.
|
||||
if(groundspeed_mps > 0){
|
||||
//Always add the left side...
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*1*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*2*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||
path.addText(-(groundspeed_mps_filt*ringTime*4*meters2pixels+10), 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||
//... and add the right side, only if it doesn't interfere with the uav info text
|
||||
if(groundspeed_mps_filt*ringTime*4*meters2pixels > 200){
|
||||
if(groundspeed_mps_filt*ringTime*2*meters2pixels > 200){
|
||||
if(groundspeed_mps_filt*ringTime*1*meters2pixels > 200){
|
||||
path.addText(groundspeed_mps_filt*ringTime*1*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime,0,'f',0));
|
||||
}
|
||||
path.addText(groundspeed_mps_filt*ringTime*2*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||
}
|
||||
path.addText(groundspeed_mps_filt*ringTime*2*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*2,0,'f',0));
|
||||
path.addText(groundspeed_mps_filt*ringTime*4*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||
}
|
||||
path.addText(groundspeed_mps_filt*ringTime*4*meters2pixels-8, 0, borderfont, QString("%1 s").arg(ringTime*4,0,'f',0));
|
||||
}
|
||||
|
||||
//Now draw the text. First pass is the outline...
|
||||
@ -414,4 +422,10 @@ namespace mapcontrol
|
||||
{
|
||||
pic.load(":/uavs/images/"+UAVPic);
|
||||
}
|
||||
|
||||
void UAVItem::SetShowUAVInfo(bool const& value)
|
||||
{
|
||||
showUAVInfo=value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,6 +218,8 @@ namespace mapcontrol
|
||||
int type() const;
|
||||
|
||||
void SetUavPic(QString UAVPic);
|
||||
void SetShowUAVInfo(bool const& value);
|
||||
|
||||
private:
|
||||
MapGraphicItem* map;
|
||||
QPolygonF arrowHead;
|
||||
@ -246,6 +248,7 @@ namespace mapcontrol
|
||||
double Distance3D(internals::PointLatLng const& coord, int const& altitude);
|
||||
double autosetdistance;
|
||||
double groundspeed_mps_filt;
|
||||
bool showUAVInfo;
|
||||
// QRectF rect;
|
||||
|
||||
public slots:
|
||||
|
@ -44,8 +44,6 @@
|
||||
#include "utils/homelocationutil.h"
|
||||
#include "utils/worldmagmodel.h"
|
||||
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavobjectmanager.h"
|
||||
@ -56,6 +54,7 @@
|
||||
#include "gyros.h"
|
||||
#include "positionactual.h"
|
||||
#include "velocityactual.h"
|
||||
|
||||
#define allow_manual_home_location_move
|
||||
|
||||
// *************************************************************************************
|
||||
@ -119,7 +118,6 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
obum = pm->getObject<UAVObjectUtilManager>();
|
||||
}
|
||||
|
||||
|
||||
// **************
|
||||
// get current location
|
||||
|
||||
@ -214,10 +212,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
|
||||
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||
|
||||
|
||||
|
||||
if(m_map->GPS)
|
||||
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the GPS position
|
||||
|
||||
model=new flightDataModel(this);
|
||||
table=new pathPlanner();
|
||||
@ -427,6 +423,8 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
contextMenu.addAction(showDiagnostics);
|
||||
|
||||
contextMenu.addAction(showUAVInfo);
|
||||
|
||||
contextMenu.addSeparator()->setText(tr("Zoom"));
|
||||
|
||||
contextMenu.addAction(zoomInAct);
|
||||
@ -1247,6 +1245,12 @@ void OPMapGadgetWidget::createActions()
|
||||
showDiagnostics->setChecked(false);
|
||||
connect(showDiagnostics, SIGNAL(toggled(bool)), this, SLOT(onShowDiagnostics_toggled(bool)));
|
||||
|
||||
showUAVInfo = new QAction(tr("Show UAV Info"), this);
|
||||
showUAVInfo->setStatusTip(tr("Show/Hide the UAV info"));
|
||||
showUAVInfo->setCheckable(true);
|
||||
showUAVInfo->setChecked(false);
|
||||
connect(showUAVInfo, SIGNAL(toggled(bool)), this, SLOT(onShowUAVInfo_toggled(bool)));
|
||||
|
||||
showHomeAct = new QAction(tr("Show Home"), this);
|
||||
showHomeAct->setStatusTip(tr("Show/Hide the Home location"));
|
||||
showHomeAct->setCheckable(true);
|
||||
@ -1539,12 +1543,20 @@ void OPMapGadgetWidget::onShowCompassAct_toggled(bool show)
|
||||
|
||||
void OPMapGadgetWidget::onShowDiagnostics_toggled(bool show)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
if (!m_widget || !m_map)
|
||||
return;
|
||||
|
||||
m_map->SetShowDiagnostics(show);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onShowUAVInfo_toggled(bool show)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
return;
|
||||
|
||||
m_map->UAV->SetShowUAVInfo(show);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
|
@ -174,6 +174,7 @@ private slots:
|
||||
void onCopyMouseLonToClipAct_triggered();
|
||||
void onShowCompassAct_toggled(bool show);
|
||||
void onShowDiagnostics_toggled(bool show);
|
||||
void onShowUAVInfo_toggled(bool show);
|
||||
void onShowUAVAct_toggled(bool show);
|
||||
void onShowHomeAct_toggled(bool show);
|
||||
void onShowTrailLineAct_toggled(bool show);
|
||||
@ -244,6 +245,7 @@ private:
|
||||
QAction *copyMouseLonToClipAct;
|
||||
QAction *showCompassAct;
|
||||
QAction *showDiagnostics;
|
||||
QAction *showUAVInfo;
|
||||
QAction *showHomeAct;
|
||||
QAction *showUAVAct;
|
||||
QAction *zoomInAct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user