From fd81fcf1f05b11fab678f8eb6cf90b9e940256af Mon Sep 17 00:00:00 2001 From: Niels Date: Thu, 4 Nov 2010 18:56:26 +0100 Subject: [PATCH] draw start and end markers only when they are set --- monavlayer.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/monavlayer.cpp b/monavlayer.cpp index 0d9bce7..9ec026b 100644 --- a/monavlayer.cpp +++ b/monavlayer.cpp @@ -111,16 +111,23 @@ void MonavLayer::paint(QPainter *painter) } } - QPoint p = map()->geo2screen(m_routeStart.x(), m_routeStart.y()); + QPoint p; QPolygon tri; - tri << p << p+QPoint(-5, -9) << p+QPoint(5, -9) << p; - painter->setBrush(Qt::red); - painter->drawPolygon(tri); - p = map()->geo2screen(m_routeEnd.x(), m_routeEnd.y()); - tri.clear(); - tri << p << p+QPoint(-5, -9) << p+QPoint(5, -9) << p; - painter->setBrush(Qt::blue); - painter->drawPolygon(tri); + + if (!m_routeStart.isNull()) { + p = map()->geo2screen(m_routeStart.x(), m_routeStart.y()); + tri << p << p+QPoint(-5, -9) << p+QPoint(5, -9) << p; + painter->setBrush(Qt::red); + painter->drawPolygon(tri); + } + + if (!m_routeEnd.isNull()) { + p = map()->geo2screen(m_routeEnd.x(), m_routeEnd.y()); + tri.clear(); + tri << p << p+QPoint(-5, -9) << p+QPoint(5, -9) << p; + painter->setBrush(Qt::blue); + painter->drawPolygon(tri); + } } void MonavLayer::keyPressed(QKeyEvent *event)