1
0
Fork 0

Move airplane drawing into the base class.

- ground work for showing airplane on airport diagram
This commit is contained in:
James Turner 2015-11-14 16:46:28 +00:00
parent 6ec9c36afb
commit 317498fe4a
4 changed files with 24 additions and 13 deletions

View 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

View 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:

View 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);

View 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()