forked from thechargedneutron/GSoC-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frame_Rate.py
35 lines (27 loc) · 1.01 KB
/
Frame_Rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
from dipy.data import read_viz_icons, fetch_viz_icons
from dipy.viz import ui, window
# Initializing a TextBox to display the Frame Rate
global tb
tb = ui.TextBlock2D()
# A callback function to calculate Frame Rate
def timer_callback(obj, event):
global show_manager, tb
tb.message = "Frame Rate : " + str(1.0/show_manager.ren.GetLastRenderTimeInSeconds())
show_manager.render()
current_size = (600, 600)
global show_manager
show_manager = window.ShowManager(size=current_size, title=" Frame Rate")
show_manager.initialize()
show_manager.ren.add(tb.get_actor())
# Rendering 10 spheres
for i in range(10):
sphereSource = window.vtk.vtkSphereSource()
sphereSource.SetCenter(i, 0, 0)
mapper = window.vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphereSource.GetOutputPort())
actor = window.vtk.vtkActor()
actor.SetMapper(mapper)
show_manager.ren.add(actor)
show_manager.add_timer_callback(True, 200, timer_callback)
show_manager.start()