]> git.mxchange.org Git - flightgear.git/commitdiff
Closed airport support.
authorJames Turner <zakalawe@mac.com>
Sun, 15 Nov 2015 14:48:48 +0000 (14:48 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 23 Nov 2015 00:48:20 +0000 (00:48 +0000)
src/Airports/airport.cxx
src/Airports/airport.hxx
src/GUI/BaseDiagram.cxx
src/GUI/airport-closed-icon.png [new file with mode: 0644]
src/GUI/resources.qrc

index c20a96d447cad02537f94a5fc1dee85832a9b897..56cdaf139c7019ca77e0d3507dc097a3f65419dc 100644 (file)
@@ -84,6 +84,7 @@ FGAirport::FGAirport( PositionedID aGuid,
     mThresholdDataLoaded(false),
     mILSDataLoaded(false)
 {
+    mIsClosed = (name.find("[x]") != std::string::npos);
 }
 
 
index b585d19d84464df7a5b12adcb409ffc17cc687e9..598a1df07931ee2345513733ecb8f9e4c7fd5dd3 100644 (file)
@@ -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;
 
index 663f54cb0ae5d1f763c25dbb7c286011b984e204..e76c417207619cf6d4a595fb1cb0302032fb36ad 100644 (file)
@@ -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 (file)
index 0000000..45ee240
Binary files /dev/null and b/src/GUI/airport-closed-icon.png differ
index 6eb011e58bff5411fd406f45be2c8c95614c8eb2..bc76f27b382ac9938586c27ea16ca652a611ad83 100644 (file)
@@ -18,5 +18,6 @@
         <file alias="ndb-small-icon">ndb-small-icon .png</file>
         <file alias="ndb-large-icon">ndb-large-icon.png</file>
         <file alias="airplane-icon">airplane-icon.png</file>
+        <file alias="airport-closed-icon">airport-closed-icon.png</file>
     </qresource>
 </RCC>