def dxfHolder(self, args): dFile = args[1] if len(os.path.dirname(dFile)) == 0: dFile = os.path.join(self.cfg.dirPath, dFile) d = Draw(self.cfg) d.open(dFile, True, False) d.material(self.xSize, self.ySize) r = self.mountSize / 2.0 for p in self.mountInfo: d.circle(p, r) for (x, y, size, _) in self.holeInfo: d.circle((x, y), size / 2.0) d.close()
def main(portrait=False): d = Draw(portrait) width = d.size[0] height = d.size[1] # Center pixel d.pixel(width // 2, height // 2, 0) # 3-by-3 vertical lines for i in range(height): d.pixel(width // 3, i, 0) d.pixel(2 * width // 3, i, 0) # 3-by-3 horizontal lines for i in range(width): d.pixel(i, height // 3, 0) d.pixel(i, 2 * height // 3, 0) # Diagonals d.line(0, 0, width - 1, height - 1, 0) d.line(0, height - 1, width - 1, 0, 0) # Center lines d.hline(0, height // 2, width, 0) d.vline(width // 2, 0, height, 0) # Sixths box using all the lines functions # Horizontal and Vertical lines using the hline and vline functions d.hline(width // 6, height // 6, 4 * width // 6, 0) d.vline(width // 6, height // 6, 4 * height // 6, 0) # Horizontal and Vertical lines using the line functions d.line(width // 6, 5 * height // 6, 5 * width // 6, 5 * height // 6, 0) d.line(5 * width // 6, height // 6, 5 * width // 6, 5 * height // 6, 0) # Quarter box using rect function d.rect(width // 4, height // 4, 3 * width // 4, 3 * height // 4, 0) # Third box using rect function with fill d.rect(width // 3, height // 3, 2 * width // 3, 2 * height // 3, 0, True) # Circle radius = min(height // 3, width // 3) d.circle(width // 2, height // 2, radius, 0) # Circle with fill radius = min(height // 6, width // 6) d.circle(width // 6, height // 2, radius, 0, True) # Write "this is only a text" at the origin of the display d.text('this is only a text', 0, 0, 0) # Write every available character on the screen. all_chars = sorted(font.keys()) y = height x = 0 for n, letter in enumerate(all_chars): if (n * 8) % width == 0: y -= 8 x = 0 else: x += 8 d.text(letter, x, y, 0) d.draw()
class Radar: ''' Classe que chama todos os procedimentos necessários ao implante da tela ''' def __init__(self): self.base = [] self.utils = Utils() self.table = "./planes/planilha de radar.csv" self.display = GraphWin("Radar", 500, 500) self.display.setBackground('black') def get_plane(self): ''' Função utiliza função para ler arquivo CSV e realiza loop que utiliza os dados obtidos no CSV, para desenhar os aviões na tela. :return: Os aviões desenhados na tela. ''' #TODO: MUDAR A FORMA DE OBTENÇÃO DOS AVIÕES self.id_flight = [ 'LA 2203', 'GZ 0331', 'AZ 0032', 'AZ 0157', 'GZ 0667' ] self.airplane_routes = self.utils.transform_data_file( self.utils.read_csv(self.table)) for time in range(0, 151, 10): for flight in self.id_flight: self.data_flight = self.airplane_routes.get( (str(time), flight)) if int(self.data_flight[5]) != 0: self.airplane = Plane( int(self.data_flight[5]) + 250, int(float(self.data_flight[6])) + 250, int(self.data_flight[7])) if int(self.data_flight[5]) == 0: self.airplane = Plane(int(self.data_flight[5]), int(float(self.data_flight[6])), int(self.data_flight[7])) self.airplane.draw_plane(self.draw, self.data_flight) tm.sleep(1) self.reset() def draw_radar(self): ''' Além do seu retorno essa função cria a variável self.base esta variável matém as informações das cores na tela após o desenho do radar. :return: Desenha as linhas do radar na tela. ''' self.draw = Draw(self.display) # Circulos concentricos self.draw.circle(250, 250, 62, 'green') self.draw.circle(250, 250, 124, 'green') self.draw.circle(250, 250, 186, 'green') self.draw.circle(250, 250, 248, 'green') # Linha do segundo ao quarto quadrante self.draw.line(0, 0, 500, 500, 'green', 1, 3) # Linha do terceiro ao primeiro quadrante self.draw.line(0, 500, 250, 250, 'green', 1, 3) self.draw.line(250, 250, 500, 0, 'green', 1, 3) # Linha horizontal self.draw.line(1, 250, 249, 249, 'green', 1, 3) self.draw.line(250, 250, 500, 250, 'green', 1, 3) # Linha vertical self.draw.line(250, 0, 250, 500, 'green', 1, 3) # Necessário o uso do deepcopy, uma vez que as listas do python se comportam como ponteiros. self.base = copy.deepcopy(self.draw.screen.pixels) self.get_plane() #Função para limpar a tela def reset(self): ''' Esta função realiza um loop por toda a variavel self.base. self.base é uma matriz(lista de listas) na organização self.base[coluna][linha] = "cor" self.base matém valores necessários para desenhar o radar. Neste loop, a função compara: Os valores da variável que guarda a cor de cada pixel, atualmente na tela. com Os valores da variável self.base :return: ''' for column_pixel in self.base: for pixel in column_pixel: if pixel != self.draw.screen.pixels[pixel.x][pixel.y]: self.draw.point(pixel.x, pixel.y, pixel.color, 1)
class Radar: #Separando os valores da classe def __init__(self): self.base = [] self.utils = Utils() self.table = "./planes/planilha de radar.csv" self.display = GraphWin("Radar", 500, 500) self.display.setBackground('black') #Função para ler o arquivo csv e colocar os aviões na tela def get_plane(self): #TODO: MUDAR A FORMA DE OBTENÇÃO DOS AVIÕES self.id_flight = [ 'LA 2203', 'GZ 0331', 'AZ 0032', 'AZ 0157', 'GZ 0667' ] self.airplane_routes = self.utils.transform_data_file( self.utils.read_csv(self.table)) for time in range(0, 151, 10): for flight in self.id_flight: self.data_flight = self.airplane_routes.get( (str(time), flight)) if int(self.data_flight[5]) != 0: self.airplane = Plane( int(self.data_flight[5]) + 250, int(float(self.data_flight[6])) + 250, int(self.data_flight[7])) if int(self.data_flight[5]) == 0: self.airplane = Plane(int(self.data_flight[5]), int(float(self.data_flight[6])), int(self.data_flight[7])) self.airplane.draw_plane(self.draw, self.data_flight) tm.sleep(2) self.reset() print('acabei o loop') #Função que desenha o radar e coloca os aviões na tela def draw_radar(self): self.draw = Draw(self.display) self.draw.circle(250, 250, 62, 'green') self.draw.circle(250, 250, 124, 'green') self.draw.circle(250, 250, 186, 'green') self.draw.circle(250, 250, 248, 'green') # Linha do segundo ao quarto quadrante self.draw.line(0, 0, 500, 500, 'green', 1, 3) # Linha do terceiro ao primeiro quadrante self.draw.line(0, 500, 250, 250, 'green', 1, 3) self.draw.line(250, 250, 500, 0, 'green', 1, 3) # Linha horizontal self.draw.line(1, 250, 249, 249, 'green', 1, 3) self.draw.line(250, 250, 500, 250, 'green', 1, 3) # Linha vertical self.draw.line(250, 0, 250, 500, 'green', 1, 3) self.base = copy.deepcopy(self.draw.screen.pixels) self.get_plane() #Função para limpar a tela def reset(self): for column_pixel in self.base: for pixel in column_pixel: if pixel != self.draw.screen.pixels[pixel.x][pixel.y]: self.draw.point(pixel.x, pixel.y, pixel.color, 1)