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) {
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)
}
}
-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
void setSelectedRunway(FGRunwayRef r);
void setSelectedHelipad(FGHelipadRef pad);
+ void setSelectedParking(FGParkingRef park);
void setApproachExtensionDistance(double distanceNm);
Q_SIGNALS:
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;
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