def get_scene_and_legend(self) -> Tuple[Scene, Dict[str, str]]: legend = Legend(self.graph.structure, color_scheme="VESTA", cmap_range=None) legend.uniform_radius = 0.3 scene = get_structure_graph_scene( self.graph, draw_image_atoms=True, bonded_sites_outside_unit_cell=False, hide_incomplete_edges=True, explicitly_calculate_polyhedra_hull=False, group_by_symmetry=True, draw_polyhedra=False, legend=legend) scene.name = "DefectStructureComponentScene" lattice: Lattice = self.graph.structure.lattice origin = -self.graph.structure.lattice.get_cartesian_coords( [0.5, 0.5, 0.5]) scene_json = scene.to_json() for idx, i in enumerate(self.interstitials, 1): site = Site(species=DummySpecie(), coords=lattice.get_cartesian_coords(i.frac_coords)) interstitial_scene = site.get_scene(origin=origin) interstitial_scene.name = f"i{idx}" interstitial_scene.contents[0].contents[0].tooltip = f"i{idx}" scene_json["contents"].append(interstitial_scene.to_json()) return scene_json, legend.get_legend()
def get_scene_and_legend(self, scene_additions=None ) -> Tuple[Scene, Dict[str, str]]: legend = Legend(self.graph.structure, color_scheme="VESTA", radius_scheme="uniform", cmap_range=None) legend.uniform_radius = 0.2 scene = get_structure_graph_scene( self.graph, draw_image_atoms=True, bonded_sites_outside_unit_cell=False, hide_incomplete_edges=True, explicitly_calculate_polyhedra_hull=False, group_by_symmetry=False, legend=legend) scene.name = "DefectStructureComponentScene" # axes = graph.structure.lattice._axes_from_lattice() # axes.visible = True # scene.contents.append(axes) scene = scene.to_json() if scene_additions: scene["contents"].append(scene_additions) lattice = self.graph.structure.lattice origin = -self.graph.structure.lattice.get_cartesian_coords( [0.5, 0.5, 0.5]) for name, frac_coords in self.vacancy_sites: site = Site(species=DummySpecie(name), coords=lattice.get_cartesian_coords(frac_coords)) vac_scene = site.get_scene(origin=origin) vac_scene.name = f"{name}_{frac_coords}" vac_scene.contents[0].contents[0].tooltip = name scene["contents"].append(vac_scene.to_json()) return scene, legend.get_legend()