def get_position(self, fs_indc): """ get position of a aerodome/fix/vor/ndb/... named as specified @param fs_indc: indicativo do objeto (str) """ # check input # assert f_model # pesquisa aeródromos l_aer = self.dct_aer.get(fs_indc, None) if l_aer is not None: # return return pll.CPosLatLng(l_aer.f_aer_lat, l_aer.f_aer_lng) # pesquisa fixos l_key = self.dct_fix.get(fs_indc, None) if l_key is not None: # return return pll.CPosLatLng(l_fix.f_fix_lat, l_fix.f_fix_lng) # return return None
def draw_aerodromo(self, fo_widget, f_aer): """ DOCUMENT ME! """ # check input assert fo_widget # posição do aeródromo l_pos = fo_widget.viewport.translate_pos(pll.CPosLatLng(f_aer.f_aer_lat, f_aer.f_aer_lng)) # X/Y do aeródromo lf_x = l_pos.f_x lf_y = l_pos.f_y # blip size lf_blip_size = fo_widget.viewport.f_blip_size # cria um QPainter lo_painter = QtGui.QPainter(fo_widget) assert lo_painter is not None # seleciona a cor do aeródromo lo_painter.setPen(gdata.G_DCT_COLORS["aerodromo"]) # desenha o aeródromo (...um +) lo_painter.drawLine(int(lf_x - lf_blip_size / 2.), int(lf_y), int(lf_x + lf_blip_size / 2.), int(lf_y)) lo_painter.drawLine(int(lf_x), int(lf_y - lf_blip_size / 2.), int(lf_x), int(lf_y + lf_blip_size / 2.)) # seleciona a cor e fonte do texto lo_painter.setPen(gdata.G_DCT_COLORS["name"]) lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size * 1.5))) # desenha o texto (indicativo do aeródromo) lo_painter.drawText(int(lf_x + lf_blip_size), int(lf_y + lf_blip_size * 2), f_aer.s_aer_indc) # para todas as pistas do aeródromo... for l_pis in f_aer.dct_aer_pistas.values(): # posição da cabeceira da pista l_cab = fo_widget.viewport.translate_pos(pll.CPosLatLng(l_pis.f_pst_lat, l_pis.f_pst_lng)) # obtém a posição da cabeceira oposta da pista l_cab_opos = fo_widget.viewport.translate_pos(pll.CPosLatLng(l_pis.f_pst_cab_opos_lat, l_pis.f_pst_cab_opos_lng)) # cria uma caneta l_pen = QtGui.QPen() assert l_pen # configura cor e estilo da caneta l_pen.setColor(gdata.G_DCT_COLORS["pista"]) l_pen.setStyle(QtCore.Qt.DashDotLine) # seleciona a caneta lo_painter.setPen(l_pen) # desenha a pista ( ...uma + ) lo_painter.drawLine(int(l_cab.f_x), int(l_cab.f_y), int(l_cab_opos.f_x), int(l_cab_opos.f_y)) # libera o QPainter del lo_painter
def translate_xy(self, f_xy): """ translate xy """ # check input assert f_xy # create answer l_pos = pll.CPosLatLng() assert l_pos is not None # get x/y lf_delta_x = (f_xy.f_x - self.__f_width / 2.) / cdefs.D_CNV_GR2NM lf_delta_y = (f_xy.f_y - self.__f_height / 2.) / cdefs.D_CNV_GR2NM # escala lf_esc = float(self.__f_zoom / self.__f_width) # calculate lat/lng l_pos.f_lat = self.__center.f_lat - lf_delta_y * lf_esc l_pos.f_lng = self.__center.f_lng + lf_delta_x / math.cos( math.radians(self.__center.f_lat)) * lf_esc # return return l_pos
def draw_trajetoria(self, fo_widget, f_trj): """ DOCUMENT ME! """ # check input assert fo_widget assert f_trj # get blip size lf_blip_size = fo_widget.viewport.f_blip_size # create painter lo_painter = QtGui.QPainter(fo_widget) assert lo_painter is not None # create pen l_pen = QtGui.QPen() assert l_pen # for all breakpoints... for l_ndx, l_brk in enumerate(f_trj.lst_trj_brk): # get breakpoint id ls_id = (ldefs.D_FMT_TRJ + "-{}").format(f_trj.i_prc_id, l_brk.i_brk_id) # breakpoint position l_pos = fo_widget.viewport.translate_pos( pll.CPosLatLng(l_brk.f_brk_lat, l_brk.f_brk_lng)) # not first breakpoint ? if 0 != l_ndx: # set line colour l_pen.setColor(gdata.G_DCT_COLORS["trajectory"]) # set line style l_pen.setStyle(QtCore.Qt.DashDotLine) # seleciona a caneta lo_painter.setPen(l_pen) # draw line lo_painter.drawLine(tMath.round(l_pos_ant.f_x, 0), tMath.round(l_pos_ant.f_y, 0), tMath.round(l_pos.f_x, 0), tMath.round(l_pos.f_y, 0)) # select colour & font lo_painter.setPen(gdata.G_DCT_COLORS["trajectory_name"]) lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size))) # draw text (indicativo do breakpoint) lo_painter.drawText(int(l_pos.f_x - lf_blip_size * 2), int(l_pos.f_y - lf_blip_size), ls_id) # save last position l_pos_ant = l_pos # free painter del lo_painter
def draw_subida(self, fo_widget, f_sub): """ DOCUMENT ME! """ # check input assert fo_widget # get blip size lf_blip_size = fo_widget.viewport.f_blip_size # create painter lo_painter = QtGui.QPainter(fo_widget) assert lo_painter is not None # create pen l_pen = QtGui.QPen() assert l_pen # for all breakpoints... for l_ndx, l_brk in enumerate(f_sub.lst_sub_brk): # get breakpoint id ls_id = (ldefs.D_FMT_SUB + "-{}").format(f_sub.i_prc_id, l_brk.i_brk_id) # breakpoint position l_pos = fo_widget.viewport.translate_pos( pll.CPosLatLng(l_brk.f_brk_lat, l_brk.f_brk_lng)) # not first breakpoint ? if 0 != l_ndx: # set line colour l_pen.setColor(gdata.G_DCT_COLORS["subida"]) # set line style l_pen.setStyle(QtCore.Qt.DashLine) # seleciona a caneta lo_painter.setPen(l_pen) # draw line lo_painter.drawLine(tMath.round(l_pos_ant.f_x, 0), tMath.round(l_pos_ant.f_y, 0), tMath.round(l_pos.f_x, 0), tMath.round(l_pos.f_y, 0)) # seleciona a cor e fonte do texto lo_painter.setPen(gdata.G_DCT_COLORS["name"]) lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size))) # desenha o texto (indicativo do breakpoint) lo_painter.drawText(int(l_pos.f_x - lf_blip_size * 2), int(l_pos.f_y - lf_blip_size), ls_id) # salva a posição anterior l_pos_ant = l_pos # remove o painter del lo_painter
def __init__(self, fs_fix_indc="NONAME", ff_fix_lat=0., ff_fix_lng=0.): """ define um navaid @param fs_fix_indc: nome @param ff_fix_lat: latitude @param ff_fix_lng: longitude """ # inicia a super classe super(CFix, self).__init__() self.__s_indc = fs_fix_indc self.__position = pll.CPosLatLng(ff_fix_lat, ff_fix_lng) assert self.__position
def update_radar_position(self, ff_tim): """ get new radar position, and push old one into history """ # última posção conhecida l_last_pos = pll.CPosLatLng(self.pos) assert l_last_pos is not None # coloca no rastro self._lst_trail.append(l_last_pos) # atualiza a posição da aeronave self.pos = self.adiru.pos # intervalo do rastro self._f_trail_interval = ff_tim
def __init__(self, fi_w, fi_h): """ constructor """ # inicia a super classe super(CViewport, self).__init__() # largura e altura da viewport self.__f_width = float(fi_w) self.__f_height = float(fi_h) # coordenada do centro da viewport self.__center = pll.CPosLatLng() assert self.__center is not None self.__f_blip_size = fi_w / 220. self.__f_zoom = 160.
def __init__(self, fs_id="NOADDR"): """ @param fs_id: identificação da aeronave """ # check input assert fs_id # air data inertial reference unit self.__adiru = cadi.CADIRU() assert self.__adiru # callsign self.__s_callsign = "NONAME" # icao address self.__s_icao_addr = fs_id # posição lat/lng self.__pos = pll.CPosLatLng() assert self.__pos is not None # status self.__s_status = "N/A"
def draw_navaid(self, fo_widget, f_fix, f_kind=None): """ DOCUMENT ME! """ # check input assert fo_widget # get beacon position l_pos = fo_widget.viewport.translate_pos(pll.CPosLatLng(f_fix.f_fix_lat, f_fix.f_fix_lng)) # get X/Y lf_x = l_pos.f_x lf_y = l_pos.f_y # get blip size lf_blip_size = fo_widget.viewport.f_blip_size # create QPainter lo_painter = QtGui.QPainter(fo_widget) assert lo_painter is not None # DME ? if ldefs.E_DME == f_fix.en_fix_tipo: # set DME colour lo_painter.setPen(gdata.G_DCT_COLORS["dme"]) # draw beacon (...um o) lo_painter.drawEllipse(int(lf_x), int(lf_y), int(lf_blip_size), int(lf_blip_size)) # NDB ? elif ldefs.E_NDB == f_fix.en_fix_tipo: # set NDB colour lo_painter.setPen(gdata.G_DCT_COLORS["ndb"]) # draw beacon (...um o) lo_painter.drawEllipse(int(lf_x), int(lf_y), int(lf_blip_size), int(lf_blip_size)) # VOR ? elif ldefs.E_VOR == f_fix.en_fix_tipo: # set VOR colour lo_painter.setPen(gdata.G_DCT_COLORS["vor"]) # draw beacon (...um o) lo_painter.drawRect(int(lf_x - lf_blip_size / 2.), int(lf_y - lf_blip_size / 2.), int(lf_blip_size), int(lf_blip_size)) # senão,... else: # set waypoint colour lo_painter.setPen(gdata.G_DCT_COLORS["navaid"]) # draw beacon (...um +) lo_painter.drawLine(int(lf_x - lf_blip_size / 2.), int(lf_y), int(lf_x + lf_blip_size / 2.), int(lf_y)) lo_painter.drawLine(int(lf_x), int(lf_y - lf_blip_size / 2.), int(lf_x), int(lf_y + lf_blip_size / 2.)) # waypoint ? if f_kind is None: # set text colour & font lo_painter.setPen(gdata.G_DCT_COLORS["name"]) lo_painter.setFont(QtGui.QFont("Arial", int(lf_blip_size * 1.5))) # draw waypoint name (indicativo do fixo) lo_painter.drawText(int(lf_x + lf_blip_size), int(lf_y + lf_blip_size * 2), f_fix.s_fix_indc) # free QPainter del lo_painter
def __make_aircraft(self, f_data, fv_initial=False): """ create an aircraft from list """ # check input assert f_data is not None # inicia o indice de dados li_ndx = 0 # identificação da aeronave li_id = int(f_data[li_ndx]) li_ndx += 1 # código transponder (ssr) li_ssr = int(f_data[li_ndx]) li_ndx += 1 # spi li_spi = int(f_data[li_ndx]) li_ndx += 1 # altitude lf_alt = float(f_data[li_ndx]) li_ndx += 1 self.adiru.f_alt = lf_alt # latitude lf_lat = float(f_data[li_ndx]) li_ndx += 1 # longitude lf_lng = float(f_data[li_ndx]) li_ndx += 1 self.adiru.pos = pll.CPosLatLng(lf_lat, lf_lng) assert self.adiru.pos if fv_initial: self.pos = pll.CPosLatLng(lf_lat, lf_lng) assert self.pos # velocidade lf_vel = float(f_data[li_ndx]) li_ndx += 1 self.adiru.f_ias = lf_vel # razão de subida lf_raz = float(f_data[li_ndx]) li_ndx += 1 # proa lf_pro = float(f_data[li_ndx]) li_ndx += 1 self.adiru.f_true_heading = lf_pro # callsign ls_ind = str(f_data[li_ndx]) li_ndx += 1 self.s_callsign = ls_ind # performance ls_prf = str(f_data[li_ndx]) li_ndx += 1 # hora lf_tim = float(f_data[li_ndx]) li_ndx += 1
def make_aircraft(self, f_data, fv_initial=False): """ create an aircraft from list """ # check input assert f_data is not None # índice de dados li_ndx = 0 # identificacao da aeronave self.s_icao_addr = str(f_data[li_ndx]) li_ndx += 1 # código transponder (ssr) self._i_ssr = int(f_data[li_ndx]) li_ndx += 1 # spi li_spi = int(f_data[li_ndx]) li_ndx += 1 # altitude (m) self.adiru.f_alt = float(f_data[li_ndx]) li_ndx += 1 # latitude lf_lat = float(f_data[li_ndx]) li_ndx += 1 # longitude lf_lng = float(f_data[li_ndx]) li_ndx += 1 self.pos = pll.CPosLatLng(lf_lat, lf_lng) assert self.pos # if fv_initial: # self.pos = pll.CPosLatLng(lf_lat, lf_lng) # assert self.pos # velocidade (kt) lf_vel = float(f_data[li_ndx]) li_ndx += 1 self.adiru.f_ias = lf_vel self.adiru.f_vel = lf_vel # razão de subida self._f_raz = float(f_data[li_ndx]) li_ndx += 1 # proa lf_pro = float(f_data[li_ndx]) li_ndx += 1 self.adiru.f_true_heading = lf_pro # callsign self.s_callsign = str(f_data[li_ndx]) li_ndx += 1 # performance self._s_prf = str(f_data[li_ndx]) li_ndx += 1 # hora self._i_hora = float(f_data[li_ndx]) li_ndx += 1