def data(self, index, role):
		row = index.row()
		col = index.column()
		if role == Qt.DisplayRole:
			if row < len(self.navpoints): # row is a navpoint
				navpoint = self.navpoints[row]
				if col == 0:
					return Navpoint.tstr(navpoint.type)
				elif col == 1:
					return navpoint.code
				elif col == 2:
					return navpoint.long_name
			else: # row is a parking position
				pk = self.pk_pos[row - len(self.navpoints)]
				#EarthCoords, Heading, str (gate|hangar|misc|tie-down), str list (heavy|jets|turboprops|props|helos)
				if col == 0:
					return 'PKG'
				elif col == 1:
					return pk
				elif col == 2:
					pk_info = env.airport_data.ground_net.parkingPosInfo(pk)
					txt = pk_info[2].capitalize()
					if pk_info[3] != []:
						txt += ' for ' + ', '.join(pk_info[3])
					return txt
		
		elif role == Qt.ToolTipRole:
			coords = self.coordsForRow(row)
			if env.radarPos() == None:
				return str(coords)
			else:
				distance = env.radarPos().distanceTo(coords)
				return '%s°, %s' % (env.radarPos().headingTo(coords).readTrue(), dist_str(distance))
 def __init__(self, route, speedHint=None, acftHint=None, parent=None):
     QDialog.__init__(self, parent)
     self.setupUi(self)
     self.installEventFilter(RadioKeyEventFilter(self))
     self.depICAO_info.setText(route.dep.code)
     self.depAD_info.setText(route.dep.long_name)
     self.arrICAO_info.setText(route.arr.code)
     self.arrAD_info.setText(route.arr.long_name)
     self.route_length = route.totalDistance()
     self.totalRouteDistance_info.setText(dist_str(self.route_length))
     self.route_scene = RouteScene(route, parent=self)
     self.route_view.setScene(self.route_scene)
     self.route_table.setModel(RouteTableModel(route, self))
     for col in [0, 1, 3, 4, 6]:
         self.route_table.resizeColumnToContents(col)
     speedHint_OK = speedHint != None and self.speed_edit.minimum(
     ) <= speedHint.kt <= self.speed_edit.maximum()
     if speedHint_OK:
         self.speed_edit.setValue(speedHint.kt)
     if acftHint != None:
         self.acftType_select.setEditText(acftHint)
         if not speedHint_OK:
             self.EETfromACFT_radioButton.setChecked(True)
     self.updateEET()
     self.route_table.selectionModel().selectionChanged.connect(
         self.legSelectionChanged)
     self.OK_button.clicked.connect(self.accept)
     self.EETfromSpeed_radioButton.toggled.connect(self.updateEET)
     self.EETfromACFT_radioButton.toggled.connect(self.updateEET)
     self.speed_edit.valueChanged.connect(self.updateEET)
     self.acftType_select.editTextChanged.connect(self.updateEET)
Esempio n. 3
0
 def updateMouseXY(self, mouseXY):
     self.prepareGeometryChange()
     self.mousePos = mouseXY
     txt = '%s°' % self.measuredHeading().read()
     if self.display_distance:
         txt += '\n%s' % dist_str(self.measuredDistance())
     self.info_box.updateText(txt)
     self.info_box.setPos(self.mousePos / 2)
Esempio n. 4
0
 def toolTipText(self):
     txt = ''
     if self.social_name != None:
         txt += self.social_name + '\n'
     txt += 'Position: '
     if self.position == None:
         txt += 'unknown'
     else:
         distance = env.radarPos().distanceTo(self.position)
         if distance < nearby_dist_threshold:
             txt += 'nearby'
         else:
             txt += '%s°, %s' % (env.radarPos().headingTo(
                 self.position).readTrue(), dist_str(distance))
     return txt
 def _mouseInfo_flyToMouse(self, radarXY):
     ref_contact = selection.acft
     if ref_contact == None:
         self.mouseInfo.emit('')
     else:
         acftXY = ref_contact.coords().toRadarCoords()
         dist = acftXY.distanceTo(radarXY)
         disp = '%s°, %s' % (acftXY.headingTo(radarXY).read(),
                             dist_str(dist))
         spd = ref_contact.groundSpeed()
         if spd != None:
             try:
                 disp += ', TTF ' + TTF_str(dist, spd)
             except ValueError:
                 pass
         self.mouseInfo.emit('To mouse: ' + disp)
    def data(self, index, role):
        row = index.row()
        col = index.column()
        if role == Qt.DisplayRole:
            if col == 0:
                return str(row + 1)
            elif col == 1:
                if row == 0:
                    return self.route.dep.code
                else:
                    return self.route.waypoint(row - 1).code
            elif col == 2:
                return ' '.join(self.route.legSpec(row))
            elif col == 3:
                return self.route.waypoint(row).code
            else:
                wp = self.route.waypoint(row)
                prev = self.route.dep if row == 0 else self.route.waypoint(
                    row - 1)
                if col == 4:
                    return prev.coordinates.headingTo(
                        wp.coordinates).read() + '°'
                elif col == 5:
                    return dist_str(prev.coordinates.distanceTo(
                        wp.coordinates))
                elif col == 6:
                    return wp.coordinates.headingFrom(
                        prev.coordinates).read() + '°'

        elif role == Qt.ToolTipRole:
            if col == 1:
                prev = self.route.dep if row == 0 else self.route.waypoint(
                    row - 1)
                return Navpoint.tstr(prev.type)
            elif col == 3:
                wp = self.route.waypoint(row)
                return Navpoint.tstr(wp.type)
            elif col == 4 or col == 6:
                return 'True heading'
Esempio n. 7
0
def text_alias_replacement(text_alias, current_selection):
    alias = text_alias.lower()
    weather = env.primaryWeather()
    ## Check for general alias
    if alias == 'ad':
        noNone(env.airport_data)
        return env.locationName()
    elif alias == 'atis':
        return noNone(settings.last_ATIS_recorded)
    elif alias == 'decl':
        return noNone(env.readDeclination())
    elif alias == 'elev':
        return '%d ft' % noNone(env.airport_data).field_elevation
    elif alias == 'frq':
        return str(noNone(settings.publicised_frequency))
    elif alias == 'icao':
        return settings.location_code
    elif alias == 'me':
        return settings.session_manager.myCallsign()
    elif alias == 'metar':
        return noNone(weather).METAR()
    elif alias == 'qfe':
        noNone(env.airport_data)
        return '%d' % env.QFE(noNone(env.QNH(noneSafe=False)))
    elif alias == 'qnh':
        return '%d' % noNone(env.QNH(noneSafe=False))
    elif alias == 'qnhg':
        return '%.2f' % (hPa2inHg * noNone(env.QNH(noneSafe=False)))
    elif alias == 'runways':
        noNone(env.airport_data)
        return env.readRunwaysInUse()
    elif alias == 'rwyarr':
        rwys = [
            rwy.name for rwy in noNone(env.airport_data).allRunways()
            if rwy.use_for_arrivals
        ]
        if rwys == []:
            raise ValueError('No RWY marked for arrival')
        return ', '.join(rwys)
    elif alias == 'rwydep':
        rwys = [
            rwy.name for rwy in noNone(env.airport_data).allRunways()
            if rwy.use_for_departures
        ]
        if rwys == []:
            raise ValueError('No RWY marked for departure')
        return ', '.join(rwys)
    elif alias == 'ta':
        return '%d ft' % env.transitionAltitude()
    elif alias == 'tl':
        noNone(env.QNH(noneSafe=False))
        return 'FL%03d' % env.transitionLevel()
    elif alias == 'utc':
        return timestr()
    elif alias == 'vis':
        return noNone(weather).readVisibility()
    elif alias == 'wind':
        return noNone(weather).readWind()
    else:  # Check for selection-dependant alias
        strip = current_selection.strip
        acft = current_selection.acft
        if alias == 'cralt':
            return noNone(noNone(strip).lookup(FPL.CRUISE_ALT, fpl=True))
        elif alias == 'dest':
            return noNone(noNone(strip).lookup(FPL.ICAO_ARR, fpl=True))
        elif alias == 'dist':
            coords = noNone(acft).coords()
            return dist_str(
                noNone(
                    env.airport_data).navpoint.coordinates.distanceTo(coords))
        elif alias == 'nseq':
            return str(env.strips.stripSequenceNumber(noNone(
                strip)))  # rightly fails with ValueError if strip is loose
        elif alias == 'qdm':
            coords = noNone(acft).coords()
            return coords.headingTo(
                noNone(env.airport_data).navpoint.coordinates).read()
        elif alias == 'rack':
            return noNone(noNone(strip).lookup(rack_detail))
        elif alias == 'route':
            return noNone(noNone(strip).lookup(FPL.ROUTE, fpl=True))
        elif alias == 'rwy':
            box = noNone(noNone(strip).lookup(runway_box_detail))
            return env.airport_data.physicalRunwayNameFromUse(
                box)  # code unreachable if env.airport_data == None
        elif alias == 'sq':
            sq = noNone(strip).lookup(assigned_SQ_detail)
            return '%04o' % noNone(sq)
        elif alias == 'valt':
            valt = noNone(strip).lookup(assigned_altitude_detail)
            return noNone(valt)  # valt is a "reading"
        elif alias == 'vhdg':
            vhdg = noNone(strip).lookup(assigned_heading_detail)
            return noNone(vhdg).read()
        elif alias == 'vspd':
            vspd = noNone(strip).lookup(assigned_speed_detail)
            return str(noNone(vspd))
        elif alias == 'wpnext':
            coords = noNone(acft).coords()
            route = noNone(strip).lookup(parsed_route_detail)
            return str(noNone(route).currentWaypoint(coords))
        elif alias == 'wpsid':
            route = noNone(strip).lookup(parsed_route_detail)
            return noNone(noNone(route).SID())
        elif alias == 'wpstar':
            route = noNone(strip).lookup(parsed_route_detail)
            return noNone(noNone(route).STAR())
        else:
            ## Check for custom alias, in order: general notes, location-specific notes, selected strip comments
            try:
                return custom_alias_search(alias, settings.general_notes)
            except ValueError:
                try:
                    return custom_alias_search(alias, settings.local_notes)
                except ValueError:
                    comments = noNone(noNone(strip).lookup(FPL.COMMENTS))
                    return custom_alias_search(alias, comments)
