Commit cbdc5cd4 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5041 from HorusAeronaves/windrose

Add wind rose in survey pattern editor
parents 5a77a96e 5a4ee779
......@@ -193,6 +193,10 @@
<file alias="takeoff.svg">resources/takeoff.svg</file>
<file alias="TrashDelete.svg">resources/TrashDelete.svg</file>
<file alias="waves.svg">resources/waves.svg</file>
<file alias="wind-guru.svg">resources/wind-guru.svg</file>
<file alias="wind-rose.svg">resources/wind-rose.svg</file>
<file alias="wind-roseBlack.svg">resources/wind-roseBlack.svg</file>
<file alias="wind-rose-arrow.svg">resources/wind-rose-arrow.svg</file>
<file alias="XDelete.svg">resources/XDelete.svg</file>
<file alias="XDeleteBlack.svg">resources/XDeleteBlack.svg</file>
<file>resources/icons/qgroundcontrol.ico</file>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"
id="svg8"
version="1.1"
viewBox="0 0 158.43947 67.648445"
height="67.648445mm"
width="158.43947mm">
<defs
id="defs2" />
<metadata
id="metadata5">
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0.09652586,0.15508566)"
id="layer1">
<path
id="path78"
d="m 114.84811,67.251388 c -2.71248,-0.83619 -4.7544,-3.60494 -4.7544,-6.446773 0,-1.769748 0.26045,-2.635012 1.20768,-4.012261 0.35692,-0.518945 4.92663,-4.448008 10.15491,-8.73125 l 9.50596,-7.787716 -62.755621,-0.132292 C 0.94854643,39.999314 4.8180651,40.082501 2.8051761,38.735071 1.2320842,37.682042 0.40019498,36.327625 0.00135558,34.170104 -0.50386682,31.437103 0.98609883,28.478453 3.5612081,27.101241 l 1.096051,-0.586187 63.4525079,-0.132292 63.452503,-0.132291 -10.0799,-7.246909 c -5.54395,-3.985799 -10.41707,-7.676737 -10.82916,-8.202083 -1.58663,-2.0226625 -1.87744,-4.9054775 -0.7312,-7.2483085 1.16241,-2.375873 3.23639,-3.66360901 5.96827,-3.70570501 1.47984,-0.0228 1.98655,0.09743 3.20605,0.76074404 1.35951,0.73946297 35.98582,25.51456047 37.19864,26.61559147 0.30835,0.279927 0.89141,1.116696 1.29568,1.859484 1.39722,2.567144 0.7956,6.166766 -1.36862,8.188783 -2.59621,2.425621 -35.60909,29.1965 -36.47102,29.57516 -1.54372,0.67819 -3.49279,0.83885 -4.9029,0.40416 z"
style="fill:#000000;stroke-width:0.26458332" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: IcoMoon.io -->
<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="352"
height="512"
viewBox="0 0 352 512"
version="1.1"
id="svg3740"
sodipodi:docname="wind-rose-arrow.svg"
style="fill:#000000"
inkscape:version="0.92.1 r">
<metadata
id="metadata3746">
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3744" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="722"
id="namedview3742"
showgrid="false"
inkscape:pagecheckerboard="true"
inkscape:zoom="0.65186406"
inkscape:cx="-149.4937"
inkscape:cy="264.4641"
inkscape:window-x="1366"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg3740" />
<g
id="g3758">
<path
inkscape:connector-curvature="0"
id="path3738"
d="M 0,416 96,512 352,256 96,0 0,96 160,256 Z" />
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Extras 1.4
import QtQuick.Layouts 1.2
import QGroundControl 1.0
......@@ -398,10 +400,40 @@ Rectangle {
columns: 2
visible: gridHeader.checked
QGCLabel { text: qsTr("Angle") }
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: _margin
rowSpacing: _margin
columns: 3
visible: gridHeader.checked
QGCLabel {
id: angleText
text: qsTr("Angle")
}
Item { Layout.fillWidth: true }
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
ToolButton {
id: windRoseButton
anchors.verticalCenter: angleText.verticalCenter
iconSource: qgcPal.globalTheme === QGCPalette.Light ? "/res/wind-roseBlack.svg" : "/res/wind-rose.svg"
visible: _activeVehicle ? _activeVehicle.fixedWing : true
onClicked: {
var cords = windRoseButton.mapToItem(_root, 0, 0)
windRosePie.popup(cords.x + windRoseButton.width / 2, cords.y + windRoseButton.height / 2);
}
}
}
FactTextField {
id: gridAngleText
fact: missionItem.gridAngle
Layout.fillWidth: true
Layout.columnSpan: 1
}
QGCLabel { text: qsTr("Turnaround dist") }
......@@ -467,13 +499,49 @@ Rectangle {
spacing: _margin
visible: manualGridHeader.visible && manualGridHeader.checked
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: _margin
rowSpacing: _margin
columns: 4
visible: gridHeader.checked
QGCLabel {
id: manualAngleText
text: qsTr("Angle")
Layout.columnSpan: 1
Layout.fillWidth: true
}
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
ToolButton {
id: manualWindRoseButton
anchors.verticalCenter: manualAngleText.verticalCenter
Layout.columnSpan: 1
iconSource: qgcPal.globalTheme === QGCPalette.Light ? "/res/wind-roseBlack.svg" : "/res/wind-rose.svg"
visible: _activeVehicle ? _activeVehicle.fixedWing : true
onClicked: {
var cords = manualWindRoseButton.mapToItem(_root, 0, 0)
windRosePie.popup(cords.x + manualWindRoseButton.width / 2, cords.y + manualWindRoseButton.height / 2);
}
}
FactTextField {
id: manualGridAngleText
fact: missionItem.gridAngle
Layout.columnSpan: 2
}
}
FactTextFieldGrid {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: ScreenTools.defaultFontPixelWidth
rowSpacing: _margin
factList: [ missionItem.gridAngle, missionItem.gridSpacing, missionItem.gridAltitude, missionItem.turnaroundDist ]
factLabels: [ qsTr("Angle"), qsTr("Spacing"), qsTr("Altitude"), qsTr("Turnaround dist")]
factList: [ missionItem.gridSpacing, missionItem.gridAltitude, missionItem.turnaroundDist ]
factLabels: [ qsTr("Spacing"), qsTr("Altitude"), qsTr("Turnaround dist")]
}
QGCCheckBox {
......@@ -516,4 +584,112 @@ Rectangle {
}
}
}
QGCColoredImage {
id: windRoseArrow
source: "/res/wind-rose-arrow.svg"
visible: windRosePie.visible
width: windRosePie.width / 5
height: width * 1.454
smooth: true
color: qgcPal.colorGrey
transform: Rotation {
origin.x: windRoseArrow.width / 2
origin.y: windRoseArrow.height / 2
axis { x: 0; y: 0; z: 1 } angle: windRosePie.angle
}
x: windRosePie.x + Math.sin(- windRosePie.angle*Math.PI/180 - Math.PI/2)*(windRosePie.width/2 - windRoseArrow.width/2) + windRosePie.width / 2 - windRoseArrow.width / 2
y: windRosePie.y + Math.cos(- windRosePie.angle*Math.PI/180 - Math.PI/2)*(windRosePie.width/2 - windRoseArrow.width/2) + windRosePie.height / 2 - windRoseArrow.height / 2
z: windRosePie.z + 1
}
QGCColoredImage {
id: windGuru
source: "/res/wind-guru.svg"
visible: windRosePie.visible
width: windRosePie.width / 3
height: width * 4.28e-1
smooth: true
color: qgcPal.colorGrey
transform: Rotation {
origin.x: windGuru.width / 2
origin.y: windGuru.height / 2
axis { x: 0; y: 0; z: 1 } angle: windRosePie.angle + 180
}
x: windRosePie.x + Math.sin(- windRosePie.angle*Math.PI/180 - 3*Math.PI/2)*(windRosePie.width/2) + windRosePie.width / 2 - windGuru.width / 2
y: windRosePie.y + Math.cos(- windRosePie.angle*Math.PI/180 - 3*Math.PI/2)*(windRosePie.height/2) + windRosePie.height / 2 - windGuru.height / 2
z: windRosePie.z + 1
}
Item {
id: windRosePie
height: 2.6*windRoseButton.height
width: 2.6*windRoseButton.width
visible: false
focus: true
property string colorCircle: qgcPal.windowShade
property string colorBackground: qgcPal.colorGrey
property real lineWidth: windRoseButton.width / 3
property real angle: 0
Canvas {
id: windRoseCanvas
anchors.fill: parent
onPaint: {
var ctx = getContext("2d")
var x = width / 2
var y = height / 2
var angleWidth = 0.03 * Math.PI
var start = windRosePie.angle*Math.PI/180 - angleWidth
var end = windRosePie.angle*Math.PI/180 + angleWidth
ctx.reset()
ctx.beginPath();
ctx.arc(x, y, (width / 3) - windRosePie.lineWidth / 2, 0, 2*Math.PI, false)
ctx.lineWidth = windRosePie.lineWidth
ctx.strokeStyle = windRosePie.colorBackground
ctx.stroke()
ctx.beginPath();
ctx.arc(x, y, (width / 3) - windRosePie.lineWidth / 2, start, end, false)
ctx.lineWidth = windRosePie.lineWidth
ctx.strokeStyle = windRosePie.colorCircle
ctx.stroke()
}
}
onFocusChanged: {
visible = focus
}
function popup(x, y) {
if (x !== undefined)
windRosePie.x = x - windRosePie.width / 2;
if (y !== undefined)
windRosePie.y = y - windRosePie.height / 2;
windRosePie.visible = true;
windRosePie.focus = true
}
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
windRosePie.visible = false;
}
onPositionChanged: {
var point = Qt.point(mouseX - parent.width / 2, mouseY - parent.height / 2)
var angle = Math.round(Math.atan2(point.y, point.x) * 180 / Math.PI)
windRoseCanvas.requestPaint()
windRosePie.angle = angle
gridAngleText.text = angle
gridAngleText.editingFinished();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment