Navaid diagram work
This commit is contained in:
parent
c277395010
commit
adedf7af65
4 changed files with 72 additions and 13 deletions
|
@ -182,14 +182,7 @@ void AirportDiagram::addParking(FGParkingRef park)
|
|||
|
||||
void AirportDiagram::paintContents(QPainter* p)
|
||||
{
|
||||
// fit bounds within our available space, allowing for a margin
|
||||
// const int MARGIN = 32; // pixels
|
||||
// double ratioInX = (width() - MARGIN * 2) / m_bounds.width();
|
||||
// double ratioInY = (height() - MARGIN * 2) / m_bounds.height();
|
||||
// double scale = std::min(ratioInX, ratioInY);
|
||||
|
||||
QTransform t(transform());
|
||||
p->setTransform(t);
|
||||
QTransform t = p->transform();
|
||||
|
||||
// pavements
|
||||
QBrush brush(QColor(0x9f, 0x9f, 0x9f));
|
||||
|
|
|
@ -113,6 +113,9 @@ void BaseDiagram::wheelEvent(QWheelEvent *we)
|
|||
m_autoScalePan = false;
|
||||
|
||||
int delta = we->angleDelta().y();
|
||||
if (delta == 0)
|
||||
return;
|
||||
|
||||
if (intSign(m_wheelAngleDeltaAccumulator) != intSign(delta)) {
|
||||
m_wheelAngleDeltaAccumulator = 0;
|
||||
}
|
||||
|
@ -121,7 +124,7 @@ void BaseDiagram::wheelEvent(QWheelEvent *we)
|
|||
if (m_wheelAngleDeltaAccumulator > 120) {
|
||||
m_wheelAngleDeltaAccumulator = 0;
|
||||
m_scale *= 2.0;
|
||||
} else if (m_wheelAngleDeltaAccumulator < 120) {
|
||||
} else if (m_wheelAngleDeltaAccumulator < -120) {
|
||||
m_wheelAngleDeltaAccumulator = 0;
|
||||
m_scale *= 0.5;
|
||||
}
|
||||
|
|
|
@ -41,12 +41,71 @@ void NavaidDiagram::setNavaid(FGPositionedRef nav)
|
|||
{
|
||||
m_navaid = nav;
|
||||
m_projectionCenter = nav ? nav->geod() : SGGeod();
|
||||
m_scale = 1.0;
|
||||
m_bounds = QRectF(); // clear
|
||||
m_geod = nav->geod();
|
||||
recomputeBounds(true);
|
||||
}
|
||||
|
||||
void NavaidDiagram::setGeod(const SGGeod &geod)
|
||||
{
|
||||
m_navaid.clear();
|
||||
m_geod = geod;
|
||||
m_projectionCenter = m_geod;
|
||||
recomputeBounds(true);
|
||||
}
|
||||
|
||||
void NavaidDiagram::setOffsetEnabled(bool offset)
|
||||
{
|
||||
if (m_offsetEnabled == offset)
|
||||
return;
|
||||
m_offsetEnabled = offset;
|
||||
recomputeBounds(true);
|
||||
}
|
||||
|
||||
void NavaidDiagram::setOffsetDistanceNm(double distanceNm)
|
||||
{
|
||||
m_offsetDistanceNm = distanceNm;
|
||||
update();
|
||||
}
|
||||
|
||||
void NavaidDiagram::paintContents(QPainter *)
|
||||
void NavaidDiagram::setOffsetBearingDeg(int bearingDeg)
|
||||
{
|
||||
m_offsetBearingDeg = bearingDeg;
|
||||
update();
|
||||
}
|
||||
|
||||
void NavaidDiagram::paintContents(QPainter *painter)
|
||||
{
|
||||
QPointF base = project(m_geod);
|
||||
|
||||
if (m_offsetEnabled) {
|
||||
double d = m_offsetDistanceNm * SG_NM_TO_METER;
|
||||
SGGeod offsetGeod = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
|
||||
QPointF offset = project(offsetGeod);
|
||||
|
||||
qDebug() << base << offset;
|
||||
|
||||
QPen pen(Qt::green);
|
||||
pen.setCosmetic(true);
|
||||
painter->setPen(pen);
|
||||
painter->drawLine(base, offset);
|
||||
}
|
||||
}
|
||||
|
||||
void NavaidDiagram::doComputeBounds()
|
||||
{
|
||||
extendBounds(project(m_geod));
|
||||
|
||||
// project three points around the base location at 40nm to give some
|
||||
// coverage
|
||||
for (int i=0; i<3; ++i) {
|
||||
SGGeod pt = SGGeodesy::direct(m_geod, i * 120, SG_NM_TO_METER * 40.0);
|
||||
extendBounds(project(pt));
|
||||
}
|
||||
|
||||
if (m_offsetEnabled) {
|
||||
double d = m_offsetDistanceNm * SG_NM_TO_METER;
|
||||
SGGeod offsetPos = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
|
||||
extendBounds(project(offsetPos));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,8 +35,10 @@ public:
|
|||
|
||||
void setNavaid(FGPositionedRef nav);
|
||||
|
||||
void setGeod(const SGGeod& geod);
|
||||
|
||||
bool isOffsetEnabled() const;
|
||||
void setOffsetEnabled(bool m_offset);
|
||||
void setOffsetEnabled(bool offset);
|
||||
|
||||
void setOffsetDistanceNm(double distanceNm);
|
||||
double offsetDistanceNm() const;
|
||||
|
@ -49,8 +51,10 @@ public:
|
|||
protected:
|
||||
void paintContents(QPainter *) Q_DECL_OVERRIDE;
|
||||
|
||||
void doComputeBounds() Q_DECL_OVERRIDE;
|
||||
private:
|
||||
FGPositionedRef m_navaid;
|
||||
SGGeod m_geod;
|
||||
|
||||
bool m_offsetEnabled;
|
||||
double m_offsetDistanceNm;
|
||||
|
|
Loading…
Add table
Reference in a new issue