Skip to content

Commit

Permalink
Version 0.0.12, added weather
Browse files Browse the repository at this point in the history
  • Loading branch information
Skipper-is committed Apr 12, 2023
1 parent 3bc56f2 commit 6a12d77
Show file tree
Hide file tree
Showing 9 changed files with 11,314 additions and 10,846 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
__pycache__/FieldParser.cpython-39.pyc
__pycache__/ysconnect.cpython-39.pyc
__pycache__/resources.cpython-39.pyc
*.toc
*.pyc
*.zip
*.pyz
*.manifest
*.pkg
build/qt/warn-qt.txt
build/qt/xref-qt.html
*.ini
*.exe
2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
version = [20181124, 20180930, 20150425, 20130817, 20130805, 20120701, 20110207]
defaultversion = 20150425
port = 7915
host = localhost
host = 192.168.0.138
username = radar

101 changes: 101 additions & 0 deletions icons/compassArrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 78 additions & 6 deletions qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
QGraphicsView, QGraphicsScene, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
QCheckBox, QStatusBar, QFrame, QGraphicsLineItem, QGraphicsItem, QGraphicsItemGroup,
QGraphicsTextItem, QTableWidget, QHeaderView, QTableWidgetItem, QFileDialog, QSpacerItem,
QMessageBox, QScrollArea, QComboBox, QAction)
QMessageBox, QScrollArea, QComboBox, QAction, )

from PyQt5.QtGui import (QIcon, QColor, QPalette, QBrush, QPen, QFont, QTransform, QPainterPath, QPolygonF, QPainter,
QMouseEvent, QWheelEvent)
QMouseEvent, QWheelEvent,)

from PyQt5.QtCore import (Qt, QSize, QRectF, QTimer, QPointF, QPoint, QEvent)

from PyQt5.QtSvg import QSvgRenderer
from PyQt5.QtSvg import QSvgRenderer, QGraphicsSvgItem

from PyQt5 import uic
import sys, _thread, json, configparser, os, math, threading
Expand All @@ -29,9 +29,10 @@
basemapLines = []
basemapRegions = []
basemapPoints = []
serverWeather = None


version = "0.0.11"
version = "0.0.12"


class MainWindow(QMainWindow):
Expand Down Expand Up @@ -738,12 +739,16 @@ def __init__(self, parent=None):
self.tabs.resize(300,200)

self.flightDirector = self.parent.flightDirector
self.flightDirector.subscribeToMessage(self.receiveFDMessages)

self.weatherTab = QWidget()

#Add tabs

self.tabs.addTab(self.aircraftListTab,"Aircraft List")
self.tabs.addTab(self.userlistTab,"User List")
self.tabs.addTab(self.messageLogTab,"Message Log")
self.tabs.addTab(self.weatherTab,"Weather")



Expand Down Expand Up @@ -822,6 +827,49 @@ def __init__(self, parent=None):
self.sendLayout.addWidget(self.sendButton)
self.sendButton.clicked.connect(self.sendMessage)

#Set up weather tab
self.weatherTab.layout = QVBoxLayout()
self.weatherTab.setLayout(self.weatherTab.layout)
self.weatherTab.layout.addWidget(QLabel("Wind:", styleSheet='font-weight: bold;'))
self.weather = None
self.windView = QGraphicsView()
self.weatherTab.layout.addWidget(self.windView)
self.windScene = QGraphicsScene()
self.windView.setScene(self.windScene)
self.windView.setMinimumHeight(100)
self.windView.setMaximumHeight(400)

#Add the compass to the scenepyqt5 add
compass = QGraphicsSvgItem(":icons/compass.svg")
self.windScene.addItem(compass)
compass.setPos(0, 0)
compass.setScale(2)

centrePoint = compass.boundingRect().center()*2

