def do_test(self): self.win.SetSize(130, 40) label = vcs.vtk_ui.Label(self.inter, "Test Rendering", fgcolor=(0, 0, 0)) label.show() self.test_file = "test_vtk_ui_label_render_initial.png" # Initialize to passing so we can tell if we failed self.passed = 0 if len(self.args) > 0: self.passed = self.check_image(self.args[0]) if self.passed == 1: return else: generate_png(self.win, self.test_file) label.actor.GetTextProperty().SetColor((.25, .5, .75)) self.test_file = "test_vtk_ui_label_render_color_change.png" label.render() if len(self.args) > 1: self.passed = self.check_image(self.args[1]) else: generate_png(self.win, self.test_file) # Skip the auto-image-check self.test_file = None return
def do(self): self.args = [ 'test_vtk_ui_widget_show.png', 'test_vtk_ui_widget_hide.png' ] self.win.SetSize((100, 100)) vw = vtk.vtkButtonWidget() vr = vtk.vtkTexturedButtonRepresentation2D() vr.SetNumberOfStates(1) r = vtk.vtkPNGReader() r.SetFileName("tests/vtk_ui/Pepper.png") r.Update() image = r.GetOutput() vr.SetButtonTexture(0, image) vw.SetRepresentation(vr) w = vcs.vtk_ui.widget.Widget(self.inter, vw) w.show() width, height, _ = image.GetDimensions() bounds = (0, 0 + width, 0, height, 0, 0) vr.SetPlaceFactor(1) vr.PlaceWidget(bounds) self.test_file = "test_vtk_ui_widget_show.png" if self.args: self.passed = self.check_image(self.args[0]) if self.passed == 1: print "Failed to show correctly" return else: vtk_ui_test.generate_png(self.win, self.test_file) assert w.showing(), "showing() thinks hidden while showing" w.hide() assert w.showing() == False, "showing() thinks showing while hidden" self.test_file = "test_vtk_ui_widget_hide.png" if len(self.args) > 1: self.passed = self.check_image(self.args[1]) if self.passed == 1: print "Failed to hide correctly" return else: vtk_ui_test.generate_png(self.win, self.test_file) self.test_file = None self.passed = 0
def do_test(self): self.win.SetSize((100, 100)) vw = vtk.vtkButtonWidget() vr = vtk.vtkTexturedButtonRepresentation2D() vr.SetNumberOfStates(1) r = vtk.vtkPNGReader() r.SetFileName("Pepper.png") r.Update() image = r.GetOutput() vr.SetButtonTexture(0, image) vw.SetRepresentation(vr) w = vcs.vtk_ui.widget.Widget(self.inter, vw) w.show() width, height, _ = image.GetDimensions() bounds = (0, 0 + width, 0, height, 0, 0) vr.SetPlaceFactor(1) vr.PlaceWidget(bounds) self.test_file = "test_vtk_ui_widget_show.png" if self.args: self.passed = self.check_image(self.args[0]) if self.passed == 1: print "Failed to show correctly" return else: generate_png(self.win, self.test_file) assert w.showing(), "showing() thinks hidden while showing" w.hide() assert w.showing() == False, "showing() thinks showing while hidden" self.test_file = "test_vtk_ui_widget_hide.png" if len(self.args) > 1: self.passed = self.check_image(self.args[1]) if self.passed == 1: print "Failed to hide correctly" return else: generate_png(self.win, self.test_file) self.test_file = None self.passed = 0