1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

Fixed bounding box size.

Conflicts:

	ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/uavitem.h
This commit is contained in:
Laura Sebesta 2012-08-17 09:46:35 +02:00
parent 62041f40ad
commit 7e55b31ca1
3 changed files with 15 additions and 7 deletions

View File

@ -34,7 +34,7 @@ namespace mapcontrol
double UAVItem::groundspeed_mps_filt = 0; double UAVItem::groundspeed_mps_filt = 0;
UAVItem::UAVItem(MapGraphicItem* map,OPMapWidget* parent,QString uavPic):map(map),mapwidget(parent),showtrail(true),showtrailline(true),trailtime(5),traildistance(50),autosetreached(true) 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),showUAVInfo(false) ,autosetdistance(100),altitude(0),showUAVInfo(false),showJustChanged(false)
{ {
pic.load(uavPic); pic.load(uavPic);
this->setFlag(QGraphicsItem::ItemIsMovable,true); this->setFlag(QGraphicsItem::ItemIsMovable,true);
@ -65,8 +65,10 @@ namespace mapcontrol
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic); painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
//Return if context menu switch for UAV info is off //Return if context menu switch for UAV info is off
if(!showUAVInfo) if(!showUAVInfo){
showJustChanged=false;
return; return;
}
QPen myPen; QPen myPen;
@ -81,9 +83,6 @@ namespace mapcontrol
myPen.setColor(myColor); myPen.setColor(myColor);
painter->setPen(myPen); painter->setPen(myPen);
//Set brush attributes
// painter->setBrush(myColor);
//Create line from (0,0), to (1,1). Later, we'll scale and rotate it //Create line from (0,0), to (1,1). Later, we'll scale and rotate it
QLineF line(0,0,1.0,1.0); QLineF line(0,0,1.0,1.0);
@ -232,11 +231,17 @@ namespace mapcontrol
painter->setPen(myPen); painter->setPen(myPen);
painter->drawPath(path); painter->drawPath(path);
//Last thing to do: set bound rectangle as function of largest object
boundingRectSize=groundspeed_mps_filt*ringTime*4*meters2pixels+10; //Largest object is currently the biggest ring + a little bit of margin for the text
} }
QRectF UAVItem::boundingRect()const QRectF UAVItem::boundingRect()const
{ {
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height()); if(showUAVInfo || showJustChanged)
return QRectF(-boundingRectSize,-boundingRectSize,2*boundingRectSize,2*boundingRectSize);
else
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
} }
void UAVItem::SetNED(double NED[3]){ void UAVItem::SetNED(double NED[3]){
@ -425,6 +430,8 @@ namespace mapcontrol
void UAVItem::SetShowUAVInfo(bool const& value) void UAVItem::SetShowUAVInfo(bool const& value)
{ {
showUAVInfo=value; showUAVInfo=value;
showJustChanged=true;
update();
} }
} }

View File

@ -249,6 +249,8 @@ namespace mapcontrol
double autosetdistance; double autosetdistance;
bool showUAVInfo; bool showUAVInfo;
static double groundspeed_mps_filt; static double groundspeed_mps_filt;
float boundingRectSize;
bool showJustChanged;
public slots: public slots:

View File

@ -1555,7 +1555,6 @@ void OPMapGadgetWidget::onShowUAVInfo_toggled(bool show)
return; return;
m_map->UAV->SetShowUAVInfo(show); m_map->UAV->SetShowUAVInfo(show);
update();
} }
void OPMapGadgetWidget::onShowHomeAct_toggled(bool show) void OPMapGadgetWidget::onShowHomeAct_toggled(bool show)