From: James Turner Date: Sun, 15 Nov 2015 14:48:48 +0000 (+0000) Subject: Closed airport support. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eb06aeba9706e033ba377a04a98e829bf4e25c91;p=flightgear.git Closed airport support. --- diff --git a/src/Airports/airport.cxx b/src/Airports/airport.cxx index c20a96d44..56cdaf139 100644 --- a/src/Airports/airport.cxx +++ b/src/Airports/airport.cxx @@ -84,6 +84,7 @@ FGAirport::FGAirport( PositionedID aGuid, mThresholdDataLoaded(false), mILSDataLoaded(false) { + mIsClosed = (name.find("[x]") != std::string::npos); } diff --git a/src/Airports/airport.hxx b/src/Airports/airport.hxx index b585d19d8..598a1df07 100644 --- a/src/Airports/airport.hxx +++ b/src/Airports/airport.hxx @@ -63,6 +63,14 @@ class FGAirport : public FGPositioned bool isSeaport() const; bool isHeliport() const; + /// is the airport closed (disused)? + /// note at rpesent we look for an [x] in the name, ideally the database + /// would explicitly include this + bool isClosed() const + { + return mIsClosed; + } + static bool isAirportType(FGPositioned* pos); virtual const std::string& name() const @@ -330,7 +338,7 @@ private: mutable bool mHelipadsLoaded; mutable bool mTaxiwaysLoaded; mutable bool mProceduresLoaded; - + bool mIsClosed; mutable bool mThresholdDataLoaded; bool mILSDataLoaded; diff --git a/src/GUI/BaseDiagram.cxx b/src/GUI/BaseDiagram.cxx index 663f54cb0..e76c41720 100644 --- a/src/GUI/BaseDiagram.cxx +++ b/src/GUI/BaseDiagram.cxx @@ -137,6 +137,8 @@ public: { // addType(FGPositioned::FIX); addType(FGPositioned::AIRPORT); + addType(FGPositioned::HELIPORT); + addType(FGPositioned::SEAPORT); addType(FGPositioned::NDB); addType(FGPositioned::VOR); } @@ -211,6 +213,7 @@ void BaseDiagram::paintNavaids(QPainter* painter) QRect iconRect = pm.rect(); iconRect.moveCenter(loc.toPoint()); painter->drawPixmap(iconRect, pm); + bool isNDB = (ty == FGPositioned::NDB); // compute label text so we can measure it QString label; @@ -235,7 +238,7 @@ void BaseDiagram::paintNavaids(QPainter* painter) textBounds.size(), textFlags); - painter->setPen(QColor(0x03, 0x83, 0xbf)); + painter->setPen(isNDB ? QColor(0x9b, 0x5d, 0xa2) : QColor(0x03, 0x83, 0xbf)); painter->drawText(textBounds, textFlags, label); } } @@ -303,46 +306,57 @@ QRect BaseDiagram::labelPositioned(const QRect& itemRect, LabelPosition lp) const { const int SHORT_MARGIN = 4; - const int DIAGONAL_MARGIN = 20; + const int DIAGONAL_MARGIN = 12; + + QPoint topLeft = itemRect.topLeft(); switch (lp) { // cardinal compass points are short (close in) case LABEL_RIGHT: - return QRect(itemRect.right() + SHORT_MARGIN, - itemRect.center().y() - bounds.height() / 2, - bounds.width(), - bounds.height()); + topLeft = QPoint(itemRect.right() + SHORT_MARGIN, + itemRect.center().y() - bounds.height() / 2); + break; case LABEL_ABOVE: - return QRect(itemRect.center().x() - (bounds.width() / 2), - itemRect.top() - (SHORT_MARGIN + bounds.height()), - bounds.width(), - bounds.height()); + topLeft = QPoint(itemRect.center().x() - (bounds.width() / 2), + itemRect.top() - (SHORT_MARGIN + bounds.height())); + break; case LABEL_BELOW: - return QRect(itemRect.center().x() - (bounds.width() / 2), - itemRect.bottom() + SHORT_MARGIN, - bounds.width(), - bounds.height()); + topLeft = QPoint(itemRect.center().x() - (bounds.width() / 2), + itemRect.bottom() + SHORT_MARGIN); + break; case LABEL_LEFT: - return QRect(itemRect.left() - (SHORT_MARGIN + bounds.width()), - itemRect.center().y() - bounds.height() / 2, - bounds.width(), - bounds.height()); + topLeft = QPoint(itemRect.left() - (SHORT_MARGIN + bounds.width()), + itemRect.center().y() - bounds.height() / 2); + break; // first diagonals are further out (to hopefully have a better chance // of finding clear space case LABEL_NE: - return QRect(itemRect.right() + DIAGONAL_MARGIN, - itemRect.top() - (DIAGONAL_MARGIN + bounds.height()), - bounds.width(), - bounds.height()); + topLeft = QPoint(itemRect.right() + DIAGONAL_MARGIN, + itemRect.top() - (DIAGONAL_MARGIN + bounds.height())); + break; + case LABEL_NW: + topLeft = QPoint(itemRect.left() - (DIAGONAL_MARGIN + bounds.width()), + itemRect.top() - (DIAGONAL_MARGIN + bounds.height())); + break; + + case LABEL_SE: + topLeft = QPoint(itemRect.right() + DIAGONAL_MARGIN, + itemRect.bottom() + DIAGONAL_MARGIN); + break; + + case LABEL_SW: + topLeft = QPoint(itemRect.left() - (DIAGONAL_MARGIN + bounds.width()), + itemRect.bottom() + DIAGONAL_MARGIN); + break; default: qWarning() << Q_FUNC_INFO << "Implement me"; } - return QRect(itemRect.x(), itemRect.y(), bounds.width(), bounds.height()); + return QRect(topLeft, bounds); } void BaseDiagram::mousePressEvent(QMouseEvent *me) @@ -540,6 +554,10 @@ QPixmap BaseDiagram::iconForPositioned(const FGPositionedRef& pos, QPixmap BaseDiagram::iconForAirport(FGAirport* apt, const IconOptions& options) { + if (apt->isClosed()) { + return QPixmap(":/airport-closed-icon"); + } + if (!apt->hasHardRunwayOfLengthFt(1500)) { return QPixmap(apt->hasTower() ? ":/airport-tower-icon" : ":/airport-icon"); } diff --git a/src/GUI/airport-closed-icon.png b/src/GUI/airport-closed-icon.png new file mode 100644 index 000000000..45ee24077 Binary files /dev/null and b/src/GUI/airport-closed-icon.png differ diff --git a/src/GUI/resources.qrc b/src/GUI/resources.qrc index 6eb011e58..bc76f27b3 100644 --- a/src/GUI/resources.qrc +++ b/src/GUI/resources.qrc @@ -18,5 +18,6 @@ ndb-small-icon .png ndb-large-icon.png airplane-icon.png + airport-closed-icon.png