1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-03 11:24:10 +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,11 +100,13 @@ 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 (!missingElements->contains(element)){
if (m_renderer->elementExists(element)) { if (m_renderer->elementExists(element)) {
QMatrix blockMatrix = m_renderer->matrixForElement(element); QMatrix blockMatrix = m_renderer->matrixForElement(element);
qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x(); qreal startX = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).x();
qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y(); qreal startY = blockMatrix.mapRect(m_renderer->boundsOnElement(element)).y();
QString element2 = element + "-" + value; QString element2 = element + "-" + value;
if (!missingElements->contains(element2)) {
if (m_renderer->elementExists(element2)) { if (m_renderer->elementExists(element2)) {
QGraphicsSvgItem *ind = new QGraphicsSvgItem(); QGraphicsSvgItem *ind = new QGraphicsSvgItem();
ind->setSharedRenderer(m_renderer); ind->setSharedRenderer(m_renderer);
@ -115,15 +117,19 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject *systemAlarm)
ind->setTransform(matrix, false); ind->setTransform(matrix, false);
} else { } else {
if (value.compare("Uninitialised") != 0) { if (value.compare("Uninitialised") != 0) {
missingElements->append(element2);
qDebug() << "Warning: element " << element2 << " not found in SVG."; qDebug() << "Warning: element " << element2 << " not found in SVG.";
} }
} }
}
} else { } else {
missingElements->append(element);
qDebug() << "Warning: Element " << element << " not found in SVG."; qDebug() << "Warning: Element " << element << " not found in SVG.";
} }
} }
} }
} }
}
SystemHealthGadgetWidget::~SystemHealthGadgetWidget() SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
{ {
@ -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.