示例#1
0
    def add_data(self, data):

        # Check if data already exists in viewer
        if not self.allow_duplicate_data and data in self._layer_artist_container:
            return True

        if self.large_data_size is not None and data.size >= self.large_data_size:
            proceed = warn('Add large data set?', 'Data set {0:s} has {1:d} points, and '
                           'may render slowly.'.format(data.label, data.size), default='Cancel',
                           setting='show_large_data_warning')
            if not proceed:
                return False

        if data not in self.session.data_collection:
            raise IncompatibleDataException("Data not in DataCollection")

        # Create layer artist and add to container
        layer = self.get_data_layer_artist(data)

        if layer is None:
            return False

        self._layer_artist_container.append(layer)
        layer.update()

        # Add existing subsets to viewer
        for subset in data.subsets:
            self.add_subset(subset)

        self.redraw()

        return True
示例#2
0
    def activate(self):

        if self.profile_viewers_exist:

            proceed = warn('A profile viewer was already created',
                           'Do you really want to create a new one?',
                           default='Cancel', setting='show_warn_profile_duplicate')

            if not proceed:
                return

        else:

            proceed = info('Creating a profile viewer',
                           'Note: profiles are '
                           'computed from datasets and subsets collapsed along all but one '
                           'dimension. To view the profile of part of the data, once you '
                           'click OK you can draw and update a subset in the current '
                           'image viewer and the profile will update accordingly.', setting='show_info_profile_open')

            if not proceed:
                return

        from glue.viewers.profile.qt import ProfileViewer
        profile_viewer = self.viewer.session.application.new_data_viewer(ProfileViewer)
        any_added = False
        for data in self.viewer.session.data_collection:
            if data in self.viewer._layer_artist_container:
                result = profile_viewer.add_data(data)
                any_added = any_added or result

        if not any_added:
            profile_viewer.close()
            return

        # If the reference data for the current image viewer is in the profile
        # viewer, we make sure that it is used as the reference data there too
        if self.viewer.state.reference_data in profile_viewer._layer_artist_container:

            profile_viewer.state.reference_data = self.viewer.state.reference_data

            # We now pick an attribute in the profile viewer that is one of the ones
            # with a slider in the image viewer. Note that the attribute viewer may
            # be a pixel attribute or world attribute depending on what information
            # is available in the coordinates, so we need to be careful about that.

            x_att = profile_viewer.state.x_att
            reference_data = self.viewer.state.reference_data

            if isinstance(profile_viewer.state.x_att, PixelComponentID):
                for att in reference_data.pixel_component_ids:
                    if att is not self.viewer.state.x_att and att is not self.viewer.state.y_att:
                        if att is not profile_viewer.state.x_att:
                            profile_viewer.state.x_att = att
            else:
                for att in reference_data.world_component_ids:
                    if att is not self.viewer.state.x_att_world and att is not self.viewer.state.y_att_world:
                        if att is not profile_viewer.state.x_att:
                            profile_viewer.state.x_att = att
示例#3
0
    def activate(self):

        if any(x() is not None for x in self.profile_viewers):

            proceed = warn('A profile viewer was already created',
                           'Do you really want to create a new one?',
                           default='Cancel',
                           setting='show_warn_profile_duplicate')

            if not proceed:
                return

        else:

            proceed = info(
                'Creating a profile viewer', 'Note: profiles are '
                'computed from datasets and subsets collapsed along all but one '
                'dimension. To view the profile of part of the data, once you '
                'click OK you can draw and update a subset in the current '
                'image viewer and the profile will update accordingly.',
                setting='show_info_profile_open')

            if not proceed:
                return

        from glue.viewers.profile.qt import ProfileViewer
        profile_viewer = self.viewer.session.application.new_data_viewer(
            ProfileViewer)
        any_added = False
        for data in self.viewer.session.data_collection:
            if data in self.viewer._layer_artist_container:
                result = profile_viewer.add_data(data)
                any_added = any_added or result
        if any_added:
            if self.viewer.state.reference_data in profile_viewer._layer_artist_container:
                profile_viewer.state.reference_data = self.viewer.state.reference_data
            self.profile_viewers.append(weakref.ref(profile_viewer))
        else:
            profile_viewer.close()
