]> git.mxchange.org Git - flightgear.git/commitdiff
Initial work on rendering parking locations.
authorJames Turner <zakalawe@mac.com>
Tue, 24 Nov 2015 20:58:01 +0000 (20:58 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 24 Nov 2015 21:46:14 +0000 (21:46 +0000)
src/GUI/AirportDiagram.cxx
src/GUI/AirportDiagram.hxx

index dea718e54bfb622d671eac649273c19efa1f30c4..d268bc2f9d9f3a37d6a8dac39ab0677f94aaa1e4 100644 (file)
@@ -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)
index 08898350e980f0f49dbb63155190a1a892848353..c5c87004dd62e26596d103a74c01a2803faa416f 100644 (file)
@@ -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<ParkingData> 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