def __init__(self, position, size, pyGaugesPanel, fontName, fontSize, fontColor, name="InputTextField"): logging.info("init InputTextField %s ", name) Container.__init__(self, position, size, name) self.entryAccepted = False self.setBorder(1, OpenGL3lib.COLOR_GREY) self.setSelectedBorder(1, OpenGL3lib.COLOR_WHITE) self.setBackgroundColor(OpenGL3lib.COLOR_BLACK) self.setBackgroundColorSelected(OpenGL3lib.COLOR_BLUE) self.textField = OpenGL3lib.GL_Font(fontName, fontSize, fontColor, True, 0) self.textHintField = OpenGL3lib.GL_Font(fontName, fonts.FONT_SIZE_MED, fontColor, True, 0) self.hintList = None self.possibleHints = [] self.hintListBackground = None self.text = "" self.name = name pyGaugesPanel.registerMouseButtonCallback(self.mouseButtonCallback) pyGaugesPanel.registerMouseCursorPosCallback( self.mouseCursorPosCallback) pyGaugesPanel.registerKeyCallback(self.keyCallback) pyGaugesPanel.registerCharCallback(self.charCallback)
def __init__(self, position, size, eventManager, fontName, fontSize, fontColor, name="TextBox"): logging.info("init TextBox %s ", name) Container.__init__(self, position, size, name) self.name = name self.setClipping(True) self.linespacing = 0 self.buffer = collections.deque() self.textFieldsArray = [] textField = OpenGL3lib.GL_Font(fontName, fontSize, fontColor, True, 0) self.nrDisplayedLines = (self.height // (textField.textHeight + self.linespacing)) for i in range(0, self.nrDisplayedLines + 1): textField = OpenGL3lib.GL_Font(fontName, fontSize, fontColor, True, 0) self.textFieldsArray.append([ textField, (self.height - textField.textHeight - (textField.textHeight + self.linespacing) * i) ])
def __init__(self,position, size, pyGaugesPanel, batchImageRenderer): self.titleBarFont = OpenGL3lib.GL_Font("data/fonts/Envy-Code-R.ttf", fonts.FONT_SIZE_MED, fonts.TXT_COLOR_WHITE, True, 0) self.batchImageRenderer = batchImageRenderer graphicsGL3.Window.__init__(self,position, size, pyGaugesPanel, self.titleBarFont, batchImageRenderer, 1, "Airport Plate Browser Window") #self.clipping = True self.setTitleText("Airport Plates Browser") pyGaugesPanel.registerKeyCallback(self.keyCallback) pyGaugesPanel.registerScrollCallback(self.scrollCallback) pyGaugesPanel.registerMouseCursorPosCallback(self.mouseMovePlateTextureCallback) self.createAirportList() self.airportPlanePanel = graphicsGL3.Container( (0,0), (self.width-4,self.height-self.titleBarHeight-4), False ) self.airportPlanePanel.setClipping(True) self.addItem(self.airportPlanePanel, (2,2),False) self.plate_texture = OpenGL3lib.GL_Texture("data/AirportPlates/FR-LFHM-MEGEVE-2.png", True) self.airportPlateImage = graphicsGL3.ImagePanel(self.plate_texture, batchImageRenderer, 1, [0,0], [self.width-4,self.height-2], [0 ,0 ]) self.airportPlateImage.resize([self.width-4,self.airportPlanePanel.height-2]) self.airportPlanePanel.addItem(self.airportPlateImage, (float(self.width-4)/2,float(self.airportPlanePanel.height-2)/2),False) self.inputText = graphicsGL3.InputTextField([0,0],[self.width,20], pyGaugesPanel, "data/fonts/Envy-Code-R.ttf", fonts.FONT_SIZE_LARGE, fonts.TXT_COLOR_WHITE) self.inputText.addHintList(self.airportNames) self.addItem(self.inputText, (0,0), False) self.loadAirportPage(self.airportNames[0],0) self.textRotation = 0
def __init__(self,position, size, eventManager, batchImageRenderer, layer = 0): self.titleBarFont = OpenGL3lib.GL_Font("data/fonts/Envy-Code-R.ttf", fonts.FONT_SIZE_MED, fonts.TXT_COLOR_WHITE, True, 0) self.consoleFont = OpenGL3lib.GL_Font("data/fonts/Envy-Code-R.ttf", fonts.FONT_SIZE_SMALL, fonts.TXT_COLOR_WHITE, True, 0) graphicsGL3.Window.__init__(self,position, size, eventManager, self.titleBarFont, batchImageRenderer, layer, "Console Window") #self.clipping = True self.setTitleText("Loading...") self.textBox = graphicsGL3.TextBox((0,0),(self.width-2, self.height - self.titleBarHeight-2),eventManager,"data/fonts/Envy-Code-R.ttf", fonts.FONT_SIZE_MED, fonts.TXT_COLOR_WHITE) self.addItem(self.textBox,(1,1),False)
def mouseCursorPosCallback(self, xpos, ypos): mousePos = OpenGL3lib.returnOpenGLcoord((xpos, ypos)) if (mousePos[0] >= self.x) and (mousePos[0] <= (self.x + self.width)): if (mousePos[1] >= self.y + self.height - self.titleBarHeight) and (mousePos[1] <= (self.y + self.height)): self.MOUSE_OVER_TITLEBAR = True else: self.MOUSE_OVER_TITLEBAR = False else: self.MOUSE_OVER_TITLEBAR = False #print("mouse over me:", self.MOUSE_OVER_ME) self.dragged = False if (self.titleBarLeftClicked == True) and (self.previousMouseLeftBtnState == "DOWN"): # I have been dragged self.dragged = True self.mousedisplacement_x = mousePos[0] - self.previousMousePos[0] self.mousedisplacement_y = mousePos[1] - self.previousMousePos[1] self.moveBy(self.mousedisplacement_x, self.mousedisplacement_y) self.previousMousePos = mousePos #logging.debug("leftclicked:%s, dragged: %s, mouse move: %s, %s", self.leftClicked, self.dragged, self.mousedisplacement_x, self.mousedisplacement_y) super(Window, self).mouseCursorPosCallback(xpos, ypos)
def mouseMovePlateTextureCallback(self, xpos, ypos): mousePos = OpenGL3lib.returnOpenGLcoord((xpos,ypos)) if (self.leftClicked == True) and (self.previousMouseLeftBtnState == "DOWN") and (self.MOUSE_OVER_TITLEBAR == False): self.textXdispl -= mousePos[0] - self.previousMousePosPlateText[0] self.textYdispl -= mousePos[1] - self.previousMousePosPlateText[1] self.airportPlateImage.translateTexture(self.textXdispl,self.textYdispl) self.previousMousePosPlateText = mousePos
def __init__(self, position, size, pyGaugesPanel, GLFont, batchImageRenderer, layer=0, name="Window"): self.titleBarHeight = 25 self.layer = layer logging.info("init Window %s, titleBarHeight: %s", name, self.titleBarHeight) Container.__init__(self, position, size, name) self.texture = OpenGL3lib.GL_Texture( "data/window/window_grey_transparent_bgd.png") self.setBorder(1, OpenGL3lib.COLOR_GREY) self.setSelectedBorder(1, OpenGL3lib.COLOR_WHITE) self.background = ImagePanel(self.texture, batchImageRenderer, self.layer, [0, 0], [self.width, self.height], [0, 0]) self.background.resize([self.width, self.height]) self.addItem(self.background, (self.width / 2, self.height / 2), False) self.titleBarHeight = 25 self.titleBarbackground = ImagePanel(self.texture, batchImageRenderer, self.layer, [0, 0], [self.width, self.titleBarHeight], [0, 0]) self.titleBarbackground.resize([self.width, self.titleBarHeight]) self.titleBar = Container((0, 0), (self.width, self.titleBarHeight), "Window title bar") self.titleBar.setBorder(1, OpenGL3lib.COLOR_GREY) self.titleBar.setSelectedBorder(1, OpenGL3lib.COLOR_WHITE) self.titleBar.addItem(self.titleBarbackground, (self.width / 2, self.titleBarHeight / 2), False) self.addItem(self.titleBar, (0, self.height - self.titleBarHeight), False) self.titleBarText = TextField(GLFont) self.titleBar.addItem( self.titleBarText, (5, (self.titleBarHeight / 2 - GLFont.textHeight / 2)), False) pyGaugesPanel.registerMouseButtonCallback(self.mouseButtonCallback) pyGaugesPanel.registerMouseCursorPosCallback( self.mouseCursorPosCallback)
def __init__(self, texture, batchImageRenderer, layer=0, position=[0, 0], cliprect=None, origin=None, name=""): self.image = OpenGL3lib.GL_Image(texture, cliprect, origin) Panel.__init__(self, position, (self.image.width, self.image.height), texture.name) self.name = name self.XPUDPServer = XPlaneUDPServer.pyXPUDPServer batchImageRenderer.addImageToRenderQueue(self.image, layer) self.image.draw((self.x, self.y), self.width, self.height, None, self.rot_angle, self.rotationCenter, (self.text_xdev, self.text_ydev), self.text_rot_angle, self.text_zoom)
def __init__(self,position, size, XPlaneDataDispatcher, batchImageRenderer, texture, name = "G1000_ArtificialHorizon"): graphics.Container.__init__(self,position, size, name) self.testMode = False self.XPlaneDataDispatcher = XPlaneDataDispatcher self.batchImageRenderer = batchImageRenderer self.layer = 0 #------------------------------------------------------------------------------------------ # Artificial Horizon #------------------------------------------------------------------------------------------ G1000HorizonTexture = OpenGL3lib.GL_Texture("data/G1000_horizon.png") # def __init__(self, texture, batchImageRenderer, layer=0, position=[0,0], cliprect=None, origin=None, name = ""): self.G1000Horizon = graphics.ImagePanel(G1000HorizonTexture, batchImageRenderer, self.layer, (0,0), [835,626], [606,713]) #G1000_horizon self.G1000BankIndicator = graphics.ImagePanel(texture, batchImageRenderer, self.layer+1,(0,0),[400,200],[56,28], "G1000BankIndicator") #G1000_bankindicator self.G1000BankIndicator.resize((400,200)) self.G1000Bug = graphics.ImagePanel(texture, batchImageRenderer, self.layer+1,(0,0),[512,256],[512,0], "G1000BankIndicator") #G1000_bug self.G1000Bug.resize((512,256)) self.G1000PitchScale = graphics.ImagePanel(texture, batchImageRenderer, self.layer+1, (0,0), [215,210], [21,2048-1409-149]) #G1000_horizon self.G1000PitchScale.resize((215,210)) self.G1000Horizon.enableTextureRotation (XPlaneDataDispatcher,(17,1),[ [-180,-180],[180,180]]) self.G1000Horizon.enableTextureTranslation (XPlaneDataDispatcher,(17,0),[ [-70,-398],[70,398]]) self.G1000Horizon.setTextureRotationCenter((982,2048-939)) self.G1000PitchScale.enableTextureRotation (XPlaneDataDispatcher,(17,1),[ [-180,-180],[180,180]]) self.G1000PitchScale.enableTextureTranslation (XPlaneDataDispatcher,(17,0),[ [-70,-398],[70,398]]) self.G1000PitchScale.setTextureRotationCenter((128,2048-1460)) self.G1000BankIndicator.enableTextureRotation (XPlaneDataDispatcher,(17,1),[ [-180,-180],[180,180]]) self.G1000BankIndicator.setTextureRotationCenter((256,2048-1994)) BUG_BANK_IND_POS = [-43,156] self.addItem(self.G1000Horizon) self.addItem(self.G1000BankIndicator,BUG_BANK_IND_POS,False) self.addItem(self.G1000Bug,BUG_BANK_IND_POS,False) self.addItem(self.G1000PitchScale,(-42,90),False)
def mouseCursorPosCallback(self, xpos, ypos): mousePos = OpenGL3lib.returnOpenGLcoord((xpos, ypos)) if (mousePos[0] >= self.x) and (mousePos[0] <= (self.x + self.width)): if (mousePos[1] >= self.y) and (mousePos[1] <= (self.y + self.height)): self.MOUSE_OVER_ME = True else: self.MOUSE_OVER_ME = False else: self.MOUSE_OVER_ME = False #print("mouse over me:", self.MOUSE_OVER_ME) self.dragged = False if (self.leftClicked == True) and (self.previousMouseLeftBtnState == "DOWN"): # I have been dragged self.dragged = True self.mousedisplacement_x = mousePos[0] - self.previousMousePos[0] self.mousedisplacement_y = mousePos[1] - self.previousMousePos[1] if self.draggable == True: self.moveBy(self.mousedisplacement_x, self.mousedisplacement_y) self.previousMousePos = mousePos
def __init__(self, imageDir, imageBaseName, startStepNumber, endStepNumber, imageNameSuffix, indexPadding, position=[0, 0], cliprect=None, origin=None, testMode=False): self.image_name = imageBaseName logging.info("init AnimatedImage %s", self.image_name) imageBaseName = os.path.join(imageDir, imageBaseName) self.startStepNumber = startStepNumber self.endStepNumber = endStepNumber self.visibleFrame = startStepNumber self.imageFrames = {} if endStepNumber >= startStepNumber: for i in range(startStepNumber, endStepNumber + 1): index = str(i).zfill(indexPadding) imagename = imageBaseName + index + imageNameSuffix logging.debug("loading AnimatedImage %s", imagename) self.imageFrames[i] = OpenGL3lib.GL_Image( imagename, cliprect, origin) self.x = position[0] self.y = position[1] self.width = self.imageFrames[startStepNumber].width self.height = self.imageFrames[startStepNumber].height self.testMode = testMode self.testValue = 1 self.dataConvertFunction = False self.XPdataSource = False self.dataSourceReference = False
def initFonts(): fontKerning = 0 antialias = True global PROFONTWINDOWS_VSMALL_WHITE global PROFONTWINDOWS_VSMALL_TURQUOISE global PROFONTWINDOWS_SMALL_WHITE global PROFONTWINDOWS_SMALL_TURQUOISE global PROFONTWINDOWS_SMALL_GREEN global PROFONTWINDOWS_MED_WHITE global PROFONTWINDOWS_MED_GREY global PROFONTWINDOWS_MED_TURQUOISE global PROFONTWINDOWS_LARGE_WHITE global PROFONTWINDOWS_LARGE_PINK global PROFONTWINDOWS_LARGE_GREY global PROFONTWINDOWS_LARGE_TURQUOISE global PROFONTWINDOWS_VLARGE_WHITE global DIGITAL_ITAL_MED_ORANGE global DIGITAL_ITAL_XXLARGE_ORANGE global ARIAL_CONDENSED_SMALL_ORANGE global VERA_VSMALL_ORANGE global VERA_VSMALL_BOLD_ORANGE global VERA_14PT_BOLD_ORANGE global VERA_13PT_BOLD_ORANGE global VERA_15PT_BOLD_ORANGE global VERA_20PT_BOLD_ORANGE PROFONTWINDOWS_VSMALL_WHITE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_VSMALL, TXT_COLOR_WHITE, antialias, fontKerning) PROFONTWINDOWS_VSMALL_TURQUOISE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_VSMALL, TXT_COLOR_TURQUOISE, antialias, fontKerning) PROFONTWINDOWS_SMALL_WHITE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_13PT, TXT_COLOR_WHITE, antialias, fontKerning+1) PROFONTWINDOWS_SMALL_TURQUOISE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_13PT, TXT_COLOR_TURQUOISE, antialias, fontKerning+1) PROFONTWINDOWS_SMALL_GREEN = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_13PT, TXT_COLOR_GREEN, antialias, fontKerning+1) PROFONTWINDOWS_MED_WHITE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_15PT, TXT_COLOR_WHITE, antialias, fontKerning) PROFONTWINDOWS_MED_GREY = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_15PT, TXT_COLOR_GREY, antialias, fontKerning) PROFONTWINDOWS_MED_TURQUOISE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_15PT, TXT_COLOR_TURQUOISE, antialias, fontKerning) PROFONTWINDOWS_LARGE_WHITE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_LARGE, TXT_COLOR_WHITE, antialias, fontKerning) PROFONTWINDOWS_LARGE_PINK = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_LARGE, TXT_COLOR_PINK, antialias, fontKerning) PROFONTWINDOWS_LARGE_GREY = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_LARGE, TXT_COLOR_GREY, antialias, fontKerning) PROFONTWINDOWS_LARGE_TURQUOISE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_LARGE, TXT_COLOR_TURQUOISE, antialias, fontKerning) PROFONTWINDOWS_VLARGE_WHITE = OpenGL3lib.GL_Font(ProFontWindows, FONT_SIZE_VLARGE, TXT_COLOR_WHITE, antialias, fontKerning) DIGITAL_ITAL_MED_ORANGE = OpenGL3lib.GL_Font(DigitalItalicFont, FONT_SIZE_XLARGE, TXT_COLOR_ORANGE, antialias, -4) DIGITAL_ITAL_XXLARGE_ORANGE = OpenGL3lib.GL_Font(DigitalItalicFont, FONT_SIZE_XXLARGE, TXT_COLOR_ORANGE, antialias, -2) VERA_VSMALL_ORANGE = OpenGL3lib.GL_Font(Vera, FONT_SIZE_VSMALL, TXT_COLOR_ORANGE, antialias, 0) VERA_VSMALL_BOLD_ORANGE = OpenGL3lib.GL_Font(VeraB, FONT_SIZE_VSMALL, TXT_COLOR_ORANGE, antialias, 0) VERA_13PT_BOLD_ORANGE = OpenGL3lib.GL_Font(VeraB, FONT_SIZE_13PT, TXT_COLOR_ORANGE, antialias, 0) VERA_14PT_BOLD_ORANGE = OpenGL3lib.GL_Font(VeraB, FONT_SIZE_14PT, TXT_COLOR_ORANGE, antialias, 0) VERA_15PT_BOLD_ORANGE = OpenGL3lib.GL_Font(VeraB, FONT_SIZE_15PT, TXT_COLOR_ORANGE, antialias, 0) VERA_20PT_BOLD_ORANGE = OpenGL3lib.GL_Font(VeraB, FONT_SIZE_20PT, TXT_COLOR_ORANGE, antialias, 0)
def addHintList(self, hintList): self.hintList = hintList self.hintListBackground = OpenGL3lib.GL_Filled_Rectangle( self.width, 20, 1, OpenGL3lib.COLOR_BLUE)
#******************************************************************************************** G1000_Panel = pyGaugesPanel() G1000_Panel.initDisplay() G1000_Panel.initXPlaneDataServer() G1000_Panel.setDrawCallback(drawInstruments) #******************************************************************************************** # # Initialise your instruments in this section # #******************************************************************************************** #------------------------------------------------------------------------------------------ # Load Textures #------------------------------------------------------------------------------------------ standard6Texture = OpenGL3lib.GL_Texture("data/c172_text_standard6.png") compassTexture = OpenGL3lib.GL_Texture("data/gen_compass.png") G1000Texture = OpenGL3lib.GL_Texture("data/G1000_2048_texture.png") #------------------------------------------------------------------------------------------ # Instruments position #------------------------------------------------------------------------------------------ ANNUNCIATOR_pos = [793, 1003] ANNUNCIATOR_size = (446, 66) ART_HOR_POSITION = (500, 450) ART_HOR_SIZE = (835, 626) ALT_POSITION = (720, 533) ALT_SIZE = (125, 325) #------------------------------------------------------------------------------------------ # Import Instruments #------------------------------------------------------------------------------------------ from instruments import C172_AnnunciatorPanel
def setBackgroundColorSelected(self, color): self.backgroundRectangleSelected = OpenGL3lib.GL_Filled_Rectangle( self.width, self.height, 1, color)
def setSelectedBorder(self, linewidth, color): self.selectedBorder = OpenGL3lib.GL_rectangle(self.width, self.height, linewidth, color)
# #******************************************************************************************** RadioStack_Panel = pyXPPanel.pyXPPanel() RadioStack_Panel.initArduinoSerialConnection() RadioStack_Panel.setDrawCallback(drawInstruments) #******************************************************************************************** # # Initialise your instruments in this section # #******************************************************************************************** #------------------------------------------------------------------------------------------ # Load Textures #------------------------------------------------------------------------------------------ RadioStackTexture = OpenGL3lib.GL_Texture("data/2048_Radio_Stack_text.png") #------------------------------------------------------------------------------------------ # Instruments position #------------------------------------------------------------------------------------------ NAVCOMM_BK165_1_POS = (35, 670) NAVCOMM_BK165_2_POS = (35, 470) DME_KN6X_POS = (25, 337) BK_ADF_KR87_POS = (25, 240) BK_XPDR_KT70_POS = (50, 110) ALT_SIZE = (125, 325) #------------------------------------------------------------------------------------------ # Import Instruments #------------------------------------------------------------------------------------------ from instruments import BendixKing_NAVCOMM_KX165A from instruments import BendixKing_DME_KN6X