format
This commit is contained in:
parent
4a6f5bf8e0
commit
7fb887e180
25
main.py
25
main.py
@ -1,9 +1,8 @@
|
|||||||
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)
|
||||||
else:
|
else:
|
||||||
print("please declare environment variable 'SUMO_HOME'")
|
print("please declare environment variable 'SUMO_HOME'")
|
||||||
|
|
||||||
from PySide6.QtCore import Qt, QTimer
|
from PySide6.QtCore import Qt, QTimer
|
||||||
@ -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)
|
||||||
|
|
||||||
@ -30,16 +29,16 @@ class MainWindow(QMainWindow):
|
|||||||
openNet.setStatusTip("Open Network file (.net.xml)")
|
openNet.setStatusTip("Open Network file (.net.xml)")
|
||||||
openNet.triggered.connect(self.mainLoop.openNetwork)
|
openNet.triggered.connect(self.mainLoop.openNetwork)
|
||||||
openMenu.addAction(openNet)
|
openMenu.addAction(openNet)
|
||||||
|
|
||||||
openVeh = QAction("&Open Vehicles",self)
|
openVeh = QAction("&Open Vehicles",self)
|
||||||
openVeh.setStatusTip("Open Vehicle description (.rou.xml)")
|
openVeh.setStatusTip("Open Vehicle description (.rou.xml)")
|
||||||
openVeh.triggered.connect(self.mainLoop.openVehicles)
|
openVeh.triggered.connect(self.mainLoop.openVehicles)
|
||||||
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):
|
||||||
if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q:
|
if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q:
|
||||||
self.close()
|
self.close()
|
||||||
@ -49,13 +48,13 @@ 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()
|
||||||
|
11
mainLoop.py
11
mainLoop.py
@ -10,19 +10,18 @@ class mainLoop():
|
|||||||
self.painter = parent.ui.mainSurf
|
self.painter = parent.ui.mainSurf
|
||||||
|
|
||||||
self.map = Map()
|
self.map = Map()
|
||||||
|
|
||||||
self.controller = CarController(self.map)
|
self.controller = CarController(self.map)
|
||||||
|
|
||||||
self.painter.addMap(self.map)
|
self.painter.addMap(self.map)
|
||||||
self.painter.addCarController(self.controller)
|
self.painter.addCarController(self.controller)
|
||||||
|
|
||||||
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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user