mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
New (better?) strategy for handling dial setting changes during a session: removed several weird artifacts, should be more solid & reliable.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@827 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2ff5424944
commit
99c2db99e3
@ -40,6 +40,7 @@ AirspeedGadgetWidget::AirspeedGadgetWidget(QWidget *parent) : QGraphicsView(pare
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
m_renderer = new QSvgRenderer();
|
||||
/*
|
||||
m_background = new QGraphicsSvgItem();
|
||||
// All other items will be clipped to the shape of the background
|
||||
m_background->setFlags(QGraphicsItem::ItemClipsChildrenToShape|
|
||||
@ -54,7 +55,7 @@ AirspeedGadgetWidget::AirspeedGadgetWidget(QWidget *parent) : QGraphicsView(pare
|
||||
m_needle3->setParentItem(m_background);
|
||||
|
||||
paint();
|
||||
|
||||
*/
|
||||
needle1Target = 0;
|
||||
needle2Target = 0;
|
||||
needle3Target = 0;
|
||||
@ -183,13 +184,21 @@ void AirspeedGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QStr
|
||||
n2enabled = false;
|
||||
n3enabled = false;
|
||||
QGraphicsScene *l_scene = scene();
|
||||
l_scene->removeItem(m_foreground);
|
||||
l_scene->removeItem(m_background);
|
||||
l_scene->removeItem(m_needle1);
|
||||
l_scene->removeItem(m_needle2);
|
||||
l_scene->removeItem(m_needle3);
|
||||
l_scene->clear(); // Deletes all items contained in the scene as well.
|
||||
m_background = new QGraphicsSvgItem();
|
||||
// All other items will be clipped to the shape of the background
|
||||
m_background->setFlags(QGraphicsItem::ItemClipsChildrenToShape|
|
||||
QGraphicsItem::ItemClipsToShape);
|
||||
m_foreground = new QGraphicsSvgItem();
|
||||
m_needle1 = new QGraphicsSvgItem();
|
||||
m_needle2 = new QGraphicsSvgItem();
|
||||
m_needle3 = new QGraphicsSvgItem();
|
||||
m_needle1->setParentItem(m_background);
|
||||
m_needle2->setParentItem(m_background);
|
||||
m_needle3->setParentItem(m_background);
|
||||
m_foreground->setParentItem(m_background);
|
||||
|
||||
// We assume the scene contains at least the background
|
||||
// We assume the dial contains at least the background
|
||||
// and needle1
|
||||
m_background->setSharedRenderer(m_renderer);
|
||||
m_background->setElementId(bg);
|
||||
@ -199,7 +208,6 @@ void AirspeedGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QStr
|
||||
m_needle1->setElementId(n1);
|
||||
l_scene->addItem(m_needle1);
|
||||
|
||||
|
||||
// The dial gadget allows Needle1 and Needle2 to be
|
||||
// the same element, for combined movement. Needle3
|
||||
// is always independent.
|
||||
@ -267,8 +275,6 @@ void AirspeedGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QStr
|
||||
}
|
||||
|
||||
l_scene->setSceneRect(m_background->boundingRect());
|
||||
m_renderer->setViewBox(m_background->boundingRect());
|
||||
|
||||
|
||||
// Now Initialize the center for all transforms of the dial needles to the
|
||||
// center of the background:
|
||||
@ -290,8 +296,6 @@ void AirspeedGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QStr
|
||||
m_needle3->setTransformOriginPoint(rectN.width()/2,rectN.height()/2);
|
||||
}
|
||||
|
||||
// Last: clip the display region to the rectangle of the background
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -300,7 +304,7 @@ void AirspeedGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QStr
|
||||
|
||||
void AirspeedGadgetWidget::paint()
|
||||
{
|
||||
QGraphicsScene *l_scene = scene();
|
||||
/* QGraphicsScene *l_scene = scene();
|
||||
l_scene->clear(); // Careful: clear() deletes the objects
|
||||
l_scene->addItem(m_background);
|
||||
l_scene->addItem(m_needle1);
|
||||
@ -308,6 +312,7 @@ void AirspeedGadgetWidget::paint()
|
||||
l_scene->addItem(m_needle3);
|
||||
l_scene->addItem(m_foreground);
|
||||
l_scene->setSceneRect(m_background->boundingRect());
|
||||
*/
|
||||
update();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user