def configurationInterface(self): super().configurationInterface() changed, current = imgui.combo("Network Adapter", self.curAdapter, self.adapters) if changed: self.curAdapter = current self.rx_bytes = [] self.rx_bytes.append(0) self.tx_bytes = [] self.tx_bytes.append(0) log.logNorm("Network watch interface changed: " + self.adapters[current]) percent_changed, percent_val = imgui.input_int("Trigger Percent", self.triggerPercent, 5) if percent_changed: self.triggerPercent = percent_val floor_changed, floor_val = imgui.input_float("Alert Floor", self.alertFloor, 0.005) if floor_changed: self.alertFloor = floor_val
def input_int(label, id_str, input_val, set_val): imgui.text(label) imgui.same_line() changed, new_val = imgui.input_int(id_str, input_val) if changed: set_val(new_val)
def _edit_field_size(self, field_geometry: GeometryFieldSize): imgui.text("Field Size") imgui.separator() # Field Length changed, value = imgui.input_int("Field Length", field_geometry.field_length) if changed: if value >= 0: field_geometry.field_length = value else: self._log.error( f"Field length cannot be negative. Got {value}.") # Field Width changed, value = imgui.input_int("Field Width", field_geometry.field_width) if changed: if value >= 0: field_geometry.field_width = value else: self._log.error( f"Field width cannot be negative. Got {value}.") # Goal Width changed, value = imgui.input_int("Goal Width", field_geometry.goal_width) if changed: if value >= 0: field_geometry.goal_width = value else: self._log.error(f"Goal width cannot be negative. Got {value}.") # Goal Depth changed, value = imgui.input_int("Goal Depth", field_geometry.goal_depth) if changed: if value >= 0: field_geometry.goal_depth = value else: self._log.error(f"Goal depth cannot be negative. Got {value}.") # Boundary Width changed, value = imgui.input_int("Boundary Width", field_geometry.boundary_width) if changed: if value >= 0: field_geometry.boundary_width = value else: self._log.error( f"Boundary width cannot be negative. Got {value}.")
def draw(self): imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_input = imgui.input_int("Integer Input Test", self.test_input) imgui.end() arcade.draw_text(str(self.test_input), 512, 128, arcade.color.WHITE_SMOKE, 64)
def render(self): imgui.new_frame() imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_input = imgui.input_int("Integer Input Test", self.test_input) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_input = imgui.input_int("Integer Input Test", self.test_input) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def drawTools(self): imgui.begin("Drawing Tools") if self.draw_mode == "c": imgui.text_colored("Currently drawing: Circle", 0.0, 1.0, 0.0) elif self.draw_mode == "e": imgui.text_colored("Currently drawing: Circle", 0.0, 1.0, 0.0) else: imgui.text_colored("Nothing Currently Selected.", 0.0, 1.0, 0.0) imgui.new_line() if imgui.button("Circle", 100, 20): # imgui.core.button, https://github.com/ocornut/imgui/issues/2481 self.draw_mode = 'c' imgui.same_line(115) if imgui.button("Ellipse", 100, 20): self.draw_mode = 'e' if self.draw_mode == 'c': changed, self.vrad = imgui.input_int("Radius", self.vrad, 1, 100) # imgui.core.input_int changed, self.x_center = imgui.input_int("X-axis center", self.x_center, 1, 800) # imgui.core.slider_int, set max to window size changed, self.y_center = imgui.input_int("Y-axis center", self.y_center, 1, 600) changed, self.color = imgui.color_edit3("Set Color", *self.color) # asterisk used for tuple, I think... elif self.draw_mode == 'e': changed, self.vrad = imgui.input_int("Vertical Radius", self.vrad, 1, 100) # imgui.core.input_int # changed, self.vrad = imgui.slider_int("", self.vrad, 0, 1000) changed, self.hrad = imgui.input_int("Horizontal Radius", self.hrad, 1, 100) # changed, self.hrad = imgui.slider_int("Horizontal Radius", self.hrad, 0, 1000) changed, self.x_center = imgui.input_int("X-axis center", self.x_center, 1, 800) # imgui.core.slider_int, set max to window size changed, self.y_center = imgui.input_int("Y-axis center", self.y_center, 1, 600) changed, self.color = imgui.color_edit3("Set Color", *self.color) # asterisk used for tuple, I think... imgui.new_line() if imgui.button("Reset", 100, 20): self.color = [.0, .0, .0] self.draw_mode = "" self.vrad = 0 self.hrad = 0 self.x_center = 400 self.y_center = 300 imgui.same_line(115) if imgui.button("Enter", 100, 20): if self.draw_mode == "": pass elif self.draw_mode == "c": drawCircle = Circle(self.x_center, self.y_center, self.vrad, color=Color(self.color[0], self.color[1], self.color[2])) self.canvas.add_object(drawCircle) elif self.draw_mode == "e": drawEllipse = Ellipse(self.x_center, self.y_center, self.vrad, self.hrad, color=Color(self.color[0], self.color[1], self.color[2])) self.canvas.add_object(drawEllipse) imgui.end()
def render_ui(self): imgui.new_frame() if imgui.begin("Settings"): imgui.push_item_width(imgui.get_window_width() * 0.33) changed = False c, SlimeConfig.move_speed = imgui.slider_float( "Movement speed", SlimeConfig.move_speed, 0.5, 50 ) changed = changed or c c, SlimeConfig.turn_speed = imgui.slider_float( "Turn speed", SlimeConfig.turn_speed, 0.5, 50, ) changed = changed or c c, SlimeConfig.evaporation_speed = imgui.slider_float( "Evaporation speed", SlimeConfig.evaporation_speed, 0.1, 10 ) changed = changed or c c, SlimeConfig.diffusion_speed = imgui.slider_float( "Diffusion speed", SlimeConfig.diffusion_speed, 0.1, 10, ) changed = changed or c c, SlimeConfig.sensor_angle = imgui.slider_float( "Sensor-angle", SlimeConfig.sensor_angle, 0, np.pi, ) changed = changed or c c, SlimeConfig.sensor_size = imgui.slider_int( "Sensor-size", SlimeConfig.sensor_size, 1, 3, ) changed = changed or c c, SlimeConfig.sensor_distance = imgui.slider_int( "Sensor distance", SlimeConfig.sensor_distance, 1, 10, ) changed = changed or c if changed: self.update_uniforms() imgui.pop_item_width() imgui.end() if imgui.begin("Appearance"): imgui.push_item_width(imgui.get_window_width() * 0.33) changed_c1, SlimeConfig.color1 = imgui.color_edit3( "Color1", *SlimeConfig.color1 ) changed_c2, SlimeConfig.color2 = imgui.color_edit3( "Color2", *SlimeConfig.color2 ) if changed_c1 or changed_c2: self.update_uniforms() imgui.end() if imgui.begin("Actions"): imgui.push_item_width(imgui.get_window_width() * 0.33) changed, SlimeConfig.N = imgui.input_int( "Number of Slimes", SlimeConfig.N, step=1024, step_fast=2**15 ) SlimeConfig.N = min(max(2048, SlimeConfig.N), 2**24) if imgui.button("Restart Slimes"): self.restart_sim() imgui.pop_item_width() imgui.end() imgui.render() self.imgui.render(imgui.get_draw_data())
def display_parameter(parameter, editable): global slider_indexes if parameter.type == "List": if len(parameter.list) == 0: imgui.text("Empty list") else: if parameter.id not in slider_indexes: slider_indexes[parameter.id] = 0 changed, values = imgui.slider_int("index", slider_indexes[parameter.id], 0, len(parameter.list)-1) if changed: slider_indexes[parameter.id] = values display_parameter(parameter.list[slider_indexes[parameter.id]], editable) if parameter.type == "Image": if parameter.image: image_to_texture = get_gl_texture(parameter.image, parameter.timestamp) # imgui.image(image_texture, image_width, image_height) window_width = 256 # imgui.get_window_width() display_width = 0 display_height = 0 image_width = image_to_texture.gl_widh image_height = image_to_texture.gl_height if image_width >= image_height: display_width = window_width display_height = image_height / (image_width/float(display_width)) else: display_height = window_width display_width = image_width / (image_height/float(display_height)) imgui.image(image_to_texture.gl_texture, display_width, display_height) imgui.text("width: " + str(parameter.image.width)) imgui.text("height: " + str(parameter.image.height)) else: imgui.text("No image available - run workflow or connect an image source") elif parameter.type == "Rectangle": if editable: changed, value = imgui.input_float("Left", parameter.left) if changed: parameter.left = value changed, value = imgui.input_float("Top", parameter.top) if changed: parameter.top = value changed, value = imgui.input_float("Right", parameter.right) if changed: parameter.right = value changed, value = imgui.input_float("Bottom", parameter.bottom) if changed: parameter.left = value else: imgui.text("Left: " + str(parameter.left)) imgui.text("Top: " + str(parameter.top)) imgui.text("Right: " + str(parameter.right)) imgui.text("Bottom: " + str(parameter.bottom)) elif parameter.type == "Coordinates": if editable: changed, value = imgui.input_float("x", parameter.x) if changed: parameter.x = value changed, value = imgui.input_float("y", parameter.y) if changed: parameter.y = value else: imgui.text("x: " + str(parameter.x)) imgui.text("y: " + str(parameter.y)) elif parameter.type == "Integer": # to do change to "number" if editable: changed, value = imgui.input_int("Value", parameter.value) if changed: parameter.value = value else: imgui.text("Value: " + str(parameter.value)) elif parameter.type == "Color": changed, color = imgui.color_edit4(parameter.id, parameter.r, parameter.g, parameter.b, parameter.a) if editable and changed: parameter.r = color[0] parameter.g = color[1] parameter.b = color[2] parameter.a = color[3] elif parameter.type == "URL": changed, textval = imgui.input_text(parameter.id, parameter.url, 1024) if editable and changed: parameter.url = textval if editable: if imgui.button("browse..."): root = tk.Tk() root.withdraw() file_path = filedialog.askopenfilename() if file_path: parameter.url = file_path elif parameter.type == "Text": changed, textval = imgui.input_text(parameter.id, parameter.text, 1024) if editable and changed: parameter.text = textval
def render(self): imgui.render() self.impl.render(imgui.get_draw_data()) imgui.new_frame() # --Imgui Windows-- # --Note: Variables are defined in __init__ under Imgui Window Variables if self.showPlayerControls: imgui.begin("Player Controls") imgui.text("Current State:") imgui.text(wire_sponge.curState.name) imgui.new_line() imgui.begin_child("movement", 320, 180, border=True) imgui.text("Movement") if imgui.button("Turn to Opposite", 300, 20): if wire_sponge.facing == Facing.left: wire_sponge.facing == Facing.right else: wire_sponge.facing = Facing.left if imgui.button("Face Left", 140, 20): wire_sponge.facing = Facing.left imgui.same_line(spacing=20) if imgui.button("Face Right", 140, 20): wire_sponge.facing = Facing.right if imgui.button("Walk (Toggle)", 300, 20): pass if imgui.button("Walk Left", 140, 20): pass imgui.same_line(spacing=20) if imgui.button("Walk Right", 140, 20): pass if imgui.button("Jump", 300, 20): if wire_sponge.on_ground: wire_sponge.setState(SpongeState.leapBegin) wire_sponge.on_ground = False imgui.new_line() imgui.end_child() imgui.begin_child("skills", 320, 120, border=True) imgui.text("Attacks and Skills") if imgui.button("Attack", 300, 20): if wire_sponge.chain.curState == ChainState.NaN \ and wire_sponge.curState != SpongeState.throwHrz \ and wire_sponge.curState != SpongeState.throwHrzRelease \ and wire_sponge.curState != SpongeState.throwHrzPullGo: wire_sponge.setState(SpongeState.throwHrzBegin) if imgui.button("Chain Spin", 300, 20): if wire_sponge.on_ground and wire_sponge.curState != SpongeState.spin: wire_sponge.setState(SpongeState.spin) if imgui.button("Thunder Dance", 300, 20): pass imgui.new_line() imgui.end_child() imgui.end() if self.showDummyControls: imgui.begin("Dummy Controls") imgui.begin_child("spawn", 320, 80, border=True) imgui.text("Spawn Controls") if imgui.button("Respawn", 300, 20): pass if imgui.button("Spawn", 140, 20): pass imgui.same_line(spacing=20) if imgui.button("Despawn", 140, 20): pass imgui.new_line() imgui.end_child() imgui.begin_child("behaviour", 320, 80, border=True) imgui.text("Behaviour Controls") changed, self.actStand = imgui.checkbox("Stand", self.actStand) changed, self.actMove = imgui.checkbox("Move", self.actMove) changed, self.actAttack = imgui.checkbox("Attack", self.actAttack) imgui.new_line() imgui.end_child() imgui.end() if self.showControlHelp: imgui.begin("Control Help") imgui.text("Arrow Keys: Move") imgui.text("Space: Jump") imgui.text("Z: Thunder Dance") imgui.text("X: Spin Chain") imgui.text("C: Attack") imgui.end() if self.showTestWindow: imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_checkbox = imgui.checkbox("Test Checkbox", self.test_checkbox) if imgui.button("Test Button", 100, 20): pass changed, self.test_input_int = imgui.input_int("Integer Input Test", self.test_input_int) imgui.end() # --This is where the fun begins-- if imgui.begin_main_menu_bar(): if imgui.begin_menu("Application", True): selected_test, clicked_test = imgui.menu_item( "Test Window", "", False, True ) if clicked_test: if not self.showTestWindow: self.showTestWindow = True else: self.showTestWindow = False if selected_test: pass selected_quit, clicked_quit = imgui.menu_item( "Quit", "", False, True ) if clicked_quit: exit(0) if selected_quit: pass imgui.end_menu() if imgui.begin_menu("Controls", True): selected_reset, clicked_reset = imgui.menu_item( "Reset All", "", False, True ) if clicked_reset: pass if selected_reset: pass selected_player, clicked_player = imgui.menu_item( "Player", "", False, True ) if clicked_player: if not self.showPlayerControls: self.showPlayerControls = True else: self.showPlayerControls = False if selected_player: pass selected_dummy, clicked_dummy = imgui.menu_item( "Dummy", "", False, True ) if clicked_dummy: if not self.showDummyControls: self.showDummyControls = True else: self.showDummyControls = False if selected_dummy: pass imgui.end_menu() if imgui.begin_menu("Help", True): selected_controls, clicked_controls = imgui.menu_item( "Keyboard Controls", "", False, True ) if clicked_controls: if self.showControlHelp: self.showControlHelp = False else: self.showControlHelp = True if selected_controls: pass selected_about, clicked_about = imgui.menu_item( "About", "", False, True ) if clicked_about: if self.showAbout: self.showAbout = False else: self.showAbout = True if selected_about: pass imgui.end_menu() imgui.end_main_menu_bar() imgui.end_frame()
def main(): loadFlightData() imgui.create_context() window = impl_glfw_init() impl = GlfwRenderer(window) while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() # get the style object and edit the object to make it look decent with GLFW style = imgui.get_style() style.window_rounding = 0 style.frame_rounding = 0 #create the main ImGuI frame to then use to display the actual GUI on imgui.new_frame() flags = imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_MENU_BAR imgui.set_next_window_size(window_width, window_height) imgui.set_next_window_position(0, 0) # Start the beginning of the ImGui window, drone flight logger being an ID imgui.begin("Drone Flight Logger", False, flags=flags) if imgui.button("Add new Flight"): imgui.open_popup("test") imgui.same_line() imgui.text("Total Flight Time: " + str(flights.getTotalFlightTime()) + "h") imgui.same_line() imgui.text("| Total Batteries Used: " + str(flights.getTotalBatteriesUsed())) # Main Menu Bar Code mainMenuBar() # create a child window in the inital window to divide the window up so there can be a preview on the left imgui.begin_child("flight_selector", width=window_width / 5 * 2, border=True) # loop through all flights and assign flight as the key value for flight in flights.getFlights(): # get the flight data based off the flight name flight_data = flights.getFlights()[flight] # if the flight location is in the List variable of currently selected locations show it if currentSelectedLocations[flight_data.getLocationName()]: # flight drop down code, passing in the flight name and flight data flightDropDown(flight, flight_data) imgui.end_child() imgui.same_line() # create the preview sidepane of the main window imgui.begin_child("flight_info", border=True) # if there is the key preview in currentviewingflightdata show the image. Done this way as I will eventually add in the flight location and other stats to the sidepane as well if "preview" in currentViewingFlightData: imgui.image(currentViewingFlightData["preview"]['image'], currentViewingFlightData["preview"]['width'] / 6, currentViewingFlightData["preview"]['height'] / 6) imgui.end_child() if imgui.begin_popup_modal("test")[0]: addNewFlightData["date"] = imgui.input_text( "Flight date", addNewFlightData["date"], 2046)[1] addNewFlightData["batteries_used"] = imgui.input_int( 'Batteries used', addNewFlightData["batteries_used"])[1] addNewFlightData["flight_time"] = imgui.input_int( 'Flight time in minutes', addNewFlightData["flight_time"])[1] addNewFlightData["location_name"] = imgui.input_text( "Flight location", addNewFlightData["location_name"], 2046)[1] addNewFlightData["copyFromFolder"] = imgui.input_text( "Folder with new flight media", addNewFlightData["copyFromFolder"], 2046)[1] if imgui.button("test"): handleAddNewFlight() imgui.close_current_popup() # imgui.text("Select an option:") # imgui.separator() # imgui.selectable("One") # imgui.selectable("Two") # imgui.selectable("Three") imgui.end_popup() imgui.end() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) impl.shutdown() glfw.terminate()
def userInterface(graphicItem, app): """ Control graphicItem parameters interactively """ imgui.new_frame() expanded, opened = imgui.begin('Controls', closable=True, flags=imgui.WINDOW_ALWAYS_AUTO_RESIZE) if opened: # Field to show current = app.ifield changed, current = imgui.combo('Field', current, list(CHOICES)) if changed: app.setField(current) # Speed Rate changed, speed = imgui.drag_float('Speed', graphicItem.speedFactor, 0.01, 0.0, 10.0) if changed: graphicItem.speedFactor = speed # Decay changed, decay = imgui.drag_float('Decay', graphicItem.decay, 0.001, 0.001, 1.0) if changed: graphicItem.decay = decay # Drop Rate Bump changed, decayBoost = imgui.drag_float('Decay boost', graphicItem.decayBoost, 0.01, 0.001, 1.0) if changed: graphicItem.decayBoost = decayBoost # Unknown const changed, opacity = imgui.drag_float('Opacity', graphicItem.fadeOpacity, 0.001, 0.900, 0.999, '%.4f') if changed: graphicItem.fadeOpacity = opacity # Palette changed, color = imgui.color_edit3('Color', *graphicItem.color) if changed: graphicItem.color = color imgui.same_line() changed, palette = imgui.checkbox("Palette", graphicItem.palette) if changed: graphicItem.palette = palette changed, bg_color = imgui.color_edit4('Background color', *app.bg_color) if changed: app.bg_color = bg_color # Point size changed, pointSize = imgui.input_int("Point size", graphicItem.pointSize, 1, 1, 1) if changed: if pointSize > 5: pointSize = 5 elif pointSize < 1: pointSize = 1 graphicItem.pointSize = pointSize # Number of Points changed, tracersCount = imgui.drag_int("Number of " "Tracers", graphicItem.tracersCount, 1000.0, 4000, 10000000) if changed: graphicItem.tracersCount = tracersCount # Periodic border changed, periodic = imgui.checkbox("Periodic", graphicItem.periodic) if changed: graphicItem.periodic = periodic # Draw field changed, drawfield = imgui.checkbox("Draw Field", graphicItem.drawField) if changed: graphicItem.drawField = drawfield imgui.end() imgui.render() return opened
def drawTools(self): imgui.begin("Drawing Tools") if imgui.button("Reset", 207, 20): self.color = .0, .0, .0 self.drawMode = "" self.vrad = 0 self.hrad = 0 self.x_center = 400 self.y_center = 300 if imgui.button( "Circle", 100, 20 ): # imgui.core.button, https://github.com/ocornut/imgui/issues/2481 self.drawMode = "c" imgui.same_line(115) if imgui.button("Ellipse", 100, 20): self.drawMode = "e" imgui.new_line() if self.drawMode == "c": changed, self.vrad = imgui.input_int("Radius", self.vrad, 1, 100) # imgui.core.input_int changed, self.x_center = imgui.slider_int( "X-axis center", self.x_center, 0, 800) # imgui.core.slider_int, set max to window size changed, self.y_center = imgui.slider_int("Y-axis center", self.y_center, 0, 600) changed, self.color = imgui.color_edit3( "Set Color", *self.color) # asterisk used for tuple, I think... elif self.drawMode == "e": changed, self.vrad = imgui.input_int("Vertical Radius", self.vrad, 1, 100) # imgui.core.input_int # changed, self.vrad = imgui.slider_int("", self.vrad, 0, 1000) changed, self.hrad = imgui.input_int("Horizontal Radius", self.hrad, 1, 100) # changed, self.hrad = imgui.slider_int("Horizontal Radius", self.hrad, 0, 1000) changed, self.x_center = imgui.slider_int( "X-axis center", self.x_center, 0, 800) # imgui.core.slider_int, set max to window size changed, self.y_center = imgui.slider_int("Y-axis center", self.y_center, 0, 600) changed, self.color = imgui.color_edit3( "Set Color", *self.color) # asterisk used for tuple, I think... imgui.new_line imgui.begin_child("Current Settings", border=True) # imgui.core.begin_child imgui.text("Currently Drawing: ") # imgui.core.text if self.drawMode == "c": imgui.same_line(200), imgui.text_colored( "Circle", 0, 1, 0) # imgui.core.same_line, imgui.core.text_colored imgui.text("Radius:"), imgui.same_line(200), imgui.text_colored( str(self.vrad), 0, 1, 0) imgui.text("X Position:"), imgui.same_line( 200), imgui.text_colored(str(self.x_center), 0, 1, 0) imgui.text("Y Position:"), imgui.same_line( 200), imgui.text_colored(str(self.y_center), 0, 1, 0) elif self.drawMode == "e": imgui.same_line(200), imgui.text_colored("Ellipse", 0, 1, 0) imgui.text("V. Radius:"), imgui.same_line(200), imgui.text_colored( str(self.vrad), 0, 1, 0) imgui.text("H. Radius:"), imgui.same_line(200), imgui.text_colored( str(self.hrad), 0, 1, 0) imgui.text("X Position:"), imgui.same_line( 200), imgui.text_colored(str(self.x_center), 0, 1, 0) imgui.text("Y Position:"), imgui.same_line( 200), imgui.text_colored(str(self.y_center), 0, 1, 0) else: imgui.text("Nothing Selected") imgui.end_child() imgui.end()
def main(): pygame.init() display = (1000, 700) screen = pygame.display.set_mode(display, DOUBLEBUF | OPENGLBLIT) imgui.create_context() impl = PygameRenderer() io = imgui.get_io() io.display_size = display pygame.display.set_caption('solar panels') gluPerspective(45, (display[0] / display[1]), 0.1, 50.0) glTranslatef(0, 0, -10) glRotatef(25, 2, 1, 0) # Coordinates x = 0 y = 0 z = 0 a = 0 # Keystates KLEFT = False KRIGHT = False KUP = False KDOWN = False KJ = False KL = False KA = False KD = False KW = False KS = False KI = False KK = False KG = False KH = False b = 0 d = 0 c = 1 while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() # KEYEVENT KEYDOWN HANDLING if event.type == pygame.KEYDOWN: # TRANSLATE if event.key == pygame.K_LEFT: KLEFT = True if event.key == pygame.K_RIGHT: KRIGHT = True if event.key == pygame.K_UP: KUP = True if event.key == pygame.K_DOWN: KDOWN = True if event.key == pygame.K_j: KJ = True if event.key == pygame.K_l: KL = True # ROTATE if event.key == pygame.K_a: KA = True if event.key == pygame.K_d: KD = True if event.key == pygame.K_w: KW = True if event.key == pygame.K_s: KS = True if event.key == pygame.K_i: KI = True if event.key == pygame.K_k: KK = True # Arm Control # Optional key usage to move arm model if event.key == pygame.K_g: KG = True if event.key == pygame.K_h: KH = True # KEYEVENT KEYUP HANDLING if event.type == pygame.KEYUP: # TRANSLATE if event.key == pygame.K_LEFT: KLEFT = False if event.key == pygame.K_RIGHT: KRIGHT = False if event.key == pygame.K_UP: KUP = False if event.key == pygame.K_DOWN: KDOWN = False if event.key == pygame.K_j: KJ = False if event.key == pygame.K_l: KL = False # ROTATE if event.key == pygame.K_a: KA = False if event.key == pygame.K_d: KD = False if event.key == pygame.K_w: KW = False if event.key == pygame.K_s: KS = False if event.key == pygame.K_i: KI = False if event.key == pygame.K_k: KK = False # Arm Angle # Optional key usage to move arm model if event.key == pygame.K_g: KG = False if event.key == pygame.K_h: KH = False # KEY PRESS ACTIONS # TRANSLATE if KH == True: glTranslatef(0, -1, 0) y += 1 if KG == True: glTranslatef(0, 1, 0) y -= 1 if KJ == True: glTranslatef(0, 0, -1) z += 1 if KL == True: glTranslatef(0, 0, 1) z -= 1 # ROTATE if KI == True: glRotate(5, 0, 1, 0) if KK == True: glRotate(5, 0, 0, 1) # Arm Angle # Optional key usage to move arm model if KRIGHT == True: a += 1 if KLEFT == True: a -= 1 if KUP == True: b += 1 if KDOWN == True: b -= 1 if KA == True: c += 1 if KD == True: c -= 1 if KW == True: d += 1 if KS == True: d -= 1 impl.process_event(event) imgui.new_frame() imgui.begin("Controle du Mirroir", True) imgui.text("Les Angles") c = imgui.slider_int("Axe des x", c, -180., 180.)[1] a = imgui.slider_int("Axe des y", a, -180., 180.)[1] changed, c = imgui.input_int('Type coefficient:', c) imgui.text('The Va;ue you entered is: %f' % c) visible = True expanded, visible = imgui.collapsing_header("Expand me!", visible) if expanded: imgui.text("Now you see me qnd perhaps you don't !") imgui.show_style_editor() imgui.end() imgui.render() gl.glClearColor(1, 1, 1, 1) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) impl.render(imgui.get_draw_data()) glPushMatrix() house() glPopMatrix() glPushMatrix() house() Mirroir(c, a) glPopMatrix() glPushMatrix() mirroir2(c, a) glRotate(180, 0, 1, 0) glPopMatrix() glPushMatrix() support(c, a) glPopMatrix() support2() pygame.display.flip()
def layers(self): imgui.begin("Layers") if imgui.button("Refresh Screen", 208, 20): self.window.clear() self.canvas.draw_layers() changed, self.delete_index = imgui.input_int("Layer to delete", self.delete_index, 1, 100) if imgui.button("Delete", 100, 20): self.canvas.delete_object(self.delete_index-1) imgui.same_line() if imgui.button("Delete All", 100, 20): clear_index = self.canvas.get_length() - 1 try: while clear_index >= 0: self.canvas.delete_object(clear_index) clear_index = clear_index - 1 except clear_index == -1: print("No objects found!") index = 0 # --Modification View if self.object_is_selected: if self.canvas.layers[self.selected].shape == "Circle": changed, self.mod_vrad = imgui.input_int("Radius", self.mod_vrad, 1, 100) # imgui.core.input_int changed, self.mod_x_center = imgui.input_int("X-axis center", self.mod_x_center, 1, 800) # imgui.core.slider_int, set max to window size changed, self.mod_y_center = imgui.input_int("Y-axis center", self.mod_y_center, 1, 600) changed, self.mod_color = imgui.color_edit3("Set Color", *self.mod_color) # asterisk used for tuple, I think... elif self.canvas.layers[self.selected].shape == "Ellipse": changed, self.mod_vrad = imgui.input_int("Vertical Radius", self.mod_vrad, 1, 100) # imgui.core.input_int changed, self.mod_hrad = imgui.input_int("Horizontal Radius", self.mod_hrad, 1, 100) changed, self.mod_x_center = imgui.input_int("X-axis center", self.mod_x_center, 1, 800) # imgui.core.slider_int, set max to window size changed, self.mod_y_center = imgui.input_int("Y-axis center", self.mod_y_center, 1, 600) changed, self.mod_color = imgui.color_edit3("Set Color", *self.mod_color) # asterisk used for tuple, I think... else: pass if imgui.button("Apply", 100, 20): self.canvas.layers[self.selected].move_to(self.mod_x_center, self.mod_y_center) self.canvas.layers[self.selected].set_color(color=Color(self.mod_color[0], self.mod_color[1], self.mod_color[2])) if self.canvas.layers[self.selected].shape == "Circle": self.canvas.layers[self.selected].change_length(self.mod_vrad) elif self.canvas.layers[self.selected].shape == "Ellipse": self.canvas.layers[self.selected].change_length(self.mod_vrad, self.mod_hrad) elif imgui.button("Cancel", 100, 20): self.object_is_selected = False imgui.new_line() imgui.separator() # --Layer View-- for layer in self.canvas.layers: layer_str = "Layer: {}, shape: {}" imgui.text(layer_str.format(index + 1, layer.shape)) layer_lbl = "Select Layer {}" if len(self.select_index) < (index + 1): self.select_index.append(False) if imgui.button(layer_lbl.format(index + 1), 125, 20): self.selected = index self.setCurrentValues(index) self.object_is_selected = True layer_str = "Layer: {}, shape: {}" imgui.same_line() imgui.text(layer_str.format(index + 1, layer.shape)) index = index + 1 imgui.end()
imgui.set_drag_drop_payload( "input", ("Button " + str(button)).encode()) imgui.text("Button %s: %s" % (button, value)) imgui.end_drag_drop_source() imgui.end() if local_motors: imgui.begin("Motor server IP address and port") changed, ip_address = imgui.input_text("IP address", other[0], 512) if changed: other = (ip_address, other[1]) changed, port = imgui.input_int("Port", other[1]) if changed: other = (other[0], port) else: imgui.begin("Motor client IP address and port") changed, ip_address = imgui.input_text("IP address", other[0], 512) if changed: other = (ip_address, other[1]) changed, port = imgui.input_int("Port", other[1]) if changed: other = (other[0], port)
def _show(self, value, read_only): imgui.push_item_width(self.width) changed, v = imgui.input_int("", value.value) if changed and not read_only: value.value = int(self.clamper(v))