diff --git a/python/raytracing/gui_utilities.py b/python/raytracing/gui_utilities.py index e2963a06..39fb165f 100644 --- a/python/raytracing/gui_utilities.py +++ b/python/raytracing/gui_utilities.py @@ -198,6 +198,17 @@ def __init__(self, label): self.num_iterations = 0 self.total_time = 0.0 self.last_time = time.time() + self._visible = False + self._text = '-fps (-ms)' + + def set_visible(self, visible): + if self._visible == visible: + return + self._visible = visible + if visible: + self.label.configure(text = self._text) + else: + self.label.configure(text = '') def __call__(self, t): self.num_iterations += 1 @@ -206,8 +217,9 @@ def __call__(self, t): current_time = time.time() fps = self.num_iterations / (current_time - self.last_time) time_ms = 1000 * self.total_time / self.num_iterations - - self.label.configure(text='%.1ffps (%dms)' % (fps, time_ms)) + self._text = '%.1ffps (%dms)' % (fps, time_ms) + if self._visible: + self.label.configure(text=self._text) self.last_time = current_time self.num_iterations = 0 self.total_time = 0.0 diff --git a/python/raytracing/inside_viewer.py b/python/raytracing/inside_viewer.py index 6b3aeb75..5d2dc748 100644 --- a/python/raytracing/inside_viewer.py +++ b/python/raytracing/inside_viewer.py @@ -92,8 +92,9 @@ def __init__(self, container, manifold, self.view_scale_value_label, update_function=self.widget.draw) - self.widget.report_time_callback = FpsLabelUpdater( + self.widget.fps_label_updater = FpsLabelUpdater( self.fps_label) + self.widget.report_time_callback = self.widget.fps_label_updater self.update_volume_label() @@ -543,6 +544,19 @@ def create_quality_frame(self, parent): left_end=1.0, right_end=4.25, update_function=self.widget.draw) + row += 1 + + misc_frame = ttk.Frame(frame) + misc_frame.grid(row=row, column=1, columnspan=3) + + self.fps_box_var = tkinter.BooleanVar() + self.fps_box_var.set(False) + fps_box = ttk.Checkbutton(misc_frame, takefocus=0) + fps_box.grid(row=0, column=0) + fps_box.configure( + variable = self.fps_box_var, + text='Show fps', + command=self.show_fps) return frame @@ -830,6 +844,10 @@ def pick_cohomology_class(self, i): def build_menus(self): pass + def show_fps(self): + self.widget.fps_label_updater.set_visible( + self.fps_box_var.get()) + def test(self): X = 100 self.widget.event_generate('', x=X, y=300, warp=True)