-
Notifications
You must be signed in to change notification settings - Fork 1
/
VendorTrackPage.qml
383 lines (374 loc) · 13.9 KB
/
VendorTrackPage.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
import QtPositioning 5.2
import QtLocation 5.3
Rectangle {
width: parent? parent.width : 500
height: parent? parent.height : 800
visible: true
Image {
visible: true
anchors.right: parent.right
anchors.rightMargin: page.width*0.05
anchors.bottom: parent.bottom
anchors.bottomMargin: page.width*0.05
width: page.width*.10
height: page.width*.10
source: "qrc:/images/logo.png"
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: page.height * 0.03
anchors.top: parent.top
text: "TRACK ORDER"
font.family: "Avenir"
font.letterSpacing: 2
}
Plugin {
id: osmplugin1
name:"osm"
}
Item {
id: tracking_drone
anchors.horizontalCenter: parent.horizontalCenter
y: page.height * 0.08
width: page.width * 0.8
height: page.width * 0.6
Text {
id: targetlatitude
visible: false
}
Text {
id: targetlongitude
visible: false
}
// Customer Address
Address {
id: fromAddress
street: if (vendor_handler.delivery == 1) {vendor_handler.street1}
else if (vendor_handler.delivery == 2) {vendor_handler.street2}
else if (vendor_handler.delivery == 3) {vendor_handler.street3}
city: if (vendor_handler.delivery == 1) {vendor_handler.city1}
else if (vendor_handler.delivery == 2) {vendor_handler.city2}
else if (vendor_handler.delivery == 3) {vendor_handler.city3}
country: if (vendor_handler.delivery == 1) {vendor_handler.region1}
else if (vendor_handler.delivery == 2) {vendor_handler.region2}
else if (vendor_handler.delivery == 3) {vendor_handler.region3}
state : if (vendor_handler.delivery == 1) {vendor_handler.state1}
else if (vendor_handler.delivery == 2) {vendor_handler.state2}
else if (vendor_handler.delivery == 3) {vendor_handler.state3}
postalCode: if (vendor_handler.delivery == 1) {vendor_handler.zip1}
else if (vendor_handler.delivery == 2) {vendor_handler.zip2}
else if (vendor_handler.delivery == 3) {vendor_handler.zip3}
}
Map {
id: map2
plugin: osmplugin1
width: tracking_drone.width
height: tracking_drone.height
zoomLevel: mapslider1.value
center {
latitude: vendor_handler.latitude
longitude: vendor_handler.longitude
}
gesture.flickDeceleration: 3000
gesture.enabled: true
// ORIGIN POINT
MapCircle {
id: point
radius: if (mapslider1.value < 13) {200}
else {30}
color: "#3938FF" // Origin Point will be in blue
border.color: "#000000"
border.width: 2
opacity: 0.6
center {
latitude: vendor_handler.latitude
longitude: vendor_handler.longitude
}
}
// DRONE POINT
MapCircle {
radius:
if (mapslider1.value > 13) {5}
else if (mapslider1.value = 13) {20}
else if (mapslider1.value > 12 & mapslider1.value < 13) {200}
else {1000}
color: "#FF0F47" // Shows drone point in red
opacity: 0.6
border.width: 2
border.color: "#000000"
center {
latitude: manual_control_handler.latitude
longitude: manual_control_handler.longitude
}
}
// IDEAL FLIGHT PATH
MapPolyline {
id: polyline2
line.width: 3
line.color: "#000000"
path: [
{ latitude: vendor_handler.latitude, longitude: vendor_handler.longitude },
{ latitude: targetlatitude.text, longitude: targetlongitude.text }
]
}
// ACUTAL FLIGHT PATH
MapPolyline {
id: actual_flight_path
line.width: 3
line.color: 'red'
path: [
{ latitude: -27, longitude: 153.0 },
{ latitude: -27, longitude: 154.1 },
{ latitude: -28, longitude: 153.5 },
{ latitude: -29, longitude: 153.5 }
]
}
// Gets coordinates from the customer address
GeocodeModel {
id: geocodeModel1
plugin: osmplugin1
autoUpdate: true
query: fromAddress
onLocationsChanged: {
map2.center.latitude = get(0).coordinate.latitude
map2.center.longitude = get(0).coordinate.longitude
targetlatitude.text = get(0).coordinate.latitude
targetlongitude.text = get(0).coordinate.longitude
}
}
Component {
id: pointDelegate1
// DESTINATION POINT
MapCircle {
id: point2
radius: if (mapslider1.value < 13) {200}
else {30}
color: "#C638FF"
border.color: "#000000"
border.width: 2
opacity: 0.6
center {
latitude: targetlatitude.text
longitude: targetlongitude.text
}
}
}
MapItemView {
model: geocodeModel1
delegate: pointDelegate1
}
}
}
Slider {
id: mapslider1
anchors.right: parent.right
anchors.rightMargin: 15
anchors.top: parent.top
anchors.topMargin: tracking_drone.y
height: map2.height
value: 15
maximumValue: 19
minimumValue: 2
tickmarksEnabled: false
updateValueWhileDragging: true
visible: true
orientation: Qt.Vertical
}
Text {
id: currentdronecoordinates
y: tracking_drone.y + tracking_drone.height + 20
anchors.left: parent.left
anchors.leftMargin: 50
text: "Current Drone Latitude: " + '<br>' + "Current Drone Longitude: "
font.family: "Avenir"
font.letterSpacing: 2
}
Text {
y: tracking_drone.y + tracking_drone.height + 20
anchors.right: parent.right
anchors.rightMargin: 50
text: manual_control_handler.latitude.toFixed(8) + '<br>' + manual_control_handler.longitude.toFixed(8)
font.family: "Avenir"
font.letterSpacing: 2
z: currentdronecoordinates.z + 3
}
Text {
id: currentdistance_label
y: currentdronecoordinates.y + currentdronecoordinates.height + 20
anchors.left: parent.left
anchors.leftMargin: 50
text: "Current Distance:"
font.family: "Avenir"
font.letterSpacing: 2
}
Text {
id: currentdistance
anchors.right: parent.right
anchors.rightMargin: 50
y: currentdronecoordinates.y + currentdronecoordinates.height + 20
text: Math.floor(6371000*Math.acos(Math.sin(vendor_handler.latitude*0.0174532925) * Math.sin(targetlatitude.text*0.0174532925) + Math.cos(vendor_handler.latitude*0.0174532925) * Math.cos(targetlatitude.text*0.0174532925) * Math.cos (targetlongitude.text*0.0174532925 - vendor_handler.longitude*0.0174532925))) + " m"
font.family: "Avenir"
font.letterSpacing: 2
}
Text {
id: deliverystatus
y: currentdistance.y + currentdistance.height + 20
anchors.left: parent.left
anchors.leftMargin: 50
text: "Current Status:"
font.family: "Avenir"
font.letterSpacing: 2
}
Text {
id: display_deliverystatus
anchors.right: parent.right
anchors.rightMargin: 50
y: currentdistance.y + currentdistance.height + 20
text:
if (delivered_validationsign.source == "checkgrey.png" & returned_validationsign.source == "checkgrey.png") {"Delivering"}
else if (delivered_validationsign.source == "checkgreen.png" & returned_validationsign.source == "checkgrey.png") {"Returning"}
else if (returned_validationsign.source == "checkgreen.png") {"Returned"}
font.family: "Avenir"
font.letterSpacing: 2
}
Text {
id: delivered
y: deliverystatus.y + deliverystatus.height + 20
anchors.left: parent.left
anchors.leftMargin: 50
text: "Delivered"
font.family: "Avenir"
font.letterSpacing: 2
}
Image {
id: delivered_validationsign
y: delivered.y - 5
height: delivered.height + 10
width: delivered.height + 10
anchors.right: parent.right
anchors.rightMargin: 50
source:
if (Math.abs(targetlatitude.text - manual_control_handler.latitude) < 0.0002 & Math.abs(targetlongitude.text - manual_control_handler.longitude) < 0.0002) {"qrc:/images/checkgreen.png"}
else {"qrc:/images/checkgrey.png"}
}
Text {
id: returned
y: delivered.y + delivered.height + 20
anchors.left: parent.left
anchors.leftMargin: 50
text: qsTr("Returned")
font.family: "Avenir"
font.letterSpacing: 2
}
Image {
id: returned_validationsign
y: returned.y - 5
height: returned.height + 10
width: returned.height + 10
anchors.right: parent.right
anchors.rightMargin: 50
source:
if (Math.abs(vendor_handler.latitude - manual_control_handler.latitude) < 0.0002 & Math.abs(vendor_handler.longitude - manual_control_handler.longitude) < 0.0002) {"qrc:/images/checkgreen.png"}
else {"qrc:/images/checkgrey.png"}
}
Text {
id: currentbattery
anchors.left: parent.left
anchors.leftMargin: 50
y: returned.y + returned.height + 20
text: if (((manual_control_handler.voltage - 13500) / 31).toFixed(1) > 0) {
"Current Battery: "+ ((manual_control_handler.voltage - 13500) / 31).toFixed(1) + "%"}
else {"Current Battery: 0%"}
font.family: "Avenir"
font.letterSpacing: 2
}
Rectangle {
id: battery1
anchors.right: parent.right
anchors.rightMargin: 50
y: currentbattery.y
width: 75
height: currentbattery.height
color: "#00000000"
border.width: 2
}
Rectangle {
id: batteryfill
x: battery1.x + 5
y: battery1.y + 5
width: if (((manual_control_handler.voltage - 13500) / 31) > 0.0) {
(battery1.width - 10.0)*(((manual_control_handler.voltage - 13500) / 3100))}
else {0}
color: if (((manual_control_handler.voltage - 13500) / 31) >= 85.00) {"#65E01F"}
else if (((manual_control_handler.voltage - 13500) / 31) >= 60.00) {"#FF790A"}
else if (((manual_control_handler.voltage - 13500) / 31) < 60.00) {"#D60000"}
height: battery1.height - 10
visible: true
}
Button {
id: return_to_manual
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: page.height * 0.14
visible: true
text: "Return to manual control"
width: cancelreturn.width
onClicked: {
vendor_track_page.visible = false
manual_control_page.visible = true
}
}
Button {
id: view_other_orders
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: page.height * 0.09
visible: true
text: "View other orders"
width: cancelreturn.width
onClicked: {
vendor_track_page.visible = false
pending_order_page.visible = true
if (delivered_validationsign.source == "checkgreen.png" | returned_validationsign.source == "checkgreen.png") {
if (vendor_handler.delivery == 1) {
vendor_handler.reset1()
vendor_handler.delivery = 0
if (vendor_handler.valid2) {
vendor_handler.pass2to1()
vendor_handler.reset2()
}
if (vendor_handler.valid3) {
vendor_handler.pass3to2()
vendor_handler.reset3()
}
}
else if (vendor_handler.delivery == 2) {
vendor_handler.reset2()
vendor_handler.delivery = 0
if (vendor_handler.valid3) {
vendor_handler.pass3to2()
vendor_handler.reset3()}
}
else if (vendor_handler.delivery == 3) {
vendor_handler.reset3()
vendor_handler.delivery = 0
}
}
}
}
Button {
id: cancelreturn
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: page.height * 0.04
visible: if (returned_validation.text == "Y") {false} else {true}
text: "Cancel Order and Return"
onClicked: {
display_deliverystatus.text = "Returning"
delivered_validationsign.source == "checkgrey.png"
}
}
}