1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-572 Handle HomeLocation.Set flag and update Home picture according to status

This commit is contained in:
Laurent Lalanne 2018-01-04 02:44:05 +01:00
parent fd92c900a8
commit b2b6e58b68
11 changed files with 210 additions and 7 deletions

View File

@ -98,6 +98,12 @@ void HomeItem::RefreshPos()
toggleRefresh = false;
}
void HomeItem::SetHomePic(QString HomePic)
{
pic.load(":/markers/images/" + HomePic);
pic = pic.scaled(30, 30, Qt::IgnoreAspectRatio);
}
void HomeItem::setOpacitySlot(qreal opacity)
{
setOpacity(opacity);

View File

@ -102,6 +102,7 @@ protected:
QPainterPath shape() const;
public slots:
void RefreshPos();
void SetHomePic(QString HomePic);
void setOpacitySlot(qreal opacity);
signals:
void homePositionChanged(internals::PointLatLng coord, float);

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="463.89285"
height="438.87704"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="dynaHouse.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4098083"
inkscape:cx="231.94643"
inkscape:cy="219.43852"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1006"
inkscape:window-height="954"
inkscape:window-x="660"
inkscape:window-y="43" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-42.339286,-276.34171)">
<path
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 437.14509,499.4375 L 437.14509,499.4375 z M 437.14509,499.4375 L 274.33259,355.25 L 111.42634,499.5 L 111.42634,705.625 C 111.42634,710.94838 115.72796,715.21875 121.05134,715.21875 L 222.86384,715.21875 L 222.86384,624.84375 C 222.86384,619.52035 227.13421,615.21875 232.45759,615.21875 L 316.11384,615.21875 C 321.43719,615.21875 325.70759,619.52037 325.70759,624.84375 L 325.70759,715.21875 L 427.55134,715.21875 C 432.87471,715.21875 437.14511,710.9484 437.14509,705.625 L 437.14509,499.4375 z M 111.42634,499.5 L 111.42634,499.5 z"
id="rect2391"
sodipodi:nodetypes="cccccccccccccccccc" />
<path
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 273.3878,276.34171 L 42.339286,480.92527 L 66.677596,508.38266 L 274.33298,324.49848 L 481.9411,508.38266 L 506.23215,480.92527 L 275.2309,276.34171 L 274.33298,277.3814 L 273.3878,276.34171 z"
id="path2399" />
<path
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-opacity:1"
d="M 111.42634,305.79074 L 169.99777,305.79074 L 169.48739,340.48183 L 111.42634,392.9336 L 111.42634,305.79074 z"
id="rect2404"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="463.89285"
height="438.87704"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
version="1.0"
sodipodi:docname="home2_set.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.2804681"
inkscape:cx="231.94643"
inkscape:cy="219.43852"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:snap-bbox="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-42.339286,-276.34171)">
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#00ff00;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.86600006;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect3345"
width="129.64009"
height="110.11597"
x="209.46567"
y="605.10278" />
<path
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 437.14509,499.4375 L 437.14509,499.4375 z M 437.14509,499.4375 L 274.33259,355.25 L 111.42634,499.5 L 111.42634,705.625 C 111.42634,710.94838 115.72796,715.21875 121.05134,715.21875 L 222.86384,715.21875 L 222.86384,624.84375 C 222.86384,619.52035 227.13421,615.21875 232.45759,615.21875 L 316.11384,615.21875 C 321.43719,615.21875 325.70759,619.52037 325.70759,624.84375 L 325.70759,715.21875 L 427.55134,715.21875 C 432.87471,715.21875 437.14511,710.9484 437.14509,705.625 L 437.14509,499.4375 z M 111.42634,499.5 L 111.42634,499.5 z"
id="rect2391"
sodipodi:nodetypes="cccccccccccccccccc" />
<path
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 273.3878,276.34171 L 42.339286,480.92527 L 66.677596,508.38266 L 274.33298,324.49848 L 481.9411,508.38266 L 506.23215,480.92527 L 275.2309,276.34171 L 274.33298,277.3814 L 273.3878,276.34171 z"
id="path2399" />
<path
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.40000001;stroke-miterlimit:4;stroke-opacity:1"
d="M 111.42634,305.79074 L 169.99777,305.79074 L 169.48739,340.48183 L 111.42634,392.9336 L 111.42634,305.79074 z"
id="rect2404"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -6,6 +6,8 @@
<file>images/wp_marker_red.png</file>
<file>images/compas.svg</file>
<file>images/home2.svg</file>
<file>images/home2_not_set.svg</file>
<file>images/home2_set.svg</file>
<file>images/nav.svg</file>
<file>images/home.png</file>
<file>images/home.svg</file>

