Skip to content

Commit 1bc7093

Browse files
committed
Initial commit
0 parents  commit 1bc7093

File tree

126 files changed

+152074
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+152074
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.user

AUTHORS.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
AUTHORS
2+
3+
Marek M. Cel
4+
5+
SVG graphics
6+
7+
Dave Culp
8+
9+
PFD ILD identification and distance indicators.
10+
11+
Berk Bavas
12+
13+
QML Port of Marek M. Cel's work https://github.com/marek-cel/QFlightinstruments

Animation.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include "Animation.h"
2+
3+
#include <QDateTime>
4+
5+
Animation::Animation(QObject *parent)
6+
: QObject(parent)
7+
, mPlayTime(0.0)
8+
{
9+
connect(&mTimer, &QTimer::timeout, this, &Animation::update);
10+
}
11+
12+
void Animation::update()
13+
{
14+
quint64 currentTime = QDateTime::currentMSecsSinceEpoch();
15+
mPlayTime += (currentTime - mPreviousTime) / 1000.0;
16+
mPreviousTime = currentTime;
17+
18+
mPfd->setAngleOfAttack(21.0 * sin(mPlayTime / 10.0));
19+
mPfd->setAngleOfSideSlip(16.0 * sin(mPlayTime / 10.0));
20+
mPfd->setRoll(180.0 * sin(mPlayTime / 10.0));
21+
mPfd->setPitch(90.0 * sin(mPlayTime / 20.0));
22+
mPfd->setHeading(360.0 * sin(mPlayTime / 40.0));
23+
mPfd->setSlipSkid(1.0 * sin(mPlayTime / 10.0));
24+
mPfd->setTurnRate(1.0 * sin(mPlayTime / 10.0));
25+
mPfd->setIlsLOC(1.0 * sin(mPlayTime / 20.0));
26+
mPfd->setIlsGS(1.0 * sin(mPlayTime / 20.0));
27+
mPfd->setFdRoll(30.0 * sin(mPlayTime / 20.0));
28+
mPfd->setFdPitch(10.0 * sin(mPlayTime / 20.0));
29+
mPfd->setAirspeed(-100.0 * cos(mPlayTime / 10.0) + 100.0);
30+
mPfd->setAltitude(-5000.0 * cos(mPlayTime / 40.0) + 5000.0);
31+
mPfd->setPressure(2.0 * sin(mPlayTime / 20.0) + 30.0);
32+
mPfd->setClimbRate(6 * sin(mPlayTime / 20.0));
33+
mPfd->setMachNumber(mPfd->airspeed() / 650.0);
34+
mPfd->setHeadingBug(-360.0 * sin(mPlayTime / 40.0));
35+
mPfd->setCourse(360.0 * sin(mPlayTime / 20.0));
36+
mPfd->setVorDeviation(1.0 * sin(mPlayTime / 20.0));
37+
mPfd->setBearing(-360.0 * sin(mPlayTime / 50.0));
38+
mPfd->setDmeDistance(99.0 * sin(mPlayTime / 100.0));
39+
mPfd->setAirspeedBug(-50.0 * cos(mPlayTime / 10.0) + 50.0);
40+
mPfd->setAltitudeBug(-1000.0 * cos(mPlayTime / 40.0) + 1000.0);
41+
}
42+
43+
void Animation::init()
44+
{
45+
mPfd->setPressureMode(PrimaryFlightData::PressureMode::IN);
46+
mPfd->setFlightMode(PrimaryFlightData::FlightMode::FD);
47+
mPfd->setSpeedMode(PrimaryFlightData::SpeedMode::Off);
48+
mPfd->setLateralNavigationMode(PrimaryFlightData::LNAV::Off);
49+
mPfd->setVerticalNavigationMode(PrimaryFlightData::VNAV::Off);
50+
mPfd->setCourseDeviationIndicatorMode(PrimaryFlightData::CDI::Off);
51+
52+
mPfd->setStall(false);
53+
mPfd->setFdVisible(false);
54+
mPfd->setIlsGSVisible(false);
55+
mPfd->setIlsGSVisible(false);
56+
57+
mPreviousTime = QDateTime::currentMSecsSinceEpoch();
58+
mTimer.start(10);
59+
}
60+
61+
void Animation::setPfd(PrimaryFlightData *newPfd)
62+
{
63+
mPfd = newPfd;
64+
}

Animation.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef ANIMATION_H
2+
#define ANIMATION_H
3+
4+
#include "PrimaryFlightData.h"
5+
6+
#include <QObject>
7+
#include <QTimer>
8+
9+
class Animation : public QObject
10+
{
11+
Q_OBJECT
12+
public:
13+
explicit Animation(QObject *parent = nullptr);
14+
15+
void setPfd(PrimaryFlightData *newPfd);
16+
17+
public slots:
18+
void update();
19+
void init();
20+
21+
private:
22+
PrimaryFlightData *mPfd;
23+
QTimer mTimer;
24+
double mPlayTime;
25+
quint64 mPreviousTime;
26+
};
27+
28+
#endif // ANIMATION_H

BasicSix/AirspeedIndicator.qml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import QtQuick 2.0
2+
3+
Item {
4+
width: 2 * radius
5+
height: 2 * radius
6+
7+
required property double radius
8+
property double airspeed: 0
9+
property double angle: 0
10+
11+
onAirspeedChanged: update();
12+
13+
function update(){
14+
angle = airspeed
15+
16+
if (angle < 0.0) angle = 0.0
17+
else if (angle > 235.0) angle = 235.0
18+
19+
if (angle < 40.0) angle = 0.9 * angle
20+
else if (angle < 70.0) angle = 36.0 + 1.8 * (angle - 40.0)
21+
else if (angle < 130.0) angle = 90.0 + 2.0 * (angle - 70.0)
22+
else if (angle < 160.0) angle = 210.0 + 1.8 * (angle - 130.0)
23+
else angle = 264.0 + 1.2 * (angle - 160.0)
24+
25+
}
26+
27+
CustomImage {
28+
anchors.fill: parent
29+
source: "../Resources/asi/asi_face.svg"
30+
}
31+
32+
CustomImage {
33+
anchors.fill: parent
34+
source: "../Resources/asi/asi_case.svg"
35+
}
36+
37+
CustomImage {
38+
anchors.fill: parent
39+
source: "../Resources/asi/asi_hand.svg"
40+
rotation: angle
41+
}
42+
43+
}

BasicSix/Altimeter.qml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import QtQuick 2.0
2+
3+
Item {
4+
width: 2 * radius
5+
height: 2 * radius
6+
7+
required property double radius
8+
property double altitude: 0
9+
property double pressure: 28
10+
11+
CustomImage {
12+
anchors.fill: parent
13+
source: "../Resources/alt/alt_face_1.svg"
14+
rotation: {
15+
var value = pressure
16+
if (value < 28.0) value = 28.0
17+
else if (value > 31.5) value = 31.5
18+
19+
return (value - 28.0) * 100.0
20+
}
21+
}
22+
23+
CustomImage {
24+
anchors.fill: parent
25+
source: "../Resources/alt/alt_face_2.svg"
26+
}
27+
28+
CustomImage {
29+
anchors.fill: parent
30+
source: "../Resources/alt/alt_face_3.svg"
31+
rotation: 0.0036 * altitude
32+
33+
}
34+
35+
CustomImage {
36+
anchors.fill: parent
37+
source: "../Resources/alt/alt_hand_1.svg"
38+
rotation: 0.036 * altitude
39+
}
40+
41+
CustomImage {
42+
anchors.fill: parent
43+
source: "../Resources/alt/alt_hand_2.svg"
44+
rotation: 0.36 * (altitude % 1000)
45+
}
46+
47+
CustomImage {
48+
anchors.fill: parent
49+
source: "../Resources/alt/alt_case.svg"
50+
}
51+
}
52+

BasicSix/AttitudeIndicator.qml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import QtQuick 2.0
2+
3+
Item {
4+
width: 2 * radius
5+
height: 2 * radius
6+
7+
required property double radius
8+
property double roll: 0
9+
property double pitch: 0
10+
readonly property double pixelPerDegree: 1.7
11+
12+
property double deltaFaceX: 0
13+
property double deltaFaceY: 0
14+
15+
onRollChanged: update()
16+
onPitchChanged: update()
17+
18+
function update()
19+
{
20+
var tempPitch = pitch
21+
if(tempPitch < -20) tempPitch = -20
22+
if(tempPitch > 20) tempPitch = 20
23+
24+
deltaFaceX = (face.width / 240) * pixelPerDegree * tempPitch * Math.sin(Math.PI * roll / 180.0)
25+
deltaFaceY = (face.height / 240) * pixelPerDegree * tempPitch * Math.cos(Math.PI * roll / 180.0)
26+
}
27+
28+
29+
CustomImage {
30+
anchors.fill: parent
31+
source: "../Resources/ai/ai_back.svg"
32+
rotation: -roll
33+
}
34+
35+
CustomImage {
36+
id: face
37+
anchors.fill: parent
38+
source: "../Resources/ai/ai_face.svg"
39+
40+
transform: [
41+
Rotation {
42+
origin.x: 0.5 * face.width
43+
origin.y: 0.5 * face.height
44+
axis {
45+
x: 0
46+
y: 0
47+
z: 1
48+
}
49+
angle: -roll
50+
},
51+
52+
Translate {
53+
x: deltaFaceX
54+
y: deltaFaceY
55+
}
56+
]
57+
}
58+
59+
CustomImage {
60+
anchors.fill: parent
61+
source: "../Resources/ai/ai_ring.svg"
62+
rotation: -roll
63+
}
64+
65+
CustomImage {
66+
anchors.fill: parent
67+
source: "../Resources/ai/ai_case.svg"
68+
}
69+
}
70+
71+

BasicSix/CustomImage.qml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import QtQuick 2.15
2+
3+
Image {
4+
sourceSize.width: 1024
5+
sourceSize.height: 1024
6+
fillMode: Image.PreserveAspectFit
7+
cache: false
8+
smooth: true
9+
antialiasing: true
10+
mipmap:true
11+
}

BasicSix/HeadingIndicator.qml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import QtQuick 2.0
2+
3+
Item {
4+
width: 2 * radius
5+
height: 2 * radius
6+
7+
required property double radius
8+
property double heading: 0
9+
10+
CustomImage {
11+
anchors.fill: parent
12+
source: "../Resources/hi/hi_face.svg"
13+
rotation: -heading
14+
}
15+
16+
CustomImage {
17+
anchors.fill: parent
18+
source: "../Resources/hi/hi_case.svg"
19+
}
20+
}

BasicSix/TurnCoordinator.qml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import QtQuick 2.0
2+
3+
Item {
4+
width: 2 * radius
5+
height: 2 * radius
6+
7+
required property double radius
8+
property double turnRate: 0
9+
property double slipSkid: 0
10+
11+
CustomImage {
12+
anchors.fill: parent
13+
source: "../Resources/tc/tc_back.svg"
14+
}
15+
16+
CustomImage {
17+
id: ball
18+
anchors.fill: parent
19+
source: "../Resources/tc/tc_ball.svg"
20+
transform: Rotation {
21+
origin.x: 0.5 * ball.width
22+
origin.y: -36 / 240 * ball.height
23+
axis {
24+
x: 0
25+
y: 0
26+
z: 1
27+
}
28+
angle: slipSkid
29+
}
30+
}
31+
32+
CustomImage {
33+
anchors.fill: parent
34+
source: "../Resources/tc/tc_face_1.svg"
35+
}
36+
37+
CustomImage {
38+
anchors.fill: parent
39+
source: "../Resources/tc/tc_face_2.svg"
40+
}
41+
42+
CustomImage {
43+
anchors.fill: parent
44+
source: "../Resources/tc/tc_mark.svg"
45+
rotation: (turnRate / 3.0) * 20.0
46+
}
47+
48+
CustomImage {
49+
anchors.fill: parent
50+
source: "../Resources/tc/tc_case.svg"
51+
}
52+
53+
}

0 commit comments

Comments
 (0)