fix jit import
This commit is contained in:
parent
10b07d1230
commit
f7336e863a
13
Car.py
13
Car.py
@ -3,11 +3,11 @@ from math import dist, ceil, sqrt, log, cos, sin, atan2, pi
|
|||||||
from random import randint, uniform
|
from random import randint, uniform
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
import time
|
import time
|
||||||
import globalImport
|
from globalImport import globalImport
|
||||||
|
|
||||||
def pysideImports():
|
def pysideImports():
|
||||||
globalImport("PySide6.QtGui", ["QPainter", "QColor"])
|
globalImport(globals(), "PySide6.QtGui", ["QPainter", "QColor"])
|
||||||
globalImport("PySide6.QtCore", ["QPointF", "Signal", "QObject", "Qt"])
|
globalImport(globals(), "PySide6.QtCore", ["QPointF", "Signal", "QObject", "Qt"])
|
||||||
|
|
||||||
class updateSignals(QObject):
|
class updateSignals(QObject):
|
||||||
updateDisp = Signal(tuple)
|
updateDisp = Signal(tuple)
|
||||||
@ -90,8 +90,12 @@ class Car():
|
|||||||
|
|
||||||
self.rawRoute = route
|
self.rawRoute = route
|
||||||
|
|
||||||
|
self.imported = False
|
||||||
|
|
||||||
if infoWidg is None:
|
if infoWidg is None:
|
||||||
return
|
return
|
||||||
|
pysideImports()
|
||||||
|
self.imported = True
|
||||||
self.signals=updateSignals()
|
self.signals=updateSignals()
|
||||||
self.signals.updateDisp.connect(self.infoWidg.setVal)
|
self.signals.updateDisp.connect(self.infoWidg.setVal)
|
||||||
self.signals.addGraphPt.connect(self.infoWidg.addSpeedPoint)
|
self.signals.addGraphPt.connect(self.infoWidg.addSpeedPoint)
|
||||||
@ -335,6 +339,9 @@ class Car():
|
|||||||
|
|
||||||
|
|
||||||
def draw(self,painter, colorOverride):
|
def draw(self,painter, colorOverride):
|
||||||
|
if not self.imported:
|
||||||
|
pysideImports()
|
||||||
|
self.imported = True
|
||||||
pt = QPointF(*self.pos)
|
pt = QPointF(*self.pos)
|
||||||
if colorOverride:
|
if colorOverride:
|
||||||
pass
|
pass
|
||||||
|
@ -2,15 +2,15 @@ import sumolib
|
|||||||
from Car import Car
|
from Car import Car
|
||||||
from Flow import Flow
|
from Flow import Flow
|
||||||
from math import ceil, dist
|
from math import ceil, dist
|
||||||
import globalImport
|
from globalImport import globalImport
|
||||||
|
|
||||||
def pysideImports():
|
def pysideImports():
|
||||||
globalImport("carInfo", "Ui_carInfo")
|
globalImport(globals(), "carInfo", "Ui_carInfo")
|
||||||
globalImport("varEdit", "Ui_varEdit")
|
globalImport(globals(), "varEdit", "Ui_varEdit")
|
||||||
globalImport("PySide6.QtWidgets", ["QWidget, QLabel, QToolBox"])
|
globalImport(globals(), "PySide6.QtWidgets", ["QWidget", "QLabel", "QToolBox"])
|
||||||
globalImport("PySide6.QtCore", ["Qt", "Slot", "Signal", "QThread"])
|
globalImport(globals(), "PySide6.QtCore", ["Qt", "Slot", "Signal", "QThread"])
|
||||||
globalImport("PySide6.QtCharts", ["QChart", "QSplineSeries", "QLineSeries"])
|
globalImport(globals(), "PySide6.QtCharts", ["QChart", "QSplineSeries", "QLineSeries"])
|
||||||
globalImport("PySide6.QtGui", ["QColor"])
|
globalImport(globals(), "PySide6.QtGui", ["QColor"])
|
||||||
|
|
||||||
class carInfo(QWidget):
|
class carInfo(QWidget):
|
||||||
def __init__(self,parent):
|
def __init__(self,parent):
|
||||||
@ -79,7 +79,8 @@ def pysideImports():
|
|||||||
return
|
return
|
||||||
obj.setText(f"{key} : {val}")
|
obj.setText(f"{key} : {val}")
|
||||||
obj.update()
|
obj.update()
|
||||||
|
|
||||||
|
global varEdit
|
||||||
class varEdit(QWidget):
|
class varEdit(QWidget):
|
||||||
def __init__(self, parent, carController, varName, value):
|
def __init__(self, parent, carController, varName, value):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
16
Map.py
16
Map.py
@ -3,16 +3,11 @@
|
|||||||
# mais si on se decide à utiliser notre propre format dans le futur ça facilitera la transition
|
# mais si on se decide à utiliser notre propre format dans le futur ça facilitera la transition
|
||||||
|
|
||||||
import sumolib
|
import sumolib
|
||||||
import globalImport
|
from globalImport import globalImport
|
||||||
|
|
||||||
imported = False
|
|
||||||
|
|
||||||
def pysideImports():
|
def pysideImports():
|
||||||
if imported:
|
globalImport(globals(), "PySide6.QtGui", ["QPainter", "QPolygonF"])
|
||||||
return
|
globalImport(globals(), "PySide6.QtCore", ["Qt", "QPointF", "QThread"])
|
||||||
globalImport("PySide6.QtGui", ["QPainter", "QPolygonF"])
|
|
||||||
globalImport("PySide6.QtCore", ["Qt", "QPointF", "QThread"])
|
|
||||||
imported = True
|
|
||||||
|
|
||||||
def safeCall(func):
|
def safeCall(func):
|
||||||
def inner(*args, **kwargs):
|
def inner(*args, **kwargs):
|
||||||
@ -28,6 +23,7 @@ class Map:
|
|||||||
if path is not None:
|
if path is not None:
|
||||||
self.fromPath(path)
|
self.fromPath(path)
|
||||||
self.net = None
|
self.net = None
|
||||||
|
self.imported = False
|
||||||
|
|
||||||
def fromPath(self,path):
|
def fromPath(self,path):
|
||||||
self.net = sumolib.net.readNet(path,withInternal=True,withConnections=True)
|
self.net = sumolib.net.readNet(path,withInternal=True,withConnections=True)
|
||||||
@ -37,7 +33,9 @@ class Map:
|
|||||||
|
|
||||||
@safeCall
|
@safeCall
|
||||||
def draw(self, painter):
|
def draw(self, painter):
|
||||||
pysideImports()
|
if not self.imported:
|
||||||
|
pysideImports()
|
||||||
|
self.imported = True
|
||||||
for edge in self.net.getEdges():
|
for edge in self.net.getEdges():
|
||||||
color=Qt.white
|
color=Qt.white
|
||||||
if(edge.getFunction()=="internal"):
|
if(edge.getFunction()=="internal"):
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
def globalImport(namespace, childrens=None):
|
from importlib import import_module
|
||||||
|
|
||||||
|
def globalImport(glob, namespace, childrens=None):
|
||||||
if childrens is None:
|
if childrens is None:
|
||||||
globals()[namespace] = __import__(namespace)
|
glob[namespace] = import_module(namespace)
|
||||||
|
return
|
||||||
elif isinstance(childrens, str):
|
elif isinstance(childrens, str):
|
||||||
globals()[namespace] = __import__(f"{namespace}.{childrens}")
|
childrens = [childrens]
|
||||||
else:
|
module = import_module(namespace)
|
||||||
for c in childrens:
|
for c in childrens:
|
||||||
globals()[c] = __import__(f"{namespace}.{c}")
|
glob[c] = getattr(module,c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user