1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

GCS/MapLib - Switched to a signal slot aproach on several functions which need

to be propagated.
This commit is contained in:
PT_Dreamer 2012-08-18 18:07:39 +01:00
parent c484dcb1db
commit f56b4b8a9b
14 changed files with 69 additions and 63 deletions

View File

@ -45,6 +45,8 @@ namespace mapcontrol
mapfollowtype=UAVMapFollowType::None;
trailtype=UAVTrailType::ByDistance;
timer.start();
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
GPSItem::~GPSItem()
{
@ -139,6 +141,11 @@ namespace mapcontrol
}
}
void GPSItem::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
void GPSItem::SetTrailType(const UAVTrailType::Types &value)
{
trailtype=value;

View File

@ -103,7 +103,6 @@ namespace mapcontrol
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void RefreshPos();
QRectF boundingRect() const;
/**
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
@ -218,7 +217,8 @@ namespace mapcontrol
// QRectF rect;
public slots:
void RefreshPos();
void setOpacitySlot(qreal opacity);
signals:
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
void UAVLeftSafetyBouble(internals::PointLatLng const& position);

View File

@ -40,6 +40,8 @@ namespace mapcontrol
coord=internals::PointLatLng(50,50);
RefreshToolTip();
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
void HomeItem::RefreshToolTip()
@ -92,6 +94,11 @@ namespace mapcontrol
}
void HomeItem::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
void HomeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button()==Qt::LeftButton)

View File

@ -47,7 +47,6 @@ namespace mapcontrol
QWidget *widget);
QRectF boundingRect() const;
int type() const;
void RefreshPos();
bool ShowSafeArea()const{return showsafearea;}
void SetShowSafeArea(bool const& value){showsafearea=value;}
int SafeArea()const{return safearea;}
@ -76,7 +75,8 @@ namespace mapcontrol
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
public slots:
void RefreshPos();
void setOpacitySlot(qreal opacity);
signals:
void homePositionChanged(internals::PointLatLng coord,float);
void homedoubleclick(HomeItem* waypoint);

View File

@ -42,8 +42,8 @@ namespace mapcontrol
this->SetZoom(2);
this->setFlag(ItemIsFocusable);
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
connect(core,SIGNAL(OnMapDrag()),this,SLOT(ChildPosRefresh()));
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(ChildPosRefresh()));
connect(core,SIGNAL(OnMapDrag()),this,SLOT(childPosRefresh()));
connect(core,SIGNAL(OnMapZoomChanged()),this,SLOT(childPosRefresh()));
setCacheMode(QGraphicsItem::ItemCoordinateCache);
//resize();
@ -82,64 +82,15 @@ namespace mapcontrol
void MapGraphicItem::Core_OnNeedInvalidation()
{
this->update();
foreach(QGraphicsItem* i,this->childItems())
{
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
if(w)
w->RefreshPos();
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
if(ww)
ww->RefreshPos();
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
if(www)
www->RefreshPos();
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
if(wwww)
wwww->RefreshPos();
}
emit childRefreshPosition();
}
void MapGraphicItem::ChildPosRefresh()
void MapGraphicItem::childPosRefresh()
{
foreach(QGraphicsItem* i,this->childItems())
{
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
if(w)
w->RefreshPos();
UAVItem* ww=qgraphicsitem_cast<UAVItem*>(i);
if(ww)
ww->RefreshPos();
HomeItem* www=qgraphicsitem_cast<HomeItem*>(i);
if(www)
www->RefreshPos();
GPSItem* wwww=qgraphicsitem_cast<GPSItem*>(i);
if(wwww)
wwww->RefreshPos();
}
emit childRefreshPosition();
}
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);
}
emit childSetOpacity(value);
}
void MapGraphicItem::ConstructLastImage(int const& zoomdiff)
{

View File

@ -200,7 +200,7 @@ namespace mapcontrol
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
private slots:
void Core_OnNeedInvalidation();
void ChildPosRefresh();
void childPosRefresh();
public slots:
/**
* @brief To be called when the scene size changes
@ -216,6 +216,8 @@ namespace mapcontrol
*/
void wpdoubleclicked(WayPointItem * wp);
void zoomChanged(double zoomtotal,double zoomreal,double zoomdigi);
void childRefreshPosition();
void childSetOpacity(qreal value);
};
}
#endif // MAPGRAPHICITEM_H