self.compassArrow = QGraphicsSvgItem(":icons/compassArrow.svg")
compassArrowcentre = self.compassArrow.boundingRect().center()
self.compassArrow.setTransformOriginPoint(compassArrowcentre)
self.compassArrow.setPos(centrePoint+QPointF(-compassArrowcentre.x(), -compassArrowcentre.y()))
self.compassArrow.setRotation(-90)
self.windScene.addItem(self.compassArrow)
self.windScene.update()
self.windValue = QLabel("N/A")
self.weatherDetailsLayout = QGridLayout()
self.weatherTab.layout.addLayout(self.weatherDetailsLayout)
self.weatherDetailsLayout.addWidget(QLabel("Wind Speed:", styleSheet='font-weight: bold;'), 0, 0)
self.weatherDetailsLayout.addWidget(self.windValue, 0, 1)

self.weatherDetailsLayout.addWidget(QLabel("Time of day: ", styleSheet='font-weight: bold;'), 1, 0)
self.timeDetails = QLabel("N/A")
self.weatherDetailsLayout.addWidget(self.timeDetails, 1, 1)
self.visibilityDetails = QLabel("N/A")
self.weatherDetailsLayout.addWidget(QLabel("Visibility: ", styleSheet='font-weight: bold;'), 2, 0)
self.weatherDetailsLayout.addWidget(self.visibilityDetails, 2, 1)


self.weatherTab.layout.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding))


layout = QHBoxLayout()

Expand Down Expand Up @@ -850,11 +898,12 @@ def sendMessage(self):
self.flightDirector.sendMessage(message)
self.messageInput.setText("")

def receiveMessages(self):
def receiveMessages(self): # This is receiving chat messages
messages = self.flightDirector.messageList
for message in messages:
self.receiveMessage(message)
self.flightDirector.messageList = []
self.updateWeather(self.weather)

def receiveMessage(self, message):
messageContainer = QLabel(message)
Expand All @@ -865,6 +914,28 @@ def receiveMessage(self, message):
if rowCount > 50:
self.messageLog.itemAt(1).widget().setParent(None)
self.messageLog.itemAt(1).widget().deleteLater()

def receiveFDMessages(self, message):
if type(message)== list:
#Should be a weather message:
if message[0] == "weather":
self.weather = message[1]


def updateWeather(self,weather):
#Weather dict contains: {"windDirection": windDirection, "windSpeed": windSpeed, "time": time, "visibility": visibility}
if weather is None:
self.windValue.setText("N/A")
self.timeDetails.setText("N/A")
self.visibilityDetails.setText("N/A")
else:
self.windValue.setText(str(weather["windSpeed"]) + " knots")
self.timeDetails.setText(str(weather["time"]))
self.visibilityDetails.setText(str(round(weather["visibility"]/1852,2)) + "nm / "+ str(round(weather["visibility"]/1000,2)) + "km")
self.compassArrow.setRotation(weather["windDirection"]-90)
self.windScene.update()




class EditCallsignDialog(QDialog):
Expand Down Expand Up @@ -1240,6 +1311,7 @@ def drawGrid(scene,number,gap,origin):
scene.addItem(line)

def updateUsers(userTable, newUserList):

for user in newUserList.getUsers():
if user.deleteFlag: #Remove the user if they've been flagged as to delete.
if user.tableRow != None:
Expand Down Expand Up @@ -1486,7 +1558,7 @@ def updateNav(mainWindow, nav):
mapScene.addPolygon(polygonLight,QPen(QColor(255,255,0,255),5)).setParentItem(navGroup)
mapScene.addPolygon(polygonDark,QPen(QColor(255,255,0,255),5),QBrush(QColor(255,255,0,255))).setParentItem(navGroup)
navSymbol.setParentItem(navGroup)
mapScene.addItem(navSymbol)
#mapScene.addItem(navSymbol)
navSymbol.update()

def updateAircraftInfo(aircraftInfoBox, aircraft):
Expand Down
Loading

0 comments on commit 6a12d77

Please sign in to comment.