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 itertools import islice
|
||||
import time
|
||||
import globalImport
|
||||
from globalImport import globalImport
|
||||
|
||||
def pysideImports():
|
||||
globalImport("PySide6.QtGui", ["QPainter", "QColor"])
|
||||
globalImport("PySide6.QtCore", ["QPointF", "Signal", "QObject", "Qt"])
|
||||
globalImport(globals(), "PySide6.QtGui", ["QPainter", "QColor"])
|
||||
globalImport(globals(), "PySide6.QtCore", ["QPointF", "Signal", "QObject", "Qt"])
|
||||
|
||||
class updateSignals(QObject):
|
||||
updateDisp = Signal(tuple)
|
||||
@ -90,8 +90,12 @@ class Car():
|
||||
|
||||
self.rawRoute = route
|
||||
|
||||
self.imported = False
|
||||
|
||||
if infoWidg is None:
|
||||
return
|
||||
pysideImports()
|
||||
self.imported = True
|
||||
self.signals=updateSignals()
|
||||
self.signals.updateDisp.connect(self.infoWidg.setVal)
|
||||
self.signals.addGraphPt.connect(self.infoWidg.addSpeedPoint)
|
||||
@ -335,6 +339,9 @@ class Car():
|
||||
|
||||
|
||||
def draw(self,painter, colorOverride):
|
||||
if not self.imported:
|
||||
pysideImports()
|
||||
self.imported = True
|
||||
pt = QPointF(*self.pos)
|
||||
if colorOverride:
|
||||
pass
|
||||
|
@ -2,15 +2,15 @@ import sumolib
|
||||
from Car import Car
|
||||
from Flow import Flow
|
||||
from math import ceil, dist
|
||||
import globalImport
|
||||
from globalImport import globalImport
|
||||
|
||||
def pysideImports():
|
||||
globalImport("carInfo", "Ui_carInfo")
|
||||
globalImport("varEdit", "Ui_varEdit")
|
||||
globalImport("PySide6.QtWidgets", ["QWidget, QLabel, QToolBox"])
|
||||
globalImport("PySide6.QtCore", ["Qt", "Slot", "Signal", "QThread"])
|
||||
globalImport("PySide6.QtCharts", ["QChart", "QSplineSeries", "QLineSeries"])
|
||||
globalImport("PySide6.QtGui", ["QColor"])
|
||||
globalImport(globals(), "carInfo", "Ui_carInfo")
|
||||
globalImport(globals(), "varEdit", "Ui_varEdit")
|
||||
globalImport(globals(), "PySide6.QtWidgets", ["QWidget", "QLabel", "QToolBox"])
|
||||
globalImport(globals(), "PySide6.QtCore", ["Qt", "Slot", "Signal", "QThread"])
|
||||
globalImport(globals(), "PySide6.QtCharts", ["QChart", "QSplineSeries", "QLineSeries"])
|
||||
globalImport(globals(), "PySide6.QtGui", ["QColor"])
|
||||
|
||||
class carInfo(QWidget):
|
||||
def __init__(self,parent):
|
||||
@ -79,7 +79,8 @@ def pysideImports():
|
||||
return
|
||||
obj.setText(f"{key} : {val}")
|
||||
obj.update()
|
||||
|
||||
|
||||
global varEdit
|
||||
class varEdit(QWidget):
|
||||
def __init__(self, parent, carController, varName, value):
|
||||
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
|
||||
|
||||
import sumolib
|
||||
import globalImport
|
||||
|
||||
imported = False
|
||||
from globalImport import globalImport
|
||||
|
||||
def pysideImports():
|
||||
if imported:
|
||||
return
|
||||
globalImport("PySide6.QtGui", ["QPainter", "QPolygonF"])
|
||||
globalImport("PySide6.QtCore", ["Qt", "QPointF", "QThread"])
|
||||
imported = True
|
||||
globalImport(globals(), "PySide6.QtGui", ["QPainter", "QPolygonF"])
|
||||
globalImport(globals(), "PySide6.QtCore", ["Qt", "QPointF", "QThread"])
|
||||
|
||||
def safeCall(func):
|
||||
def inner(*args, **kwargs):
|
||||
@ -28,6 +23,7 @@ class Map:
|
||||
if path is not None:
|
||||
self.fromPath(path)
|
||||
self.net = None
|
||||
self.imported = False
|
||||
|
||||
def fromPath(self,path):
|
||||
self.net = sumolib.net.readNet(path,withInternal=True,withConnections=True)
|
||||
@ -37,7 +33,9 @@ class Map:
|
||||
|
||||
@safeCall
|
||||
def draw(self, painter):
|
||||
pysideImports()
|
||||
if not self.imported:
|
||||
pysideImports()
|
||||
self.imported = True
|
||||
for edge in self.net.getEdges():
|
||||
color=Qt.white
|
||||
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:
|
||||
globals()[namespace] = __import__(namespace)
|
||||
glob[namespace] = import_module(namespace)
|
||||
return
|
||||
elif isinstance(childrens, str):
|
||||
globals()[namespace] = __import__(f"{namespace}.{childrens}")
|
||||
else:
|
||||
for c in childrens:
|
||||
globals()[c] = __import__(f"{namespace}.{c}")
|
||||
childrens = [childrens]
|
||||
module = import_module(namespace)
|
||||
for c in childrens:
|
||||
glob[c] = getattr(module,c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user