def _image_molecule(self, molecule, ball_stick=False, colorlist=[], rotation=[0., 0., 0.], width=300, height=300, zoom=1., lines=[], linestyle='impostors'): v = QtViewer() w = v.widget w.camera.orbit_z = MethodType(orbit_z, w.camera) w.initializeGL() if ball_stick: r = v.add_renderer(BallAndStickRenderer, molecule.r_array, molecule.type_array, molecule.bonds, rgba_array=colorlist, linestyle=linestyle) else: r = v.add_renderer(AtomRenderer, molecule.r_array, molecule.type_array, rgba_array=colorlist) for line in lines: #line = [start_coord, end_coord, start_color, end_color, width, dashed] #for some reason it didn't like unpacking them to named variables v.add_renderer(LineRenderer, [line[0], line[1]], [[str_to_colour(line[2]), str_to_colour(line[3])]], width=line[4], dashed=line[5]) #v.add_post_processing(SSAOEffect) w.camera.autozoom(molecule.r_array * 1. / zoom) w.camera.orbit_x(rotation[0] * np.pi / 180.) w.camera.orbit_y(rotation[1] * np.pi / 180.) w.camera.orbit_z(rotation[2] * np.pi / 180.) image = w.toimage(width, height) # Cleanup v.clear() del v del w del r return self._trim_image(image)