Add helipad support to the diagram.
- stops crashes selecting a heliport.
This commit is contained in:
parent
b15e5f559f
commit
cfcdd9da45
3 changed files with 99 additions and 26 deletions
|
@ -111,6 +111,7 @@ void AirportDiagram::setAirport(FGAirportRef apt)
|
|||
m_runways.clear();
|
||||
m_approachDistanceNm = -1.0;
|
||||
m_parking.clear();
|
||||
m_helipads.clear();
|
||||
|
||||
if (apt) {
|
||||
buildTaxiways();
|
||||
|
@ -139,6 +140,11 @@ void AirportDiagram::setSelectedRunway(FGRunwayRef r)
|
|||
update();
|
||||
}
|
||||
|
||||
void AirportDiagram::setSelectedHelipad(FGHelipadRef pad)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AirportDiagram::setApproachExtensionDistance(double distanceNm)
|
||||
{
|
||||
m_approachDistanceNm = distanceNm;
|
||||
|
@ -181,6 +187,10 @@ void AirportDiagram::doComputeBounds()
|
|||
extendBounds(p.pt);
|
||||
}
|
||||
|
||||
Q_FOREACH(const HelipadData& p, m_helipads) {
|
||||
extendBounds(p.pt);
|
||||
}
|
||||
|
||||
if (m_selectedRunway && (m_approachDistanceNm > 0.0)) {
|
||||
double d = SG_NM_TO_METER * m_approachDistanceNm;
|
||||
QPointF pt = project(m_selectedRunway->pointOnCenterline(-d));
|
||||
|
@ -196,6 +206,14 @@ void AirportDiagram::addParking(FGParkingRef park)
|
|||
update();
|
||||
}
|
||||
|
||||
void AirportDiagram::addHelipad(FGHelipadRef pad)
|
||||
{
|
||||
HelipadData pd = { project(pad->geod()), pad };
|
||||
m_helipads.push_back(pd);
|
||||
recomputeBounds(false);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void AirportDiagram::paintContents(QPainter* p)
|
||||
{
|
||||
|
@ -215,7 +233,7 @@ void AirportDiagram::paintContents(QPainter* p)
|
|||
p->drawLine(t.p1, t.p2);
|
||||
}
|
||||
|
||||
|
||||
drawHelipads(p);
|
||||
drawParkings(p);
|
||||
|
||||
// runways
|
||||
|
@ -303,6 +321,20 @@ void AirportDiagram::paintContents(QPainter* p)
|
|||
}
|
||||
}
|
||||
|
||||
void AirportDiagram::drawHelipads(QPainter* painter)
|
||||
{
|
||||
QTransform t = painter->transform();
|
||||
QPixmap icon(":/heliport-icon");
|
||||
|
||||
QRect r = icon.rect();
|
||||
r.moveCenter(QPoint(0, 0));
|
||||
|
||||
Q_FOREACH(const HelipadData& p, m_helipads) {
|
||||
painter->setTransform(t);
|
||||
painter->translate(p.pt);
|
||||
painter->drawPixmap(r, icon);
|
||||
}
|
||||
}
|
||||
|
||||
void AirportDiagram::drawParkings(QPainter* painter)
|
||||
{
|
||||
|
|
|
@ -38,10 +38,13 @@ public:
|
|||
|
||||
void addRunway(FGRunwayRef rwy);
|
||||
void addParking(FGParkingRef park);
|
||||
|
||||
void addHelipad(FGHelipadRef pad);
|
||||
|
||||
FGRunwayRef selectedRunway() const;
|
||||
void setSelectedRunway(FGRunwayRef r);
|
||||
|
||||
void setSelectedHelipad(FGHelipadRef pad);
|
||||
|
||||
void setApproachExtensionDistance(double distanceNm);
|
||||
Q_SIGNALS:
|
||||
void clickedRunway(FGRunwayRef rwy);
|
||||
|
@ -61,6 +64,7 @@ private:
|
|||
|
||||
void drawILS(QPainter *painter, FGRunwayRef runway) const;
|
||||
void drawParkings(QPainter *p);
|
||||
void drawHelipads(QPainter *painter);
|
||||
|
||||
FGAirportRef m_airport;
|
||||
|
||||
|
@ -93,6 +97,14 @@ private:
|
|||
|
||||
QVector<ParkingData> m_parking;
|
||||
|
||||
struct HelipadData
|
||||
{
|
||||
QPointF pt;
|
||||
FGHelipadRef parking;
|
||||
};
|
||||
|
||||
QVector<HelipadData> m_helipads;
|
||||
|
||||
QPainterPath m_parkingIconPath, // arrow points right
|
||||
m_parkingIconLeftPath; // arrow points left
|
||||
double m_approachDistanceNm;
|
||||
|
|
|
@ -527,24 +527,35 @@ void LocationWidget::setLocationOptions()
|
|||
opt->addOption("airport", apt->ident());
|
||||
|
||||
if (m_ui->runwayRadio->isChecked()) {
|
||||
int index = m_ui->runwayCombo->itemData(m_ui->runwayCombo->currentIndex()).toInt();
|
||||
if (index >= 0) {
|
||||
// explicit runway choice
|
||||
FGRunwayRef runway = apt->getRunwayByIndex(index);
|
||||
opt->addOption("runway", runway->ident());
|
||||
if (apt->type() == FGPositioned::AIRPORT) {
|
||||
int index = m_ui->runwayCombo->itemData(m_ui->runwayCombo->currentIndex()).toInt();
|
||||
if (index >= 0) {
|
||||
// explicit runway choice
|
||||
FGRunwayRef runway = apt->getRunwayByIndex(index);
|
||||
opt->addOption("runway", runway->ident());
|
||||
|
||||
// set nav-radio 1 based on selected runway
|
||||
if (runway->ILS()) {
|
||||
double mhz = runway->ILS()->get_freq() / 100.0;
|
||||
QString navOpt = QString("%1:%2").arg(runway->headingDeg()).arg(mhz);
|
||||
opt->addOption("nav1", navOpt.toStdString());
|
||||
// set nav-radio 1 based on selected runway
|
||||
if (runway->ILS()) {
|
||||
double mhz = runway->ILS()->get_freq() / 100.0;
|
||||
QString navOpt = QString("%1:%2").arg(runway->headingDeg()).arg(mhz);
|
||||
opt->addOption("nav1", navOpt.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->onFinalCheckbox->isChecked()) {
|
||||
opt->addOption("glideslope", "3.0");
|
||||
double offsetNm = m_ui->approachDistanceSpin->value();
|
||||
opt->addOption("offset-distance", QString::number(offsetNm).toStdString());
|
||||
if (m_ui->onFinalCheckbox->isChecked()) {
|
||||
opt->addOption("glideslope", "3.0");
|
||||
double offsetNm = m_ui->approachDistanceSpin->value();
|
||||
opt->addOption("offset-distance", QString::number(offsetNm).toStdString());
|
||||
}
|
||||
} else if (apt->type() == FGPositioned::HELIPORT) {
|
||||
int index = m_ui->runwayCombo->itemData(m_ui->runwayCombo->currentIndex()).toInt();
|
||||
if (index >= 0) {
|
||||
// explicit pad choice
|
||||
FGHelipadRef pad = apt->getHelipadByIndex(index);
|
||||
opt->addOption("runway", pad->ident());
|
||||
}
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "implement me";
|
||||
}
|
||||
|
||||
} else if (m_ui->parkingRadio->isChecked()) {
|
||||
|
@ -667,12 +678,23 @@ void LocationWidget::onLocationChanged()
|
|||
|
||||
m_ui->runwayCombo->clear();
|
||||
m_ui->runwayCombo->addItem("Automatic", -1);
|
||||
for (unsigned int r=0; r<apt->numRunways(); ++r) {
|
||||
FGRunwayRef rwy = apt->getRunwayByIndex(r);
|
||||
// add runway with index as data role
|
||||
m_ui->runwayCombo->addItem(QString::fromStdString(rwy->ident()), r);
|
||||
|
||||
m_ui->airportDiagram->addRunway(rwy);
|
||||
if (apt->type() == FGPositioned::HELIPORT) {
|
||||
for (unsigned int r=0; r<apt->numHelipads(); ++r) {
|
||||
FGHelipadRef pad = apt->getHelipadByIndex(r);
|
||||
// add pad with index as data role
|
||||
m_ui->runwayCombo->addItem(QString::fromStdString(pad->ident()), r);
|
||||
|
||||
m_ui->airportDiagram->addHelipad(pad);
|
||||
}
|
||||
} else {
|
||||
for (unsigned int r=0; r<apt->numRunways(); ++r) {
|
||||
FGRunwayRef rwy = apt->getRunwayByIndex(r);
|
||||
// add runway with index as data role
|
||||
m_ui->runwayCombo->addItem(QString::fromStdString(rwy->ident()), r);
|
||||
|
||||
m_ui->airportDiagram->addRunway(rwy);
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->parkingCombo->clear();
|
||||
|
@ -817,10 +839,17 @@ void LocationWidget::updateDescription()
|
|||
if (m_ui->runwayRadio->isChecked()) {
|
||||
int comboIndex = m_ui->runwayCombo->currentIndex();
|
||||
int runwayIndex = m_ui->runwayCombo->itemData(comboIndex).toInt();
|
||||
// we can't figure out the active runway in the launcher (yet)
|
||||
FGRunwayRef rwy = (runwayIndex >= 0) ?
|
||||
apt->getRunwayByIndex(runwayIndex) : FGRunwayRef();
|
||||
m_ui->airportDiagram->setSelectedRunway(rwy);
|
||||
if (apt->type() == FGPositioned::HELIPORT) {
|
||||
m_ui->airportDiagram->setSelectedRunway(FGRunwayRef());
|
||||
FGHelipadRef pad = (runwayIndex >= 0) ?
|
||||
apt->getHelipadByIndex(runwayIndex) : FGHelipadRef();
|
||||
m_ui->airportDiagram->setSelectedHelipad(pad);
|
||||
} else {
|
||||
// we can't figure out the active runway in the launcher (yet)
|
||||
FGRunwayRef rwy = (runwayIndex >= 0) ?
|
||||
apt->getRunwayByIndex(runwayIndex) : FGRunwayRef();
|
||||
m_ui->airportDiagram->setSelectedRunway(rwy);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->onFinalCheckbox->isChecked()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue