Skip to content

Commit 55fcd9f

Browse files
authored
Merge pull request #17 from blauret/bearing_pr
Added bearing pointer for Radio1 and 2
2 parents 1e4b412 + b2c50c6 commit 55fcd9f

File tree

4 files changed

+269
-5
lines changed

4 files changed

+269
-5
lines changed

assets/demoView.png

61.9 KB
Loading

pyG5/pyG5Network.py

+32
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,38 @@ def __init__(self, parent=None):
4949
# list the datarefs to request
5050
self.datarefs = [
5151
# ( dataref, frequency, unit, description, num decimals to display in formatted output )
52+
(
53+
"sim/cockpit/radios/nav1_dme_dist_m",
54+
30,
55+
"kt",
56+
"dme Range anv1",
57+
0,
58+
"_nav1dme",
59+
),
60+
(
61+
"sim/cockpit/radios/nav2_dme_dist_m",
62+
30,
63+
"kt",
64+
"dme Range nav2",
65+
0,
66+
"_nav2dme",
67+
),
68+
(
69+
"sim/cockpit2/radios/indicators/nav1_bearing_deg_mag",
70+
30,
71+
"degrees",
72+
"Nav bearing",
73+
0,
74+
"_nav1bearing",
75+
),
76+
(
77+
"sim/cockpit2/radios/indicators/nav2_bearing_deg_mag",
78+
30,
79+
"degrees",
80+
"Nav bearing",
81+
0,
82+
"_nav2bearing",
83+
),
5284
(
5385
"sim/cockpit2/autopilot/altitude_hold_ft",
5486
20,

pyG5/pyG5View.py

+233-5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ def __init__(self, parent=None):
165165
("nav2gs", 0),
166166
("nav1dft", 0),
167167
("nav2dft", 0),
168+
("nav1bearing", 0),
169+
("nav2bearing", 0),
170+
("nav1dme", 0),
171+
("nav2dme", 0),
168172
("gpsdft", 0),
169173
("gpsgsavailable", 0),
170174
("gpsvnavavailable", 0),
@@ -1072,6 +1076,97 @@ def paintEvent(self, event):
10721076
vertAvailable = self._nav1gsavailable
10731077
gsDev = self._nav1gs
10741078

1079+
# bearing 1
1080+
if int(self._nav1fromto) != 0:
1081+
self.qp.rotate(90 - self._headingBug + self._nav1bearing)
1082+
1083+
self.setPen(2, Qt.GlobalColor.cyan)
1084+
1085+
# upside
1086+
self.qp.drawPolyline(
1087+
QPolygonF(
1088+
[
1089+
QPointF(rotatinghsiCircleRadius - 25, 0),
1090+
QPointF(hsiCircleRadius, 0),
1091+
]
1092+
)
1093+
)
1094+
# backside
1095+
self.qp.drawPolyline(
1096+
QPolygonF(
1097+
[
1098+
QPointF(-rotatinghsiCircleRadius + 25, 0),
1099+
QPointF(-hsiCircleRadius, 0),
1100+
]
1101+
)
1102+
)
1103+
# arrow
1104+
self.qp.drawPolyline(
1105+
QPolygonF(
1106+
[
1107+
QPointF(hsiCircleRadius + 20, -10),
1108+
QPointF(hsiCircleRadius + 30, 0),
1109+
QPointF(hsiCircleRadius + 20, 10),
1110+
]
1111+
)
1112+
)
1113+
1114+
self.qp.rotate(-90 + self._headingBug - self._nav1bearing)
1115+
1116+
# bearing 2
1117+
if int(self._nav2fromto) != 0:
1118+
self.qp.rotate(90 - self._headingBug + self._nav2bearing)
1119+
1120+
self.setPen(2, Qt.GlobalColor.cyan)
1121+
1122+
# backside
1123+
self.qp.drawPolyline(
1124+
QPolygonF(
1125+
[
1126+
QPointF(-hsiCircleRadius, -5),
1127+
QPointF(-hsiCircleRadius - 25, -5),
1128+
QPointF(-hsiCircleRadius - 30, 0),
1129+
QPointF(-rotatinghsiCircleRadius + 25, 0),
1130+
QPointF(-hsiCircleRadius - 30, 0),
1131+
QPointF(-hsiCircleRadius - 25, +5),
1132+
QPointF(-hsiCircleRadius, +5),
1133+
]
1134+
)
1135+
)
1136+
1137+
# upside
1138+
self.qp.drawPolyline(
1139+
QPolygonF(
1140+
[
1141+
QPointF(rotatinghsiCircleRadius - 42, -5),
1142+
QPointF(hsiCircleRadius, -5),
1143+
]
1144+
)
1145+
)
1146+
self.qp.drawPolyline(
1147+
QPolygonF(
1148+
[
1149+
QPointF(rotatinghsiCircleRadius - 42, +5),
1150+
QPointF(hsiCircleRadius, +5),
1151+
]
1152+
)
1153+
)
1154+
# arrow
1155+
self.qp.drawPolyline(
1156+
QPolygonF(
1157+
[
1158+
QPointF(hsiCircleRadius + 25, -10),
1159+
QPointF(hsiCircleRadius + 35, 0),
1160+
QPointF(hsiCircleRadius + 45, 0),
1161+
QPointF(hsiCircleRadius + 35, 0),
1162+
QPointF(hsiCircleRadius + 25, 10),
1163+
]
1164+
)
1165+
)
1166+
1167+
self.qp.rotate(-90 + self._headingBug - self._nav2bearing)
1168+
1169+
self.setPen(1, Qt.GlobalColor.black)
10751170
self.qp.setBrush(QBrush(navColor))
10761171
# Draw the CDI
10771172
self.qp.rotate(90 - self._headingBug + navcrs)
@@ -1178,13 +1273,14 @@ def paintEvent(self, event):
11781273
)
11791274

11801275
# Draw the heading Bug indicator bottom corner
1181-
self.setPen(2, Qt.GlobalColor.cyan)
1276+
self.setPen(2, Qt.GlobalColor.gray)
11821277
self.qp.setBrush(QBrush(Qt.GlobalColor.black))
11831278

11841279
headingWidth = 105
11851280
headingHeigth = 30
11861281
self.qp.drawRect(QRectF(g5Width, g5Height, -headingWidth, -headingHeigth))
11871282

1283+
self.setPen(2, Qt.GlobalColor.cyan)
11881284
# draw the bug symbol
11891285
self.setPen(1, Qt.GlobalColor.cyan)
11901286
self.qp.setBrush(QBrush(Qt.GlobalColor.cyan))
@@ -1211,7 +1307,11 @@ def paintEvent(self, event):
12111307
)
12121308

