Enroute Flight Navigation
A navigation app for VFR pilots
SideViewQuickItem.h
1/***************************************************************************
2 * Copyright (C) 2024 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QQmlEngine>
24#include <QtQuick/QQuickPaintedItem>
25#include <set>
26
27#include "GlobalObject.h"
28#include "PositionInfo.h"
29#include "GeoMapProvider.h"
30
31namespace Ui {
32
35
36class SideViewQuickItem : public QQuickPaintedItem
37{
38 Q_OBJECT
39 QML_NAMED_ELEMENT(SideView)
40
41public:
46 explicit SideViewQuickItem(QQuickItem *parent = nullptr);
47
52 void paint(QPainter *painter) override;
53
54private:
55 struct Airspace2D { //TODO: Rename later
56 GeoMaps::Airspace airspace;
57 int firstStep;
58 int lastStep;
59 QPolygon polygon;
60 bool operator<(const Airspace2D &other) const {
61 return GeoMaps::qHash(airspace) < GeoMaps::qHash(other.airspace);
62 }
63 };
64
65 struct MergedAirspace2D {
66 std::vector<Airspace2D> airspaces;
67 QString category;
68
69 };
70
71 void drawNoTrackAvailable(QPainter *painter);
72 void drawSky(QPainter *painter);
73 std::vector<int> getElevations(const Positioning::PositionInfo &info, double track, float steps, float stepSizeInMeter, float stepOffset);
74 int getHighestElevation(std::vector<int> &elevations, const Positioning::PositionInfo &info, float defaultUpperLimit);
75 std::vector<Airspace2D> get2dAirspaces(double track, float steps, float stepsBackwards, float stepSizeInMeter);
76 std::vector<MergedAirspace2D> mergedAirspaces2D(std::vector<Airspace2D> airspaces, std::vector<int> &elevations, float steps, int highestElevation);
77 std::vector<MergedAirspace2D> mergeAirspaces(std::vector<Airspace2D> mergedAirspaces);
78 void drawAirspacesOutline(QPainter *painter, const MergedAirspace2D &mergedAirspaces2D);
79 void drawAirspacesArea(QPainter *painter, const MergedAirspace2D &mergedAirspaces2D);
80 void drawAirspacesLabel(QPainter *painter, const MergedAirspace2D &mergedAirspaces2D);
81 void drawTerrain(QPainter *painter, const std::vector<int> &elevations, int highestElevation, float steps);
82 QStringList airspaceSortedCategories();
83 void drawAircraft(QPainter *painter, const Positioning::PositionInfo &info, int highestElevation, float steps, float stepsOffset);
84 void drawCurrentHorizontalPosition(QPainter *painter, const Positioning::PositionInfo &info, float steps, float stepsBackwards);
85 void drawFlightPath(QPainter *painter, const Positioning::PositionInfo &info, int highestElevation, float steps, float stepOffset);
86 int yCoordinate(int altitude, int maxHeight, int objectHeight);
87 int widgetHeight();
88 int widgetWidth();
89 Units::Distance pressureAltitude();
90 QPointF getPolygonCentroid(const QPolygonF &polygon);
91 Q_DISABLE_COPY_MOVE(SideViewQuickItem)
92
93};
94
95} // namespace Ui
A very simple class that describes an airspace.
Definition Airspace.h:33
void paint(QPainter *painter) override
Re-implemented from QQuickPaintedItem to implement painting.
SideViewQuickItem(QQuickItem *parent=nullptr)
Standard constructor.