Commit 39d9a923 authored by lm's avatar lm

Runtime issues resolved, quick application startup and good runtime stats:...

Runtime issues resolved, quick application startup and good runtime stats: 0.3% load in idle mode, 15% load showing map and UAS list. Map has a zooming issue, but should be resolvable
parent caaff76a
......@@ -58,7 +58,7 @@ DebugConsole::DebugConsole(QWidget *parent) :
snapShotBytes(0),
dataRate(0.0f),
lowpassDataRate(0.0f),
dataRateThreshold(500),
dataRateThreshold(400),
commandIndex(0),
m_ui(new Ui::DebugConsole)
{
......@@ -121,10 +121,10 @@ DebugConsole::DebugConsole(QWidget *parent) :
loadSettings();
// Warn user about not activated hold
if (!m_ui->holdCheckBox->isChecked()) {
m_ui->receiveText->appendHtml(QString("<font color=\"%1\">%2</font>\n").arg(QColor(Qt::red).name(), tr("WARNING: You have NOT enabled auto-hold (stops updating the console is huge amounts of serial data arrive). Updating the console consumes significant CPU load, so if you receive more than about 5 KB/s of serial data, make sure to enable auto-hold if not using the console.")));
}
// // Warn user about not activated hold
// if (!m_ui->holdCheckBox->isChecked()) {
// m_ui->receiveText->appendHtml(QString("<font color=\"%1\">%2</font>\n").arg(QColor(Qt::red).name(), tr("WARNING: You have NOT enabled auto-hold (stops updating the console if huge amounts of serial data arrive). Updating the console consumes significant CPU load, so if you receive more than about 5 KB/s of serial data, make sure to enable auto-hold if not using the console.")));
// }
}
void DebugConsole::hideEvent(QHideEvent* event)
......@@ -245,6 +245,17 @@ void DebugConsole::setAutoHold(bool hold)
if (m_ui->holdCheckBox->isChecked() != hold) {
m_ui->holdCheckBox->setChecked(hold);
}
if (!hold)
{
// Warn user about not activated hold
m_ui->receiveText->appendHtml(QString("<font color=\"%1\">%2</font>\n").arg(QColor(Qt::red).name(), tr("WARNING: You have NOT enabled auto-hold (stops updating the console if huge amounts of serial data arrive). Updating the console consumes significant CPU load, so if you receive more than about 5 KB/s of serial data, make sure to enable auto-hold if not using the console.")));
}
else
{
m_ui->receiveText->clear();
}
// Set new state
autoHold = hold;
}
......@@ -280,6 +291,8 @@ void DebugConsole::receiveTextMessage(int id, int component, int severity, QStri
}
m_ui->receiveText->appendHtml(QString("<font color=\"%1\">(%2:%3) %4</font>\n").arg(UASManager::instance()->getUASForId(id)->getColor().name(), name, comp, text));
// Ensure text area scrolls correctly
m_ui->receiveText->ensureCursorVisible();
}
}
......
......@@ -106,19 +106,6 @@ MainWindow::MainWindow(QWidget *parent):
loadStyle(currentStyle);
// // Set the application style (not the same as a style sheet)
// // Set the style to Plastique
// qApp->setStyle("plastique");
// // Set style sheet as last step
// QFile* styleSheet = new QFile(":/images/style-mission.css");
// if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
// {
// QString style = QString(styleSheet->readAll());
// style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "/images/");
// qApp->setStyleSheet(style);
// }
// Create actions
connectCommonActions();
......@@ -287,19 +274,27 @@ void MainWindow::buildCustomWidget()
for(int i = 0; i < widgets.size(); ++i) {
// Check if this widget already has a parent, do not create it in this case
QDockWidget* dock = dynamic_cast<QDockWidget*>(widgets.at(i)->parentWidget());
QGCToolWidget* tool = widgets.at(i);
QDockWidget* dock = dynamic_cast<QDockWidget*>(tool->parentWidget());
if (!dock) {
QDockWidget* dock = new QDockWidget(widgets.at(i)->windowTitle(), this);
dock->setObjectName(widgets.at(i)->objectName()+"_DOCK");
dock->setWidget(widgets.at(i));
connect(widgets.at(i), SIGNAL(destroyed()), dock, SLOT(deleteLater()));
QDockWidget* dock = new QDockWidget(tool->windowTitle(), this);
dock->setObjectName(tool->objectName()+"_DOCK");
dock->setWidget(tool);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this);
showAction->setCheckable(true);
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
widgets.at(i)->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
addDockWidget(Qt::BottomDockWidgetArea, dock);
// Load visibility for view (default is off)
dock->setVisible(tool->isVisible(currentView));
// Load dock widget location (default is bottom)
Qt::DockWidgetArea location = static_cast <Qt::DockWidgetArea>(tool->getDockWidgetArea(currentView));
addDockWidget(location, dock);
}
}
}
......
......@@ -524,10 +524,10 @@ QProgressBar::chunk#thrustBar {
<double>0.050000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
<double>5000.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
<double>1.000000000000000</double>
</property>
<property name="value">
<double>20.000000000000000</double>
......@@ -579,6 +579,9 @@ Time to stay at this position before advancing</string>
<property name="suffix">
<string> turns</string>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
......
......@@ -12,6 +12,20 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
firingWaypointChange(NULL),
maxUpdateInterval(2) // 2 seconds
{
// Widget is inactive until shown
}
QGCMapWidget::~QGCMapWidget()
{
SetShowHome(false); // doing this appears to stop the map lib crashing on exit
SetShowUAV(false); // " "
}
void QGCMapWidget::showEvent(QShowEvent* event)
{
// Pass on to parent widget
OPMapWidget::showEvent(event);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUASSet(UASInterface*)));
foreach (UASInterface* uas, UASManager::instance()->getUASList())
......@@ -94,14 +108,66 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
// Start timer
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateGlobalPosition()));
updateTimer.start(maxUpdateInterval*1000);
updateGlobalPosition();
QTimer::singleShot(300, this, SLOT(loadSettings()));
}
QGCMapWidget::~QGCMapWidget()
void QGCMapWidget::hideEvent(QHideEvent* event)
{
SetShowHome(false); // doing this appears to stop the map lib crashing on exit
SetShowUAV(false); // " "
storeSettings();
OPMapWidget::hideEvent(event);
}
void QGCMapWidget::loadSettings()
{
// Atlantic Ocean near Africa, coordinate origin
double lastZoom = 1;
double lastLat = 0;
double lastLon = 0;
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
lastLat = settings.value("LAST_LATITUDE", lastLat).toDouble();
lastLon = settings.value("LAST_LONGITUDE", lastLon).toDouble();
lastZoom = settings.value("LAST_ZOOM", lastZoom).toDouble();
settings.endGroup();
// SET INITIAL POSITION AND ZOOM
SetZoom(lastZoom); // set map zoom level
internals::PointLatLng pos_lat_lon = internals::PointLatLng(lastLat, lastLon);
SetCurrentPosition(pos_lat_lon); // set the map position
}
void QGCMapWidget::storeSettings()
{
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
internals::PointLatLng pos = CurrentPosition();
settings.setValue("LAST_LATITUDE", pos.Lat());
settings.setValue("LAST_LONGITUDE", pos.Lng());
settings.setValue("LAST_ZOOM", ZoomReal());
settings.endGroup();
settings.sync();
}
void QGCMapWidget::mouseDoubleClickEvent(QMouseEvent* event)
{
OPMapWidget::mouseDoubleClickEvent(event);
if (currEditMode == EDIT_MODE_WAYPOINTS)
{
// If a waypoint manager is available
if (currWPManager)
{
// Create new waypoint
internals::PointLatLng pos = this->currentMousePosition();
Waypoint* wp = currWPManager->createWaypoint();
wp->setLatitude(pos.Lat());
wp->setLongitude(pos.Lng());
}
}
}
/**
*
* @param uas the UAS/MAV to monitor/display with the HUD
......@@ -424,8 +490,7 @@ void QGCMapWidget::updateWaypointList(int uas)
{
waypointsToIcons.remove(wp);
iconsToWaypoints.remove(icon);
delete icon;
icon = NULL;
WPDelete(icon);
}
}
......
......@@ -52,6 +52,9 @@ public slots:
/** @brief Set update rate limit */
void setUpdateRateLimit(float seconds);
void loadSettings();
void storeSettings();
protected slots:
/** @brief Convert a map edit into a QGC waypoint event */
void handleMapWaypointEdit(WayPointItem* waypoint);
......@@ -59,7 +62,10 @@ protected slots:
protected:
/** @brief Update the highlighting of the currently controlled system */
void updateSelectedSystem(int uas);
/** @brief Set the current mouse position on the map as new home position */
/** @brief Initialize */
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
UASWaypointManager* currWPManager; ///< The current waypoint manager
QMap<Waypoint* , mapcontrol::WayPointItem*> waypointsToIcons;
......@@ -67,15 +73,17 @@ protected:
Waypoint* firingWaypointChange;
QTimer updateTimer;
float maxUpdateInterval;
// enum editMode {
// NONE,
// WAYPOINTS,
// SWEEP,
// UAVS,
// HOME,
// SAFE_AREA
// };
//editMode currEditMode; ///< The current edit mode on the map
enum editMode {
EDIT_MODE_NONE,
EDIT_MODE_WAYPOINTS,
EDIT_MODE_SWEEP,
EDIT_MODE_UAVS,
EDIT_MODE_HOME,
EDIT_MODE_SAFE_AREA,
EDIT_MODE_CACHING
};
editMode currEditMode; ///< The current edit mode on the map
};
......
......@@ -58,13 +58,36 @@ void Waypoint2DIcon::SetHeading(float heading)
void Waypoint2DIcon::updateWaypoint()
{
if (waypoint) {
// Store old size
static QRectF oldSize;
SetHeading(waypoint->getYaw());
SetCoord(internals::PointLatLng(waypoint->getLatitude(), waypoint->getLongitude()));
SetDescription(waypoint->getDescription());
SetAltitude(waypoint->getAltitude());
// FIXME Add SetNumber (currently needs a separate call)
drawIcon();
this->update();
QRectF newSize = boundingRect();
qDebug() << "WIDTH" << newSize.width() << "<" << oldSize.width();
// If new size is smaller than old size, update surrounding
if ((newSize.width() <= oldSize.width()) || (newSize.height() <= oldSize.height()))
{
// If the symbol size was reduced, enforce an update of the environment
// update(oldSize);
int oldWidth = oldSize.width() + 20;
int oldHeight = oldSize.height() + 20;
map->update(this->x()-10, this->y()-10, oldWidth, oldHeight);
qDebug() << "UPDATING DUE TO SMALLER SIZE";
qDebug() << "X:" << this->x()-1 << "Y:" << this->y()-1 << "WIDTH:" << oldWidth << "HEIGHT:" << oldHeight;
}
else
{
// Symbol size stayed constant or increased, use new size for update
this->update();
}
oldSize = boundingRect();
qDebug() << "UPDATING WP";
}
}
......@@ -89,6 +112,20 @@ QRectF Waypoint2DIcon::boundingRect() const
return QRectF(-width,-height,2*width,2*height);
}
void Waypoint2DIcon::SetReached(const bool &value)
{
// DO NOTHING
Q_UNUSED(value);
// reached=value;
// emit WPValuesChanged(this);
// if(value)
// picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
// else
// picture.load(QString::fromUtf8(":/markers/images/marker.png"));
// this->update();
}
void Waypoint2DIcon::drawIcon()
{
picture.fill(Qt::transparent);
......@@ -139,8 +176,8 @@ void Waypoint2DIcon::drawIcon()
(waypoint->getAction() != (int)MAV_CMD_NAV_TAKEOFF) &&
(waypoint->getAction() != (int)MAV_CMD_NAV_LAND) &&
(waypoint->getAction() != (int)MAV_CMD_NAV_LOITER_UNLIM) &&
(waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TIME) &&
(waypoint->getAction() == (int)MAV_CMD_NAV_LOITER_TURNS)
(waypoint->getAction() != (int)MAV_CMD_NAV_LOITER_TIME) &&
(waypoint->getAction() != (int)MAV_CMD_NAV_LOITER_TURNS)
)))
{
painter.drawLine(p.x(), p.y(), p.x()+sin(Heading()) * rad, p.y()-cos(Heading()) * rad);
......@@ -151,8 +188,8 @@ void Waypoint2DIcon::drawIcon()
// Takeoff waypoint
int width = (picture.width()-1);
int height = (picture.height()-1);
painter.drawRect(0, 0, 2*width, 2*height);
painter.drawRect(width*0.2, height*0.2f, 2*width*0.6f, 2*height*0.6f);
painter.drawRect(0, 0, width, height);
painter.drawRect(width*0.2, height*0.2f, width*0.6f, height*0.6f);
}
else if ((waypoint != NULL) && (waypoint->getAction() == (int)MAV_CMD_NAV_LAND))
{
......
......@@ -42,6 +42,8 @@ public:
void drawIcon();
/** @brief Draw the icon on a QPainter device (map) */
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
/** @brief UNUSED FUNCTION: Waypoints in QGC are purely passive */
void SetReached(const bool &value);
public:
void updateWaypoint();
......
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