Move airplane drawing into the base class.
- ground work for showing airplane on airport diagram
This commit is contained in:
parent
6ec9c36afb
commit
317498fe4a
4 changed files with 24 additions and 13 deletions
|
@ -267,6 +267,10 @@ void AirportDiagram::paintContents(QPainter* p)
|
||||||
p->setPen(pen);
|
p->setPen(pen);
|
||||||
p->drawLine(pt, pt2);
|
p->drawLine(pt, pt2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// aircraft pos and heading...
|
||||||
|
// paintAirplaneIcon(painter, );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const
|
void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const
|
||||||
|
|
|
@ -115,6 +115,21 @@ void BaseDiagram::paintEvent(QPaintEvent* pe)
|
||||||
paintContents(&p);
|
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
|
class MapFilter : public FGPositioned::TypeFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -76,6 +76,8 @@ protected:
|
||||||
static QPointF project(const SGGeod &geod, const SGGeod ¢er);
|
static QPointF project(const SGGeod &geod, const SGGeod ¢er);
|
||||||
|
|
||||||
static SGGeod unproject(const QPointF &xy, const SGGeod ¢er);
|
static SGGeod unproject(const QPointF &xy, const SGGeod ¢er);
|
||||||
|
|
||||||
|
void paintAirplaneIcon(QPainter *painter, const SGGeod &geod, int headingDeg);
|
||||||
private:
|
private:
|
||||||
void paintNavaids(QPainter *p);
|
void paintNavaids(QPainter *p);
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,7 @@ void NavaidDiagram::paintContents(QPainter *painter)
|
||||||
{
|
{
|
||||||
QPointF base = project(m_geod);
|
QPointF base = project(m_geod);
|
||||||
|
|
||||||
QPointF airplaneIconPos = base;
|
SGGeod aircraftPos = m_geod;
|
||||||
|
|
||||||
if (m_offsetEnabled) {
|
if (m_offsetEnabled) {
|
||||||
double d = m_offsetDistanceNm * SG_NM_TO_METER;
|
double d = m_offsetDistanceNm * SG_NM_TO_METER;
|
||||||
SGGeod offsetGeod = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
|
SGGeod offsetGeod = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
|
||||||
|
@ -95,19 +94,10 @@ void NavaidDiagram::paintContents(QPainter *painter)
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->drawLine(base, offset);
|
painter->drawLine(base, offset);
|
||||||
|
|
||||||
airplaneIconPos = offset;
|
aircraftPos = offsetGeod;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap pix(":/airplane-icon");
|
paintAirplaneIcon(painter, aircraftPos, m_headingDeg);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavaidDiagram::doComputeBounds()
|
void NavaidDiagram::doComputeBounds()
|
||||||
|
|
Loading…
Add table
Reference in a new issue