Esempio n. 8
0
    def updateDisplay(self):
        if self.radar_contact == None:
            self.info_area.setEnabled(False)
            return
        else:
            self.info_area.setEnabled(True)

        # AIRCRAFT BOX
        # Heading
        hdg = self.radar_contact.heading()
        self.aircraftHeading_info.setText('?' if hdg == None else hdg.read() +
                                          '°')
        # Alt./FL
        alt = self.radar_contact.xpdrAlt()
        if alt == None:
            self.aircraftAltitude_info.setText(
                'N/A' if settings.SSR_mode_capability in '0A' else '?')
        else:
            alt_str = env.readStdAlt(alt, step=None, unit=True)
            if not alt_str.startswith('FL') and env.QNH(
                    noneSafe=False) == None:
                alt_str += '  !!QNH'
            self.aircraftAltitude_info.setText(alt_str)
        # Ground speed
        groundSpeed = self.radar_contact.groundSpeed()
        if groundSpeed == None:
            self.aircraftGroundSpeed_info.setText('?')
        else:
            self.aircraftGroundSpeed_info.setText(str(groundSpeed))
        # Indicated airspeed speed
        ias = self.radar_contact.IAS()
        if ias == None:
            self.indicatedAirSpeed_info.setText(
                '?' if settings.SSR_mode_capability == 'S' else 'N/A')
        else:
            s = str(ias)
            if self.radar_contact.xpdrIAS() == None:
                s += '  !!estimate'
            self.indicatedAirSpeed_info.setText(s)
        # Vertical speed
        vs = self.radar_contact.verticalSpeed()
        if vs == None:
            self.aircraftVerticalSpeed_info.setText(
                'N/A' if settings.SSR_mode_capability in '0A' else '?')
        else:
            self.aircraftVerticalSpeed_info.setText('%+d ft/min' % vs)

        # ROUTE BOX
        coords = self.radar_contact.coords()
        strip = env.linkedStrip(self.radar_contact)
        route = None if strip == None else strip.lookup(parsed_route_detail)
        self._last_known_route = route
        if route == None:
            self.route_box.setEnabled(False)
        else:
            self.route_box.setEnabled(True)
            i_leg = route.currentLegIndex(coords)
            wpdist = coords.distanceTo(route.waypoint(i_leg).coordinates)
            self.legCount_info.setText('%d of %d' %
                                       (i_leg + 1, route.legCount()))
            self.legSpec_info.setText(route.legStr(i_leg))
            self.waypointAt_info.setText(dist_str(wpdist))
            try:  # TTF
                if groundSpeed == None:
                    raise ValueError('No ground speed info')
                self.waypointTTF_info.setText(TTF_str(wpdist, groundSpeed))
            except ValueError:
                self.waypointTTF_info.setText('?')

        # AIRPORT BOX
        if env.airport_data != None:
            airport_dist = coords.distanceTo(env.radarPos())
            self.airportBearing_info.setText(
                coords.headingTo(env.radarPos()).read())
            self.airportDistance_info.setText(dist_str(airport_dist))
            try:  # TTF
                if groundSpeed == None:
                    raise ValueError('No ground speed info')
                self.airportTTF_info.setText(TTF_str(airport_dist,
                                                     groundSpeed))
            except ValueError:
                self.airportTTF_info.setText('?')