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

OP-960 Prevent a warning to appear each time an alarm not in svg is received

+review OPReview
This commit is contained in:
Alessio Morale 2013-05-21 00:15:18 +02:00
parent 0798d8e330
commit 81e10c9d1b
2 changed files with 28 additions and 20 deletions

View File

@ -48,7 +48,7 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV
background = new QGraphicsSvgItem(); background = new QGraphicsSvgItem();
foreground = new QGraphicsSvgItem(); foreground = new QGraphicsSvgItem();
nolink = new QGraphicsSvgItem(); nolink = new QGraphicsSvgItem();
missingElements = new QStringList();
paint(); paint();
// Now connect the widget to the SystemAlarms UAVObject // Now connect the widget to the SystemAlarms UAVObject
@ -100,26 +100,32 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject *systemAlarm)
for (uint i = 0; i < field->getNumElements(); ++i) { for (uint i = 0; i < field->getNumElements(); ++i) {
QString element = field->getElementNames()[i]; QString element = field->getElementNames()[i];
QString value = field->getValue(i).toString(); QString value = field->getValue(i).toString();
if (m_renderer->elementExists(element)) { if (!missingElements->contains(element)){
QMatrix blockMatrix = m_renderer->matrixForElement(element); if (m_renderer->elementExists(element)) {
qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x(); QMatrix blockMatrix = m_renderer->matrixForElement(element);
qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y(); qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x();
QString element2 = element + "-" + value; qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y();
if (m_renderer->elementExists(element2)) { QString element2 = element + "-" + value;
QGraphicsSvgItem *ind = new QGraphicsSvgItem(); if (!missingElements->contains(element2)) {
ind->setSharedRenderer(m_renderer); if (m_renderer->elementExists(element2)) {
ind->setElementId(element2); QGraphicsSvgItem *ind = new QGraphicsSvgItem();
ind->setParentItem(background); ind->setSharedRenderer(m_renderer);
QTransform matrix; ind->setElementId(element2);
matrix.translate(startX, startY); ind->setParentItem(background);
ind->setTransform(matrix, false); QTransform matrix;
} else { matrix.translate(startX, startY);
if (value.compare("Uninitialised") != 0) { ind->setTransform(matrix, false);
qDebug() << "Warning: element " << element2 << " not found in SVG."; } else {
if (value.compare("Uninitialised") != 0) {
missingElements->append(element2);
qDebug() << "Warning: element " << element2 << " not found in SVG.";
}
}
} }
} else {
missingElements->append(element);
qDebug() << "Warning: Element " << element << " not found in SVG.";
} }
} else {
qDebug() << "Warning: Element " << element << " not found in SVG.";
} }
} }
} }
@ -133,6 +139,8 @@ SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
void SystemHealthGadgetWidget::setSystemFile(QString dfn) void SystemHealthGadgetWidget::setSystemFile(QString dfn)
{ {
// Clear the list of elements not found on svg
missingElements->clear();
setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor())); setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor()));
if (QFile::exists(dfn)) { if (QFile::exists(dfn)) {
m_renderer->load(dfn); m_renderer->load(dfn);

View File

@ -64,7 +64,7 @@ private:
QGraphicsSvgItem *background; QGraphicsSvgItem *background;
QGraphicsSvgItem *foreground; QGraphicsSvgItem *foreground;
QGraphicsSvgItem *nolink; QGraphicsSvgItem *nolink;
QStringList *missingElements;
// Simple flag to skip rendering if the // Simple flag to skip rendering if the
bool fgenabled; // layer does not exist. bool fgenabled; // layer does not exist.