]> git.mxchange.org Git - flightgear.git/commitdiff
Launcher: show selected parking in yellow.
authorJames Turner <zakalawe@mac.com>
Sat, 16 Jul 2016 11:07:18 +0000 (12:07 +0100)
committerRoland Haeder <roland@mxchange.org>
Thu, 22 Sep 2016 21:27:47 +0000 (23:27 +0200)
src/GUI/AirportDiagram.cxx
src/GUI/AirportDiagram.hxx
src/GUI/LocationWidget.cxx

index 4e23b072b4a8e2fe86d1f1e4b5e89d0211c4319e..6f33a82fbafa6f5b6ceac332da19faa98d447cb8 100644 (file)
@@ -109,8 +109,7 @@ void AirportDiagram::setAirport(FGAirportRef apt)
     m_airport = apt;
     m_projectionCenter = apt ? apt->geod() : SGGeod();
     m_runways.clear();
-    m_approachDistanceNm = -1.0;
-    m_parking.clear();
+    m_approachDistanceNm = -1.0;    m_parking.clear();
     m_helipads.clear();
 
     if (apt) {
@@ -135,14 +134,26 @@ void AirportDiagram::setSelectedRunway(FGRunwayRef r)
     if (r == m_selectedRunway) {
         return;
     }
-    
+
+    m_selectedParking.clear();
     m_selectedRunway = r;
     update();
 }
 
 void AirportDiagram::setSelectedHelipad(FGHelipadRef pad)
 {
+    qWarning() << Q_FUNC_INFO << "implement me";
+}
 
+void AirportDiagram::setSelectedParking(FGParkingRef park)
+{
+    if (m_selectedParking == park) {
+        return;
+    }
+
+    m_selectedRunway.clear();
+    m_selectedParking = park;
+    update();
 }
 
 void AirportDiagram::setApproachExtensionDistance(double distanceNm)
@@ -336,46 +347,76 @@ void AirportDiagram::drawHelipads(QPainter* painter)
     }
 }
 
-void AirportDiagram::drawParkings(QPainter* painter)
+void AirportDiagram::drawParking(QPainter* painter, const ParkingData& p) const
 {
-    QTransform t = painter->transform();
+    painter->translate(p.pt);
 
+    double hdg = p.parking->getHeading();
+    bool useLeftIcon = false;
+    QRect labelRect(-62, -14, 40, 28);
 
-    QFont f = painter->font();
-    f.setPixelSize(16);
-    painter->setFont(f);
+    if (hdg > 180.0) {
+        hdg += 90;
+        useLeftIcon = true;
+        labelRect = QRect(22, -14, 40, 28);
+    } else {
+        hdg -= 90;
+    }
 
-    Q_FOREACH(const ParkingData& p, m_parking) {
-        painter->setTransform(t);
-        painter->translate(p.pt);
+    painter->rotate(hdg);
+
+    if (p.parking == m_selectedParking) {
+        painter->setBrush(Qt::yellow);
+    } else {
+        painter->setBrush(QColor(255, 196, 196)); // kind of pink
+    }
 
-        double hdg = p.parking->getHeading();
-        bool useLeftIcon = false;
-        QRect labelRect(-62, -14, 40, 28);
+    painter->drawPath(useLeftIcon ? m_parkingIconLeftPath : m_parkingIconPath);
 
-        if (hdg > 180.0) {
-            hdg += 90;
-            useLeftIcon = true;
-            labelRect = QRect(22, -14, 40, 28);
-        } else {
-            hdg -= 90;
+    painter->fillRect(labelRect, Qt::white);
+
+    // draw text
+    painter->setPen(Qt::black);
+    painter->drawText(labelRect,
+                      Qt::AlignVCenter | Qt::AlignHCenter,
+                      QString::fromStdString(p.parking->name()));
+}
+
+AirportDiagram::ParkingData AirportDiagram::findParkingData(const FGParkingRef &pk) const
+{
+    Q_FOREACH(const ParkingData& p, m_parking) {
+        if (p.parking == m_selectedParking) {
+            return p;
         }
+    }
 
-        painter->rotate(hdg);
+    return ParkingData();
+}
 
-        painter->setBrush(QColor(255, 196, 196)); // kind of pink
-        painter->drawPath(useLeftIcon ? m_parkingIconLeftPath : m_parkingIconPath);
+void AirportDiagram::drawParkings(QPainter* painter) const
+{
+    painter->save();
+    QTransform t = painter->transform();
 
-        painter->fillRect(labelRect, Qt::white);
+    QFont f = painter->font();
+    f.setPixelSize(16);
+    painter->setFont(f);
+
+    Q_FOREACH(const ParkingData& p, m_parking) {
+        if (p.parking == m_selectedParking) {
+            continue; // skip and draw last
+        }
 
-        // draw text
-        painter->setPen(Qt::black);
-        painter->drawText(labelRect,
-                          Qt::AlignVCenter | Qt::AlignHCenter,
-                          QString::fromStdString(p.parking->name()));
+        painter->setTransform(t);
+        drawParking(painter, p);
+    }
+
+    if (m_selectedParking) {
+        painter->setTransform(t);
+        drawParking(painter, findParkingData(m_selectedParking));
     }
 
-    painter->setTransform(t);
+    painter->restore();
 }
 
 void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const
index 24c254b6a980b83a1cbf50621464deacfcf59e77..4778811003736f8d53e1100f615aa134214dd812 100644 (file)
@@ -44,6 +44,7 @@ public:
     void setSelectedRunway(FGRunwayRef r);
 
     void setSelectedHelipad(FGHelipadRef pad);
+    void setSelectedParking(FGParkingRef park);
 
     void setApproachExtensionDistance(double distanceNm);
 Q_SIGNALS:
@@ -59,12 +60,7 @@ protected:
     void doComputeBounds() Q_DECL_OVERRIDE;
 private:
 
-    void buildTaxiways();
-    void buildPavements();
 
-    void drawILS(QPainter *painter, FGRunwayRef runway) const;
-    void drawParkings(QPainter *p);
-    void drawHelipads(QPainter *painter);
 
     FGAirportRef m_airport;
 
@@ -105,10 +101,23 @@ private:
 
     QVector<HelipadData> m_helipads;
 
+    void buildTaxiways();
+    void buildPavements();
+
+    void drawILS(QPainter *painter, FGRunwayRef runway) const;
+
+    void drawParkings(QPainter *p) const;
+    void drawParking(QPainter *painter, const ParkingData &p) const;
+
+    ParkingData findParkingData(const FGParkingRef& pk) const;
+
+    void drawHelipads(QPainter *painter);
+
     QPainterPath m_parkingIconPath, // arrow points right
         m_parkingIconLeftPath; // arrow points left
     double m_approachDistanceNm;
     FGRunwayRef m_selectedRunway;
+    FGParkingRef m_selectedParking;
 };
 
 #endif // of GUI_AIRPORT_DIAGRAM_HXX
index 7c5ae624ecd806d934c4325c816a9b0f9f36f4e8..f09acbdd187ff79f298aa15d7ac9548dd86aa093 100644 (file)
@@ -764,7 +764,7 @@ void LocationWidget::onAirportParkingClicked(FGParkingRef park)
         m_ui->parkingRadio->setChecked(true);
         int parkingIndex = m_ui->parkingCombo->findData(park->getIndex());
         m_ui->parkingCombo->setCurrentIndex(parkingIndex);
-        m_ui->airportDiagram->setSelectedRunway(FGRunwayRef());
+        m_ui->airportDiagram->setSelectedParking(park);
     }
 
     updateDescription();