1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Merge remote-tracking branch 'origin/andrecillo/OP-1283_SystemHealthGadgetWidget_updateAlarms_coordinate_calculation_correction' into next

This commit is contained in:
Alessio Morale 2014-04-01 22:11:32 +02:00
commit b58dd938d2

View File

@ -97,6 +97,8 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject *systemAlarm)
delete item; // removeItem does _not_ delete the item. delete item; // removeItem does _not_ delete the item.
} }
QMatrix backgroundMatrix = (m_renderer->matrixForElement(background->elementId())).inverted();
QString alarm = systemAlarm->getName(); QString alarm = systemAlarm->getName();
foreach(UAVObjectField * field, systemAlarm->getFields()) { foreach(UAVObjectField * field, systemAlarm->getFields()) {
for (uint i = 0; i < field->getNumElements(); ++i) { for (uint i = 0; i < field->getNumElements(); ++i) {
@ -104,18 +106,21 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject *systemAlarm)
QString value = field->getValue(i).toString(); QString value = field->getValue(i).toString();
if (!missingElements->contains(element)) { if (!missingElements->contains(element)) {
if (m_renderer->elementExists(element)) { if (m_renderer->elementExists(element)) {
QMatrix blockMatrix = m_renderer->matrixForElement(element);
qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x();
qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y();
QString element2 = element + "-" + value; QString element2 = element + "-" + value;
if (!missingElements->contains(element2)) { if (!missingElements->contains(element2)) {
if (m_renderer->elementExists(element2)) { if (m_renderer->elementExists(element2)) {
// element2 is in global coordinates
// transform its matrix into the coordinates of background
QMatrix blockMatrix = backgroundMatrix * m_renderer->matrixForElement(element2);
// use this composed projection to get the position in background coordinates
QRectF rectProjected = blockMatrix.mapRect(m_renderer->boundsOnElement(element2));
QGraphicsSvgItem *ind = new QGraphicsSvgItem(); QGraphicsSvgItem *ind = new QGraphicsSvgItem();
ind->setSharedRenderer(m_renderer); ind->setSharedRenderer(m_renderer);
ind->setElementId(element2); ind->setElementId(element2);
ind->setParentItem(background); ind->setParentItem(background);
QTransform matrix; QTransform matrix;
matrix.translate(startX, startY); matrix.translate(rectProjected.x(), rectProjected.y());
ind->setTransform(matrix, false); ind->setTransform(matrix, false);
} else { } else {
if (value.compare("Uninitialised") != 0) { if (value.compare("Uninitialised") != 0) {