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)
Exemplo n.º 2
0
 def dropMimeData(self, mime, drop_action, row, column, parent):
     if drop_action == Qt.MoveAction and mime.hasFormat(strip_mime_type):
         strip = env.strips.fromMimeDez(mime)
         atc_callsign = self.ATCs[parent.row()].callsign
         if not settings.confirm_handovers or settings.session_manager.session_type == SessionType.TEACHER or \
           yesNo_question(self.gui, 'Confirm handover', 'You are about to send your strip to %s.' % atc_callsign, 'Confirm?'):
             if settings.strip_autofill_before_handovers:
                 strip.fillFromXPDR(ovr=False)
                 strip.fillFromFPL(ovr=False)
             try:
                 settings.session_manager.stripDroppedOnATC(
                     strip, atc_callsign)
             except HandoverBlocked as err:
                 if not err.silent:
                     QMessageBox.critical(self.gui, 'Handover aborted',
                                          str(err))
             else:
                 selection.deselect()
                 strip.writeDetail(sent_to_detail, atc_callsign)
                 if settings.session_manager.session_type != SessionType.TEACHER:
                     strip.linkAircraft(None)
                     strip.linkFPL(None)
                     env.strips.removeStrip(strip)
                     env.discarded_strips.addStrip(strip)
                 return True
     return False
Exemplo n.º 3
0
	def killSelectedAircraft(self):
		selected = selection.acft
		if selected == None:
			QMessageBox.critical(self, 'Cheat error', 'No aircraft selected.')
		else:
			selection.deselect()
			settings.session_manager.killAircraft(selected) # WARNING: killAircraft method must exist
			env.radar.scan()
Exemplo n.º 4
0
	def aircraftHasDisappeared(self, acft):
		strip = env.linkedStrip(acft)
		if strip != None:
			strip.linkAircraft(None)
		if selection.acft is acft:
			if strip == None: # was not linked
				selection.deselect()
			else:
				selection.selectStrip(strip)
Exemplo n.º 5
0
	def startStopSession(self, start_func):
		if settings.session_manager.isRunning(): # Stop session
			selection.deselect()
			env.cpdlc.endAllDataLinks()
			settings.session_manager.stop()
		else: # Start session
			settings.session_start_sound_lock = True
			start_func()
		self.updateSessionStartStopActions()
		if not settings.session_manager.isRunning():
			settings.session_start_sound_lock = False
Exemplo n.º 6
0
def discard_strip(parent_widget, strip, shelve):
    '''
	Returns the discarded strip if operation not aborted.
	Argument "shelve" is True to shelve; False to delete.
	'''
    if strip == None:
        return
    acft = strip.linkedAircraft()
    fpl = strip.linkedFPL()
    if shelve:  # shelving strip
        if fpl == None or strip.FPLconflictList() != []:
            if settings.confirm_lossy_strip_releases and not yesNo_question(parent_widget, 'Lossy shelving', \
              'Strip has conflicts or no linked flight plan.', 'Release contact losing strip details?'):
                signals.stripEditRequest.emit(strip)
                return  # abort shelving
        elif not fpl.existsOnline() or fpl.needsUpload():
            if settings.confirm_lossy_strip_releases and not yesNo_question(parent_widget, 'Lossy shelving', \
              'Linked FPL is not online or has local changes.', 'Release contact without pushing details online?'):
                signals.FPLeditRequest.emit(fpl)
                return  # abort shelving
        if fpl != None and fpl.status(
        ) == FPL.OPEN:  # no aborting here, but offer to close FPL if releasing at destination
            if env.airport_data != None and fpl[
                    FPL.ICAO_ARR] == env.airport_data.navpoint.code:
                if yesNo_question(parent_widget, 'Shelving with open FPL', \
                  'Linked FPL is open and arrival filed at location.', 'Would you like to close the flight plan?'):
                    try:
                        settings.session_manager.changeFplStatus(
                            fpl, FPL.CLOSED)
                    except FplError as err:
                        QMessageBox.critical(parent_widget,
                                             'FPL open/close error', str(err))
    else:  # deleting strip (not shelving)
        if acft != None or fpl != None:
            if settings.confirm_linked_strip_deletions and not yesNo_question(
                    parent_widget, 'Delete strip', 'Strip is linked.',
                    'Delete?'):
                return  # abort deletion
    strip.linkAircraft(None)
    strip.linkFPL(None)
    env.strips.removeStrip(strip)
    strip.writeDetail(shelved_detail, shelve)
    env.discarded_strips.addStrip(strip)
    if strip is selection.strip:
        selection.deselect()
    return strip
 def mousePressEvent(self, event):
     if self.mouseGrabberItem() == None:
         selection.deselect()
         event.accept()
     QGraphicsScene.mousePressEvent(self, event)
 def removeFPL(self):
     env.FPLs.removeFPL(selection.fpl)
     selection.deselect()
     self.updateButtons()