12131309
# draw the dist box
1214-
if int(self._hsiSource) == 2:
1310+
if (
1311+
int(self._hsiSource) == 2
1312+
or (int(self._hsiSource) == 1 and int(self._nav2fromto) != 0)
1313+
or (int(self._hsiSource) == 0 and int(self._nav1fromto) != 0)
1314+
):
12151315
font.setPixelSize(12)
12161316
font.setBold(False)
12171317
self.qp.setFont(font)
@@ -1231,12 +1331,18 @@ def paintEvent(self, event):
12311331
font.setBold(True)
12321332
self.qp.setFont(font)
12331333
self.setPen(1, navColor)
1334+
if int(self._hsiSource) == 2:
1335+
dist = self._gpsdmedist
1336+
elif int(self._hsiSource) == 1:
1337+
dist = self._nav2dme
1338+
else:
1339+
dist = self._nav1dme
12341340

12351341
distRect = QRectF(g5Width - 105, 12, 105, 45 - 12)
12361342
self.qp.drawText(
12371343
distRect,
12381344
Qt.AlignmentFlag.AlignCenter,
1239-
"{}".format(round(self._gpsdmedist, 1)),
1345+
"{}".format(round(dist, 1)),
12401346
)
12411347

12421348
# set default font size
@@ -1445,11 +1551,133 @@ def paintEvent(self, event):
14451551

14461552
self.qp.resetTransform()
14471553

1448-
# draw the CRS selection
1449-
14501554
crsBoxHeight = 30
14511555
crsBoxWidth = 105
14521556

