Exemplo n.º 1
0
def test_text_widget():

    interactive = False

    renderer = window.Renderer()
    axes = actor.axes()
    window.add(renderer, axes)
    renderer.ResetCamera()

    show_manager = window.ShowManager(renderer, size=(900, 900))

    if interactive:
        show_manager.initialize()
        show_manager.render()

    fetch_viz_icons()
    button_png = read_viz_icons(fname='home3.png')

    def button_callback(obj, event):
        print('Button Pressed')

    button = widget.button(show_manager.iren, show_manager.ren,
                           button_callback, button_png, (.8, 1.2), (100, 100))

    global rulez
    rulez = True

    def text_callback(obj, event):

        global rulez
        print('Text selected')
        if rulez:
            obj.GetTextActor().SetInput("Diffusion Imaging Rulez!!")
            rulez = False
        else:
            obj.GetTextActor().SetInput("Diffusion Imaging in Python")
            rulez = True
        show_manager.render()

    text = widget.text(show_manager.iren,
                       show_manager.ren,
                       text_callback,
                       message="Diffusion Imaging in Python",
                       left_down_pos=(0., 0.),
                       right_top_pos=(0.4, 0.05),
                       opacity=1.,
                       border=False)

    if not interactive:
        button.Off()
        text.Off()
        pass

    if interactive:
        show_manager.render()
        show_manager.start()

    arr = window.snapshot(renderer, size=(900, 900))
    report = window.analyze_snapshot(arr)
    npt.assert_equal(report.objects, 3)
Exemplo n.º 2
0
                       right_normalized_pos=(.98, 0.7),
                       size=(120, 0), label_format="%0.2lf",
                       color=(0.4, 0.4, 0.4),
                       selected_color=(0.2, 0.2, 0.2))

"""
And we add a simple clickable text overlay at the bottom left corner.
"""


def text_clicked(obj, event):
    print("Awesome!")

text = widget.text(show_manager.iren, show_manager.ren,
                   message="Powered by DIPY",
                   callback=text_clicked,
                   color=(1., .5, .0),
                   left_down_pos=(10, 5),
                   right_top_pos=(200, 35))

"""
Position the camera.
"""

renderer.zoom(0.7)
renderer.roll(10.)
renderer.reset_clipping_range()

"""
Uncomment the following lines to start the interaction.
"""
Exemplo n.º 3
0
def test_text_widget():

    interactive = False

    renderer = window.Renderer()
    axes = fvtk.axes()
    window.add(renderer, axes)
    renderer.ResetCamera()

    show_manager = window.ShowManager(renderer, size=(900, 900))

    if interactive:
        show_manager.initialize()
        show_manager.render()

    fetch_viz_icons()
    button_png = read_viz_icons(fname='home3.png')

    def button_callback(obj, event):
        print('Button Pressed')

    button = widget.button(show_manager.iren,
                           show_manager.ren,
                           button_callback,
                           button_png, (.8, 1.2), (100, 100))

    global rulez
    rulez = True

    def text_callback(obj, event):

        global rulez
        print('Text selected')
        if rulez:
            obj.GetTextActor().SetInput("Diffusion Imaging Rulez!!")
            rulez = False
        else:
            obj.GetTextActor().SetInput("Diffusion Imaging in Python")
            rulez = True
        show_manager.render()

    text = widget.text(show_manager.iren,
                       show_manager.ren,
                       text_callback,
                       message="Diffusion Imaging in Python",
                       left_down_pos=(0., 0.),
                       right_top_pos=(0.4, 0.05),
                       opacity=1.,
                       border=False)

    if not interactive:
        button.Off()
        text.Off()
        pass

    if interactive:
        show_manager.render()
        show_manager.start()

    arr = window.snapshot(renderer, size=(900, 900))
    report = window.analyze_snapshot(arr)
    npt.assert_equal(report.objects, 3)
Exemplo n.º 4
0
                       label_format="%0.2lf",
                       color=(0.4, 0.4, 0.4),
                       selected_color=(0.2, 0.2, 0.2))
"""
And we add a simple clickable text overlay at the bottom left corner.
"""


def text_clicked(obj, event):
    print("Awesome!")


text = widget.text(show_manager.iren,
                   show_manager.ren,
                   message="Powered by DIPY",
                   callback=text_clicked,
                   color=(1., .5, .0),
                   left_down_pos=(10, 5),
                   right_top_pos=(200, 35))
"""
Position the camera.
"""

renderer.zoom(0.7)
renderer.roll(10.)
renderer.reset_clipping_range()
"""
Uncomment the following lines to start the interaction.
"""

# show_manager.initialize()