示例#4
0
    def activate(self):

        if any(x() is not None for x in self.profile_viewers):

            proceed = warn('A profile viewer was already created',
                           'Do you really want to create a new one?',
                           default='Cancel', setting='show_warn_profile_duplicate')

            if not proceed:
                return

        else:

            proceed = info('Creating a profile viewer',
                           'Note: profiles are '
                           'computed from datasets and subsets collapsed along all but one '
                           'dimension. To view the profile of part of the data, once you '
                           'click OK you can draw and update a subset in the current '
                           'image viewer and the profile will update accordingly.', setting='show_info_profile_open')

            if not proceed:
                return

        from glue.viewers.profile.qt import ProfileViewer
        profile_viewer = self.viewer.session.application.new_data_viewer(ProfileViewer)
        any_added = False
        for data in self.viewer.session.data_collection:
            if data in self.viewer._layer_artist_container:
                result = profile_viewer.add_data(data)
                any_added = any_added or result
        if any_added:
            if self.viewer.state.reference_data in profile_viewer._layer_artist_container:
                profile_viewer.state.reference_data = self.viewer.state.reference_data
            self.profile_viewers.append(weakref.ref(profile_viewer))
        else:
            profile_viewer.close()
示例#5
0
    def activate(self):

        if self.profile_viewers_exist:

            proceed = warn('A profile viewer was already created',
                           'Do you really want to create a new one?',
                           default='Cancel',
                           setting='show_warn_profile_duplicate')

            if not proceed:
                return

        else:

            proceed = info(
                'Creating a profile viewer', 'Note: profiles are '
                'computed from datasets and subsets collapsed along all but one '
                'dimension. To view the profile of part of the data, once you '
                'click OK you can draw and update a subset in the current '
                'image viewer and the profile will update accordingly.',
                setting='show_info_profile_open')

            if not proceed:
                return

        from glue.viewers.profile.qt import ProfileViewer
        profile_viewer = self.viewer.session.application.new_data_viewer(
            ProfileViewer)
        any_added = False
        for data in self.viewer.session.data_collection:
            if data in self.viewer._layer_artist_container:
                result = profile_viewer.add_data(data)
                any_added = any_added or result

        if not any_added:
            profile_viewer.close()
            return

        # If the reference data for the current image viewer is in the profile
        # viewer, we make sure that it is used as the reference data there too
        if self.viewer.state.reference_data in profile_viewer._layer_artist_container:

            profile_viewer.state.reference_data = self.viewer.state.reference_data

            # We now pick an attribute in the profile viewer that is one of the ones
            # with a slider in the image viewer. Note that the attribute viewer may
            # be a pixel attribute or world attribute depending on what information
            # is available in the coordinates, so we need to be careful about that.

            x_att = profile_viewer.state.x_att
            reference_data = self.viewer.state.reference_data

            if isinstance(profile_viewer.state.x_att, PixelComponentID):
                for att in reference_data.pixel_component_ids:
                    if att is not self.viewer.state.x_att and att is not self.viewer.state.y_att:
                        if att is not profile_viewer.state.x_att:
                            profile_viewer.state.x_att = att
            else:
                for att in reference_data.world_component_ids:
                    if att is not self.viewer.state.x_att_world and att is not self.viewer.state.y_att_world:
                        if att is not profile_viewer.state.x_att:
                            profile_viewer.state.x_att = att
示例#6
0
 def warn(self, message, *args, **kwargs):
     return warn(message, *args, **kwargs)
示例#7
0
 def warn(self, message, *args, **kwargs):
     return warn(message, *args, **kwargs)