Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShowManager Repeating Timer behavior and window size attribute #483

Open
devmessias opened this issue Aug 4, 2021 · 2 comments
Open

ShowManager Repeating Timer behavior and window size attribute #483

devmessias opened this issue Aug 4, 2021 · 2 comments
Assignees
Labels
type:Bug Fix Something isn't working

Comments

@devmessias
Copy link
Contributor

devmessias commented Aug 4, 2021

Hi everyone. I noticed some bugs on the ShowManager object

Timer Event

ShowManager destroy_timer method destroys the timer without removing the callback related with the observer. Thus,
we lost the reference for the callback. Because of that, another timer event created after that will keep calling the
callback function with the missed reference. See the code bellow,

from fury.window import ShowManager
from fury.actor import sphere
import numpy as np

repeat = False # bug appears with both options: False or True
centers = np.array([[1, 0,0]])
showm = ShowManager(size=(400, 400))
i1 = 0
i2 = 0

def t1(_, __):
    global i1
    i1 += 1
    print(f'timer 1 event {i1}')

def t2(_, __):
    global i2
    i2 += 1
    print(f'timer 2 event {i2}')

showm.initialize()
showm.add_timer_callback(repeat, 1, t1)
showm.add_timer_callback(repeat, 2, t2)

showm.destroy_timer(showm.timers[0])
color = np.array([0, 1, 0])
actor = sphere(centers ,color)
showm.scene.add(actor)

showm.start()
#showm.render()
assert i1 == 0

Size Window

This is more trickly and usually happens on Windows. The vtk creates a window instance with a slightly different size.
Therefore, the following test can fail:

size = (300, 400)
showm = ShowManager(size=size)
# code goes here
assert size[0] = showm.size[0] and size[1] == showm.size[1]

I noticed that bug running the tests of PR #437 on windows github actions.

OS and pkgs

{'fury_version': '0.7.1', 'pkg_path': '/home/devmessias/phd/fury/fury',
'commit_hash': '426c15b9e4895bdba449be3c63168b5179a34202', 'sys_version': '3.8.5
(default, Sep  4 2020, 07:30:14) \n[GCC 7.3.0]', 'sys_executable':
'/home/devmessias/anaconda3/bin/python', 'sys_platform': 'linux',
'numpy_version': '1.20.3', 'scipy_version': '1.5.2', 'vtk_version': '9.0.3',
'matplotlib_version': '3.3.2', 'dipy_version': '1.4.1'}
@devmessias devmessias added the type:Bug Fix Something isn't working label Aug 4, 2021
@devmessias devmessias self-assigned this Aug 4, 2021
@Garyfallidis Garyfallidis changed the title Fix: ShowManager Repeating Timer behavior and window size attribute ShowManager Repeating Timer behavior and window size attribute Aug 4, 2021
@skoudoro
Copy link
Contributor

skoudoro commented Aug 5, 2021

Hi @devmessias,

Good catch for the timer event issue !!

I can not reproduce the error on window size. Are you sure about this one?

@filipinascimento
Copy link
Contributor

I confirm the window size bug happens on my Windows version. Vtk 9.0.3, fury from master. It seems to create a padding (maybe of the size of the titlebar). Updating the window size inside the showm as soon as the window is created may fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Fix Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants