def update_view(self, param):
        cols = param.props['cols']
        radius = param.props['radius']
        if param.name == 'sphere':
            rows = param.props['rows']
            mesh = gen.create_sphere(cols, rows, radius=radius)
        elif param.name == 'cone':
            length = param.props['length']
            mesh = gen.create_cone(cols, radius=radius, length=length)
        elif param.name == 'cylinder':
            rows = param.props['rows']
            length = param.props['length']
            radius2 = param.props['radius Top.']
            mesh = gen.create_cylinder(rows, cols, radius=[radius, radius2],
                                       length=length)
        elif param.name == 'arrow':
            length = param.props['length']
            rows = param.props['rows']
            cone_radius = param.props['cone_radius']
            cone_length = param.props['cone_length']
            mesh = gen.create_arrow(rows, cols, radius=radius, length=length,
                                    cone_radius=cone_radius,
                                    cone_length=cone_length)
        else:
            return

        self.canvas.visible = param.props['visible']
        self.mesh.set_vertices(mesh.vertices())
        self.mesh.set_faces(mesh.faces())
        self.mesh.set_vertex_colors(DEFAULT_COLOR)
        vertices, filled, outline = self.mesh.get_glTriangles()
        self.canvas.set_data(vertices, filled, outline)
Ejemplo n.º 2
0
    def update_view(self, param):
        cols = param.props['cols']
        radius = param.props['radius']
        if param.name == 'sphere':
            rows = param.props['rows']
            mesh = gen.create_sphere(cols, rows, radius=radius)
        elif param.name == 'cone':
            length = param.props['length']
            mesh = gen.create_cone(cols, radius=radius, length=length)
        elif param.name == 'cylinder':
            rows = param.props['rows']
            length = param.props['length']
            radius2 = param.props['radius Top.']
            mesh = gen.create_cylinder(rows, cols, radius=[radius, radius2],
                                       length=length)
        elif param.name == 'arrow':
            length = param.props['length']
            rows = param.props['rows']
            cone_radius = param.props['cone_radius']
            cone_length = param.props['cone_length']
            mesh = gen.create_arrow(rows, cols, radius=radius, length=length,
                                    cone_radius=cone_radius,
                                    cone_length=cone_length)
        else:
            return

        self.canvas.visible = param.props['visible']
        self.mesh.set_vertices(mesh.get_vertices())
        self.mesh.set_faces(mesh.get_faces())
        colors = np.tile(DEFAULT_COLOR, (self.mesh.n_vertices, 1))
        self.mesh.set_vertex_colors(colors)
        vertices, filled, outline = self.mesh.get_glTriangles()
        self.canvas.set_data(vertices, filled, outline)