]> git.mxchange.org Git - flightgear.git/commitdiff
Move airplane drawing into the base class.
authorJames Turner <zakalawe@mac.com>
Sat, 14 Nov 2015 16:46:28 +0000 (16:46 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 23 Nov 2015 00:48:20 +0000 (00:48 +0000)
- ground work for showing airplane on airport diagram

src/GUI/AirportDiagram.cxx
src/GUI/BaseDiagram.cxx
src/GUI/BaseDiagram.hxx
src/GUI/NavaidDiagram.cxx

index 449957dfd9879982c726429c42684f2c9346c219..2fd2ce7e950644d40c80874690ff8a42bce067f4 100644 (file)
@@ -267,6 +267,10 @@ void AirportDiagram::paintContents(QPainter* p)
         p->setPen(pen);
         p->drawLine(pt, pt2);
     }
+
+
+  // aircraft pos and heading...
+ //   paintAirplaneIcon(painter, );
 }
 
 void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const
index bced50f42ceeda67d5fbe662a27eec17b49a0d9a..4c301a20ed86151d54d42e00faa8f1857e32568e 100644 (file)
@@ -115,6 +115,21 @@ void BaseDiagram::paintEvent(QPaintEvent* pe)
     paintContents(&p);
 }
 
+void BaseDiagram::paintAirplaneIcon(QPainter* painter, const SGGeod& geod, int headingDeg)
+{
+    QPointF pos = project(geod);
+    QPixmap pix(":/airplane-icon");
+    pos = painter->transform().map(pos);
+    painter->resetTransform();
+    painter->translate(pos.x(), pos.y());
+    painter->rotate(headingDeg);
+
+    painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
+    QRect airplaneIconRect = pix.rect();
+    airplaneIconRect.moveCenter(QPoint(0,0));
+    painter->drawPixmap(airplaneIconRect, pix);
+}
+
 class MapFilter : public FGPositioned::TypeFilter
 {
 public:
index 9c82d21abecf7dc50bfbcb73879249cb9e17352a..5bbd4bf83cce2f38c86e8bdcdf8dcd90d4830434 100644 (file)
@@ -76,6 +76,8 @@ protected:
     static QPointF project(const SGGeod &geod, const SGGeod &center);
 
     static SGGeod unproject(const QPointF &xy, const SGGeod &center);
+
+    void paintAirplaneIcon(QPainter *painter, const SGGeod &geod, int headingDeg);
 private:
     void paintNavaids(QPainter *p);
 
index 29857991e5cbd47b396d153574c8febe24b4887b..a621ebd05bf2b5049a5bbf92e74c76055084ff33 100644 (file)
@@ -83,8 +83,7 @@ void NavaidDiagram::paintContents(QPainter *painter)
 {
     QPointF base = project(m_geod);
 
-    QPointF airplaneIconPos = base;
-
+    SGGeod aircraftPos = m_geod;
     if (m_offsetEnabled) {
         double d = m_offsetDistanceNm * SG_NM_TO_METER;
         SGGeod offsetGeod = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
@@ -95,19 +94,10 @@ void NavaidDiagram::paintContents(QPainter *painter)
         painter->setPen(pen);
         painter->drawLine(base, offset);
 
-        airplaneIconPos = offset;
+        aircraftPos = offsetGeod;
     }
 
-    QPixmap pix(":/airplane-icon");
-    airplaneIconPos = painter->transform().map(airplaneIconPos);
-    painter->resetTransform();
-    painter->translate(airplaneIconPos.x(), airplaneIconPos.y());
-    painter->rotate(m_headingDeg);
-
-    painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
-    QRect airplaneIconRect = pix.rect();
-    airplaneIconRect.moveCenter(QPoint(0,0));
-    painter->drawPixmap(airplaneIconRect, pix);
+    paintAirplaneIcon(painter, aircraftPos, m_headingDeg);
 }
 
 void NavaidDiagram::doComputeBounds()