How to use the itkwidgets.trait_types.PolyDataList function in itkwidgets

To help you get started, we’ve selected a few itkwidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github InsightSoftwareConsortium / itkwidgets / itkwidgets / widget_viewer.py View on Github external
sync=True,
        **polydata_list_serialization)
    point_set_colors = NDArray(dtype=np.float32, default_value=np.zeros((0, 3), dtype=np.float32),
                               help="RGB colors for the points sets")\
        .tag(sync=True, **array_serialization)\
        .valid(shape_constraints(None, 3))
    point_set_opacities = NDArray(dtype=np.float32, default_value=np.zeros((0,), dtype=np.float32),
                                  help="Opacities for the points sets")\
        .tag(sync=True, **array_serialization)\
        .valid(shape_constraints(None,))
    point_set_representations = List(
        trait=Unicode(),
        default_value=[],
        help="Point set representation").tag(
        sync=True)
    geometries = PolyDataList(
        default_value=None,
        allow_none=True,
        help="Geometries to visualize").tag(
        sync=True,
        **polydata_list_serialization)
    geometry_colors = NDArray(dtype=np.float32, default_value=np.zeros((0, 3), dtype=np.float32),
                              help="RGB colors for the geometries")\
        .tag(sync=True, **array_serialization)\
        .valid(shape_constraints(None, 3))
    geometry_opacities = NDArray(dtype=np.float32, default_value=np.zeros((0,), dtype=np.float32),
                                 help="Opacities for the geometries")\
        .tag(sync=True, **array_serialization)\
        .valid(shape_constraints(None,))
    ui_collapsed = CBool(
        default_value=False,
        help="Collapse the built in user interface.").tag(
github InsightSoftwareConsortium / itkwidgets / itkwidgets / trait_types.py View on Github external
decompressed_arrays.append(
                            {'data': decompressed_array})
                    decompressed_data['arrays'] = decompressed_arrays
                    polydata[data_type] = decompressed_data

            polydata_list.append(polydata)
        return polydata_list


polydata_list_serialization = {
    'from_json': polydata_list_from_json,
    'to_json': polydata_list_to_json
}


class PointSetList(PolyDataList):
    """A trait type holding a list of Python data structures compatible with vtk.js that
    is coerced from point set-like data structures."""

    info_text = 'Point set representation for rendering geometry in vtk.js.'

    # Hold a reference to the source object to use with shallow views
    _source_object = None

    def validate(self, obj, value):
        self._source_object = value

        # For convenience, support assigning a single point set instead of a
        # list
        point_sets = value
        if not isinstance(
                point_sets, collections.Sequence) and point_sets is not None: