From eb06aeba9706e033ba377a04a98e829bf4e25c91 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 15 Nov 2015 14:48:48 +0000 Subject: [PATCH] Closed airport support. --- src/Airports/airport.cxx | 1 + src/Airports/airport.hxx | 10 ++++- src/GUI/BaseDiagram.cxx | 64 ++++++++++++++++++++------------ src/GUI/airport-closed-icon.png | Bin 0 -> 949 bytes src/GUI/resources.qrc | 1 + 5 files changed, 52 insertions(+), 24 deletions(-) create mode 100644 src/GUI/airport-closed-icon.png 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 0000000000000000000000000000000000000000..45ee240771fdfdb199227f2140b02997908f75c5 GIT binary patch literal 949 zcmV;m14{gfP)0FfbXm1woCKcL1IOQpM$;doK^G>*L}Sv8bdoNHVVD_fr86W7E~-Wo6W!Vx8>z)&jFG6D#(>fm zM!w@hz{`NqcXe~#_dNHUlbb7mOy@g|Wz)j5?{@wMP>PkR=R#N892PaxF0e)b(5z(V z@J!TO-9&smzC?utkVzC$lHFHb<#v}B{Uauh0k>9$EA+i#gMG#B_foB?aBV|m$S=D$ z1(5DfS8bWAnKYvr*-ifes*oKwqe)WDvR`~ctL4!|VaQ`gHtCoGF0DN80Gc;O^y8wh zz3aL0_#ayUvhn;=l`zB3nA2eYSl3jrKHQOSc3#K89u1^#4r}3IU_zx>se0aB`If-V zBrcmV)?4g4wAqrm_T1J#&7Bi=eV{xO@pa8^E_AhR9Sr+egm(guXXAxeD`Dx5+#Sna zUpTXqLLUaK?elIS>KqmgHY|HyK5)9@CwyqP$qr`X`4?8bOf26L^7%mrQ!Yu)Td_-JkTFPQH)nusQ$1 zNPA%?KrWWM8@O|A9PCSFR@e%Kd)ZGpadkM8d;CcoQwGsq-HUl;B$P#-AIEH^ARx%hZ|$*{qSo`|p$nOMGM z11y$r5$=Hs7=~UP7#=7KAk~@**F_@V0NXbi=m(4oEB9yuZmA47bo@Xuc@#h=Vx{ZC z?#cuZ0)5Tqf1H1n%%+jMTve?-`%ms)a5bUdBQh?AYOS@mm^_ME8!+=fSTlz9xjOE} zxVBWbxBgyY6Q%ppRiU}+eTJeAS_~Rj!m}REB2D$CkdV2OR X@dQJ0=`QF?00000NkvXXu0mjfhtRq- literal 0 HcmV?d00001 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 -- 2.39.5