130 if(posOriginal[1] == guiLogic.landmarkType.TIMEKEEPING):
133 if(type == guiLogic.landmarkType.BLUE):
134 posOriginal[1] = guiLogic.landmarkType.BLUE
135 self.scene().changeConeType(i,type)
136 elif(type == guiLogic.landmarkType.YELLOW):
137 posOriginal[1] = guiLogic.landmarkType.YELLOW
138 self.scene().changeConeType(i,type)
139 elif(type == guiLogic.landmarkType.ORANGE):
140 posOriginal[1] = guiLogic.landmarkType.ORANGE
141 self.scene().changeConeType(i,type)
142 elif(type == guiLogic.landmarkType.BIG_ORANGE):
143 posOriginal[1] = guiLogic.landmarkType.BIG_ORANGE
144 self.scene().changeConeType(i,type)
145 elif(type == guiLogic.landmarkType.UNDEFINED):
146 posOriginal[1] = guiLogic.landmarkType.UNDEFINED
147 self.scene().changeConeType(i,type)
154 for i
in self.items():
155 anySelected = anySelected
or i.isSelected()
158 submenuType = menu.addMenu(
"Change color")
159 blueAction = submenuType.addAction(
"Blue")
160 yellowAction = submenuType.addAction(
"Yellow")
161 orangeAction = submenuType.addAction(
"Orange")
162 bigOrangeAction = submenuType.addAction(
"Big orange")
163 unknownAction = submenuType.addAction(
"Unknown")
164 deleteAction = menu.addAction(
"&Delete")
166 action = menu.exec_(pos)
167 if action == deleteAction:
169 elif action == blueAction:
171 elif action == yellowAction:
173 elif action == orangeAction:
175 elif action == bigOrangeAction:
177 elif action == unknownAction:
208 minX = min(start[0], end[0])
209 minY = min(start[1], end[1])
210 maxX = max(start[0], end[0])
211 maxY = max(start[1], end[1])
212 result = (point[0] >= minX
and point[0] <= maxX
and point[1] >= minY
and point[1] <= maxY)
248 position = self.mapToScene(event.pos())
250 mouseButton = event.button()
252 if(self.
guiLogic.editorMode == guiLogic.editorMode.ADD
or self.
guiLogic.editorMode == guiLogic.editorMode.TIMEKEEPING_START):
256 if(event.modifiers() == QtCore.Qt.ControlModifier):
261 self.
rubberBand = QRubberBand(QRubberBand.Rectangle, self)
265 elif(event.modifiers() == QtCore.Qt.NoModifier):
267 for i
in self.items():
268 anySelected = anySelected
or i.isSelected()
270 for i
in self.items():
271 numberUnderMouse = numberUnderMouse + int(i.isUnderMouse())
272 anyUnderMouse = (numberUnderMouse >= 1)
274 if(mouseButton == Qt.MouseButton.LeftButton):
280 if(self.
guiLogic.editorMode == guiLogic.editorMode.ADD):
282 if(self.
guiLogic.landmarkType == guiLogic.landmarkType.UNDEFINED):
283 t = self.scene().addConeUnknown(position)
286 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.BLUE):
287 t = self.scene().addConeLeft(position)
290 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.YELLOW):
291 t = self.scene().addConeRight(position)
294 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.ORANGE):
295 t = self.scene().addConeOrange(position)
298 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.BIG_ORANGE):
299 t = self.scene().addConeBigOrange(position)
302 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.INVISIBLE):
303 t = self.scene().addConeInvisible(position)
306 elif(self.
guiLogic.landmarkType == guiLogic.landmarkType.TIMEKEEPING):
307 t = self.scene().addConeTimeKeeping(position)
311 elif(self.
guiLogic.editorMode == guiLogic.editorMode.TIMEKEEPING_START):
314 firstLine = len(self.
guiLogic.timeKeepingGates) == 0
316 duringLine = len(self.
guiLogic.timeKeepingGates[-1]) == 1
318 t = self.scene().addConeTimeKeeping(position)
319 cone = [self.
positionToWorld(position), guiLogic.landmarkType.TIMEKEEPING]
323 self.
guiLogic.timeKeepingGates[-1].append(cone)
331 t =self.scene().addTimeKeepingLine(start, end, lineType)
334 self.
guiLogic.timeKeepingGates.append([cone])
337 elif(mouseButton == Qt.MouseButton.RightButton):
340 elif (numberUnderMouse == 1):
341 for i
in self.items():
342 if(i.isUnderMouse()
and not (i
in self.scene().gridLines)):
344 elif(self.
guiLogic.editorMode == guiLogic.editorMode.LANE_CONNECT_LEFT):
348 c.setFlags(c.flags() & ~c.ItemIsMovable & ~c.ItemIsSelectable)
349 if(c.isUnderMouse()):
354 plausibleConnection =
False
355 if(plausibleConnection):
356 clickedCones.append(c)
361 t =self.scene().addLeftConnectionLine(start, end)
364 clickedCones.append(c)
369 done = (self.
guiLogic.lanesConnectionLeft[0]
is self.
guiLogic.lanesConnectionLeft[-1])
371 self.
guiLogic.editorMode = guiLogic.editorMode.LANE_CONNECT_RIGHT
373 elif(self.
guiLogic.editorMode == guiLogic.editorMode.LANE_CONNECT_RIGHT):
376 c.setFlags(c.flags() & ~c.ItemIsMovable & ~c.ItemIsSelectable)
377 if(c.isUnderMouse()):
381 plausibleConnection =
False
382 if(plausibleConnection):
383 clickedCones.append(c)
388 t =self.scene().addRightConnectionLine(start, end)
391 clickedCones.append(c)
396 done = (self.
guiLogic.lanesConnectionRight[0]
is self.
guiLogic.lanesConnectionRight[-1])
475 c = QtCore.QPointF(-cone[0][0]*self.scene().pixelPerMeter, cone[0][1]*self.scene().pixelPerMeter)
476 if(cone[1] == guiLogic.landmarkType.UNDEFINED):
477 t = self.scene().addConeUnknown(c)
478 elif(cone[1] == guiLogic.landmarkType.BLUE):
479 t = self.scene().addConeLeft(c)
480 elif(cone[1] == guiLogic.landmarkType.YELLOW):
481 t = self.scene().addConeRight(c)
482 elif(cone[1] == guiLogic.landmarkType.ORANGE):
483 t = self.scene().addConeOrange(c)
484 elif(cone[1] == guiLogic.landmarkType.BIG_ORANGE):
485 t = self.scene().addConeBigOrange(c)
486 elif(cone[1] == guiLogic.landmarkType.INVISIBLE):
487 t = self.scene().addConeInvisible(c)
488 elif(cone[1] == guiLogic.landmarkType.TIMEKEEPING):
489 t = self.scene().addConeTimeKeeping(c)
491 print(
"error adding cone")
610 centerPoint = relScale * np.array([64,64])
612 c = -self.
guiLogic.originENURotation[2] - np.pi/2
613 Rz = np.array([[np.cos(c), -np.sin(c)], [np.sin(c), np.cos(c)]])
614 centerPointRotated = Rz
@centerPoint
615 a = self.mapToScene(int(-centerPointRotated[0]+centerPoint[0]), int(-centerPointRotated[1]+centerPoint[1]))
616 self.scene().compass.setScale(relScale*1/self.
zoomLevel)
617 self.scene().compass.setRotation(c * 180.0 / np.pi)
618 self.scene().compass.setPos(a)