diff --git a/Car.py b/Car.py
index 1854649..a34f7de 100644
--- a/Car.py
+++ b/Car.py
@@ -82,6 +82,9 @@ class Car:
vsec=vleader+(S-vmax*T)/(vbar/bbar+T)
vd=min(self.v+self.a*dt,vmax,vsec)
self.v=max(0,vd)
+ self.infoWidg.addSpeedPoint(2,self.controller.t,self.v)
+ self.infoWidg.addSpeedPoint(0,self.controller.t,vmax)
+ self.infoWidg.addSpeedPoint(1,self.controller.t,vsec)
def update(self,dt):
leaders=self.controller.getCarsOnEdge(self.route[self.index].getID())
diff --git a/CarController.py b/CarController.py
index e5e35dc..8497b18 100644
--- a/CarController.py
+++ b/CarController.py
@@ -3,12 +3,39 @@ from Car import Car
from carInfo import Ui_carInfo
from PySide6.QtWidgets import QWidget, QLabel
from PySide6.QtCore import Qt
+from PySide6.QtCharts import QChart, QSplineSeries, QLineSeries
class carInfo(QWidget):
def __init__(self):
super(carInfo,self).__init__()
self.ui = Ui_carInfo()
self.ui.setupUi(self)
+ self.maxV = 0
+
+ self.chart = self.ui.speedGraph.chart()
+
+ speedsNames = ["vmax","vsec","Vitesse (m.s^-1)"]
+ self.speedSeries = []
+ for ind,s in enumerate(speedsNames):
+ self.speedSeries.append(QLineSeries())
+ self.speedSeries[ind].setName(s)
+ self.chart.addSeries(self.speedSeries[ind])
+ self.chart.createDefaultAxes()
+
+ def addSpeedPoint(self,ind,t,val):
+ if(t>500):
+ self.speedSeries[ind].remove(0)
+ self.speedSeries[ind].append(t,val)
+
+ xAxis = self.chart.axes(Qt.Horizontal,self.speedSeries[ind])[0]
+ xAxis.setRange(max(t-500,0),t)
+
+ if(val>self.maxV):
+ self.maxV = val
+ yAxis = self.chart.axes(Qt.Vertical, self.speedSeries[ind])[0]
+ yAxis.setMax(val+1)
+
+ self.ui.speedGraph.update()
def setVal(self,key,val):
obj = self.findChild(QLabel,key)
@@ -21,9 +48,11 @@ class CarController:
def __init__(self,parentMap):
self.map=parentMap
self.cars=[]
+ self.t=0
def fromPath(self,path):
self.cars=[]
+ self.t=0
while(self.infoWidget.count() != 0):
self.infoWidget.removeItem(0)
@@ -47,6 +76,7 @@ class CarController:
def update(self):
if(self.map.net is None):
return
+ self.t+=1
for car in self.cars:
car.update(1.0/60)
diff --git a/carInfo.py b/carInfo.py
index 652ba5d..9912358 100644
--- a/carInfo.py
+++ b/carInfo.py
@@ -8,6 +8,7 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
+from PySide6.QtCharts import QChartView
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
@@ -50,6 +51,11 @@ class Ui_carInfo(object):
self.verticalLayout.addWidget(self.Leader)
+ self.speedGraph = QChartView(carInfo)
+ self.speedGraph.setObjectName(u"speedGraph")
+
+ self.verticalLayout.addWidget(self.speedGraph)
+
self.retranslateUi(carInfo)
diff --git a/carInfo.ui b/carInfo.ui
index dfb9a13..889e7aa 100644
--- a/carInfo.ui
+++ b/carInfo.ui
@@ -49,8 +49,18 @@
+ -
+
+
+
+
+ QChartView
+ QGraphicsView
+
+
+
diff --git a/mainLoop.py b/mainLoop.py
index 8c43701..bb5021f 100644
--- a/mainLoop.py
+++ b/mainLoop.py
@@ -2,6 +2,7 @@ from Map import Map
from CarController import CarController
from PySide6.QtWidgets import QFileDialog
+from PySide6.QtCore import QElapsedTimer
class mainLoop():
def __init__(self, parent):