Initial work on rendering parking locations.
This commit is contained in:
parent
cc725c61de
commit
3cee5eea73
2 changed files with 65 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue