-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPrimaryFlightDisplayQML.cpp
More file actions
822 lines (687 loc) · 23.6 KB
/
PrimaryFlightDisplayQML.cpp
File metadata and controls
822 lines (687 loc) · 23.6 KB
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
/*===================================================================
APM_PLANNER Open Source Ground Control Station
(c) 2014 Bill Bonney <billbonney@communistech.com>
This file is part of the APM_PLANNER project
APM_PLANNER is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
APM_PLANNER is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "PrimaryFlightDisplayQML.h"
#include <QVBoxLayout>
#include <QMessagebox>
#include <QtQml/QQmlContext>
#include <QtQuick/QQuickItem>
#include <QtQml/QQmlEngine>
#include <QGst/Init>
#include <QSettings>
#include <QApplication>
#include <RelPositionOverview.h>
#include <AbsPositionOverview.h>
#include <VehicleOverview.h>
#include "LinkManager1.h"
#include "UASManager1.h"
#include <QGst/Quick/VideoItem>
#include "HUDApplication.h"
#define ToRad(x) (x*0.01745329252) // *pi/180
#define ToDeg(x) (x*57.2957795131) // *180/pi
// Callback to update the custom plugin
void* update_node(void* surface, void* node, qreal x, qreal y, qreal w, qreal h);
QDialog * PrimaryFlightDisplayQML::s_primaryFlightDisplayDialog = NULL;
PrimaryFlightDisplayQML::PrimaryFlightDisplayQML(QWidget *parent) :
QWidget(parent),
m_declarativeView(NULL),
m_uasInterface(NULL),
m_player(NULL),
m_player2(NULL),
m_surface(NULL),
m_surface2(NULL),
m_viewcontainer(NULL),
m_showToolAction(NULL),
m_videoEnabled(true),
m_topMostMode(false),
m_enableGStreamer(true),
m_uasConnected(false),
m_setHome(false),
m_sonyCamera(NULL),
m_recording(false),
m_zoomingIn(false),
m_zoomingOut(false),
m_close(false)
{
m_currentState = new QCurrentState();
m_declarativeView = new QQuickView();
m_surface = new QGst::Quick::VideoSurface;
m_surface2 = new QGst::Quick::VideoSurface;
m_player = new GStreamerPlayer(m_declarativeView);
m_player->setVideoSink(m_surface->videoSink());
m_player2 = new GStreamerPlayer(m_declarativeView);
m_player2->setVideoSink(m_surface2->videoSink());
m_declarativeView->setResizeMode(QQuickView::SizeRootObjectToView);
m_declarativeView->engine()->addImportPath("./qml"); //For local or win32 builds
m_declarativeView->engine()->addImportPath("./qml/quick2"); //For local or win32 builds
QString path = m_declarativeView->engine()->offlineStoragePath();
qDebug() << "Database Storage Path = " << path;
m_declarativeView->rootContext()->setContextProperty(QLatin1String("videoSurface1"), m_surface);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("videoSurface2"), m_surface2);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("player"), m_player);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("player2"), m_player2);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("container"), this);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("currentState"), m_currentState);
connect(m_player, SIGNAL(messageBox(QString)), this,
SLOT(messageBox(QString)), Qt::UniqueConnection);
connect(m_player2, SIGNAL(messageBox(QString)), this,
SLOT(messageBox(QString)), Qt::UniqueConnection);
// Default to video display until user selects
InitializeDisplayWithVideo();
// Connect with UAS
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this,
SLOT(setActiveUAS(UASInterface*)), Qt::UniqueConnection);
show();
}
PrimaryFlightDisplayQML::~PrimaryFlightDisplayQML()
{
delete m_player;
m_player = NULL;
delete m_player2;
m_player2=NULL;
if (s_primaryFlightDisplayDialog != NULL)
{
s_primaryFlightDisplayDialog->close();
s_primaryFlightDisplayDialog = NULL;
}
if (m_currentState != NULL)
{
delete m_currentState;
m_currentState = NULL;
}
if (m_sonyCamera != NULL)
{
delete m_sonyCamera;
}
}
void PrimaryFlightDisplayQML::setActiveUAS(UASInterface *uas)
{
if (m_uasInterface) {
disconnect(m_uasInterface,SIGNAL(textMessageReceived(int,int,int,QString)),
this,SLOT(uasTextMessage(int,int,int,QString)));
disconnect(m_uasInterface, SIGNAL(navModeChanged(int, int, QString)),
this, SLOT(updateNavMode(int, int, QString)));
}
m_uasInterface = dynamic_cast<UAS*>(uas);
if (m_uasInterface) {
connect(uas,SIGNAL(textMessageReceived(int,int,int,QString)),
this,SLOT(uasTextMessage(int,int,int,QString)));
connect(uas, SIGNAL(navModeChanged(int, int, QString)),
this, SLOT(updateNavMode(int, int, QString)));
m_currentState->setUAS(m_uasInterface);
VehicleOverview *obj = LinkManager::instance()->getUasObject(uas->getUASID())->getVehicleOverview();
RelPositionOverview *rel = LinkManager::instance()->getUasObject(uas->getUASID())->getRelPositionOverview();
AbsPositionOverview *abs = LinkManager::instance()->getUasObject(uas->getUASID())->getAbsPositionOverview();
if (m_declarativeView)
{
m_declarativeView->rootContext()->setContextProperty("vehicleoverview",obj);
m_declarativeView->rootContext()->setContextProperty("relpositionoverview",rel);
m_declarativeView->rootContext()->setContextProperty("abspositionoverview",abs);
QMetaObject::invokeMethod(m_declarativeView->rootObject(),"activeUasSet");
}
}
}
void PrimaryFlightDisplayQML::uasTextMessage(int uasid, int componentid, int severity, QString text)
{
Q_UNUSED(uasid);
Q_UNUSED(componentid);
if (severity >=0 && severity<255)
{
if (m_declarativeView)
{
QObject *root = m_declarativeView->rootObject();
root->setProperty("statusMessage", text);
root->setProperty("showStatusMessage", true);
QTimer::singleShot(5000,this,SLOT(clearTextMessage()));
}
}
qCritical() << text;
}
void PrimaryFlightDisplayQML::clearTextMessage()
{
if (m_declarativeView)
{
QObject *root = m_declarativeView->rootObject();
root->setProperty("statusMessage", "");
root->setProperty("showStatusMessage", false);
}
}
void PrimaryFlightDisplayQML::updateNavMode(int uasid, int mode, const QString& text)
{
Q_UNUSED(uasid);
Q_UNUSED(mode);
if (m_declarativeView)
{
QObject *root = m_declarativeView->rootObject();
root->setProperty("navMode", text);
}
}
void PrimaryFlightDisplayQML::applicationStateChanged(Qt::ApplicationState state)
{
QString strState = "Unknown";
switch (state)
{
case Qt::ApplicationState::ApplicationSuspended:
strState = "Suspended";
if (m_player) m_player->stop();
break;
case Qt::ApplicationState::ApplicationHidden:
strState = "Hidden";
if (m_player) m_player->stop();
break;
case Qt::ApplicationState::ApplicationInactive:
strState = "Inactive";
if (m_player) m_player->stop();
break;
case Qt::ApplicationState::ApplicationActive:
strState = "Active";
if (m_player) m_player->play();
break;
}
qDebug() << "Application State Changed to " + strState;
}
// QtGStreamer and the Qt docking system don't play well, so when we dock/undock, we need to reload (TODO: fix this)
void PrimaryFlightDisplayQML::topLevelChanged(bool topLevel)
{
if (m_videoEnabled && topLevel) InitializeDisplayWithVideo();
}
void PrimaryFlightDisplayQML::dockLocationChanged(Qt::DockWidgetArea)
{
if (m_videoEnabled) InitializeDisplayWithVideo();
}
void PrimaryFlightDisplayQML::InitializeDisplayWithVideo()
{
QString qml = "./qml/PrimaryFlightDisplayWithVideoQML.qml";
QFileInfo fileInfo(qml);
QUrl url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
if (!QFile::exists(qml))
{
QMessageBox::information(0,"Error", "" + qml + " not found. Please reinstall the application and try again");
exit(-1);
}
m_declarativeView->setFlags(Qt::FramelessWindowHint);
m_declarativeView->setSource(url);
QVBoxLayout* layout = new QVBoxLayout();
m_viewcontainer = QWidget::createWindowContainer(m_declarativeView);
layout->addWidget(m_viewcontainer);
layout->setMargin(0);
setLayout(layout);
setActiveUAS(UASManager::instance()->getActiveUAS());
m_player->play();
m_player2->play();
}
void PrimaryFlightDisplayQML::enableVideo(bool enabled)
{
if (enabled)
{
m_player->play();
m_player2->play();
}
else
{
m_player->stop();
m_player2->stop();
}
}
void PrimaryFlightDisplayQML::setTopMostMode(bool value) {
m_topMostMode = value;
if (!value && s_primaryFlightDisplayDialog != NULL) {
if (m_showToolAction)
{
m_showToolAction->setChecked(false);
m_showToolAction->trigger();
}
emit topMostModeChanged();
}
if (value && s_primaryFlightDisplayDialog == NULL) {
// Hide dock version from user
if (m_showToolAction)
{
m_showToolAction->setChecked(true);
m_showToolAction->trigger();
}
// Create top most dialog
s_primaryFlightDisplayDialog = new QDialog(NULL, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowStaysOnTopHint);
s_primaryFlightDisplayDialog->resize(640,480);
PrimaryFlightDisplayQML *child = new PrimaryFlightDisplayQML();
child->setShowToolAction(m_showToolAction);
s_primaryFlightDisplayDialog->setModal(false);
s_primaryFlightDisplayDialog->setAttribute(Qt::WA_DeleteOnClose);
s_primaryFlightDisplayDialog->setWindowTitle(tr("Primary Flight Display"));
s_primaryFlightDisplayDialog->setLayoutDirection (Qt::LeftToRight);
QBoxLayout *mainDialogLayout = new QBoxLayout(QBoxLayout::LeftToRight);
mainDialogLayout->addWidget(child);
mainDialogLayout->setMargin (0);
s_primaryFlightDisplayDialog->setLayout(mainDialogLayout);
mainDialogLayout->update();
mainDialogLayout->activate();
s_primaryFlightDisplayDialog->setObjectName(child->objectName());
s_primaryFlightDisplayDialog->setMinimumHeight(320);
s_primaryFlightDisplayDialog->setMinimumWidth(240);
s_primaryFlightDisplayDialog->show();
connect(child, SIGNAL(topMostModeChanged()), this, SLOT(onTopMostModeChanged()));
child->show();
emit topMostModeChanged();
}
}
void PrimaryFlightDisplayQML::setPipelineString(QString pipelineString)
{
m_pipelineString = pipelineString; emit pipelineStringChanged();
if (m_player) m_player->setPipelineString(m_pipelineString);
}
void PrimaryFlightDisplayQML::setPipelineString2(QString pipelineString)
{
m_pipelineString2 = pipelineString; emit pipelineStringChanged2();
if (m_player) m_player2->setPipelineString(m_pipelineString2);
}
void PrimaryFlightDisplayQML::setCameraIpAddress(QString ipAddress)
{
m_cameraIpAddress = ipAddress; emit cameraIpAddressChanged();
}
void PrimaryFlightDisplayQML::messageBox(QString text)
{
QObject *root = m_declarativeView->rootObject();
root->setProperty("messageBoxText", text);
root->setProperty("showMessageBox", true);
qCritical() << text;
}
void PrimaryFlightDisplayQML::setIpOrHost(QString ipOrHost)
{
m_ipOrHost = ipOrHost; emit ipOrHostChanged();
}
void PrimaryFlightDisplayQML::ResetDisplay()
{
// Removes the current engine and widgets
if (m_player)
{
m_player->stop();
m_player2->stop();
delete m_player;
delete m_player2;
m_player = NULL;
m_player2 = NULL;
}
if (m_declarativeView)
{
m_declarativeView->hide();
m_declarativeView->close();
m_declarativeView->rootContext()->setContextProperty(QLatin1String("videoSurface1"), 0);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("videoSurface2"), 0);
m_declarativeView->engine()->clearComponentCache();
m_declarativeView->setParent(NULL);
m_declarativeView = NULL;
}
if (m_surface)
{
delete m_surface;
m_surface = NULL;
}
if (m_surface2)
{
delete m_surface2;
m_surface2 = NULL;
}
if (m_viewcontainer)
{
layout()->removeWidget(m_viewcontainer);
m_viewcontainer->close();
m_viewcontainer = NULL;
delete layout();
}
}
void PrimaryFlightDisplayQML::setVideoEnabled(bool value) {
this->m_videoEnabled = value;
this->enableVideo(value);
emit videoEnabledChanged();
}
void PrimaryFlightDisplayQML::setUasConnected(bool value) {
LinkManager *pLinkMgr = LinkManager::instance();
int iLinkId = -1;
if (m_connectionMap.contains(m_ipOrHost))
{
iLinkId = m_connectionMap.value(m_ipOrHost);
}
if (iLinkId >= 0)
{
if (value) value = pLinkMgr->connectLink(iLinkId);
else pLinkMgr->disconnectLink(iLinkId);
this->m_uasConnected = value;
emit uasConnectedChanged();
return;
}
// Not in list, add new
QStringList split = m_ipOrHost.split(":");
QString token;
QString ipOrHost;
int iToken = 0;
int iBaudRate = 0;
int iPort = 0;
bool isSerialPort = false;
bool isTCP = false;
bool isUDP = false;
QString text;
Q_FOREACH(token, split)
{
switch (iToken)
{
case 0:
if (token.startsWith("COM"))
{
isSerialPort = true;
ipOrHost = token;
iToken++;
break;
}
if (token.startsWith("TCP"))
{
isTCP = true;
iToken++;
break;
}
if (token.startsWith("UDP"))
{
isUDP = true;
iToken++;
break;
}
// Error if got here, invalid string
text = "Invalid connect string '" + m_ipOrHost + "', missing COM,TCP,UDP";
this->messageBox(text);
value = false;
this->m_uasConnected = value;
emit uasConnectedChanged();
return;
case 1:
if (isSerialPort)
{
iBaudRate = token.toInt();
iToken++;
break;
}
if (isTCP)
{
ipOrHost = token;
iToken++;
break;
}
if (isUDP)
{
iPort = token.toInt();
iToken++;
break;
}
break;
case 2:
if (isTCP)
{
iPort = token.toInt();
iToken++;
break;
}
break;
}
}
if (isSerialPort)
{
iLinkId = pLinkMgr->addSerialConnection(ipOrHost, iBaudRate);
m_connectionMap.insert(m_ipOrHost, iLinkId);
}
else if (isTCP)
{
QHostAddress addr(ipOrHost);
iLinkId = pLinkMgr->addTcpConnection(addr, iPort, false);
m_connectionMap.insert(m_ipOrHost, iLinkId);
}
else if (isUDP)
{
iLinkId = pLinkMgr->addUdpConnection(QHostAddress::Any, iPort);
m_connectionMap.insert(m_ipOrHost, iLinkId);
}
if (!pLinkMgr->connectLink(iLinkId))
{
text = "Cannot open connection '" + m_ipOrHost + "'!";
this->messageBox(text);
value = false;
}
this->m_uasConnected = value;
emit uasConnectedChanged();
}
void PrimaryFlightDisplayQML::resetHome(bool value)
{
if (value && this->m_uasInterface != NULL)
{
this->m_setHome = true;
emit setHomeChanged();
AbsPositionOverview *abs = LinkManager::instance()->getUasObject(this->m_uasInterface->getUASID())->getAbsPositionOverview();
abs->setLatHome(0);
this->m_setHome = false;
emit setHomeChanged();
}
}
void PrimaryFlightDisplayQML::setFullScreenMode(bool value) {
this->m_fullScreenMode = value;
QWidget *p = dynamic_cast<QWidget*>(this->parent());
if (!value && p->isFullScreen()) {
p->showNormal();
emit fullScreenModeChanged();
}
if (value && !p->isFullScreen()) {
p->showFullScreen();
emit fullScreenModeChanged();
}
}
bool PrimaryFlightDisplayQML::isFullScreenMode() const {
QWidget *p = dynamic_cast<QWidget*>(this->parent());
return p->isFullScreen();
}
void PrimaryFlightDisplayQML::setSwapColorMatrix1(bool value) {
this->m_swapColorMatrix1 = value;
this->m_player->setSwapColorMatrix(value);
emit swapColorMatrixChanged1();
}
bool PrimaryFlightDisplayQML::isSwapColorMatrix1() const {
return this->m_player->getSwapColorMatrix();
}
void PrimaryFlightDisplayQML::setSwapColorMatrix2(bool value) {
this->m_swapColorMatrix2 = value;
this->m_player2->setSwapColorMatrix(value);
emit swapColorMatrixChanged2();
}
bool PrimaryFlightDisplayQML::isSwapColorMatrix2() const {
return this->m_player2->getSwapColorMatrix();
}
void PrimaryFlightDisplayQML::setRecording(bool value) {
src::Sony_Remote_Camera_Interface* camera = this->camera();
if (camera != NULL)
{
try
{
if (camera->Set_Shoot_Mode(src::Camera_State::MOVIE) == src::SC_NO_ERROR)
{
camera->Set_Recording(value);
}
this->m_recording = value;
}
catch(...)
{}
}
emit recordingChanged();
}
void PrimaryFlightDisplayQML::setTakePicture(bool value) {
src::Sony_Remote_Camera_Interface* camera = this->camera();
if (camera != NULL && !isRecording())
{
try
{
if (value)
{
if (camera->Set_Shoot_Mode(src::Camera_State::STILL) == src::SC_NO_ERROR)
{
camera->TakePicture();
}
}
this->m_takePicture = value;
}
catch(...)
{}
}
emit takePictureChanged();
}
bool PrimaryFlightDisplayQML::isRecording() const {
return this->m_recording;
}
bool PrimaryFlightDisplayQML::isTakePicture() const {
return this->m_takePicture;
}
void PrimaryFlightDisplayQML::setZoomingIn(bool value) {
src::Sony_Remote_Camera_Interface* camera = this->camera();
if (camera != NULL)
{
try
{
camera->Zoom(true, value);
this->m_zoomingIn = value;
}
catch(...)
{}
}
emit zoomingInChanged();
}
bool PrimaryFlightDisplayQML::isZoomingIn() const {
return this->m_zoomingIn;
}
void PrimaryFlightDisplayQML::setZoomingOut(bool value) {
src::Sony_Remote_Camera_Interface* camera = this->camera();
if (camera != NULL)
{
try
{
camera->Zoom(false, value);
this->m_zoomingOut = value;
}
catch(...)
{}
}
emit zoomingOutChanged();
}
bool PrimaryFlightDisplayQML::isZoomingOut() const {
return this->m_zoomingOut;
}
void PrimaryFlightDisplayQML::onTopMostModeChanged()
{
// Will delete itself
if (s_primaryFlightDisplayDialog)
{
s_primaryFlightDisplayDialog->close();
s_primaryFlightDisplayDialog = NULL;
m_topMostMode = false;
}
emit topMostModeChanged();
}
void PrimaryFlightDisplayQML::hideEvent(QHideEvent *event)
{
QWidget::hideEvent(event);
}
void PrimaryFlightDisplayQML::closeEvent(QCloseEvent *event)
{
if (!m_close)
{
m_close = true;
event->setAccepted(false);
m_player->setStopped(true);
m_player2->setStopped(true);
QTimer::singleShot(1500,this->parent(),SLOT(close()));
return;
}
ResetDisplay();
QWidget::closeEvent(event);
}
void PrimaryFlightDisplayQML::SetCurrentState(CCurrentState &theState)
{
// This method will update the bound state variables in the QML
m_currentState->setRoll(theState.getRoll());
m_currentState->setPitch(theState.getPitch());
m_currentState->setYaw(theState.getYaw());
m_currentState->setGroundspeed(theState.getGroundspeed());
m_currentState->setAirspeed(theState.getAirspeed());
m_currentState->setBatteryVoltage(theState.getBatteryVoltage());
m_currentState->setBatteryCurrent(theState.getBatteryCurrent());
m_currentState->setBatteryRemaining(theState.getBatteryRemaining());
m_currentState->setAltitude(theState.getAltitude());
m_currentState->setWatts(theState.getWatts());
m_currentState->setGpsstatus(theState.getGpsStatus());
m_currentState->setGpshdop(theState.getGpsHdop());
m_currentState->setSatcount(theState.getSatCount());
m_currentState->setWp_dist(theState.getWpDist());
m_currentState->setCh3percent(theState.getCh3Percent());
m_currentState->setTimeInAir(theState.getTimeInAir());
m_currentState->setDistToHome(theState.getDistToHome());
m_currentState->setDistTraveled(theState.getDistTravled());
m_currentState->setAZToMAV(theState.getAzToMav());
m_currentState->setLat(theState.getLat());
m_currentState->setLng(theState.getLng());
m_currentState->setArmed(theState.getArmed());
m_currentState->setDistUnit(QString::fromWCharArray(theState.getDistUnit()));
m_currentState->setSpeedUnit(QString::fromWCharArray(theState.getSpeedUnit()));
m_currentState->setMessage(QString::fromWCharArray(theState.getMessage()));
m_currentState->setFlightMode(QString::fromWCharArray(theState.getFlightMode()));
}
bool PrimaryFlightDisplayQML::isSplitImage() const {
return this->m_player->getSplitImage();
}
void PrimaryFlightDisplayQML::setSplitImage(bool value) {
m_splitImage = value;
m_player->setSplitImage(value);
m_player2->setSplitImage(value);
QSize size = theMainWindow->size();
size += QSize(0,1);
theMainWindow->resize(size);
QTimer::singleShot(10,this,SLOT(updateSize()));
qDebug() << "Image split mode " << (value ? "on" : "off");
emit splitImageChanged();
}
void PrimaryFlightDisplayQML::updateSize()
{
QSize size = theMainWindow->size();
size += QSize(0,-1);
theMainWindow->resize(size);
}
bool PrimaryFlightDisplayQML::isSwapImages() const {
return m_swapImages;
}
void PrimaryFlightDisplayQML::setSwapImages(bool value) {
this->m_swapImages = value;
emit swapImagesChanged();
setSplitImage(this->m_splitImage);
}
src::Sony_Remote_Camera_Interface* PrimaryFlightDisplayQML::camera()
{
if (m_sonyCamera == NULL)
{
if (!m_cameraIpAddress.isEmpty())
{
QStringList adapterAndIp = m_cameraIpAddress.remove("\n").split(":");
if (adapterAndIp.count() == 2)
{
QString adapterIpAddress = adapterAndIp.at(0);
QString cameraIpAddress = adapterAndIp.at(1);
QString liveViewURL = QString("http://%1:60152/liveview.JPG?%211234%21http%2dget%3a%2a%3aimage%2fjpeg%3a%2a%21%21%21%21%21").arg(cameraIpAddress);
QString cameraServiceURL = QString("http://%1:10000/sony").arg(cameraIpAddress);
m_sonyCamera = src::GetSonyRemoteCamera(adapterIpAddress.toStdString().c_str(), cameraServiceURL.toStdString().c_str(), liveViewURL.toStdString().c_str());
}
}
}
return m_sonyCamera;
}