From 3cee5eea735545dddd0c1e5b9551d97cf8f79c2c Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 24 Nov 2015 20:58:01 +0000 Subject: [PATCH] Initial work on rendering parking locations. --- src/GUI/AirportDiagram.cxx | 60 ++++++++++++++++++++++++++++++++++++++ src/GUI/AirportDiagram.hxx | 7 +++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/GUI/AirportDiagram.cxx b/src/GUI/AirportDiagram.cxx index dea718e54..d268bc2f9 100644 --- a/src/GUI/AirportDiagram.cxx +++ b/src/GUI/AirportDiagram.cxx @@ -84,6 +84,19 @@ AirportDiagram::AirportDiagram(QWidget* pr) : BaseDiagram(pr), m_approachDistanceNm(-1.0) { + m_parkingIconPath.moveTo(0,0); + m_parkingIconPath.lineTo(-16, -16); + m_parkingIconPath.lineTo(-64, -16); + m_parkingIconPath.lineTo(-64, 16); + m_parkingIconPath.lineTo(-16, 16); + m_parkingIconPath.lineTo(0, 0); + + m_parkingIconLeftPath.moveTo(0,0); + m_parkingIconLeftPath.lineTo(16, -16); + m_parkingIconLeftPath.lineTo(64, -16); + m_parkingIconLeftPath.lineTo(64, 16); + m_parkingIconLeftPath.lineTo(16, 16); + m_parkingIconLeftPath.lineTo(0, 0); } AirportDiagram::~AirportDiagram() @@ -97,6 +110,7 @@ void AirportDiagram::setAirport(FGAirportRef apt) m_projectionCenter = apt ? apt->geod() : SGGeod(); m_runways.clear(); m_approachDistanceNm = -1.0; + m_parking.clear(); if (apt) { buildTaxiways(); @@ -201,6 +215,9 @@ void AirportDiagram::paintContents(QPainter* p) p->drawLine(t.p1, t.p2); } + + drawParkings(p); + // runways QFont f; f.setPixelSize(14); @@ -286,6 +303,49 @@ void AirportDiagram::paintContents(QPainter* p) } } + +void AirportDiagram::drawParkings(QPainter* painter) +{ + QTransform t = painter->transform(); + + + QFont f = painter->font(); + f.setPixelSize(16); + painter->setFont(f); + + Q_FOREACH(const ParkingData& p, m_parking) { + painter->setTransform(t); + painter->translate(p.pt); + + double hdg = p.parking->getHeading(); + bool useLeftIcon = false; + QRect labelRect(-62, -14, 40, 28); + + if (hdg > 180.0) { + hdg += 90; + useLeftIcon = true; + labelRect = QRect(22, -14, 40, 28); + } else { + hdg -= 90; + } + + painter->rotate(hdg); + + painter->setBrush(QColor(255, 196, 196)); // kind of pink + painter->drawPath(useLeftIcon ? m_parkingIconLeftPath : m_parkingIconPath); + + painter->fillRect(labelRect, Qt::white); + + // draw text + painter->setPen(Qt::black); + painter->drawText(labelRect, + Qt::AlignVCenter | Qt::AlignHCenter, + QString::fromStdString(p.parking->name())); + } + + painter->setTransform(t); +} + void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const { if (!runway) diff --git a/src/GUI/AirportDiagram.hxx b/src/GUI/AirportDiagram.hxx index 08898350e..c5c87004d 100644 --- a/src/GUI/AirportDiagram.hxx +++ b/src/GUI/AirportDiagram.hxx @@ -59,6 +59,9 @@ private: void buildTaxiways(); void buildPavements(); + void drawILS(QPainter *painter, FGRunwayRef runway) const; + void drawParkings(QPainter *p); + FGAirportRef m_airport; struct RunwayData { @@ -90,10 +93,10 @@ private: QVector m_parking; + QPainterPath m_parkingIconPath, // arrow points right + m_parkingIconLeftPath; // arrow points left double m_approachDistanceNm; FGRunwayRef m_selectedRunway; - - void drawILS(QPainter *painter, FGRunwayRef runway) const; }; #endif // of GUI_AIRPORT_DIAGRAM_HXX -- 2.39.2