View File

@ -50,6 +50,9 @@ namespace mapcontrol
mapfollowtype=UAVMapFollowType::None;
trailtype=UAVTrailType::ByDistance;
timer.start();
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
UAVItem::~UAVItem()
{
@ -233,6 +236,7 @@ namespace mapcontrol
//Last thing to do: set bound rectangle as function of largest object
prepareGeometryChange();
boundingRectSize=groundspeed_mps_filt*ringTime*4*meters2pixels+20; //Largest object is currently the biggest ring + a little bit of margin for the text
}
@ -401,6 +405,11 @@ namespace mapcontrol
}
}
void UAVItem::setOpacitySlot(qreal opacity)
{
this->setOpacity(opacity);
}
void UAVItem::SetTrailType(const UAVTrailType::Types &value)
{
trailtype=value;

View File

@ -128,7 +128,6 @@ namespace mapcontrol
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void RefreshPos();
QRectF boundingRect() const;
/**
* @brief Sets the trail time to be used if TrailType is ByTimeElapsed
@ -253,7 +252,8 @@ namespace mapcontrol
bool showJustChanged;
public slots:
void RefreshPos();
void setOpacitySlot(qreal opacity);
signals:
void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
void UAVLeftSafetyBouble(internals::PointLatLng const& position);

View File

@ -38,6 +38,7 @@ WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius,bool c
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
connect(radius,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
refreshLocations();
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
@ -48,6 +49,7 @@ WayPointCircle::WayPointCircle(HomeItem *radius, WayPointItem *center, bool cloc
connect(center,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
refreshLocations();
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
int WayPointCircle::type() const
@ -106,4 +108,9 @@ void WayPointCircle::waypointdeleted()
this->deleteLater();
}
void WayPointCircle::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
}

View File

@ -62,6 +62,7 @@ protected:
public slots:
void refreshLocations();
void waypointdeleted();
void setOpacitySlot(qreal opacity);
};
}

View File

@ -60,6 +60,8 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitu
}
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
emit manualCoordChange(this);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(false),description(""),shownumber(true),isDragging(false),altitude(0),map(map)
@ -105,6 +107,8 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
}
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
emit manualCoordChange(this);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map,wptype type):coord(coord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map),myType(type)
{
@ -136,6 +140,8 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
}
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
emit manualCoordChange(this);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const QString &description, MapGraphicItem *map):relativeCoord(relativeCoordenate),reached(false),description(description),shownumber(true),isDragging(false),map(map)
@ -169,6 +175,8 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
RefreshPos();
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
emit manualCoordChange(this);
connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos()));
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
void WayPointItem::setWPType(wptype type)
@ -455,6 +463,11 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
this->setPos(point.X(),point.Y());
emit localPositionChanged(this->pos(),this);
}
void WayPointItem::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
void WayPointItem::RefreshToolTip()
{
QString type_str;

View File

@ -156,7 +156,6 @@ public:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void RefreshPos();
void RefreshToolTip();
QPixmap picture;
QString customString(){return myCustomString;}
@ -217,6 +216,8 @@ public slots:
void WPInserted(int const& number,WayPointItem* waypoint);
void onHomePositionChanged(internals::PointLatLng,float altitude);
void RefreshPos();
void setOpacitySlot(qreal opacity);
signals:
/**
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)

View File

@ -44,6 +44,7 @@ WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem
this->setZValue(9);
else if(myColor==Qt::red)
this->setZValue(8);
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color):source(from),
@ -59,6 +60,7 @@ WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map
this->setZValue(9);
else if(myColor==Qt::red)
this->setZValue(8);
connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal)));
}
int WayPointLine::type() const
{
@ -112,4 +114,9 @@ void WayPointLine::waypointdeleted()
this->deleteLater();
}
void WayPointLine::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);
}
}

View File

@ -60,6 +60,7 @@ protected:
public slots:
void refreshLocations();
void waypointdeleted();
void setOpacitySlot(qreal opacity);
};
}
#endif // WAYPOINTLINE_H