Commit 1d560d9c authored by pixhawk's avatar pixhawk

Merged

parents 6e5626f9 1b2b89a5
......@@ -13,6 +13,7 @@ google.load("earth", "1", { 'language': 'en'});
var ge = null;
var initialized = false;
var aircraft = new Array();
var currAircraft = 220;
var followAircraft = false;
......@@ -37,6 +38,9 @@ var currView = null;
var planeOrient;
var planeLoc;
var trail;
var lineStringPlacemark;
var lineStyle;
// Aircraft class
......@@ -95,27 +99,9 @@ function setGCSHome(lat, lon, alt)
goHome();
}
function initCallback(object)
function createAircraft(id, type, color)
{
ge = object;
ge.getWindow().setVisibility(true);
ge.getOptions().setStatusBarVisibility(true);
ge.getOptions().setScaleLegendVisibility(true);
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
// Now after the Google Earth initialization, initialize the GCS view
setGCSHome(currLat, currLon, currAlt);
// Create the first aircraft model
// Load 3D model
var planePlacemark = ge.createPlacemark('');
planePlacemark = ge.createPlacemark('');
planePlacemark.setName('aircraft');
planeModel = ge.createModel('');
ge.getFeatures().appendChild(planePlacemark);
......@@ -135,9 +121,77 @@ function initCallback(object)
planePlacemark.setGeometry(planeModel);
setAircraftPositionAttitude(220, 47.3772, currLon, currAlt+50, 20, 15, 50);
enableFollowing(true);
updateFollowAircraft();
// Write into global structure
aircraft[id] = planePlacemark;
attitudes[id] = planeOrient;
locations[id] = planeLoc;
//createTrail(id, color);
}
function createTrail(id, color)
{
lineStringPlacemark = ge.createPlacemark('');
// Create the placemark
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
trail = ge.createLineString('');
lineStringPlacemark.setGeometry(trail);
trail.setExtrude(true);
trail.setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set(color);
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
ge.getFeatures().appendChild(lineStringPlacemark);
}
function addTrailPosition(id, lat, lon, alt)
{
trail.setExtrude(true);
trail.setAltitudeMode(ge.ALTITUDE_ABSOLUTE);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
trail.getCoordinates().pushLatLngAlt(currLat, currLon, currAlt);
// Create a style and set width and color of line
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set('99bbaaff');
//lineStyle.getColor().set(color);  // aabbggrr format
// Add the feature to Earth
ge.getFeatures().replaceChild(lineStringPlacemark, lineStringPlacemark);
}
function initCallback(object)
{
ge = object;
ge.getWindow().setVisibility(true);
ge.getOptions().setStatusBarVisibility(true);
ge.getOptions().setScaleLegendVisibility(true);
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);
createTrail(220, 'bb2222ff');
createAircraft(220);
initialized = true;
......@@ -164,6 +218,18 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
}
function enableDaylight(enabled)
{
if(enabled)
{
ge.getSun().setVisibility(true);
}
else
{
ge.getSun().setVisibility(false);
}
}
function goHome()
{
var currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
......
......@@ -154,6 +154,7 @@ linux-g++ {
release {
DESTDIR = $$TARGETDIR/release
DEFINES += QT_NO_DEBUG
}
QMAKE_POST_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/.
......@@ -223,6 +224,7 @@ linux-g++-64 {
release {
DESTDIR = $$TARGETDIR/release
DEFINES += QT_NO_DEBUG
}
QMAKE_POST_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/.
......@@ -295,6 +297,7 @@ win32-msvc2008 {
release {
CONFIG -= console
DEFINES += QT_NO_DEBUG
}
debug {
......@@ -382,6 +385,7 @@ win32-g++ {
release {
CONFIG -= console
DEFINES += QT_NO_DEBUG
#DESTDIR = $$BUILDDIR/release
}
......
......@@ -245,7 +245,6 @@ HEADERS += src/MG.h \
src/comm/QGCMAVLink.h \
src/ui/QGCWebView.h \
src/ui/map3D/QGCWebPage.h \
src/ui/map3D/QGCGoogleEarthView.h\
src/ui/SlugsDataSensorView.h \
src/ui/SlugsHilSim.h \
src/ui/SlugsPIDControl.h \
......@@ -255,6 +254,11 @@ HEADERS += src/MG.h \
src/comm/MAVLinkSwarmSimulationLink.h \
src/ui/uas/QGCUnconnectedInfoWidget.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008: {
HEADERS += src/ui/map3D/QGCGoogleEarthView.h
}
contains(DEPENDENCIES_PRESENT, osg) {
message("Including headers for OpenSceneGraph")
......@@ -357,7 +361,6 @@ SOURCES += src/main.cc \
src/ui/RadioCalibration/AbstractCalibrator.cc \
src/ui/RadioCalibration/RadioCalibrationData.cc \
src/ui/QGCWebView.cc \
src/ui/map3D/QGCGoogleEarthView.cc \
src/ui/map3D/QGCWebPage.cc \
src/ui/SlugsDataSensorView.cc \
src/ui/SlugsHilSim.cc \
......@@ -367,6 +370,11 @@ SOURCES += src/main.cc \
src/ui/QGCMainWindowAPConfigurator.cc \
src/comm/MAVLinkSwarmSimulationLink.cc \
src/ui/uas/QGCUnconnectedInfoWidget.cc
macx|win32-msvc2008: {
SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
}
contains(DEPENDENCIES_PRESENT, osg) {
message("Including sources for OpenSceneGraph")
......
......@@ -19,4 +19,6 @@ namespace QGC
const QString COMPANYNAME = "OPENMAV";
}
#define QGC_EVENTLOOP_DEBUG 0
#endif // QGC_H
......@@ -192,6 +192,7 @@ void MAVLinkSimulationLink::mainloop()
static unsigned int rate1hzCounter = 1;
static unsigned int rate10hzCounter = 1;
static unsigned int rate50hzCounter = 1;
static unsigned int circleCounter = 0;
// Vary values
......@@ -374,17 +375,20 @@ void MAVLinkSimulationLink::mainloop()
// Move X Position
x = x*0.93f + 0.07f*(x+sin(static_cast<float>(QGC::groundTimeUsecs()) * 0.08f));
y = y*0.93f + 0.07f*(y+sin(static_cast<float>(QGC::groundTimeUsecs()) * 0.5f));
z = z*0.93f + 0.07f*(z+sin(static_cast<float>(QGC::groundTimeUsecs()*0.001f)) * 0.1f);
x = 8.0*sin((double)circleCounter/50.0);
y = 3.0*cos((double)circleCounter/40.0);
z = 1.8 + 1.2*sin((double)circleCounter/60.0);
x = (x > 5.0f) ? 5.0f : x;
y = (y > 5.0f) ? 5.0f : y;
z = (z > 3.0f) ? 3.0f : z;
circleCounter++;
x = (x < -5.0f) ? -5.0f : x;
y = (y < -5.0f) ? -5.0f : y;
z = (z < -3.0f) ? -3.0f : z;
// x = (x > 5.0f) ? 5.0f : x;
// y = (y > 5.0f) ? 5.0f : y;
// z = (z > 3.0f) ? 3.0f : z;
// x = (x < -5.0f) ? -5.0f : x;
// y = (y < -5.0f) ? -5.0f : y;
// z = (z < -3.0f) ? -3.0f : z;
// Send back new setpoint
mavlink_message_t ret;
......@@ -401,15 +405,15 @@ void MAVLinkSimulationLink::mainloop()
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// GPS RAW
mavlink_msg_gps_raw_pack(systemId, componentId, &ret, 0, 3, 47.376417+(x*0.00001), 8.548103+(y*0.00001), z, 0, 0, 2.5f, 0.1f);
bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
// // GPS RAW
// mavlink_msg_gps_raw_pack(systemId, componentId, &ret, 0, 3, 47.376417+(x*0.00001), 8.548103+(y*0.00001), z, 0, 0, 2.5f, 0.1f);
// bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
// //add data into datastream
// memcpy(stream+streampointer,buffer, bufferlength);
// streampointer += bufferlength;
// GLOBAL POSITION
mavlink_msg_global_position_pack(systemId, componentId, &ret, 0, 47.378028137103+(x*0.00001), 8.54899892510421+(y*0.00001), z, 0, 0, 0);
mavlink_msg_global_position_pack(systemId, componentId, &ret, 0, 47.378028137103+(x*0.001), 8.54899892510421+(y*0.001), z+25.0, 0, 0, 0);
bufferlength = mavlink_msg_to_send_buffer(buffer, &ret);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
......@@ -508,6 +512,7 @@ void MAVLinkSimulationLink::mainloop()
detectionCounter++;
status.vbat = voltage * 1000; // millivolts
status.load = 33 * detectionCounter % 1000;
// Pack message and get size of encoded byte string
messageSize = mavlink_msg_sys_status_encode(systemId, componentId, &msg, &status);
......@@ -520,7 +525,7 @@ void MAVLinkSimulationLink::mainloop()
// Pack debug text message
mavlink_statustext_t text;
text.severity = 0;
strcpy((char*)(text.text), "DEBUG MESSAGE TEXT");
strcpy((char*)(text.text), "Text message from system 32");
mavlink_msg_statustext_encode(systemId, componentId, &msg, &text);
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
memcpy(stream+streampointer, buffer, bufferlength);
......@@ -578,11 +583,11 @@ void MAVLinkSimulationLink::mainloop()
streampointer += bufferlength;
/*
// HEARTBEAT VEHICLE 2
// Pack message and get size of encoded byte string
messageSize = mavlink_msg_heartbeat_pack(42, componentId, &msg, MAV_FIXED_WING);
messageSize = mavlink_msg_heartbeat_pack(54, componentId, &msg, MAV_FIXED_WING, MAV_AUTOPILOT_ARDUPILOTMEGA);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
......@@ -590,25 +595,19 @@ void MAVLinkSimulationLink::mainloop()
streampointer += bufferlength;
// STATUS VEHICLE 2
sys_status_t status2;
mavlink_sys_status_t status2;
status2.mode = MAV_MODE_LOCKED;
status2.vbat = voltage;
status2.load = 120;
status2.status = MAV_STATE_STANDBY;
// Pack message and get size of encoded byte string
messageSize = mavlink_msg_sys_status_encode(systemId, componentId, &msg, &status);
messageSize = mavlink_msg_sys_status_encode(54, componentId, &msg, &status);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
*/
//qDebug() << "BOOT" << "BUF LEN" << bufferlength << "POINTER" << streampointer;
// AUX STATUS
#ifdef MAVLINK_ENABLED_PIXHAWK
rawAuxValues.vbat = voltage;
#endif
rate1hzCounter = 1;
}
......@@ -780,31 +779,6 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
j++;
}
/*
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)"ROLL_K_P", 0.5f);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)"PITCH_K_P", 0.6f);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;
// Pack message and get size of encoded byte string
mavlink_msg_param_value_pack(systemId, componentId, &msg, (int8_t*)"YAW_K_P", 0.8f);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer+=bufferlength;*/
qDebug() << "SIMULATION SENT PARAMETERS TO GCS";
}
}
......
......@@ -94,8 +94,8 @@ protected:
// UAS properties
float roll, pitch, yaw;
float x, y, z;
float spX, spY, spZ, spYaw;
double x, y, z;
double spX, spY, spZ, spYaw;
int battery;
QTimer* timer;
......
......@@ -7,7 +7,7 @@
#ifdef MAVLINK_ENABLED_SLUGS
#define SERIAL_POLL_INTERVAL 7
#else
#define SERIAL_POLL_INTERVAL 2
#define SERIAL_POLL_INTERVAL 7
#endif
/** @brief Heartbeat emission rate, in Hertz (times per second) */
......@@ -16,6 +16,6 @@
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.7.7 (Beta)"
#define QGC_APPLICATION_VERSION "v. 0.8.0 (Beta)"
#endif // CONFIGURATION_H
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
......@@ -10,15 +9,15 @@ This file is part of the QGROUNDCONTROL project
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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
......@@ -47,17 +46,20 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes
{
// Let UAS handle the default message set
UAS::receiveMessage(link, message);
// Handle your special messages
switch (message.msgid)
if (message.sysid == uasId)
{
case MAVLINK_MSG_ID_HEARTBEAT:
// Handle your special messages
switch (message.msgid)
{
qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
case MAVLINK_MSG_ID_HEARTBEAT:
{
qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
break;
}
default:
qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
default:
qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
}
......@@ -60,100 +60,102 @@ SlugsMAV::SlugsMAV(MAVLinkProtocol* mavlink, int id) :
void SlugsMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
{
// Let UAS handle the default message set
UAS::receiveMessage(link, message);
UAS::receiveMessage(link, message);
// Handle your special messages mavlink_message_t* msg = &message;
switch (message.msgid)
if (message.sysid == uasId)
{
// Handle your special messages mavlink_message_t* msg = &message;
switch (message.msgid)
{
#ifdef MAVLINK_ENABLED_SLUGS
case MAVLINK_MSG_ID_BOOT:
mavlink_msg_boot_decode(&message,&mlBoot);
emit slugsBootMsg(uasId, mlBoot);
break;
case MAVLINK_MSG_ID_BOOT:
mavlink_msg_boot_decode(&message,&mlBoot);
emit slugsBootMsg(uasId, mlBoot);
break;
case MAVLINK_MSG_ID_ATTITUDE:
mavlink_msg_attitude_decode(&message, &mlAttitude);
break;
case MAVLINK_MSG_ID_ATTITUDE:
mavlink_msg_attitude_decode(&message, &mlAttitude);
break;
case MAVLINK_MSG_ID_GPS_RAW:
mavlink_msg_gps_raw_decode(&message, &mlGpsData);
case MAVLINK_MSG_ID_GPS_RAW:
mavlink_msg_gps_raw_decode(&message, &mlGpsData);
break;
case MAVLINK_MSG_ID_ACTION_ACK: // 62
mavlink_msg_action_ack_decode(&message,&mlActionAck);
case MAVLINK_MSG_ID_ACTION_ACK: // 62
mavlink_msg_action_ack_decode(&message,&mlActionAck);
break;
case MAVLINK_MSG_ID_CPU_LOAD: //170
mavlink_msg_cpu_load_decode(&message,&mlCpuLoadData);
case MAVLINK_MSG_ID_CPU_LOAD: //170
mavlink_msg_cpu_load_decode(&message,&mlCpuLoadData);
break;
case MAVLINK_MSG_ID_AIR_DATA: //171
mavlink_msg_air_data_decode(&message,&mlAirData);
case MAVLINK_MSG_ID_AIR_DATA: //171
mavlink_msg_air_data_decode(&message,&mlAirData);
break;
case MAVLINK_MSG_ID_SENSOR_BIAS: //172
mavlink_msg_sensor_bias_decode(&message,&mlSensorBiasData);
break;
case MAVLINK_MSG_ID_SENSOR_BIAS: //172
mavlink_msg_sensor_bias_decode(&message,&mlSensorBiasData);
break;
case MAVLINK_MSG_ID_DIAGNOSTIC: //173
mavlink_msg_diagnostic_decode(&message,&mlDiagnosticData);
break;
case MAVLINK_MSG_ID_DIAGNOSTIC: //173
mavlink_msg_diagnostic_decode(&message,&mlDiagnosticData);
break;
case MAVLINK_MSG_ID_PILOT_CONSOLE: //174
mavlink_msg_pilot_console_decode(&message,&mlPilotConsoleData);
case MAVLINK_MSG_ID_PILOT_CONSOLE: //174
mavlink_msg_pilot_console_decode(&message,&mlPilotConsoleData);
break;
case MAVLINK_MSG_ID_PWM_COMMANDS: //175
mavlink_msg_pwm_commands_decode(&message,&mlPwmCommands);
break;
case MAVLINK_MSG_ID_PWM_COMMANDS: //175
mavlink_msg_pwm_commands_decode(&message,&mlPwmCommands);
break;
case MAVLINK_MSG_ID_SLUGS_NAVIGATION://176
mavlink_msg_slugs_navigation_decode(&message,&mlNavigation);
case MAVLINK_MSG_ID_SLUGS_NAVIGATION://176
mavlink_msg_slugs_navigation_decode(&message,&mlNavigation);
break;
case MAVLINK_MSG_ID_DATA_LOG: //177
mavlink_msg_data_log_decode(&message,&mlDataLog);
break;
case MAVLINK_MSG_ID_DATA_LOG: //177
mavlink_msg_data_log_decode(&message,&mlDataLog);
break;
case MAVLINK_MSG_ID_FILTERED_DATA: //178
mavlink_msg_filtered_data_decode(&message,&mlFilteredData);
break;
case MAVLINK_MSG_ID_FILTERED_DATA: //178
mavlink_msg_filtered_data_decode(&message,&mlFilteredData);
break;
case MAVLINK_MSG_ID_GPS_DATE_TIME: //179
mavlink_msg_gps_date_time_decode(&message,&mlGpsDateTime);
case MAVLINK_MSG_ID_GPS_DATE_TIME: //179
mavlink_msg_gps_date_time_decode(&message,&mlGpsDateTime);
break;
case MAVLINK_MSG_ID_MID_LVL_CMDS: //180
case MAVLINK_MSG_ID_MID_LVL_CMDS: //180
break;
break;
case MAVLINK_MSG_ID_CTRL_SRFC_PT: //181
case MAVLINK_MSG_ID_CTRL_SRFC_PT: //181
break;
case MAVLINK_MSG_ID_PID: //182
memset(&mlSinglePid,0,sizeof(mavlink_pid_t));
mavlink_msg_pid_decode(&message, &mlSinglePid);
qDebug() << "\nSLUGS RECEIVED PID Message = "<<mlSinglePid.idx;
case MAVLINK_MSG_ID_PID: //182
memset(&mlSinglePid,0,sizeof(mavlink_pid_t));
mavlink_msg_pid_decode(&message, &mlSinglePid);
qDebug() << "\nSLUGS RECEIVED PID Message = "<<mlSinglePid.idx;
emit slugsPidValues(uasId, mlSinglePid);
emit slugsPidValues(uasId, mlSinglePid);
break;
break;
case MAVLINK_MSG_ID_SLUGS_ACTION: //183
case MAVLINK_MSG_ID_SLUGS_ACTION: //183
break;
break;
#endif
default:
// qDebug() << "\nSLUGS RECEIVED MESSAGE WITH ID" << message.msgid;
default:
// qDebug() << "\nSLUGS RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
}
}
......
......@@ -211,7 +211,7 @@ public slots:
void addLink(LinkInterface* link);
/** @brief Receive a message from one of the communication links. */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
virtual void receiveMessage(LinkInterface* link, mavlink_message_t message);
/** @brief Send a message over this link (to this or to all UAS on this link) */
void sendMessage(LinkInterface* link, mavlink_message_t message);
......
......@@ -38,6 +38,7 @@ This file is part of the PIXHAWK project
#include "HDDisplay.h"
#include "ui_HDDisplay.h"
#include "MG.h"
#include "QGC.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
......@@ -171,6 +172,9 @@ void HDDisplay::paintEvent(QPaintEvent * event)
void HDDisplay::renderOverlay()
{
#if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif
quint64 refreshInterval = 100;
quint64 currTime = MG::TIME::getGroundTimeNow();
if (currTime - lastPaintTime < refreshInterval)
......@@ -227,20 +231,17 @@ void HDDisplay::renderOverlay()
void HDDisplay::setActiveUAS(UASInterface* uas)
{
//qDebug() << "ATTEMPTING TO SET UAS";
if (this->uas != NULL && this->uas != uas)
if (this->uas != NULL)
{
// Disconnect any previously connected active MAV
disconnect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
disconnect(this->uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
}
// Now connect the new UAS
//if (this->uas != uas)
// {
//qDebug() << "UAS SET!" << "ID:" << uas->getUASID();
// Setup communication
connect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
//}
this->uas = uas;
}
......@@ -663,16 +664,19 @@ void HDDisplay::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
Q_UNUSED(event)
{
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
refreshTimer->start(updateInterval);
}
}
void HDDisplay::hideEvent(QHideEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event)
{
refreshTimer->stop();
}
}
......
......@@ -76,6 +76,7 @@ protected:
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent * event);
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
float refLineWidthToPen(float line);
float refToScreenX(float x);
float refToScreenY(float y);
......
This diff is collapsed.
......@@ -112,6 +112,7 @@ protected slots:
protected:
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
/** @brief Get color from GPS signal-to-noise colormap */
static QColor getColorForSNR(float snr);
/** @brief Metric world coordinates to metric body coordinates */
......
......@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASManager.h"
#include "HUD.h"
#include "MG.h"
#include "QGC.h"
// Fix for some platforms, e.g. windows
#ifndef GL_MULTISAMPLE
......@@ -179,16 +180,19 @@ void HUD::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
Q_UNUSED(event)
{
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
refreshTimer->start(updateInterval);
}
}
void HUD::hideEvent(QHideEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event)
{
refreshTimer->stop();
}
}
......@@ -561,6 +565,10 @@ void HUD::paintHUD()
// qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
// interval = MG::TIME::getGroundTimeNow();
#if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif
// Read out most important values to limit hash table lookups
static float roll = 0.0f;
static float pitch = 0.0f;
......
......@@ -118,8 +118,10 @@ protected:
float refLineWidthToPen(float line);
/** @brief Rotate a polygon around a point clockwise */
void rotatePolygonClockWiseRad(QPolygonF& p, float angle, QPointF origin);
/** @brief Override base class show */
/** @brief Start updating widget */
void showEvent(QShowEvent* event);
/** @brief Stop updating widget */
void hideEvent(QHideEvent* event);
static const int updateInterval = 50;
......
This diff is collapsed.
......@@ -63,7 +63,9 @@ This file is part of the QGROUNDCONTROL project
#include "HSIDisplay.h"
#include "QGCDataPlot2D.h"
#include "QGCRemoteControlView.h"
#if (defined Q_OS_MAC) | (defined _MSC_VER)
#include "QGCGoogleEarthView.h"
#endif
//#include "QMap3DWidget.h"
#include "SlugsDataSensorView.h"
#include "LogCompressor.h"
......@@ -148,8 +150,6 @@ public slots:
void loadWidgets();
/** @brief Load data view, allowing to plot flight data */
void loadDataView();
/** @brief Load data view, allowing to plot flight data */
void loadDataView(QString fileName);
......
......@@ -77,12 +77,15 @@ void ObjectDetectionView::changeEvent(QEvent *e)
void ObjectDetectionView::setUAS(UASInterface* uas)
{
//if (this->uas == NULL && uas != NULL)
//{
if (this->uas != NULL)
{
disconnect(this->uas, SIGNAL(patternDetected(int, QString, float, bool)), this, SLOT(newPattern(int, QString, float, bool)));
disconnect(this->uas, SIGNAL(letterDetected(int, QString, float, bool)), this, SLOT(newLetter(int, QString, float, bool)));
}
this->uas = uas;
connect(uas, SIGNAL(patternDetected(int, QString, float, bool)), this, SLOT(newPattern(int, QString, float, bool)));
connect(uas, SIGNAL(letterDetected(int, QString, float, bool)), this, SLOT(newLetter(int, QString, float, bool)));
//}
}
void ObjectDetectionView::newPattern(int uasId, QString patternPath, float confidence, bool detected)
......
......@@ -126,6 +126,13 @@ void QGCDataPlot2D::savePlot()
fileName = QFileDialog::getSaveFileName(
this, "Export File Name", QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
"PDF Documents (*.pdf);;SVG Images (*.svg)");
if (!fileName.contains("."))
{
// .csv is default extension
fileName.append(".pdf");
}
while(!(fileName.endsWith(".svg") || fileName.endsWith(".pdf")))
{
QMessageBox msgBox;
......@@ -262,7 +269,7 @@ void QGCDataPlot2D::selectFile()
// Let user select the log file name
//QDate date(QDate::currentDate());
// QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log")
fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), tr("."), tr("Logfile (*.txt)"));
fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), QString(), "Logfile (*.csv *.txt *.log)");
// Store reference to file
QFileInfo fileInfo(fileName);
......
......@@ -62,26 +62,38 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
horizontalLayout->addWidget(tree, 0, 0, 1, 3);
QPushButton* refreshButton = new QPushButton(tr("Refresh"));
refreshButton->setToolTip(tr("Load parameters currently in non-permanent memory of aircraft."));
refreshButton->setWhatsThis(tr("Load parameters currently in non-permanent memory of aircraft."));
connect(refreshButton, SIGNAL(clicked()), this, SLOT(requestParameterList()));
horizontalLayout->addWidget(refreshButton, 1, 0);
QPushButton* setButton = new QPushButton(tr("Transmit"));
setButton->setToolTip(tr("Set current parameters in non-permanent onboard memory"));
setButton->setWhatsThis(tr("Set current parameters in non-permanent onboard memory"));
connect(setButton, SIGNAL(clicked()), this, SLOT(setParameters()));
horizontalLayout->addWidget(setButton, 1, 1);
QPushButton* writeButton = new QPushButton(tr("Write (ROM)"));
writeButton->setToolTip(tr("Copy current parameters in non-permanent memory of the aircraft to permanent memory. Transmit your parameters first to write these."));
writeButton->setWhatsThis(tr("Copy current parameters in non-permanent memory of the aircraft to permanent memory. Transmit your parameters first to write these."));
connect(writeButton, SIGNAL(clicked()), this, SLOT(writeParameters()));
horizontalLayout->addWidget(writeButton, 1, 2);
QPushButton* readButton = new QPushButton(tr("Read (ROM)"));
readButton->setToolTip(tr("Copy parameters from permanent memory to non-permanent current memory of aircraft. DOES NOT update the parameters in this view, click refresh after copying them to get them."));
readButton->setWhatsThis(tr("Copy parameters from permanent memory to non-permanent current memory of aircraft. DOES NOT update the parameters in this view, click refresh after copying them to get them."));
connect(readButton, SIGNAL(clicked()), this, SLOT(readParameters()));
horizontalLayout->addWidget(readButton, 2, 2);
QPushButton* loadFileButton = new QPushButton(tr("Load File"));
loadFileButton->setToolTip(tr("Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them."));
loadFileButton->setWhatsThis(tr("Load parameters from a file on this computer in the view. To write them to the aircraft, use transmit after loading them."));
connect(loadFileButton, SIGNAL(clicked()), this, SLOT(loadParameters()));
horizontalLayout->addWidget(loadFileButton, 2, 0);
QPushButton* saveFileButton = new QPushButton(tr("Save File"));
saveFileButton->setToolTip(tr("Save parameters in this view to a file on this computer."));
saveFileButton->setWhatsThis(tr("Save parameters in this view to a file on this computer."));
connect(saveFileButton, SIGNAL(clicked()), this, SLOT(saveParameters()));
horizontalLayout->addWidget(saveFileButton, 2, 1);
......
......@@ -62,11 +62,9 @@ public slots:
void setLinkName(QString name);
void setupPortList();
protected slots:
protected:
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
protected:
bool userConfigured; ///< Switch to detect if current values are user-selected and shouldn't be overriden
private:
......
......@@ -43,6 +43,8 @@ This file is part of the PIXHAWK project
#include <MG.h>
#include <QPaintEngine>
#include "QGC.h"
/**
* @brief The default constructor
*
......@@ -55,7 +57,7 @@ maxTime(QUINT64_MIN),
maxInterval(MAX_STORAGE_INTERVAL),
timeScaleStep(DEFAULT_SCALE_INTERVAL), // 10 seconds
automaticScrollActive(false),
m_active(true),
m_active(false),
m_groundTime(true),
d_data(NULL),
d_curve(NULL)
......@@ -142,7 +144,7 @@ d_curve(NULL)
// Start QTimer for plot update
updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(paintRealtime()));
updateTimer->start(DEFAULT_REFRESH_RATE);
//updateTimer->start(DEFAULT_REFRESH_RATE);
// QwtPlot::setAutoReplot();
......@@ -155,6 +157,18 @@ LinechartPlot::~LinechartPlot()
removeAllData();
}
void LinechartPlot::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
updateTimer->start(DEFAULT_REFRESH_RATE);
}
void LinechartPlot::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
updateTimer->stop();
}
int LinechartPlot::getPlotId()
{
return this->plotid;
......@@ -184,6 +198,14 @@ double LinechartPlot::getMedian(QString id)
return data.value(id)->getMedian();
}
/**
* @param id curve identifier
*/
double LinechartPlot::getVariance(QString id)
{
return data.value(id)->getVariance();
}
int LinechartPlot::getAverageWindow()
{
return averageWindowSize;
......@@ -272,6 +294,14 @@ void LinechartPlot::enforceGroundTime(bool enforce)
m_groundTime = enforce;
}
/**
* @return True if the data points are stamped with the packet receive time
*/
bool LinechartPlot::groundTime()
{
return m_groundTime;
}
void LinechartPlot::addCurve(QString id)
{
QColor currentColor = getNextColor();
......@@ -454,6 +484,23 @@ bool LinechartPlot::isVisible(QString id)
return curves.value(id)->isVisible();
}
/**
* @return The visibility, true if it is visible, false otherwise
**/
bool LinechartPlot::anyCurveVisible()
{
bool visible = false;
foreach (QString key, curves.keys())
{
if (curves.value(key)->isVisible())
{
visible = true;
}
}
return visible;
}
/**
* @brief Allows to block interference of the automatic scrolling with user interaction
* When the plot is updated very fast (at 1 ms for example) with new data, it might
......@@ -580,6 +627,9 @@ void LinechartPlot::paintRealtime()
{
if (m_active)
{
#if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif
// Update plot window value to new max time if the last time was also the max time
windowLock.lock();
if (automaticScrollActive)
......@@ -701,8 +751,9 @@ TimeSeriesData::TimeSeriesData(QwtPlot* plot, QString friendlyName, quint64 plot
maxValue(DBL_MIN),
zeroValue(0),
count(0),
mean(0.00),
median(0.00),
mean(0.0),
median(0.0),
variance(0.0),
averageWindow(50)
{
this->plot = plot;
......@@ -760,6 +811,14 @@ void TimeSeriesData::append(quint64 ms, double value)
medianList.append(this->value[count-i]);
}
mean = mean / static_cast<double>(qMin(averageWindow,static_cast<unsigned int>(count)));
this->variance = 0;
for (unsigned int i = 0; (i < averageWindow) && (((int)count - (int)i) >= 0); ++i)
{
this->variance += (this->value[count-i] - mean) * (this->value[count-i] - mean);
}
this->variance = this->variance / static_cast<double>(qMin(averageWindow,static_cast<unsigned int>(count)));
qSort(medianList);
if (medianList.count() > 2)
......@@ -859,6 +918,14 @@ double TimeSeriesData::getMedian()
return median;
}
/**
* @return the variance
*/
double TimeSeriesData::getVariance()
{
return variance;
}
double TimeSeriesData::getCurrentValue()
{
return lastValue;
......
......@@ -132,6 +132,8 @@ public:
double getMean();
/** @brief Get the short-term median */
double getMedian();
/** @brief Get the short-term variance */
double getVariance();
/** @brief Get the current value */
double getCurrentValue();
void setZeroValue(double zeroValue);
......@@ -166,6 +168,7 @@ private:
QwtArray<double> value;
double mean;
double median;
double variance;
unsigned int averageWindow;
QwtArray<double> outputMs;
QwtArray<double> outputValue;
......@@ -190,6 +193,8 @@ public:
QList<QwtPlotCurve*> getCurves();
bool isVisible(QString id);
/** @brief Check if any curve is visible */
bool anyCurveVisible();
int getPlotId();
/** @brief Get the number of values to average over */
......@@ -206,6 +211,8 @@ public:
double getMean(QString id);
/** @brief Get the short-term median of a curve */
double getMedian(QString id);
/** @brief Get the short-term variance of a curve */
double getVariance(QString id);
/** @brief Get the last inserted value */
double getCurrentValue(QString id);
......@@ -214,8 +221,8 @@ public:
static const int SCALE_LOGARITHMIC = 2;
static const int DEFAULT_REFRESH_RATE = 50; ///< The default refresh rate is 25 Hz / every 100 ms
static const int DEFAULT_PLOT_INTERVAL = 1000 * 12; ///< The default plot interval is 15 seconds
static const int DEFAULT_SCALE_INTERVAL = 1000 * 5;
static const int DEFAULT_PLOT_INTERVAL = 1000 * 8; ///< The default plot interval is 15 seconds
static const int DEFAULT_SCALE_INTERVAL = 1000 * 8;
public slots:
void setRefreshRate(int ms);
......@@ -243,6 +250,8 @@ public slots:
/** @brief Enforce the use of the receive timestamp */
void enforceGroundTime(bool enforce);
/** @brief Check if the receive timestamp is enforced */
bool groundTime();
// General interaction
void setWindowPosition(quint64 end);
......@@ -301,6 +310,8 @@ protected:
// Methods
void addCurve(QString id);
QColor getNextColor();
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
private:
TimeSeriesData* d_data;
......
This diff is collapsed.
......@@ -77,8 +77,10 @@ public slots:
void setPlotWindowPosition(int scrollBarValue);
void setPlotWindowPosition(quint64 position);
void setPlotInterval(quint64 interval);
/** @brief Override base class show */
virtual void showEvent(QShowEvent* event);
/** @brief Start automatic updates once visible */
void showEvent(QShowEvent* event);
/** @brief Stop automatic updates once hidden */
void hideEvent(QHideEvent* event);
void setActive(bool active);
/** @brief Set the number of values to average over */
void setAverageWindow(int windowSize);
......@@ -107,6 +109,7 @@ protected:
QMap<QString, QLabel*>* curveLabels; ///< References to the curve labels
QMap<QString, QLabel*>* curveMeans; ///< References to the curve means
QMap<QString, QLabel*>* curveMedians; ///< References to the curve medians
QMap<QString, QLabel*>* curveVariances; ///< References to the curve variances
QWidget* curvesWidget; ///< The QWidget containing the curve selection button
QVBoxLayout* curvesWidgetLayout; ///< The layout for the curvesWidget QWidget
......@@ -129,6 +132,7 @@ protected:
bool logging;
QTimer* updateTimer;
LogCompressor* compressor;
quint64 logStartTime;
static const int MAX_CURVE_MENUITEM_NUMBER = 8;
static const int PAGESTEP_TIME_SCROLLBAR_VALUE = (MAX_TIME_SCROLLBAR_VALUE - MIN_TIME_SCROLLBAR_VALUE) / 10;
......
......@@ -10,28 +10,47 @@ Linecharts::Linecharts(QWidget *parent) :
plots(),
active(true)
{
this->setVisible(false);
// Get current MAV list
QList<UASInterface*> systems = UASManager::instance()->getUASList();
this->setVisible(false);
// Get current MAV list
QList<UASInterface*> systems = UASManager::instance()->getUASList();
// Add each of them
foreach (UASInterface* sys, systems)
{
addSystem(sys);
}
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
this, SLOT(addSystem(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)),
this, SLOT(selectSystem(int)));
connect(this, SIGNAL(logfileWritten(QString)),
MainWindow::instance(), SLOT(loadDataView(QString)));
// Add each of them
foreach (UASInterface* sys, systems)
{
addSystem(sys);
}
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
this, SLOT(addSystem(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)),
this, SLOT(selectSystem(int)));
connect(this, SIGNAL(logfileWritten(QString)),
MainWindow::instance(), SLOT(loadDataView(QString)));
}
void Linecharts::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
Q_UNUSED(event)
{
QWidget* prevWidget = currentWidget();
if (prevWidget)
{
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
if (chart)
{
this->active = true;
chart->setActive(true);
}
}
}
}
void Linecharts::hideEvent(QHideEvent* event)
{
// React only to internal (pre-display)
// events
Q_UNUSED(event)
{
QWidget* prevWidget = currentWidget();
if (prevWidget)
......@@ -39,16 +58,8 @@ void Linecharts::showEvent(QShowEvent* event)
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
if (chart)
{
if (event->type() == QEvent::Hide)
{
this->active = false;
chart->setActive(false);
}
else if (event->type() == QEvent::Show)
{
this->active = true;
chart->setActive(true);
}
this->active = false;
chart->setActive(false);
}
}
}
......
......@@ -26,8 +26,10 @@ public slots:
protected:
QMap<int, LinechartWidget*> plots;
bool active;
/** @brief Start updating widget */
void showEvent(QShowEvent* event);
/** @brief Stop updating widget */
void hideEvent(QHideEvent* event);
};
......
......@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project
*/
#include "Q3DWidget.h"
#include "QGC.h"
#include <osg/Geometry>
#include <osg/LineWidth>
......@@ -105,24 +106,23 @@ Q3DWidget::init(float fps)
cameraManipulator->setDistance(cameraParams.minZoomRange * 2.0);
connect(&timer, SIGNAL(timeout()), this, SLOT(redraw()));
timer.start(static_cast<int>(floorf(1000.0f / fps)));
// DO NOT START TIMER IN INITIALIZATION! IT IS STARTED IN THE SHOW EVENT
}
void Q3DWidget::showEvent(QShowEvent* event)
{
// React only to internal (pre/post-display)
// events
if (!event->spontaneous())
{
if (event->type() == QEvent::Hide)
{
timer.stop();
}
else if (event->type() == QEvent::Show)
{
timer.start(static_cast<int>(floorf(1000.0f / fps)));
}
}
Q_UNUSED(event)
timer.start(static_cast<int>(floorf(1000.0f / fps)));
}
void Q3DWidget::hideEvent(QHideEvent* event)
{
// React only to internal (pre/post-display)
// events
Q_UNUSED(event)
timer.stop();
}
osg::ref_ptr<osg::Geode>
......@@ -263,6 +263,9 @@ Q3DWidget::getGlobalCursorPosition(int32_t cursorX, int32_t cursorY, double z)
void
Q3DWidget::redraw(void)
{
#if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif
updateGL();
}
......
......@@ -122,8 +122,10 @@ protected slots:
protected:
/** @brief Enable / disable widget updating */
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
/**
* @brief Get base robot geode.
......
......@@ -2,8 +2,8 @@
#include <QDir>
#include <QShowEvent>
#include <QSettings>
#include <QAxObject>
#include <QUuid>
#include <QAxObject>
#include <QUuid>
#include <QDebug>
#include <QFile>
......@@ -16,6 +16,7 @@
#include "QGCWebPage.h"
#endif
#include "QGC.h"
#include "ui_QGCGoogleEarthView.h"
#include "QGCGoogleEarthView.h"
......@@ -102,7 +103,8 @@ QGCGoogleEarthView::~QGCGoogleEarthView()
void QGCGoogleEarthView::addUAS(UASInterface* uas)
{
#ifdef Q_OS_MAC
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg(uas->getColor().name()));
// uasid, type, color (in aarrbbgg format)
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg(uas->getColor().name().remove(0, 1).prepend("50")));
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
......@@ -134,6 +136,9 @@ void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, dou
Q_UNUSED(usec);
#ifdef Q_OS_MAC
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
//qDebug() << QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15);
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
......@@ -180,20 +185,17 @@ void QGCGoogleEarthView::setHome(double lat, double lon, double alt)
#endif
}
void QGCGoogleEarthView::hideEvent(QHideEvent* event)
{
Q_UNUSED(event) updateTimer->stop();
}
void QGCGoogleEarthView::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
Q_UNUSED(event)
{
if (event->type() == QEvent::Hide)
{
// Disable widget
updateTimer->stop();
qDebug() << "STOPPED GOOGLE EARTH UPDATES";
}
else if (event->type() == QEvent::Show)
{
// Enable widget, initialize on first run
if (!webViewInitialized)
{
......@@ -240,7 +242,6 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
QTimer::singleShot(1000, this, SLOT(initializeGoogleEarth()));
updateTimer->start(refreshRateMs);
}
}
}
}
......@@ -285,6 +286,9 @@ void QGCGoogleEarthView::initializeGoogleEarth()
void QGCGoogleEarthView::updateState()
{
#if (QGC_EVENTLOOP_DEBUG)
qDebug() << "EVENTLOOP:" << __FILE__ << __LINE__;
#endif
if (gEarthInitialized)
{
int uasId = 0;
......
......@@ -106,8 +106,10 @@ protected:
QWebView* webViewMac;
#endif
/** @brief Enable / disable widget updating */
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
private:
#ifdef _MSC_VER
......
This diff is collapsed.
......@@ -107,8 +107,10 @@ protected:
void enterEvent(QEvent* event);
/** @brief Mouse leaves the widget */
void leaveEvent(QEvent* event);
/** @brief Enable / disable widget updating */
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
private:
Ui::UASView *m_ui;
......
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