Пример #1
0
    def __init__(self, win, nch, nlin, winx, winy):
        # Was Helvetica,14
        self.fontedit = Fastfont(win, 'Courier New', 14, white, False,
                                 False)  # name, size, bold,italic

        # Edit window: 6 line of 64 chars
        self.content = []
        self.nch = nch  # number of chars per line
        self.nlin = nlin  # number of lines in windows
        self.winx = winx  # x-coordinate in pixels of left side
        self.winy = winy - self.nlin * self.fontedit.linedy  # y-coordinate in pixels of top
        self.msg = []  # Messages in edit window

        for i in range(self.nlin):
            line = self.nch * [' ']
            self.content.append(line)
        self.content0 = self.content

        self.xcursor = 0
        self.xedit = 0
        # self.printeditwin('Testing 1,2,3')
        self.bmpdy = self.nlin * self.fontedit.linedy
        self.bmpdx = self.nch * self.fontedit.linedy * 10 / 17 + 2  # Guess max aspect ratio
        self.bmp = pg.Surface([self.bmpdx, self.bmpdy], pg.SRCALPHA, 32)

        self.bmp.fill(darkblue)
        self.rect = pg.Rect(self.winx, self.winy, self.bmpdx, self.bmpdy)
        self.redraw = True

        return
Пример #2
0
    def init(self):
        # Read Screen configuration file:
        print
        print "Setting up screen..."

        lst = np.genfromtxt("data/graphics/scr_cfg.dat",
                            comments='#',
                            dtype='i4')

        self.swfullscreen = int(lst[0]) == 0

        self.width = int(lst[1])  # default value to create variable
        self.height = int(lst[2])  # default value to create variable

        # Dimensions radar window
        self.lat1 = 53.  # [deg] upper limit display
        self.lat0 = 51.  # [deg] lowerlimit display
        self.lon0 = -1.  # [deg] left side of screen

        dellat = self.lat1 - self.lat0

        avelat = (self.lat0 + self.lat1) * 0.5

        dellon = dellat * self.width / (self.height * cos(radians(avelat)))
        avelon = (self.lon0 + dellon / 2. + 180.) % 360. - 180.

        self.lon1 = (self.lon0 + dellon + 180.) % 360. - 180.

        self.ctrlat = avelat
        self.ctrlon = avelon

        #----------------------------SYMBOLS-----------------------------
        # Read graphics for acsymbol (normal = green) + amber
        self.acsymbol = []
        for i in range(60):
            self.acsymbol.append(pg.image.load("data/graphics/acsymbol/acsymbol" \
                                  + str(i) + ".png"))

        self.ambacsymbol = []
        for i in range(60):
            self.ambacsymbol.append(pg.image.load("data/graphics/amb-acsymbol/amb-acsymbol" \
                                     + str(i) + ".png"))

        # Lable lines& default no trails
        self.swlabel = 3

        # Read and scale waypoint symbol
        wptgif = pg.image.load("data/graphics/waypoint.gif")
        self.wptsymbol = pg.transform.scale(wptgif, (10, 7))
        self.wpsw = 1  # 0=None, 1 = VOR 2 = non-digit ones, 3 =all

        # Read and scale airport symbol
        aptgif = pg.image.load("data/graphics/airport.gif")
        self.aptsymbol = pg.transform.scale(aptgif, (12, 9))
        self.apsw = 1  # 0 = None, 1 = Large, 2 = All

        # Free flight displays
        self.swsep = False  # To show circles of 2.5 nm radius around each aircraft
        # Note: circles will be distorted when away from equator
        self.swspd = False  # To show speed vectors of each aircraft
        self.swtestarea = False

        #--------------------------------MAPS---------------------------------
        # Read map of world
        self.mapbmp = pg.image.load("data/graphics/world.jpg")
        w, h = self.mapbmp.get_size()

        # Two ref positions for scaling, convert to scaling factors x=a*lat+b
        x1, y1, lat1, lon1 = 0., 0., 90., -180.
        x2, y2, lat2, lon2 = w, h, -90., 180.
        self.mapax = (x2 - x1) / (lon2 - lon1)
        self.mapbx = x2 - self.mapax * lon2
        self.mapay = (y2 - y1) / (lat2 - lat1)
        self.mapby = y2 - self.mapay * lat2

        self.swsat = True

        # Nav display projection mode
        self.swnavdisp = False
        self.ndacid = ""
        self.ndlat = 0.0
        self.ndlon = 0.0
        self.ndhdg = 0.0

        #------------------------WINDOW SETUP and scaling--------------------------
        # Empty tuple to force reselection waypoints & airports to be drawn
        self.navsel = (
        )  # Empty tuple to force reselection waypoints to be drawn
        self.satsel = (
        )  # Empty tuple to force reselection satellite imagery to be drawn

        # Set up window
        splash.destroy()  # does pg.display.quit()!
        pg.display.init()

        # Full screen
        di = pg.display.Info()
        if self.swfullscreen:
            self.width = di.current_w
            self.height = di.current_h
            reso = (self.width, self.height)
            self.win = pg.display.set_mode(reso, pg.FULLSCREEN)
        else:
            # Windowed
            self.height = min(self.height, di.current_h * 90 / 100)
            self.width = min(self.width, di.current_w * 90 / 100)
            reso = (self.width, self.height)
            self.win = pg.display.set_mode(reso)

        pg.display.set_caption(
            "BlueSky Open ATM Simulator (F11 = Full Screen)", "BlueSky")
        iconpath = imgpath = "data/graphics/icon.gif"
        iconbmp = pg.image.load(iconpath)
        pg.display.set_icon(iconbmp)

        self.radbmp = self.win.copy()
        self.redrawradbg = True  # Switch to redraw background

        #---------------------RADAR FONTS & EDIT WINDOW-----------------------------
        # Set up fonts
        self.fontrad = Fastfont(self.win, 'Arial', 14, green, False,
                                False)  # name, size, bold,italic
        self.fontamb = Fastfont(self.win, 'Arial', 14, amber, False,
                                False)  # name, size, bold,italic
        self.fontnav = Fastfont(self.win, 'Arial', 12, lightgreyblue, False,
                                False)  # name, size, bold,italic
        self.fontsys = Fastfont(self.win, 'Helvetica', 14, white, False,
                                False)  # name, size, bold,italic

        # Edit window: 6 line of 64 chars
        nch = lst[3]  # number of chars per line
        nlin = lst[4]  # number of lines in windows
        winx = lst[5]  # x-coordinate in pixels of left side
        winy = self.height - lst[6]  # y-coordinate in pixels of bottom
        self.editwin = Console(self.win, nch, nlin, winx, winy)

        # Menu button window
        self.menu = Menu(self.win, 10, 36)

        #-------------------------COASTLINE DATA--------------------------------------
        # Init geo (coastline)  data
        f = open("data/global/coastlines.dat", 'r')
        print "Reading coastlines.dat"
        lines = f.readlines()
        f.close()
        records = []
        for line in lines:
            if not (line.strip() == "" or line.strip()[0] == '#'):
                arg = line.split()
                if len(arg) == 3:
                    records.append([arg[0], float(arg[1]), float(arg[2])])

        # print len(records), " records read."
        # Convert pen up/pen down format of coastlines to numpy arrays with lat/lon

        coastlat0 = []
        coastlon0 = []
        coastlat1 = []
        coastlon1 = []
        clat, clon = -1, -1

        for rec in records:
            lat, lon = rec[1], rec[2]
            if rec[0] == 'D':
                coastlat0.append(clat)
                coastlon0.append(clon)
                coastlat1.append(lat)
                coastlon1.append(lon)
            clat, clon = lat, lon

        self.coastlat0 = np.array(coastlat0)
        self.coastlon0 = np.array(coastlon0)
        self.coastlat1 = np.array(coastlat1)
        self.coastlon1 = np.array(coastlon1)

        del coastlat0, coastlon0, coastlat1, coastlon1  # Clear memory

        self.geosel = ()  # Force reselect first time coastlines
        self.firsel = ()  # Force reselect first time FIR lines

        print "    ", len(self.coastlat0), " coastlines added."

        # Set default coastlines & FIRs on:
        self.swgeo = True
        self.swfir = True
        self.swgrid = False

        # Route drawing for which acid? "" =  None
        self.acidrte = ""
        self.rtewpid = []
        self.rtewplabel = []

        # User defined background objects
        self.objtype = []
        self.objcolor = []
        self.objdata = []
        self.objname = []

        # Wpt and apt drawing logic memory
        self.wpswbmp = []  # switch indicating whether label bmp is present
        self.wplabel = []  # List to store bitmaps of label
        self.apswbmp = []  # switch indicating whether label bmp is present
        self.aplabel = []  # List to store bitmaps of label

        self.updateNavBuffers()
        return