def mouseReleaseEvent(self, event): rxy = RadarCoords.fromQPointF(event.scenePos()) if self.measuring_tool.isVisible() and event.button() in [ Qt.LeftButton, Qt.RightButton ]: if self.using_special_tool: stxy = RadarCoords.fromQPointF(self.measuring_tool.pos()) signals.specialTool.emit(EarthCoords.fromRadarCoords(stxy), self.measuring_tool.measuredHeading()) self.measuring_tool.stop(False) else: # using normal measuring tool if settings.measuring_tool_logs_coordinates: print('RELEASE: %s' % EarthCoords.fromRadarCoords(rxy).toString()) text, ok = QInputDialog.getText( self.parent(), 'Logging coordinates', 'Text label for logged coordinates (optional):') if ok: print('TEXT: %s' % text) self.measuring_tool.stop(True) elif event.button() == Qt.LeftButton: if self.prevent_mouse_release_deselect or self.mouseGrabberItem( ) != None: self.prevent_mouse_release_deselect = False else: selection.deselect() self._mouseInfo_flyToMouse(rxy) QGraphicsScene.mouseReleaseEvent(self, event)
def mousePressEvent(self, event): QGraphicsScene.mousePressEvent(self, event) if not event.isAccepted(): if event.button() == Qt.RightButton: self.using_special_tool = settings.session_manager.session_type == SessionType.TEACHER \ and settings.session_manager.isRunning() and event.modifiers() & Qt.ShiftModifier self.measuring_tool.setPos(event.scenePos()) if self.using_special_tool: # using measuring tool with ulterior motive (creating teacher traffic) self.measuring_tool.start(False) else: # using normal measuring tool self.measuring_tool.start(True) rxy = RadarCoords.fromQPointF(event.scenePos()) self._mouseInfo_elevation(rxy) if settings.measuring_tool_logs_coordinates: print( 'Logging coordinates of new radar measurement...') print('PRESS: %s' % EarthCoords.fromRadarCoords(rxy).toString()) if not event.button() == Qt.LeftButton or event.modifiers( ) & Qt.ShiftModifier: # not panning event.accept()
def earthCoords(self): return EarthCoords.fromRadarCoords( RadarCoords.fromQPointF(self.scenePos()))
def updateMouseXY(self, sceneXY): self.target_point = EarthCoords.fromRadarCoords( RadarCoords.fromQPointF(sceneXY)) p_acft = self.acft.coords().toRadarCoords() acft_qpoint = p_acft.toQPointF() # Get node route sequence if QPointF.dotProduct( sceneXY - acft_qpoint, sceneXY - acft_qpoint ) < min_taxi_drag * min_taxi_drag: # min mouse move not reached self.node_route = None else: # get route end nodes src_node = None dest_node = None if env.airport_data != None: src_node = env.airport_data.ground_net.closestNode( self.acft.coords()) if src_node != None: dest_node = env.airport_data.ground_net.closestNode( self.target_point, maxdist=taxi_tool_snap_dist) if src_node == None or dest_node == None: self.node_route = None else: try: self.node_route = env.airport_data.ground_net.shortestTaxiRoute( src_node, dest_node, settings.taxi_instructions_avoid_runways) p_src = env.airport_data.ground_net.nodePosition( src_node).toRadarCoords() if self.node_route == []: # src and dest nodes are identical if p_acft.distanceTo( p_src) > groundnet_pos_taxi_precision: self.node_route = [src_node] else: # first node of list is the one following src; check if we must insert src p_next = env.airport_data.ground_net.nodePosition( self.node_route[0]).toRadarCoords() if not p_acft.isBetween(p_src, p_next, groundnet_pos_taxi_precision): self.node_route.insert(0, src_node) except ValueError: # no taxi route found self.node_route = None # Get parking position self.parking_position = None if self.node_route == None or self.node_route == []: d_max_snap = taxi_tool_snap_dist else: d_last_node = env.airport_data.ground_net.nodePosition( self.node_route[-1]).distanceTo(self.target_point) d_max_snap = min(taxi_tool_snap_dist, d_last_node) self.parking_position = env.airport_data.ground_net.closestParkingPosition( self.target_point, maxdist=d_max_snap) # Update bounding box and specify the lines to draw self.prepareGeometryChange() if self.node_route == None and self.parking_position == None: self.snapped_OK = False line_tip = sceneXY - acft_qpoint self.lines = [(QPointF(0, 0), line_tip)] self.bbox = QRectF(QPointF(0, 0), line_tip).normalized() else: self.snapped_OK = True self.lines = [] self.bbox = QRectF(0, 0, 0, 0) prev = QPointF(0, 0) if self.node_route != None: for n in self.node_route: p = env.airport_data.ground_net.nodePosition( n).toQPointF() - acft_qpoint self.lines.append((prev, p)) self.bbox |= QRectF(prev, p).normalized() prev = p if self.parking_position != None: pk_point = env.airport_data.ground_net.parkingPosition( self.parking_position).toQPointF() - acft_qpoint self.lines.append((prev, pk_point)) self.bbox |= QRectF(prev, pk_point).normalized() self.update()
def SEcoords(self): return EarthCoords.fromRadarCoords( RadarCoords.fromQPointF( self.mapToScene(self.boundingRect().bottomRight())))