This commit is contained in:
leo 2022-02-17 21:00:43 +01:00
parent 4a6f5bf8e0
commit 7fb887e180
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
2 changed files with 17 additions and 19 deletions

17
main.py
View File

@ -1,5 +1,4 @@
import os, sys import os, sys
import time
if 'SUMO_HOME' in os.environ: if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'], 'tools') tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
sys.path.append(tools) sys.path.append(tools)
@ -15,7 +14,7 @@ from mainLoop import mainLoop
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super().__init__()
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
@ -37,7 +36,7 @@ class MainWindow(QMainWindow):
openMenu.addAction(openVeh) openMenu.addAction(openVeh)
timer = QTimer(self) timer = QTimer(self)
timer.timeout.connect(self.mainLoop.update) timer.timeout.connect(self.ui.mainSurf.update)
timer.start(1.0/60) timer.start(1.0/60)
def keyPressEvent(self, e): def keyPressEvent(self, e):
@ -50,12 +49,12 @@ class MainWindow(QMainWindow):
if __name__ == "__main__": if __name__ == "__main__":
app = QApplication() app = QApplication()
format = QSurfaceFormat() f = QSurfaceFormat()
format.setDepthBufferSize(24) f.setDepthBufferSize(24)
format.setVersion(3, 2) f.setVersion(3, 2)
format.setSamples(4) f.setSamples(4)
format.setProfile(QSurfaceFormat.CoreProfile) f.setProfile(QSurfaceFormat.CoreProfile)
QSurfaceFormat.setDefaultFormat(format) QSurfaceFormat.setDefaultFormat(f)
window = MainWindow() window = MainWindow()
window.show() window.show()

View File

@ -18,11 +18,10 @@ class mainLoop():
def update(self): def update(self):
self.controller.update() self.controller.update()
self.painter.update()
def openNetwork(self): def openNetwork(self):
fileName = QFileDialog.getOpenFileName(self.parent,"Open Network", "./", "Network File (*.net.xml)") fileName = QFileDialog.getOpenFileName(self.parent,"Open Network", "./", "Network File (*.net.xml)")
if(fileName[0] == ''): if fileName[0] == '':
return return
self.map.fromPath(fileName[0]) self.map.fromPath(fileName[0])
self.painter.generateTransform() self.painter.generateTransform()
@ -31,10 +30,10 @@ class mainLoop():
def openVehicles(self): def openVehicles(self):
fileName = QFileDialog.getOpenFileName(self.parent,"Open Vehicle trip description", "./", "Route File (*.rou.xml)") fileName = QFileDialog.getOpenFileName(self.parent,"Open Vehicle trip description", "./", "Route File (*.rou.xml)")
if(fileName[0] == ''): if fileName[0] == '':
return return
self.controller.fromPath(fileName[0]) self.controller.fromPath(fileName[0])
if(self.map.isLoaded()): if self.map.isLoaded():
self.controller.prepareRoute() self.controller.prepareRoute()
def quickLoad(self): def quickLoad(self):