painter->drawLine(endR, endCentre);
}
+static double pointDistance(const QPointF& p1, const QPointF& p2)
+{
+ QPointF d = p2 - p1;
+ return ::sqrt((d.x() * d.x()) + (d.y() * d.y()));
+}
+
void AirportDiagram::mouseReleaseEvent(QMouseEvent* me)
{
if (m_didPan)
QTransform t(transform());
double minDist = std::numeric_limits<double>::max();
FGRunwayRef bestRunway;
-
+ FGHelipadRef bestHelipad;
+ FGParkingRef bestParking;
+
Q_FOREACH(const RunwayData& r, m_runways) {
QPointF p1(t.map(r.p1)), p2(t.map(r.p2));
double t;
minDist = d;
}
}
+
+ Q_FOREACH(const ParkingData& parking, m_parking) {
+ double d = pointDistance(me->pos(), t.map(parking.pt));
+ if (d < minDist) {
+ bestParking = parking.parking;
+ bestRunway.clear();
+ minDist = d;
+ }
+ }
+
+ Q_FOREACH(const HelipadData& pad, m_helipads) {
+ double d = pointDistance(me->pos(), t.map(pad.pt));
+ if (d < minDist) {
+ bestHelipad = pad.helipad;
+ bestRunway.clear();
+ bestParking.clear();
+ minDist = d;
+ }
+ }
+
if (minDist < 16.0) {
- emit clickedRunway(bestRunway);
+ if (bestRunway)
+ emit clickedRunway(bestRunway);
+ else if (bestParking)
+ emit clickedParking(bestParking);
+ else if (bestHelipad)
+ emit clickedHelipad(bestHelipad);
}
}
void setApproachExtensionDistance(double distanceNm);
Q_SIGNALS:
void clickedRunway(FGRunwayRef rwy);
-
+ void clickedHelipad(FGHelipadRef pad);
void clickedParking(FGParkingRef park);
protected:
struct HelipadData
{
QPointF pt;
- FGHelipadRef parking;
+ FGHelipadRef helipad;
};
QVector<HelipadData> m_helipads;
this, SLOT(updateDescription()));
connect(m_ui->airportDiagram, &AirportDiagram::clickedRunway,
- this, &LocationWidget::onAirportDiagramClicked);
+ this, &LocationWidget::onAirportRunwayClicked);
+ connect(m_ui->airportDiagram, &AirportDiagram::clickedParking,
+ this, &LocationWidget::onAirportParkingClicked);
connect(m_ui->locationSearchEdit, &QLineEdit::returnPressed,
this, &LocationWidget::onSearch);
updateDescription();
}
-void LocationWidget::onAirportDiagramClicked(FGRunwayRef rwy)
+void LocationWidget::onAirportRunwayClicked(FGRunwayRef rwy)
{
if (rwy) {
m_ui->runwayRadio->setChecked(true);
updateDescription();
}
+void LocationWidget::onAirportParkingClicked(FGParkingRef park)
+{
+ if (park) {
+ m_ui->parkingRadio->setChecked(true);
+ int parkingIndex = m_ui->parkingCombo->findText(QString::fromStdString(park->name()));
+ m_ui->parkingCombo->setCurrentIndex(parkingIndex);
+ m_ui->airportDiagram->setSelectedRunway(FGRunwayRef());
+ }
+
+ updateDescription();
+}
+
QString compassPointFromHeading(int heading)
{
const int labelArc = 360 / 8;
void onSearchResultSelected(const QModelIndex& index);
void onSearchComplete();
- void onAirportDiagramClicked(FGRunwayRef rwy);
+ void onAirportRunwayClicked(FGRunwayRef rwy);
+ void onAirportParkingClicked(FGParkingRef park);
+
void onOffsetBearingTrueChanged(bool on);
void addToRecent(FGPositionedRef pos);