From fd27a23225f10f8572e852f18b55ab472a2914ea Mon Sep 17 00:00:00 2001 From: Andres <> Date: Fri, 28 Mar 2014 18:16:03 +0100 Subject: [PATCH] OP-1283 Matrix inversion outside loop, mapRect called once --- .../plugins/systemhealth/systemhealthgadgetwidget.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp index f8882c875..2f78e8141 100644 --- a/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/systemhealth/systemhealthgadgetwidget.cpp @@ -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) {