mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
GCS/OPMap-Make the overlays opacity user selectable and persistent.
This commit is contained in:
parent
70bdbf49c3
commit
8bc83d49a5
@ -113,6 +113,31 @@ namespace mapcontrol
|
||||
wwww->RefreshPos();
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::setOverlayOpacity(qreal value)
|
||||
{
|
||||
foreach(QGraphicsItem* i,this->childItems())
|
||||
{
|
||||
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||
if(w)
|
||||
w->setOpacity(value);
|
||||
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
|
||||
if(ww)
|
||||
ww->setOpacity(value);
|
||||
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
|
||||
if(www)
|
||||
www->setOpacity(value);
|
||||
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
|
||||
if(wwww)
|
||||
wwww->setOpacity(value);
|
||||
WayPointLine* wwwww=qgraphicsitem_cast<WayPointLine*>(i);
|
||||
if(wwwww)
|
||||
wwwww->setOpacity(value);
|
||||
WayPointCircle* wwwwww=qgraphicsitem_cast<WayPointCircle*>(i);
|
||||
if(wwwwww)
|
||||
wwwwww->setOpacity(value);
|
||||
|
||||
}
|
||||
}
|
||||
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
|
||||
{
|
||||
QImage temp;
|
||||
|
@ -94,7 +94,6 @@ namespace mapcontrol
|
||||
bool IsDragging()const{return core->IsDragging();}
|
||||
|
||||
QImage lastimage;
|
||||
// QPainter* imagePainter;
|
||||
core::Point lastimagepoint;
|
||||
void paintImage(QPainter* painter);
|
||||
void ConstructLastImage(int const& zoomdiff);
|
||||
@ -102,7 +101,7 @@ namespace mapcontrol
|
||||
double Zoom();
|
||||
double ZoomDigi();
|
||||
double ZoomTotal();
|
||||
|
||||
void setOverlayOpacity(qreal value);
|
||||
protected:
|
||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||
|
@ -59,6 +59,7 @@ namespace mapcontrol
|
||||
SetShowDiagnostics(showDiag);
|
||||
this->setMouseTracking(followmouse);
|
||||
SetShowCompass(true);
|
||||
overlayOpacity=1;
|
||||
|
||||
}
|
||||
void OPMapWidget::SetShowDiagnostics(bool const& value)
|
||||
@ -92,6 +93,7 @@ namespace mapcontrol
|
||||
{
|
||||
GPS=new GPSItem(map,this);
|
||||
GPS->setParentItem(map);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,26 +110,34 @@ namespace mapcontrol
|
||||
{
|
||||
if(!from|!to)
|
||||
return NULL;
|
||||
return new WayPointLine(from,to,map,color);
|
||||
WayPointLine* ret= new WayPointLine(from,to,map,color);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
WayPointLine * OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to,QColor color)
|
||||
{
|
||||
if(!from|!to)
|
||||
return NULL;
|
||||
return new WayPointLine(from,to,map,color);
|
||||
WayPointLine* ret= new WayPointLine(from,to,map,color);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
WayPointCircle * OPMapWidget::WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise,QColor color)
|
||||
{
|
||||
if(!center|!radius)
|
||||
return NULL;
|
||||
return new WayPointCircle(center,radius,clockwise,map,color);
|
||||
WayPointCircle* ret= new WayPointCircle(center,radius,clockwise,map,color);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise,QColor color)
|
||||
{
|
||||
if(!center|!radius)
|
||||
return NULL;
|
||||
return new WayPointCircle(center,radius,clockwise,map,color);
|
||||
WayPointCircle* ret= new WayPointCircle(center,radius,clockwise,map,color);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
void OPMapWidget::SetShowUAV(const bool &value)
|
||||
{
|
||||
@ -137,6 +147,7 @@ namespace mapcontrol
|
||||
UAV->setParentItem(map);
|
||||
connect(this,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)),UAV,SIGNAL(UAVLeftSafetyBouble(internals::PointLatLng)));
|
||||
connect(this,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)),UAV,SIGNAL(UAVReachedWayPoint(int,WayPointItem*)));
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
}
|
||||
else if(!value)
|
||||
{
|
||||
@ -234,6 +245,7 @@ namespace mapcontrol
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude)
|
||||
{
|
||||
@ -242,6 +254,7 @@ namespace mapcontrol
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description)
|
||||
@ -251,6 +264,7 @@ namespace mapcontrol
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, const QString &description)
|
||||
@ -260,6 +274,7 @@ namespace mapcontrol
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
emit WPCreated(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(const int &position)
|
||||
@ -269,6 +284,7 @@ namespace mapcontrol
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
emit WPInserted(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
void OPMapWidget::WPInsert(WayPointItem* item,const int &position)
|
||||
@ -277,7 +293,7 @@ namespace mapcontrol
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
emit WPInserted(position,item);
|
||||
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude,const int &position)
|
||||
{
|
||||
@ -286,6 +302,7 @@ namespace mapcontrol
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
emit WPInserted(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,const int &position)
|
||||
@ -306,6 +323,7 @@ namespace mapcontrol
|
||||
emit WPInserted(position,item);
|
||||
if(reloc)
|
||||
emit WPValuesChanged(item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(distBearingAltitude const& relative, QString const& description,const int &position)
|
||||
@ -315,6 +333,7 @@ namespace mapcontrol
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
emit WPInserted(position,item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
}
|
||||
void OPMapWidget::WPDelete(WayPointItem *item)
|
||||
@ -481,6 +500,12 @@ namespace mapcontrol
|
||||
compass=0;
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapWidget::setOverlayOpacity(qreal value)
|
||||
{
|
||||
map->setOverlayOpacity(value);
|
||||
overlayOpacity=value;
|
||||
}
|
||||
void OPMapWidget::SetRotate(qreal const& value)
|
||||
{
|
||||
map->mapRotate(value);
|
||||
|
@ -353,6 +353,8 @@ namespace mapcontrol
|
||||
|
||||
void SetShowCompass(bool const& value);
|
||||
|
||||
void setOverlayOpacity(qreal value);
|
||||
|
||||
UAVItem* UAV;
|
||||
GPSItem* GPS;
|
||||
HomeItem* Home;
|
||||
@ -390,6 +392,7 @@ namespace mapcontrol
|
||||
QTimer * diagTimer;
|
||||
QGraphicsTextItem * diagGraphItem;
|
||||
bool showDiag;
|
||||
qreal overlayOpacity;
|
||||
private slots:
|
||||
void diagRefresh();
|
||||
// WayPointItem* item;//apagar
|
||||
|
@ -31,14 +31,15 @@ OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *pa
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget),m_config(NULL)
|
||||
{
|
||||
connect(m_widget,SIGNAL(defaultLocationAndZoomChanged(double,double,double)),this,SLOT(saveConfiguration(double,double,double)));
|
||||
connect(m_widget,SIGNAL(defaultLocationAndZoomChanged(double,double,double)),this,SLOT(saveDefaultLocation(double,double,double)));
|
||||
connect(m_widget,SIGNAL(overlayOpacityChanged(qreal)),this,SLOT(saveOpacity(qreal)));
|
||||
}
|
||||
|
||||
OPMapGadget::~OPMapGadget()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
void OPMapGadget::saveConfiguration(double lng,double lat,double zoom)
|
||||
void OPMapGadget::saveDefaultLocation(double lng,double lat,double zoom)
|
||||
{
|
||||
if(m_config)
|
||||
{
|
||||
@ -49,6 +50,13 @@ void OPMapGadget::saveConfiguration(double lng,double lat,double zoom)
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapGadget::saveOpacity(qreal value)
|
||||
{
|
||||
if(m_config)
|
||||
{
|
||||
m_config->setOpacity(value);
|
||||
}
|
||||
}
|
||||
void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
m_config = qobject_cast<OPMapGadgetConfiguration*>(config);
|
||||
@ -62,6 +70,6 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
m_widget->setZoom(m_config->zoom());
|
||||
m_widget->setPosition(QPointF(m_config->longitude(), m_config->latitude()));
|
||||
m_widget->setHomePosition(QPointF(m_config->longitude(), m_config->latitude()));
|
||||
|
||||
m_widget->setOverlayOpacity(m_config->opacity());
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,8 @@ private:
|
||||
OPMapGadgetWidget *m_widget;
|
||||
OPMapGadgetConfiguration *m_config;
|
||||
private slots:
|
||||
void saveConfiguration(double lng, double lat, double zoom);
|
||||
void saveOpacity(qreal value);
|
||||
void saveDefaultLocation(double lng, double lat, double zoom);
|
||||
};
|
||||
|
||||
|
||||
|
@ -42,7 +42,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings*
|
||||
m_cacheLocation(Utils::PathUtils().GetStoragePath() + "mapscache" + QDir::separator()),
|
||||
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png")),
|
||||
m_maxUpdateRate(2000), // ms
|
||||
m_settings(qSettings)
|
||||
m_settings(qSettings),
|
||||
m_opacity(1)
|
||||
{
|
||||
|
||||
//if a saved configuration exists load it
|
||||
@ -60,6 +61,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings*
|
||||
QString uavSymbol=qSettings->value("uavSymbol").toString();
|
||||
int max_update_rate = qSettings->value("maxUpdateRate").toInt();
|
||||
|
||||
m_opacity=qSettings->value("overlayOpacity",1).toReal();
|
||||
|
||||
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
||||
m_defaultZoom = zoom;
|
||||
m_defaultLatitude = latitude;
|
||||
@ -95,6 +98,7 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
||||
m->m_cacheLocation = m_cacheLocation;
|
||||
m->m_uavSymbol = m_uavSymbol;
|
||||
m->m_maxUpdateRate = m_maxUpdateRate;
|
||||
m->m_opacity=m_opacity;
|
||||
|
||||
return m;
|
||||
}
|
||||
@ -112,6 +116,7 @@ void OPMapGadgetConfiguration::saveConfig() const {
|
||||
m_settings->setValue("uavSymbol", m_uavSymbol);
|
||||
m_settings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation));
|
||||
m_settings->setValue("maxUpdateRate", m_maxUpdateRate);
|
||||
m_settings->setValue("overlayOpacity",m_opacity);
|
||||
}
|
||||
void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("mapProvider", m_mapProvider);
|
||||
@ -125,6 +130,7 @@ void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("uavSymbol", m_uavSymbol);
|
||||
qSettings->setValue("cacheLocation", Utils::PathUtils().RemoveStoragePath(m_cacheLocation));
|
||||
qSettings->setValue("maxUpdateRate", m_maxUpdateRate);
|
||||
qSettings->setValue("overlayOpacity",m_opacity);
|
||||
}
|
||||
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation){
|
||||
m_cacheLocation = cacheLocation;
|
||||
|
@ -48,6 +48,7 @@ Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
|
||||
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
|
||||
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
|
||||
Q_PROPERTY(int maxUpdateRate READ maxUpdateRate WRITE setMaxUpdateRate)
|
||||
Q_PROPERTY(qreal overlayOpacity READ opacity WRITE setOpacity)
|
||||
|
||||
public:
|
||||
explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
@ -66,11 +67,13 @@ public:
|
||||
QString cacheLocation() const { return m_cacheLocation; }
|
||||
QString uavSymbol() const { return m_uavSymbol; }
|
||||
int maxUpdateRate() const { return m_maxUpdateRate; }
|
||||
qreal opacity() const { return m_opacity; }
|
||||
void saveConfig() const;
|
||||
public slots:
|
||||
void setMapProvider(QString provider) { m_mapProvider = provider; }
|
||||
void setZoom(int zoom) { m_defaultZoom = zoom; }
|
||||
void setLatitude(double latitude) { m_defaultLatitude = latitude; }
|
||||
void setOpacity(qreal value) { m_opacity = value; }
|
||||
void setLongitude(double longitude) { m_defaultLongitude = longitude; }
|
||||
void setUseOpenGL(bool useOpenGL) { m_useOpenGL = useOpenGL; }
|
||||
void setShowTileGridLines(bool showTileGridLines) { m_showTileGridLines = showTileGridLines; }
|
||||
@ -93,6 +96,7 @@ private:
|
||||
QString m_uavSymbol;
|
||||
int m_maxUpdateRate;
|
||||
QSettings * m_settings;
|
||||
qreal m_opacity;
|
||||
};
|
||||
|
||||
#endif // OPMAP_GADGETCONFIGURATION_H
|
||||
|
@ -220,6 +220,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
magicWayPoint=m_map->magicWPCreate();
|
||||
magicWayPoint->setVisible(false);
|
||||
|
||||
m_map->setOverlayOpacity(0.5);
|
||||
|
||||
// **************
|
||||
// create various context menu (mouse right click menu) actions
|
||||
|
||||
@ -504,6 +506,10 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
// *********
|
||||
|
||||
QMenu overlaySubMenu(tr("&Overlay Opacity "),this);
|
||||
for (int i = 0; i < overlayOpacityAct.count(); i++)
|
||||
overlaySubMenu.addAction(overlayOpacityAct.at(i));
|
||||
contextMenu.addMenu(&overlaySubMenu);
|
||||
contextMenu.addSeparator();
|
||||
|
||||
contextMenu.addAction(closeAct2);
|
||||
@ -676,7 +682,7 @@ void OPMapGadgetWidget::zoomChanged(double zoomt, double zoom, double zoomd)
|
||||
|
||||
int index0_zoom = i_zoom - m_min_zoom; // zoom level starting at index level '0'
|
||||
if (index0_zoom < zoomAct.count())
|
||||
zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level
|
||||
zoomAct.at(index0_zoom)->setChecked(true); // set the right-click context menu zoom level
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::OnCurrentPositionChanged(internals::PointLatLng point)
|
||||
@ -987,6 +993,14 @@ void OPMapGadgetWidget::setZoom(int zoom)
|
||||
|
||||
m_map->SetMouseWheelZoomType(zoom_type);
|
||||
}
|
||||
void OPMapGadgetWidget::setOverlayOpacity(qreal value)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
return;
|
||||
m_map->setOverlayOpacity(value);
|
||||
overlayOpacityAct.at(value*10)->setChecked(true);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::setHomePosition(QPointF pos)
|
||||
{
|
||||
if (!m_widget || !m_map)
|
||||
@ -1302,6 +1316,16 @@ void OPMapGadgetWidget::createActions()
|
||||
clearWayPointsAct->setStatusTip(tr("Clear waypoints"));
|
||||
connect(clearWayPointsAct, SIGNAL(triggered()), this, SLOT(onClearWayPointsAct_triggered()));
|
||||
|
||||
overlayOpacityActGroup = new QActionGroup(this);
|
||||
connect(overlayOpacityActGroup, SIGNAL(triggered(QAction *)), this, SLOT(onOverlayOpacityActGroup_triggered(QAction *)));
|
||||
overlayOpacityAct.clear();
|
||||
for (int i = 0; i <= 10; i++)
|
||||
{
|
||||
QAction *overlayAct = new QAction(QString::number(i*10), overlayOpacityActGroup);
|
||||
overlayAct->setCheckable(true);
|
||||
overlayAct->setData(i*10);
|
||||
overlayOpacityAct.append(overlayAct);
|
||||
}
|
||||
|
||||
homeMagicWaypointAct = new QAction(tr("Home magic waypoint"), this);
|
||||
homeMagicWaypointAct->setStatusTip(tr("Move the magic waypoint to the home position"));
|
||||
@ -2089,3 +2113,12 @@ void OPMapGadgetWidget::onHomeDoubleClick(HomeItem *)
|
||||
{
|
||||
new homeEditor(m_map->Home,this);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::onOverlayOpacityActGroup_triggered(QAction *action)
|
||||
{
|
||||
if (!m_widget || !m_map || !action)
|
||||
return;
|
||||
|
||||
m_map->setOverlayOpacity(action->data().toReal()/100);
|
||||
emit overlayOpacityChanged(action->data().toReal()/100);
|
||||
}
|
||||
|
@ -115,8 +115,10 @@ public:
|
||||
void SetUavPic(QString UAVPic);
|
||||
void setMaxUpdateRate(int update_rate);
|
||||
void setHomePosition(QPointF pos);
|
||||
void setOverlayOpacity(qreal value);
|
||||
signals:
|
||||
void defaultLocationAndZoomChanged(double lng,double lat,double zoom);
|
||||
void overlayOpacityChanged(qreal);
|
||||
|
||||
public slots:
|
||||
void homePositionUpdated(UAVObject *);
|
||||
@ -207,6 +209,7 @@ private slots:
|
||||
void onChangeDefaultLocalAndZoom();
|
||||
void on_tbFind_clicked();
|
||||
void onHomeDoubleClick(HomeItem*);
|
||||
void onOverlayOpacityActGroup_triggered(QAction *action);
|
||||
private:
|
||||
int m_min_zoom;
|
||||
int m_max_zoom;
|
||||
@ -281,7 +284,9 @@ private:
|
||||
QList<QAction *> mapModeAct;
|
||||
|
||||
QActionGroup *zoomActGroup;
|
||||
QActionGroup *overlayOpacityActGroup;
|
||||
QList<QAction *> zoomAct;
|
||||
QList<QAction *> overlayOpacityAct;
|
||||
|
||||
QActionGroup *maxUpdateRateActGroup;
|
||||
QList<QAction *> maxUpdateRateAct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user