1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-1273 OP-1282 OP-1283 smal enhancements on SystemHealthGadgetWidget: Matrix inversion out of loop and mapRect called once

This commit is contained in:
Andres 2014-03-28 18:20:06 +01:00
parent a08b7ad21c
commit cf1c5b3f36

View File

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