1
0
Fork 0

Launcher: show selected parking in yellow.

This commit is contained in:
James Turner 2016-07-16 12:07:18 +01:00
parent 4aee633be3
commit 38202b0774
3 changed files with 87 additions and 37 deletions

View 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) {
@ -136,13 +135,25 @@ void AirportDiagram::setSelectedRunway(FGRunwayRef r)
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);
if (hdg > 180.0) {
hdg += 90;
useLeftIcon = true;
labelRect = QRect(22, -14, 40, 28);
} else {
hdg -= 90;
}
painter->rotate(hdg);
if (p.parking == m_selectedParking) {
painter->setBrush(Qt::yellow);
} else {
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()));
}
AirportDiagram::ParkingData AirportDiagram::findParkingData(const FGParkingRef &pk) const
{
Q_FOREACH(const ParkingData& p, m_parking) {
if (p.parking == m_selectedParking) {
return p;
}
}
return ParkingData();
}
void AirportDiagram::drawParkings(QPainter* painter) const
{
painter->save();
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;
if (p.parking == m_selectedParking) {
continue; // skip and draw last
}
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);
drawParking(painter, p);
}
painter->setTransform(t);
if (m_selectedParking) {
painter->setTransform(t);
drawParking(painter, findParkingData(m_selectedParking));
}
painter->restore();
}
void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const

View 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

View 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();