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

OP-69: improve performance and memory usage.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1091 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-07-14 10:20:04 +00:00 committed by edouard
parent aa53b57d55
commit 72360c553c
2 changed files with 7 additions and 27 deletions

View File

@ -56,10 +56,6 @@ SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsV
SystemAlarms* obj = dynamic_cast<SystemAlarms*>(objManager->getObject(QString("SystemAlarms"))); SystemAlarms* obj = dynamic_cast<SystemAlarms*>(objManager->getObject(QString("SystemAlarms")));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateAlarms(UAVObject*))); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateAlarms(UAVObject*)));
// Test code for timer to move the index
testValue=0;
connect(&m_testTimer, SIGNAL(timeout()), this, SLOT(testRotate()));
m_testTimer.start(1000);
} }
void SystemHealthGadgetWidget::updateAlarms(UAVObject* systemAlarm) void SystemHealthGadgetWidget::updateAlarms(UAVObject* systemAlarm)
@ -69,10 +65,10 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject* systemAlarm)
// name, so it's just as simple to reset the scene: // name, so it's just as simple to reset the scene:
// And add the one with the right name. // And add the one with the right name.
QGraphicsScene *m_scene = scene(); QGraphicsScene *m_scene = scene();
foreach ( QGraphicsItem* item , m_scene->items()){ foreach ( QGraphicsItem* item ,background->childItems()){
m_scene->removeItem(item); m_scene->removeItem(item);
delete item; // removeItem does _not_ delete the item.
} }
m_scene->addItem(background);
QString alarm = systemAlarm->getName(); QString alarm = systemAlarm->getName();
foreach (UAVObjectField *field, systemAlarm->getFields()) { foreach (UAVObjectField *field, systemAlarm->getFields()) {
@ -88,19 +84,18 @@ void SystemHealthGadgetWidget::updateAlarms(UAVObject* systemAlarm)
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);
QTransform matrix; QTransform matrix;
matrix.translate(startX,startY); matrix.translate(startX,startY);
ind->setTransform(matrix,false); ind->setTransform(matrix,false);
m_scene->addItem(ind);
} else { } else {
std::cout << "Warning: element " << element2.toStdString() << " not found in SVG."<<std::endl; qDebug() << "Warning: element " << element2 << " not found in SVG.";
} }
} else { } else {
std::cout << "Warning: Element " << element.toStdString() << " not found in SVG." << std::endl; qDebug() << "Warning: Element " << element << " not found in SVG.";
} }
} }
} }
m_scene->addItem(foreground);
} }
SystemHealthGadgetWidget::~SystemHealthGadgetWidget() SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
@ -134,7 +129,7 @@ void SystemHealthGadgetWidget::setSystemFile(QString dfn)
} }
} }
else else
{ std::cout<<"no file: "<<std::endl; } { qDebug() <<"SystemHealthGadget: no file"; }
} }
void SystemHealthGadgetWidget::paint() void SystemHealthGadgetWidget::paint()
@ -150,7 +145,7 @@ void SystemHealthGadgetWidget::paintEvent(QPaintEvent *event)
{ {
// Skip painting until the dial file is loaded // Skip painting until the dial file is loaded
if (! m_renderer->isValid()) { if (! m_renderer->isValid()) {
std::cout<<"System file not loaded, not rendering"<<std::endl; qDebug() <<"SystemHealthGadget: System file not loaded, not rendering";
return; return;
} }
QGraphicsView::paintEvent(event); QGraphicsView::paintEvent(event);
@ -163,11 +158,3 @@ void SystemHealthGadgetWidget::resizeEvent(QResizeEvent *event)
{ {
fitInView(background, Qt::KeepAspectRatio ); fitInView(background, Qt::KeepAspectRatio );
} }
// Test function for timer to rotate needles
void SystemHealthGadgetWidget::test()
{
testValue=0;
}

View File

@ -53,8 +53,6 @@ protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
private slots: private slots:
// Test function
void test();
void updateAlarms(UAVObject *systemAlarm); // Called by the systemalarms UAVObject void updateAlarms(UAVObject *systemAlarm); // Called by the systemalarms UAVObject
private: private:
@ -65,10 +63,5 @@ private:
// 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.
// Test variables
double testValue;
QTimer m_testTimer;
// End test variables
}; };
#endif /* SYSTEMHEALTHGADGETWIDGET_H_ */ #endif /* SYSTEMHEALTHGADGETWIDGET_H_ */