def test_ui_disk_slider_2d(recording=False): filename = "test_ui_disk_slider_2d" recording_filename = pjoin(DATA_DIR, filename + ".log.gz") expected_events_counts_filename = pjoin(DATA_DIR, filename + ".pkl") disk_slider_2d_test = ui.DiskSlider2D() disk_slider_2d_test.set_center((300, 300)) disk_slider_2d_test.value = 90 # Assign the counter callback to every possible event. event_counter = EventCounter() event_counter.monitor(disk_slider_2d_test) current_size = (600, 600) show_manager = window.ShowManager(size=current_size, title="DIPY Disk Slider") show_manager.ren.add(disk_slider_2d_test) if recording: # Record the following events # 1. Left Click on the disk and hold it # 2. Move to the left the disk and make 1.5 tour # 3. Release the disk # 4. Left Click on the disk and hold it # 5. Move to the right the disk and make 1 tour # 6. Release the disk show_manager.record_events_to_file(recording_filename) print(list(event_counter.events_counts.items())) event_counter.save(expected_events_counts_filename) else: show_manager.play_events_from_file(recording_filename) expected = EventCounter.load(expected_events_counts_filename) event_counter.check_counts(expected)
def test_ui_disk_slider_2d(recording=False): filename = "test_ui_disk_slider_2d" recording_filename = pjoin(DATA_DIR, filename + ".log.gz") expected_events_counts_filename = pjoin(DATA_DIR, filename + ".pkl") disk_slider_2d_test = ui.DiskSlider2D() disk_slider_2d_test.set_center((300, 300)) disk_slider_2d_test.value = 90 # Assign the counter callback to every possible event. event_counter = EventCounter() event_counter.monitor(disk_slider_2d_test) current_size = (600, 600) show_manager = window.ShowManager(size=current_size, title="DIPY Disk Slider") show_manager.ren.add(disk_slider_2d_test) if recording: show_manager.record_events_to_file(recording_filename) print(list(event_counter.events_counts.items())) event_counter.save(expected_events_counts_filename) else: show_manager.play_events_from_file(recording_filename) expected = EventCounter.load(expected_events_counts_filename) event_counter.check_counts(expected)
line_slider = ui.LineSlider2D(initial_value=-2, min_value=-5, max_value=5) line_slider.add_callback(line_slider.slider_disk, "MouseMoveEvent", translate_green_cube) """ 2D Disk Slider ============== """ def rotate_red_cube(i_ren, obj, slider): angle = slider.value cube_actor_1.RotateY(0.005 * angle) disk_slider = ui.DiskSlider2D() disk_slider.set_center((200, 200)) disk_slider.add_callback(disk_slider.handle, "MouseMoveEvent", rotate_red_cube) """ 2D File Select Menu ============== """ file_select_menu = ui.FileSelectMenu2D(size=(500, 500), position=(300, 300), font_size=16, extensions=["py", "png"], directory_path=os.getcwd(), parent=None) """ Adding Elements to the ShowManager