View File

@ -107,6 +107,12 @@ void OPMapWidget::SetUavPic(QString UAVPic)
GPS->SetUavPic(UAVPic);
}
}
void OPMapWidget::SetHomePic(QString HomePic)
{
if (Home != 0) {
Home->SetHomePic(HomePic);
}
}
WayPointLine *OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed, int width)
{

View File

@ -521,6 +521,7 @@ public:
}
void SetShowDiagnostics(bool const & value);
void SetUavPic(QString UAVPic);
void SetHomePic(QString HomePic);
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
WayPointLine *WPLineCreate(HomeItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed = false, int width = -1);

View File

@ -936,6 +936,16 @@ void OPMapGadgetWidget::homePositionUpdated(UAVObject *hp)
if (obum->getHomeLocation(set, LLA) < 0) {
return; // error
}
QString HomePic;
if (set) {
HomePic = "home2_set.svg";
} else {
HomePic = "home2_not_set.svg";
}
SetHomePic(HomePic);
setHome(internals::PointLatLng(LLA[0], LLA[1]), LLA[2]);
}
@ -2412,7 +2422,7 @@ bool OPMapGadgetWidget::setHomeLocationObject()
}
double LLA[3] = { m_home_position.coord.Lat(), m_home_position.coord.Lng(), m_home_position.altitude };
return obum->setHomeLocation(LLA, true) >= 0;
return obum->setHomeLocation(LLA, m_telemetry_connected) >= 0;
}
// *************************************************************************************
@ -2422,6 +2432,11 @@ void OPMapGadgetWidget::SetUavPic(QString UAVPic)
m_map->SetUavPic(UAVPic);
}
void OPMapGadgetWidget::SetHomePic(QString HomePic)
{
m_map->SetHomePic(HomePic);
}
void OPMapGadgetWidget::on_tbFind_clicked()
{
QPalette pal = m_widget->leFind->palette();

View File

@ -111,6 +111,7 @@ public:
void setCacheLocation(QString cacheLocation);
void setMapMode(opMapModeType mode);
void SetUavPic(QString UAVPic);
void SetHomePic(QString HomePic);
void setMaxUpdateRate(int update_rate);
void setHomePosition(QPointF pos);
void setOverlayOpacity(qreal value);

View File

@ -321,7 +321,7 @@ QString UAVObjectUtilManager::getBoardDescriptionString()
// ******************************
// HomeLocation
int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard)
int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool set)
{
double Be[3];
@ -341,13 +341,11 @@ int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard)
homeLocationData.Be[1] = Be[1];
homeLocationData.Be[2] = Be[2];
homeLocationData.Set = HomeLocation::SET_TRUE;
homeLocationData.Set = set;
homeLocation->setData(homeLocationData);
if (save_to_sdcard) {
saveObjectToSD(homeLocation);
}
saveObjectToSD(homeLocation);
return 0;
}

View File

@ -53,7 +53,7 @@ public:
UAVObjectUtilManager();
~UAVObjectUtilManager();
int setHomeLocation(double LLA[3], bool save_to_sdcard);
int setHomeLocation(double LLA[3], bool set);
int getHomeLocation(bool &set, double LLA[3]);
int getGPSPositionSensor(double LLA[3]);