def on_key(event, drawer): # Message loop called whenever a key is pressed on the figure if event.key == "t": drawer.arcs = get_random_arcs() elif event.key == "c": drawer.arcs = None elif event.key == "n": drawer.toggle_norm_arrow_visibility() elif event.key == "a": drawer.norm_arrow_count += 1 elif event.key == "z": drawer.norm_arrow_count -= 1 elif event.key == "k": drawer.norm_arrow_length *= 1.1 elif event.key == "m": drawer.norm_arrow_length *= 0.9 elif event.key == "u": drawer.color = next(COLORS) elif event.key == "i": drawer.style = next(STYLES) elif event.key == "d": drawer.draw() drawing.redraw_current_figure()
def on_key(event, system): # Message loop called whenever a key is pressed on the figure system.update() drawer.segments = system.optical_segments drawer.draw() ray_drawer.rays = system.sources ray_drawer.draw() drawing.redraw_current_figure()
def redraw(): source.update() drawer.rays = source drawer.draw() drawing.redraw_current_figure() print("Source field printout:") for key in source.keys(): print(f"{key}: {source[key].shape}") print("----------------------")
def update_display(session, central_angle, slice_angle): ray_drawer.rays = np.concatenate( session.run([reacted_rays, active_rays, finished_rays, dead_rays], feed_dict={central_angle_placeholder: central_angle})) ray_drawer.draw() segment_drawer.segments = session.run( segments, feed_dict={central_angle_placeholder: central_angle}) segment_drawer.draw() drawing.redraw_current_figure()
def on_key( event, drawer, optical_system, source, angular_distribution, base_point_distribution ): # Message loop called whenever a key is pressed on the figure # Extract the center and central_angle center = source.center central_angle = source.central_angle if event.key == "w": # move the center up center[1] = center[1] + 0.1 elif event.key == "s": # move the center down center[1] = center[1] - 0.1 elif event.key == "a": # move the center left center[0] = center[0] - 0.1 elif event.key == "d": # move the center right center[0] = center[0] + 0.1 elif event.key == "q": # rotate source ccw central_angle += 0.1 elif event.key == "e": # rotate source cw central_angle -= 0.1 elif event.key == "r": # reduce angle sample count if angular_distribution.sample_count > 1: angular_distribution.sample_count -= 1 elif event.key == "f": # increase angle sample count angular_distribution.sample_count += 1 elif event.key == "t": # reduce base point sample count if base_point_distribution.sample_count > 1: base_point_distribution.sample_count -= 1 elif event.key == "g": # increase base point sample count base_point_distribution.sample_count += 1 source.center = center source.central_angle = central_angle optical_system.update() drawer.rays = optical_system.sources drawer.draw() drawing.redraw_current_figure()
def redraw(engine, ray_drawer, arc_drawer): """ handles redrawing the display.""" system = engine.optical_system system.update() arc_drawer.arcs = system.optical_arcs arc_drawer.draw() if engine.all_rays: ray_drawer.rays = engine.all_rays else: ray_drawer.rays = system.sources ray_drawer.draw() drawing.redraw_current_figure()
def on_key(event, drawer, source, system): # Message loop called whenever a key is pressed on the figure central_angle = source.central_angle if event.key == 'a': central_angle -= .1 elif event.key == 'd': central_angle += .1 source.central_angle = central_angle system.update() drawer.rays = source drawer.draw() drawing.redraw_current_figure()
def on_key(event, drawer): # Message loop called whenever a key is pressed on the figure if event.key == "t": drawer.rays = get_rays() elif event.key == "c": drawer.rays = None elif event.key == "n": drawer.set_wavelength_limits(0.450, 0.650) elif event.key == "m": drawer.set_wavelength_limits(drawing.VISIBLE_MIN, drawing.VISIBLE_MAX) elif event.key == "i": drawer.style = next(STYLES) elif event.key == "u": drawer.colormap = next(COLORMAPS) drawer.draw() drawing.redraw_current_figure()
def transformed_map(): global arrows for arrow in arrows: arrow.remove() arrows = [] for i in range(point_count): sq = square[i] cir = mapped_circle[i] arrows.append( plt.arrow( cir[0], cir[1], sq[0] - cir[0], sq[1] - cir[1], color="green", head_width=.05, head_length=.05, length_includes_head=True ) ) drawing.redraw_current_figure()
def on_key(event, drawer, boundary, system): # Message loop called whenever a key is pressed on the figure p0 = boundary.surfaces[0].parameters p1 = boundary.surfaces[1].parameters p2 = boundary.surfaces[2].parameters dp0 = np.linspace(-0.2, 0.2, p0.shape[0], dtype=np.float64)**2 dp1 = np.linspace(-0.2, 0.2, p1.shape[0], dtype=np.float64)**2 dp2 = np.linspace(-0.2, 0.2, p2.shape[0], dtype=np.float64)**2 if event.key == "n": drawer.toggle_norm_arrow_visibility() elif event.key == "q": p0.assign_sub(dp0) elif event.key == "e": p0.assign_add(dp0) elif event.key == "a": p1.assign_sub(dp1) elif event.key == "d": p1.assign_add(dp1) elif event.key == "z": p2.assign_sub(dp2) elif event.key == "c": p2.assign_add(dp2) """elif event.key == '0': boundary.constraints[0].target_vertex = 0 boundary.constraints[1].target_vertex = 0 elif event.key == '7': boundary.constraints[0].target_vertex = 7 boundary.constraints[1].target_vertex = 7 elif event.key == 'm': boundary.constraints[0].target_vertex = 7 boundary.constraints[1].parent_vertex = 0""" system.update() drawer.segments = system.optical_segments drawer.draw() drawing.redraw_current_figure()
def redraw(): source.update() drawer.rays = source drawer.draw() drawing.redraw_current_figure() """print("Source field printout:")