1557+
# draw the Selected Nav Bearing type
1558+
self.setPen(2, greyColor)
1559+
self.qp.setBrush(QBrush(Qt.GlobalColor.black))
1560+
1561+
if int(self._nav1fromto) != 0:
1562+
# draw the contour
1563+
self.qp.drawPolyline(
1564+
QPolygonF(
1565+
[
1566+
QPointF(0, g5Height - crsBoxHeight),
1567+
QPointF(0, g5Height - 3 * crsBoxHeight),
1568+
QPointF(60, g5Height - 3 * crsBoxHeight),
1569+
]
1570+
)
1571+
)
1572+
1573+
# draw the contour arc
1574+
self.qp.drawArc(
1575+
QRectF(g5Width / 2 - 195, g5Height / 2 - 185, 390, 390),
1576+
3268,
1577+
350,
1578+
)
1579+
1580+
# set color to cyan and draw the bearing symbol
1581+
self.setPen(2, Qt.GlobalColor.cyan)
1582+
1583+
self.qp.drawPolyline(
1584+
QPolygonF(
1585+
[
1586+
QPointF(10, g5Height - 2.5 * crsBoxHeight),
1587+
QPointF(50, g5Height - 2.5 * crsBoxHeight),
1588+
]
1589+
)
1590+
)
1591+
self.qp.drawPolyline(
1592+
QPolygonF(
1593+
[
1594+
QPointF(30, g5Height - 2.8 * crsBoxHeight),
1595+
QPointF(40, g5Height - 2.5 * crsBoxHeight),
1596+
QPointF(30, g5Height - 2.2 * crsBoxHeight),
1597+
]
1598+
)
1599+
)
1600+
1601+
# draw the nav type
1602+
self.qp.drawText(
1603+
QRectF(
1604+
QPointF(0, g5Height - crsBoxHeight),
1605+
QPointF(crsBoxWidth, g5Height - 2 * crsBoxHeight),
1606+
),
1607+
Qt.AlignmentFlag.AlignCenter | Qt.AlignmentFlag.AlignVCenter,
1608+
"{}".format(self.getNavTypeString(self._nav1type, "")),
1609+
)
1610+
1611+
if int(self._nav2fromto) != 0 and vertAvailable == 0:
1612+
# set color to grey
1613+
self.setPen(2, Qt.GlobalColor.gray)
1614+
1615+
# draw the contour
1616+
self.qp.drawPolyline(
1617+
QPolygonF(
1618+
[
1619+
QPointF(g5Width, g5Height - crsBoxHeight),
1620+
QPointF(g5Width, g5Height - 3 * crsBoxHeight),
1621+
QPointF(g5Width - 60, g5Height - 3 * crsBoxHeight),
1622+
]
1623+
)
1624+
)
1625+
1626+
# draw the contour arc
1627+
self.qp.drawArc(
1628+
QRectF(g5Width / 2 - 195, g5Height / 2 - 185, 390, 390),
1629+
5036,
1630+
335,
1631+
)
1632+
1633+
# set color to cyan and draw the bearing symbol
1634+
self.setPen(2, Qt.GlobalColor.cyan)
1635+
self.qp.drawPolyline(
1636+
QPolygonF(
1637+
[
1638+
QPointF(g5Width - 40, g5Height - 2.5 * crsBoxHeight),
1639+
QPointF(g5Width - 50, g5Height - 2.5 * crsBoxHeight),
1640+
]
1641+
)
1642+
)
1643+
self.qp.drawPolyline(
1644+
QPolygonF(
1645+
[
1646+
QPointF(g5Width - 10, g5Height - 2.5 * crsBoxHeight + 5),
1647+
QPointF(g5Width - 34, g5Height - 2.5 * crsBoxHeight + 5),
1648+
]
1649+
)
1650+
)
1651+
self.qp.drawPolyline(
1652+
QPolygonF(
1653+
[
1654+
QPointF(g5Width - 10, g5Height - 2.5 * crsBoxHeight - 5),
1655+
QPointF(g5Width - 34, g5Height - 2.5 * crsBoxHeight - 5),
1656+
]
1657+
)
1658+
)
1659+
self.qp.drawPolyline(
1660+
QPolygonF(
1661+
[
1662+
QPointF(g5Width - 30, g5Height - 2.8 * crsBoxHeight),
1663+
QPointF(g5Width - 40, g5Height - 2.5 * crsBoxHeight),
1664+
QPointF(g5Width - 30, g5Height - 2.2 * crsBoxHeight),
1665+
]
1666+
)
1667+
)
1668+
1669+
# draw the nav type
1670+
self.qp.drawText(
1671+
QRectF(
1672+
QPointF(g5Width, g5Height - crsBoxHeight),
1673+
QPointF(g5Width - crsBoxWidth, g5Height - 2 * crsBoxHeight),
1674+
),
1675+
Qt.AlignmentFlag.AlignCenter | Qt.AlignmentFlag.AlignVCenter,
1676+
"{}".format(self.getNavTypeString(self._nav2type, "")),
1677+
)
1678+
1679+
# draw the CRS selection
1680+
14531681
self.setPen(2, greyColor)
14541682
self.qp.setBrush(QBrush(Qt.GlobalColor.black))
14551683

pyG5/pyG5ViewTester.py

+4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@ def makeControlDict(name, min, max):
142142
makeControlDict("hsiSource", 0, 2),
143143
makeControlDict("nav1crs", 0, 360),
144144
makeControlDict("nav1dft", -3, 3),
145+
makeControlDict("nav1fromto", 0, 1),
146+
makeControlDict("nav1bearing", 0, 360),
145147
makeControlDict("nav1gsavailable", 0, 1),
146148
makeControlDict("nav1gs", -30, 30),
147149
makeControlDict("nav2crs", 0, 360),
148150
makeControlDict("nav2dft", -3, 3),
151+
makeControlDict("nav2fromto", 0, 1),
152+
makeControlDict("nav2bearing", 0, 360),
149153
makeControlDict("nav2gsavailable", 0, 1),
150154
makeControlDict("nav2gs", -30, 30),
151155
makeControlDict("gpscrs", 0, 360),

0 commit comments

Comments
 (0)